diff --git a/Gemfile b/Gemfile index 07eee77c..8cdae360 100755 --- a/Gemfile +++ b/Gemfile @@ -65,20 +65,9 @@ gem 'devise', '~> 4.4' gem 'config', '> 1.5' gem 'dry-validation', '~> 0.13.3' # used only for config validation gem 'foreman', '~> 0.85.0' -gem 'grape_devise', path: 'gems/grape_devise' -gem 'grape_logging', '~> 1.8', '>= 1.8.1' -gem 'grape_url_validator', '~> 1.0' -gem 'grape-entity', '~> 0.7.1' -gem 'grape-swagger-entity', '~> 0.3.3' -gem 'grape-swagger', '~> 0.33.0' -gem 'grape', '~> 1.2', '>= 1.2.4' gem 'wisper', '~> 2.0' gem 'wisper-activejob', '~> 1.0.0' -group :development do - gem 'grape_on_rails_routes', '~> 0.3.2' -end - group :development, :ci do gem 'debase', '~> 0.2.3' gem 'ruby-debug-ide', '~> 0.7.0' diff --git a/Gemfile.lock b/Gemfile.lock index da264075..c5e9f935 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,14 +8,6 @@ GIT multi_json (~> 1.0) stripe (>= 1.31.0, <= 1.58.0) -PATH - remote: gems/grape_devise - specs: - grape_devise (0.1.1) - devise (>= 2.2.8, < 5) - grape (> 0.7) - rails (> 3.2, < 6) - PATH remote: gems/ruby-param-validation specs: @@ -106,10 +98,6 @@ GEM xml-simple aws-sigv4 (1.1.0) aws-eventstream (~> 1.0, >= 1.0.2) - axiom-types (0.1.1) - descendants_tracker (~> 0.0.4) - ice_nine (~> 0.11.0) - thread_safe (~> 0.3, >= 0.3.1) backport (1.1.2) bcrypt (3.1.13) binding_of_caller (0.8.0) @@ -129,8 +117,6 @@ GEM carrierwave (>= 0.7, < 2.0) chronic (0.10.2) coderay (1.1.2) - coercible (1.0.0) - descendants_tracker (~> 0.0.1) colorize (0.8.1) concurrent-ruby (1.1.5) config (1.7.2) @@ -153,8 +139,6 @@ GEM debase-ruby_core_source (0.10.5) debug_inspector (0.0.3) deep_merge (1.2.1) - descendants_tracker (0.0.4) - thread_safe (~> 0.3, >= 0.3.1) devise (4.6.2) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -200,7 +184,6 @@ GEM dry-equalizer (~> 0.2) dry-logic (~> 0.5, >= 0.5.0) dry-types (~> 0.14.0) - equalizer (0.0.11) erubi (1.8.0) execjs (2.7.0) factory_bot (5.0.2) @@ -226,28 +209,6 @@ GEM ffi (~> 1.0) globalid (0.4.2) activesupport (>= 4.2.0) - grape (1.2.4) - activesupport - builder - mustermann-grape (~> 1.0.0) - rack (>= 1.3.0) - rack-accept - virtus (>= 1.0.0) - grape-entity (0.7.1) - activesupport (>= 4.0) - multi_json (>= 1.3.2) - grape-swagger (0.33.0) - grape (>= 0.16.2) - grape-swagger-entity (0.3.3) - grape-entity (>= 0.5.0) - grape-swagger (>= 0.31.0) - grape_logging (1.8.1) - grape - rack - grape_on_rails_routes (0.3.2) - rails (>= 3.1.1) - grape_url_validator (1.0.0) - grape (>= 0.12.0) hamster (3.0.0) concurrent-ruby (~> 1.0) hashdiff (1.0.0) @@ -265,7 +226,6 @@ GEM i18n-js (3.3.0) i18n (>= 0.6.6) i18n_data (0.8.0) - ice_nine (0.11.2) jaro_winkler (1.5.3) jbuilder (2.10.0) activesupport (>= 5.0.0) @@ -300,9 +260,6 @@ GEM multi_json (1.13.1) multi_xml (0.6.0) multipart-post (2.1.1) - mustermann (1.0.3) - mustermann-grape (1.0.0) - mustermann (~> 1.0.0) nearest_time_zone (0.0.4) andand kdtree @@ -334,8 +291,6 @@ GEM rabl (0.14.1) activesupport (>= 2.3.14) rack (2.0.9) - rack-accept (0.4.5) - rack (>= 0.4) rack-attack (5.4.2) rack (>= 1.0, < 3) rack-ssl (1.4.1) @@ -482,11 +437,6 @@ GEM unf_ext (0.0.7.6) unicode-display_width (1.6.0) unicode_utils (1.4.0) - virtus (1.0.5) - axiom-types (~> 0.1) - coercible (~> 1.0) - descendants_tracker (~> 0.0, >= 0.0.3) - equalizer (~> 0.0, >= 0.0.9) warden (1.2.8) rack (>= 2.0.6) webmock (3.6.2) @@ -534,14 +484,6 @@ DEPENDENCIES foreman (~> 0.85.0) fullcontact (~> 0.18.0) geocoder (~> 1.5) - grape (~> 1.2, >= 1.2.4) - grape-entity (~> 0.7.1) - grape-swagger (~> 0.33.0) - grape-swagger-entity (~> 0.3.3) - grape_devise! - grape_logging (~> 1.8, >= 1.8.1) - grape_on_rails_routes (~> 0.3.2) - grape_url_validator (~> 1.0) hamster (~> 3.0) heroku-deflater (~> 0.6.3) httparty (~> 0.17.0) diff --git a/app/____api/houdini/api.rb b/app/____api/houdini/api.rb deleted file mode 100644 index f1e5f35c..00000000 --- a/app/____api/houdini/api.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -class Houdini::API < Grape::API - format :json - mount Houdini::V1::API => '/v1' -end diff --git a/app/____api/houdini/v1/api.rb b/app/____api/houdini/v1/api.rb deleted file mode 100644 index 43b6516b..00000000 --- a/app/____api/houdini/v1/api.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -require 'houdini/v1/validations' -class Houdini::V1::API < Grape::API - logger.formatter = GrapeLogging::Formatters::Rails.new - use GrapeLogging::Middleware::RequestLogger, logger: logger - content_type :json, 'application/json' - default_format :json - rescue_from Grape::Exceptions::ValidationErrors do |e| - output = { errors: e } - error! output, 400 - end - - # include Houdini::V1::Helpers::ApplicationHelper - mount Houdini::V1::Nonprofit => '/nonprofit' - # Additional mounts are added via generators above this line - # DON'T REMOVE THIS OR THE PREVIOUS LINES!!! - uri_for_host = URI.parse(Settings.api_domain&.url || Settings.cdn.url) - add_swagger_documentation \ - host: "#{uri_for_host.host}#{uri_for_host.port ? ":#{uri_for_host.port}" : ''}", - schemes: [uri_for_host.scheme], - base_path: '/api/v1' -end diff --git a/app/____api/houdini/v1/base_api.rb b/app/____api/houdini/v1/base_api.rb deleted file mode 100644 index 49a57136..00000000 --- a/app/____api/houdini/v1/base_api.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -class Houdini::V1::BaseAPI < Grape::API -end diff --git a/app/____api/houdini/v1/entities/nonprofit.rb b/app/____api/houdini/v1/entities/nonprofit.rb deleted file mode 100644 index 6922e0d0..00000000 --- a/app/____api/houdini/v1/entities/nonprofit.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -class Houdini::V1::Entities::Nonprofit < Grape::Entity - expose :id -end diff --git a/app/____api/houdini/v1/entities/validation_error.rb b/app/____api/houdini/v1/entities/validation_error.rb deleted file mode 100644 index d275a2f7..00000000 --- a/app/____api/houdini/v1/entities/validation_error.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -class Houdini::V1::Entities::ValidationError < Grape::Entity - expose :params, documentation: { type: 'String', desc: 'Params where the following had an error.', is_array: true } - expose :messages, documentation: { type: 'String', desc: 'The validation messages for the params', is_array: true } -end diff --git a/app/____api/houdini/v1/entities/validation_errors.rb b/app/____api/houdini/v1/entities/validation_errors.rb deleted file mode 100644 index 303893b5..00000000 --- a/app/____api/houdini/v1/entities/validation_errors.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -class Houdini::V1::Entities::ValidationErrors < Grape::Entity - expose :errors, documentation: { type: ValidationError, desc: 'errors', is_array: true } -end diff --git a/app/____api/houdini/v1/helpers/application_helper.rb b/app/____api/houdini/v1/helpers/application_helper.rb deleted file mode 100644 index d3b80ee6..00000000 --- a/app/____api/houdini/v1/helpers/application_helper.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -module Houdini::V1::Helpers::ApplicationHelper - extend Grape::API::Helpers -end diff --git a/app/____api/houdini/v1/helpers/rescue_helper.rb b/app/____api/houdini/v1/helpers/rescue_helper.rb deleted file mode 100644 index 66de5e36..00000000 --- a/app/____api/houdini/v1/helpers/rescue_helper.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -module Houdini::V1::Helpers::RescueHelper - require 'active_support/concern' - - extend ActiveSupport::Concern - include Grape::DSL::Configuration - module ClassMethods - def rescue_ar_invalid(*class_to_hash) - rescue_with ActiveRecord::RecordInvalid do |error| - output = [] - error.record.errors do |attr, message| - output.push(params: "#{class_to_hash[error.record.class]}['#{attr}']", - message: message) - end - raise Grape::Exceptions::ValidationErrors, output - end - end - end -end diff --git a/app/____api/houdini/v1/nonprofit.rb b/app/____api/houdini/v1/nonprofit.rb deleted file mode 100644 index c8de72d3..00000000 --- a/app/____api/houdini/v1/nonprofit.rb +++ /dev/null @@ -1,107 +0,0 @@ -# frozen_string_literal: true - -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -class Houdini::V1::Nonprofit < Houdini::V1::BaseAPI - helpers Houdini::V1::Helpers::ApplicationHelper, Houdini::V1::Helpers::RescueHelper - - desc 'Return a nonprofit.' do - success Houdini::V1::Entities::Nonprofit - end - params do - requires :id, type: Integer, desc: 'Status id.' - end - route_param :id do - get do - np = ::Nonprofit.find(params[:id]) - present np, as: Houdini::V1::Entities::Nonprofit - end - end - - desc 'Register a nonprofit' do - success Houdini::V1::Entities::Nonprofit - - # this needs to be a validation an array - failure [{ code: 400, message: 'Validation Errors', model: Houdini::V1::Entities::ValidationErrors }] - end - - params do - requires :nonprofit, type: Hash do - requires :name, type: String, desc: 'Organization Name', allow_blank: false, documentation: { param_type: 'body' } - optional :website, type: String, desc: 'Organization website URL', allow_blank: true, regexp: URI::DEFAULT_PARSER.make_regexp, documentation: { param_type: 'body' }, coerce_with: lambda { |url| - coerced_url = url - unless url =~ %r{\Ahttp://.*}i || url =~ %r{\Ahttps://.*}i - coerced_url = 'http://' + coerced_url - end - coerced_url - } - requires :zip_code, type: String, allow_blank: false, desc: 'Organization Address ZIP Code', documentation: { param_type: 'body' } - requires :state_code, type: String, allow_blank: false, desc: 'Organization Address State Code', documentation: { param_type: 'body' } - requires :city, type: String, allow_blank: false, desc: 'Organization Address City', documentation: { param_type: 'body' } - optional :email, type: String, desc: 'Organization email (public)', regexp: Email::Regex, documentation: { param_type: 'body' } - optional :phone, type: String, desc: 'Organization phone (public)', documentation: { param_type: 'body' } - end - - requires :user, type: Hash do - requires :name, type: String, desc: 'Full name', allow_blank: false, documentation: { param_type: 'body' } - requires :email, type: String, desc: 'Username', allow_blank: false, documentation: { param_type: 'body' } - requires :password, type: String, desc: 'Password', allow_blank: false, is_equal_to: :password_confirmation, documentation: { param_type: 'body' } - requires :password_confirmation, type: String, desc: 'Password confirmation', allow_blank: false, documentation: { param_type: 'body' } - end - end - post do - declared_params = declared(params) - np = nil - u = nil - Qx.transaction do - np = ::Nonprofit.new(OnboardAccounts.set_nonprofit_defaults(declared_params[:nonprofit])) - - begin - np.save! - rescue ActiveRecord::RecordInvalid => e - if e.record.errors[:slug] - begin - slug = SlugNonprofitNamingAlgorithm.new(np.state_code_slug, np.city_slug).create_copy_name(np.slug) - np.slug = slug - np.save! - rescue UnableToCreateNameCopyError - raise Grape::Exceptions::ValidationErrors.new(errors: [Grape::Exceptions::Validation.new( - params: ['nonprofit[name]'], - message: 'has an invalid slug. Contact support for help.' - )]) - end - else - raise e - end - end - - u = User.new(declared_params[:user]) - u.save! - - role = u.roles.build(host: np, name: 'nonprofit_admin') - role.save! - - billing_plan = BillingPlan.find(Settings.default_bp.id) - b_sub = np.build_billing_subscription(billing_plan: billing_plan, status: 'active') - b_sub.save! - rescue ActiveRecord::RecordInvalid => e - class_to_name = { Nonprofit => 'nonprofit', User => 'user' } - if class_to_name[e.record.class] - errors = e.record.errors.keys.map do |k| - errors = e.record.errors[k].uniq - errors.map do |error| - Grape::Exceptions::Validation.new( - params: ["#{class_to_name[e.record.class]}[#{k}]"], - message: error - ) - end - end - - raise Grape::Exceptions::ValidationErrors.new(errors: errors.flatten) - else - raise e - end - end - # onboard callback - present np, with: Houdini::V1::Entities::Nonprofit - end -end diff --git a/app/____api/houdini/v1/validations.rb b/app/____api/houdini/v1/validations.rb deleted file mode 100644 index 692a5bed..00000000 --- a/app/____api/houdini/v1/validations.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -require 'houdini/v1/validators/is_equal_to' diff --git a/app/____api/houdini/v1/validators/is_equal_to.rb b/app/____api/houdini/v1/validators/is_equal_to.rb deleted file mode 100644 index 73faf52b..00000000 --- a/app/____api/houdini/v1/validators/is_equal_to.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -class Houdini::V1::Validators::IsEqualTo < Grape::Validations::Base - def validate_param!(attr_name, params) - if params[attr_name] != params[@option] - raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name), @scope.full_name(@option)], message: message(:is_equal_to) - end - end -end diff --git a/config/locales/grape.en.yml b/config/locales/grape.en.yml deleted file mode 100644 index 8e7ad93f..00000000 --- a/config/locales/grape.en.yml +++ /dev/null @@ -1,7 +0,0 @@ -# License: CC0-1.0 -# grape validation errors require a very specific format for their translation messages. Why? *shrug* -en: - grape: - errors: - messages: - is_equal_to: "must be the same" \ No newline at end of file diff --git a/gems/grape_devise/.gitignore b/gems/grape_devise/.gitignore deleted file mode 100644 index 10543367..00000000 --- a/gems/grape_devise/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.bundle/ -log/*.log -pkg/ -spec/dummy/db/*.sqlite3 -spec/dummy/db/*.sqlite3-journal -spec/dummy/log/*.log -spec/dummy/tmp/ -spec/dummy/.sass-cache -.idea -*.iml diff --git a/gems/grape_devise/.travis.yml b/gems/grape_devise/.travis.yml deleted file mode 100644 index 916650fa..00000000 --- a/gems/grape_devise/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: ruby -rvm: - - 2.1.0 -sudo: false diff --git a/gems/grape_devise/Gemfile b/gems/grape_devise/Gemfile deleted file mode 100644 index 1a91d437..00000000 --- a/gems/grape_devise/Gemfile +++ /dev/null @@ -1,16 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -# Declare your gem's dependencies in grape_devise.gemspec. -# Bundler will treat runtime dependencies like base dependencies, and -# development dependencies will be added by default to the :development group. -gemspec - -# Declare any dependencies that are still in development here instead of in -# your gemspec. These might include edge Rails or gems from your path or -# Git. Remember to move these dependencies to your gemspec before releasing -# your gem to rubygems.org. - -# To use debugger -# gem 'debugger' diff --git a/gems/grape_devise/Gemfile.lock b/gems/grape_devise/Gemfile.lock deleted file mode 100644 index 4335bedb..00000000 --- a/gems/grape_devise/Gemfile.lock +++ /dev/null @@ -1,176 +0,0 @@ -PATH - remote: . - specs: - grape_devise (0.1.1) - devise (>= 2.2.8, < 4) - grape (~> 0.7) - rails (> 3.2, < 5) - -GEM - remote: https://rubygems.org/ - specs: - actionmailer (4.1.6) - actionpack (= 4.1.6) - actionview (= 4.1.6) - mail (~> 2.5, >= 2.5.4) - actionpack (4.1.6) - actionview (= 4.1.6) - activesupport (= 4.1.6) - rack (~> 1.5.2) - rack-test (~> 0.6.2) - actionview (4.1.6) - activesupport (= 4.1.6) - builder (~> 3.1) - erubis (~> 2.7.0) - activemodel (4.1.6) - activesupport (= 4.1.6) - builder (~> 3.1) - activerecord (4.1.6) - activemodel (= 4.1.6) - activesupport (= 4.1.6) - arel (~> 5.0.0) - activerecord-nulldb-adapter (0.3.1) - activerecord (>= 2.0.0) - activesupport (4.1.6) - i18n (~> 0.6, >= 0.6.9) - json (~> 1.7, >= 1.7.7) - minitest (~> 5.1) - thread_safe (~> 0.1) - tzinfo (~> 1.1) - arel (5.0.1.20140414130214) - axiom-types (0.1.1) - descendants_tracker (~> 0.0.4) - ice_nine (~> 0.11.0) - thread_safe (~> 0.3, >= 0.3.1) - bcrypt (3.1.11) - builder (3.2.2) - capybara (2.4.1) - mime-types (>= 1.16) - nokogiri (>= 1.3.3) - rack (>= 1.0.0) - rack-test (>= 0.5.4) - xpath (~> 2.0) - coercible (1.0.0) - descendants_tracker (~> 0.0.1) - concurrent-ruby (1.0.5) - descendants_tracker (0.0.4) - thread_safe (~> 0.3, >= 0.3.1) - devise (3.5.10) - bcrypt (~> 3.0) - orm_adapter (~> 0.1) - railties (>= 3.2.6, < 5) - responders - thread_safe (~> 0.1) - warden (~> 1.2.3) - diff-lcs (1.2.5) - equalizer (0.0.11) - erubis (2.7.0) - factory_girl (4.4.0) - activesupport (>= 3.0.0) - grape (0.19.1) - activesupport - builder - hashie (>= 2.1.0) - multi_json (>= 1.3.2) - multi_xml (>= 0.5.2) - mustermann-grape (~> 0.4.0) - rack (>= 1.3.0) - rack-accept - virtus (>= 1.0.0) - hashie (3.5.5) - i18n (0.6.11) - ice_nine (0.11.2) - json (1.8.1) - mail (2.6.4) - mime-types (>= 1.16, < 4) - mime-types (2.3) - mini_portile (0.6.0) - minitest (5.4.1) - multi_json (1.12.1) - multi_xml (0.6.0) - mustermann (0.4.0) - tool (~> 0.2) - mustermann-grape (0.4.0) - mustermann (= 0.4.0) - nokogiri (1.6.3.1) - mini_portile (= 0.6.0) - orm_adapter (0.5.0) - rack (1.5.2) - rack-accept (0.4.5) - rack (>= 0.4) - rack-test (0.6.2) - rack (>= 1.0) - rails (4.1.6) - actionmailer (= 4.1.6) - actionpack (= 4.1.6) - actionview (= 4.1.6) - activemodel (= 4.1.6) - activerecord (= 4.1.6) - activesupport (= 4.1.6) - bundler (>= 1.3.0, < 2.0) - railties (= 4.1.6) - sprockets-rails (~> 2.0) - railties (4.1.6) - actionpack (= 4.1.6) - activesupport (= 4.1.6) - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rake (10.3.2) - responders (1.1.2) - railties (>= 3.2, < 4.2) - rspec (2.99.0) - rspec-core (~> 2.99.0) - rspec-expectations (~> 2.99.0) - rspec-mocks (~> 2.99.0) - rspec-collection_matchers (1.0.0) - rspec-expectations (>= 2.99.0.beta1) - rspec-core (2.99.2) - rspec-expectations (2.99.2) - diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.99.2) - rspec-rails (2.99.0) - actionpack (>= 3.0) - activemodel (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-collection_matchers - rspec-core (~> 2.99.0) - rspec-expectations (~> 2.99.0) - rspec-mocks (~> 2.99.0) - sprockets (3.7.1) - concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (2.3.3) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) - sqlite3 (1.3.9) - thor (0.19.1) - thread_safe (0.3.4) - tool (0.2.3) - tzinfo (1.2.2) - thread_safe (~> 0.1) - virtus (1.0.5) - axiom-types (~> 0.1) - coercible (~> 1.0) - descendants_tracker (~> 0.0, >= 0.0.3) - equalizer (~> 0.0, >= 0.0.9) - warden (1.2.7) - rack (>= 1.0) - xpath (2.0.0) - nokogiri (~> 1.3) - -PLATFORMS - ruby - -DEPENDENCIES - activerecord-nulldb-adapter (~> 0.3.1) - capybara (~> 2.4.1) - factory_girl (~> 4.4.0) - grape_devise! - rspec (~> 2.99.0) - rspec-rails (~> 2.99.0) - sqlite3 - -BUNDLED WITH - 1.14.5 diff --git a/gems/grape_devise/MIT-LICENSE b/gems/grape_devise/MIT-LICENSE deleted file mode 100644 index 018ae82b..00000000 --- a/gems/grape_devise/MIT-LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -Copyright 2014 justinm -Copyright 2018 CommitChange - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/gems/grape_devise/README.md b/gems/grape_devise/README.md deleted file mode 100644 index 85831604..00000000 --- a/gems/grape_devise/README.md +++ /dev/null @@ -1,39 +0,0 @@ -# Grape::Devise - -Grape::Devise adds support for devise helpers from inside Grape::APIs. - -NOTE: this project was originally at https://github.com/justinm/grape_devise -but is not longer supported so we moved it into our repo. - -## Installing - -Installing is simple. Just add the grape_devise gem to your Gemfile, run -```bundle install``` and it's ready to go. - -``` -gem 'grape_devise' -``` - -## Usage - -The devise API can now be accessed from inside of Grape request blocks. - -``` -class MyAPI < Grape::API - get "/requires-authentication" do - authenticate_user! - end - - get "/who-am-i" do - current_user - end -end - -``` - -## FAQ - -####Can I use this with rails -Yes you can! Grape::Devise works with your existing rails sessions to provide -seamless authentication between your rails app and grape APIs. - diff --git a/gems/grape_devise/Rakefile b/gems/grape_devise/Rakefile deleted file mode 100644 index 07595d91..00000000 --- a/gems/grape_devise/Rakefile +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -begin - require 'bundler/setup' -rescue LoadError - puts 'You must `gem install bundler` and `bundle install` to run rake tasks' -end - -require 'rdoc/task' - -RDoc::Task.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'GrapeDevise' - rdoc.options << '--line-numbers' - rdoc.rdoc_files.include('README.rdoc') - rdoc.rdoc_files.include('lib/**/*.rb') -end - -require 'rspec/core/rake_task' - -RSpec::Core::RakeTask.new(:spec) - -Bundler::GemHelper.install_tasks - -task default: :spec diff --git a/gems/grape_devise/grape_devise.gemspec b/gems/grape_devise/grape_devise.gemspec deleted file mode 100644 index 6cf5fa2f..00000000 --- a/gems/grape_devise/grape_devise.gemspec +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -$LOAD_PATH.push File.expand_path('lib', __dir__) - -# Maintain your gem's version: -require 'grape_devise/version' - -# Describe your gem and declare its dependencies: -Gem::Specification.new do |s| - s.name = 'grape_devise' - s.version = GrapeDevise::VERSION - s.authors = ['Justin McCormick'] - s.email = ['me@justinmccormick.com'] - s.homepage = 'http://github.com/justinm/grape_devise' - s.summary = 'Adds support for devise in grape applications' - s.description = 'This gem provides access to devise helpers inside of ' - 'Grape applications.' - - s.licenses = ['MIT'] - - s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE ', 'Rakefile', 'README.rdoc'] - s.test_files = Dir['test/**/*'] - - s.add_development_dependency 'activerecord-nulldb-adapter', '~> 0.3.1' - s.add_development_dependency 'capybara', '~> 2.4.1' - s.add_development_dependency 'factory_girl', '~> 4.4.0' - s.add_development_dependency 'rspec', '~> 2.99.0' - s.add_development_dependency 'rspec-rails', '~> 2.99.0' - s.add_development_dependency 'sqlite3' - - s.add_dependency 'devise', '>= 2.2.8', '< 5' - s.add_dependency 'grape', '> 0.7' - s.add_dependency 'rails', '> 3.2', '< 6' -end diff --git a/gems/grape_devise/lib/grape_devise.rb b/gems/grape_devise/lib/grape_devise.rb deleted file mode 100644 index 533cc787..00000000 --- a/gems/grape_devise/lib/grape_devise.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -module GrapeDevise -end - -require 'devise' -require 'grape' -require 'grape_devise/api' - -Devise.helpers << GrapeDevise::API -Grape::Endpoint.send :include, GrapeDevise::API diff --git a/gems/grape_devise/lib/grape_devise/api.rb b/gems/grape_devise/lib/grape_devise/api.rb deleted file mode 100644 index 771d69f7..00000000 --- a/gems/grape_devise/lib/grape_devise/api.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -require 'devise' - -module GrapeDevise::API - extend ActiveSupport::Concern - include Devise::Controllers::SignInOut - - def self.define_helpers(mapping) - mapping = mapping.name.to_s - - class_eval <<-METHODS, __FILE__, __LINE__ + 1 - def warden - env["warden"] - end - - def authenticate_#{mapping}!(opts={}) - opts[:scope] = :#{mapping} - env["devise.allow_params_authentication"] = true - if opts.delete(:force) || current_#{mapping}.nil? - error!("401 Forbidden", 401) unless warden.authenticate(opts) - end - end - - def #{mapping}_signed_in? - !!current_#{mapping} - end - - def current_#{mapping} - @current_#{mapping} ||= warden.authenticate(scope: :#{mapping}) - end - - def #{mapping}_session - current_#{mapping} && warden.session(:#{mapping}) - end - METHODS - end -end diff --git a/gems/grape_devise/lib/grape_devise/version.rb b/gems/grape_devise/lib/grape_devise/version.rb deleted file mode 100644 index 0932866c..00000000 --- a/gems/grape_devise/lib/grape_devise/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -module GrapeDevise - VERSION = '0.1.1' -end diff --git a/gems/grape_devise/spec/dummy/README.rdoc b/gems/grape_devise/spec/dummy/README.rdoc deleted file mode 100644 index dd4e97e2..00000000 --- a/gems/grape_devise/spec/dummy/README.rdoc +++ /dev/null @@ -1,28 +0,0 @@ -== README - -This README would normally document whatever steps are necessary to get the -application up and running. - -Things you may want to cover: - -* Ruby version - -* System dependencies - -* Configuration - -* Database creation - -* Database initialization - -* How to run the test suite - -* Services (job queues, cache servers, search engines, etc.) - -* Deployment instructions - -* ... - - -Please feel free to use a different markup language if you do not plan to run -rake doc:app. diff --git a/gems/grape_devise/spec/dummy/Rakefile b/gems/grape_devise/spec/dummy/Rakefile deleted file mode 100644 index 5df4030a..00000000 --- a/gems/grape_devise/spec/dummy/Rakefile +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -# Add your own tasks in files placed in lib/tasks ending in .rake, -# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. - -require File.expand_path('config/application', __dir__) - -require 'rspec/core/rake_task' -RSpec::Core::RakeTask.new(:spec) - -Dummy::Application.load_tasks diff --git a/gems/grape_devise/spec/dummy/app/api/api.rb b/gems/grape_devise/spec/dummy/app/api/api.rb deleted file mode 100644 index b341fc5d..00000000 --- a/gems/grape_devise/spec/dummy/app/api/api.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -require 'grape_devise' - -class API < Grape::API - format :json - - get 'me' do - authenticate_user! - current_user - end - - get 'authorized' do - user_signed_in? - end - - post 'signin' do - authenticate_user! - end -end diff --git a/gems/grape_devise/spec/dummy/app/assets/images/.keep b/gems/grape_devise/spec/dummy/app/assets/images/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/gems/grape_devise/spec/dummy/app/assets/javascripts/application.js b/gems/grape_devise/spec/dummy/app/assets/javascripts/application.js deleted file mode 100644 index 5bc2e1c8..00000000 --- a/gems/grape_devise/spec/dummy/app/assets/javascripts/application.js +++ /dev/null @@ -1,13 +0,0 @@ -// This is a manifest file that'll be compiled into application.js, which will include all the files -// listed below. -// -// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, -// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. -// -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// compiled file. -// -// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details -// about supported directives. -// -//= require_tree . diff --git a/gems/grape_devise/spec/dummy/app/assets/stylesheets/application.css b/gems/grape_devise/spec/dummy/app/assets/stylesheets/application.css deleted file mode 100644 index 3192ec89..00000000 --- a/gems/grape_devise/spec/dummy/app/assets/stylesheets/application.css +++ /dev/null @@ -1,13 +0,0 @@ -/* - * This is a manifest file that'll be compiled into application.css, which will include all the files - * listed below. - * - * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, - * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. - * - * You're free to add application-wide styles to this file and they'll appear at the top of the - * compiled file, but it's generally better to create a new file per style scope. - * - *= require_self - *= require_tree . - */ diff --git a/gems/grape_devise/spec/dummy/app/controllers/application_controller.rb b/gems/grape_devise/spec/dummy/app/controllers/application_controller.rb deleted file mode 100644 index 1ff0944d..00000000 --- a/gems/grape_devise/spec/dummy/app/controllers/application_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class ApplicationController < ActionController::Base - # Prevent CSRF attacks by raising an exception. - # For APIs, you may want to use :null_session instead. - protect_from_forgery with: :exception -end diff --git a/gems/grape_devise/spec/dummy/app/controllers/concerns/.keep b/gems/grape_devise/spec/dummy/app/controllers/concerns/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/gems/grape_devise/spec/dummy/app/helpers/application_helper.rb b/gems/grape_devise/spec/dummy/app/helpers/application_helper.rb deleted file mode 100644 index 15b06f0f..00000000 --- a/gems/grape_devise/spec/dummy/app/helpers/application_helper.rb +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true - -module ApplicationHelper -end diff --git a/gems/grape_devise/spec/dummy/app/mailers/.keep b/gems/grape_devise/spec/dummy/app/mailers/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/gems/grape_devise/spec/dummy/app/models/.keep b/gems/grape_devise/spec/dummy/app/models/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/gems/grape_devise/spec/dummy/app/models/concerns/.keep b/gems/grape_devise/spec/dummy/app/models/concerns/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/gems/grape_devise/spec/dummy/app/models/user.rb b/gems/grape_devise/spec/dummy/app/models/user.rb deleted file mode 100644 index e6a02e67..00000000 --- a/gems/grape_devise/spec/dummy/app/models/user.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -class User < ActiveRecord::Base - # Include default devise modules. Others available are: - # :confirmable, :lockable, :timeoutable and :omniauthable - devise :database_authenticatable -end diff --git a/gems/grape_devise/spec/dummy/app/views/layouts/application.html.erb b/gems/grape_devise/spec/dummy/app/views/layouts/application.html.erb deleted file mode 100644 index 670d1875..00000000 --- a/gems/grape_devise/spec/dummy/app/views/layouts/application.html.erb +++ /dev/null @@ -1,14 +0,0 @@ - - -
-You may have mistyped the address or the page may have moved.
-If you are the application owner check the logs for more information.
- - diff --git a/gems/grape_devise/spec/dummy/public/422.html b/gems/grape_devise/spec/dummy/public/422.html deleted file mode 100644 index fbb4b84d..00000000 --- a/gems/grape_devise/spec/dummy/public/422.html +++ /dev/null @@ -1,58 +0,0 @@ - - - -Maybe you tried to change something you didn't have access to.
-If you are the application owner check the logs for more information.
- - diff --git a/gems/grape_devise/spec/dummy/public/500.html b/gems/grape_devise/spec/dummy/public/500.html deleted file mode 100644 index e9052d35..00000000 --- a/gems/grape_devise/spec/dummy/public/500.html +++ /dev/null @@ -1,57 +0,0 @@ - - - -If you are the application owner check the logs for more information.
- - diff --git a/gems/grape_devise/spec/dummy/public/favicon.ico b/gems/grape_devise/spec/dummy/public/favicon.ico deleted file mode 100644 index e69de29b..00000000 diff --git a/gems/grape_devise/spec/factories.rb b/gems/grape_devise/spec/factories.rb deleted file mode 100644 index a3975f3a..00000000 --- a/gems/grape_devise/spec/factories.rb +++ /dev/null @@ -1,9 +0,0 @@ -# frozen_string_literal: true - -FactoryGirl.define do - factory :user do - email 'john.doe@example.com' - password '12345' - password_confirmation '12345' - end -end diff --git a/gems/grape_devise/spec/requests/user_spec.rb b/gems/grape_devise/spec/requests/user_spec.rb deleted file mode 100644 index 25ce81bd..00000000 --- a/gems/grape_devise/spec/requests/user_spec.rb +++ /dev/null @@ -1,53 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' -require 'warden/test/helpers' - -RSpec.describe API, type: :request do - include Warden::Test::Helpers - - let(:user) { build(:user) } - - after { Warden.test_reset! } - - it 'should return the current user' do - login_as user, scope: :user - - get '/me' - - response.body.should eq(user.to_json) - end - - it 'should return an error if not logged in' do - login_as nil, scope: :user - - get '/me' - - response.code.should eq('401') - end - - it 'should return true if logged in' do - login_as user, scope: :user - - get '/authorized' - - response.body.should eq('true') - end - - it 'should return false if logged out' do - login_as nil, scope: :user - - get '/authorized' - - response.body.should eq('false') - end - - it 'should log in the user' do - User.stub :find_for_database_authentication do - user - end - post '/signin', user: { email: user.email, password: user.password } - - response.code.should eq('201') - end -end diff --git a/gems/grape_devise/spec/spec_helper.rb b/gems/grape_devise/spec/spec_helper.rb deleted file mode 100644 index 0212f7b1..00000000 --- a/gems/grape_devise/spec/spec_helper.rb +++ /dev/null @@ -1,38 +0,0 @@ -# frozen_string_literal: true - -# Configure Rails Environment -ENV['RAILS_ENV'] = 'test' - -require File.expand_path('dummy/config/environment.rb', __dir__) -require 'rspec' -require 'rspec/rails' -require 'factory_girl' -require 'warden' -require 'devise' -require 'capybara/dsl' -require 'factories' -require 'nulldb/rails' -Warden.test_mode! - -Rails.backtrace_cleaner.remove_silencers! - -# Requires supporting ruby files with custom matchers and macros, etc, -# in spec/support/ and its subdirectories. -Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } - -RSpec.configure do |config| - # == Mock Framework - # - # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: - # - # config.mock_with :mocha - # config.mock_with :flexmock - # config.mock_with :rr - config.mock_with :rspec - config.use_transactional_fixtures = true - config.infer_spec_type_from_file_location! - - config.include Capybara::DSL, type: :request - config.include FactoryGirl::Syntax::Methods - config.include Devise::Test::ControllerHelpers, type: :controller -end diff --git a/lib/generators/api/entity/USAGE b/lib/generators/api/entity/USAGE deleted file mode 100644 index 562368c0..00000000 --- a/lib/generators/api/entity/USAGE +++ /dev/null @@ -1,9 +0,0 @@ -Description: - Generates a new entity to be returned by the API - -Example: - rails generate api:entity EntityName - - This will create: - A new subclass of Grape::Entity called Houdini::V1::Entities::EntityName - in app/api/houdini/v1/entities/entity_name.rb diff --git a/lib/generators/api/entity/entity_generator.rb b/lib/generators/api/entity/entity_generator.rb deleted file mode 100644 index 1382f313..00000000 --- a/lib/generators/api/entity/entity_generator.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -require 'rails/generators' -class Api::EntityGenerator < Rails::Generators::NamedBase - source_root File.expand_path('templates', __dir__) - def copy_to_entity - template 'entity.rb.erb', File.join('app/api/houdini/v1/entities', "#{name.underscore}.rb") - end -end diff --git a/lib/generators/api/entity/templates/entity.rb.erb b/lib/generators/api/entity/templates/entity.rb.erb deleted file mode 100644 index 64f86fee..00000000 --- a/lib/generators/api/entity/templates/entity.rb.erb +++ /dev/null @@ -1,4 +0,0 @@ -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -class Houdini::V1::Entities::<%= name.camelcase %> < Grape::Entity - -end \ No newline at end of file diff --git a/lib/generators/api/resource/USAGE b/lib/generators/api/resource/USAGE deleted file mode 100644 index 74598d4b..00000000 --- a/lib/generators/api/resource/USAGE +++ /dev/null @@ -1,10 +0,0 @@ -Description: - Creates a new resource for API usage - -Example: - rails generate api:resource ResourceName - - This will create: - * A new subclass of Grape::API called Houdini::V1::ResourceName - at app/api/houdini/v1/resource_name.rb - * Houdini::V1::ResourceName mounted to the api in app/api/houdini/v1/api.rb \ No newline at end of file diff --git a/lib/generators/api/resource/resource_generator.rb b/lib/generators/api/resource/resource_generator.rb deleted file mode 100644 index a233320f..00000000 --- a/lib/generators/api/resource/resource_generator.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -require 'rails/generators' -class Api::ResourceGenerator < Rails::Generators::NamedBase - source_root File.expand_path('templates', __dir__) - def copy_to_resource - template 'resource.rb.erb', File.join('app/api/houdini/v1', "#{name.underscore}.rb") - end - - def copy_to_spec - template 'spec.rb.erb', File.join('spec/api/houdini/', "#{name.underscore}_spec.rb") - end - - def add_to_root_api - inject_into_file 'app/api/houdini/v1/api.rb', "mount Houdini::V1::#{name.camelcase} => \"/#{name.underscore}\"\n ", before: '# Additional mounts are added via generators above this line' - end -end diff --git a/lib/generators/api/resource/templates/resource.rb.erb b/lib/generators/api/resource/templates/resource.rb.erb deleted file mode 100644 index ac7e9d67..00000000 --- a/lib/generators/api/resource/templates/resource.rb.erb +++ /dev/null @@ -1,3 +0,0 @@ -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -class Houdini::V1::<%= name.camelcase %> < Grape::API -end \ No newline at end of file diff --git a/lib/generators/api/resource/templates/spec.rb.erb b/lib/generators/api/resource/templates/spec.rb.erb deleted file mode 100644 index 66d129b1..00000000 --- a/lib/generators/api/resource/templates/spec.rb.erb +++ /dev/null @@ -1,8 +0,0 @@ -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -require 'rails_helper' - -describe Houdini::V1::<%= name.camelcase %>, :type => :request do - describe 'get', :get do - - end -end \ No newline at end of file diff --git a/lib/generators/api/validator/USAGE b/lib/generators/api/validator/USAGE deleted file mode 100644 index 93ffa304..00000000 --- a/lib/generators/api/validator/USAGE +++ /dev/null @@ -1,8 +0,0 @@ -Description: - Explain the generator - -Example: - rails generate validator Thing - - This will create: - what/will/it/create diff --git a/lib/generators/api/validator/templates/validator.rb.erb b/lib/generators/api/validator/templates/validator.rb.erb deleted file mode 100644 index 3dcb5584..00000000 --- a/lib/generators/api/validator/templates/validator.rb.erb +++ /dev/null @@ -1,6 +0,0 @@ -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -class Houdini::V1::Validators::<%= name.camelcase %> < Grape::Validations::Base - def validate_param!(attr_name, params) - fail Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: 'MESSAGE' - end -end \ No newline at end of file diff --git a/lib/generators/api/validator/validator_generator.rb b/lib/generators/api/validator/validator_generator.rb deleted file mode 100644 index 23492492..00000000 --- a/lib/generators/api/validator/validator_generator.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later -require 'rails/generators' -class Api::ValidatorGenerator < Rails::Generators::NamedBase - source_root File.expand_path('templates', __dir__) - - def copy_to_validators - post_api_part = File.join('houdini/v1/validators', "#{name.underscore}.rb") - output_file = File.join('app/api', post_api_part) - template 'validator.rb.erb', output_file - end - - def add_to_root_validations - post_api_part = File.join('houdini/v1/validators', name.underscore.to_s) - append_to_file 'app/api/houdini/v1/validations.rb', "\nrequire '#{post_api_part}'" - end -end diff --git a/lib/tasks/oapi.rake b/lib/tasks/oapi.rake deleted file mode 100644 index 46fb359a..00000000 --- a/lib/tasks/oapi.rake +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -require 'grape-swagger/rake/oapi_tasks' -namespace :oapi do - task gen: [:environment] do - ENV['store'] = 'tmp/openapi.json' - GrapeSwagger::Rake::OapiTasks.new(Houdini::API) - Rake::Task['oapi:fetch'].invoke - end -end