draper 4.0.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a90d57e1df50336b735a6f16cc119a558ee8472b70bd9748c59f25b70afc319a
4
- data.tar.gz: a4510f40a8afac7976e7afea4659d8e1c3eb981c005bc4046660b4d110874df7
3
+ metadata.gz: 6b009279cf28737a6fcf4027fc26f3dc2a955741c7c5e5d2220c8dcb383490e3
4
+ data.tar.gz: 22455a3a7126650483af269d6a0e432a5a4465a59c762518ce78f40bcecb4286
5
5
  SHA512:
6
- metadata.gz: bee71715525fdc2de5336c399b1dfe4a774d9fd68071bb01468c8f31712504cf6af8beecf1f4facf4ea25ef5bcad7a14b2e2f12bec12f7b6f1e55c04318c4f7a
7
- data.tar.gz: 8f013f4b36efa767ada401a979e5bf10e28f068997d24fd8035e4025254300709eb7c2e80c5f0498cc49c176b7561fbff48e2cc03f39b418f368c3266bf30359
6
+ metadata.gz: 2fd6c0b87227c23320e9ee211b4b2001c81cbf76d103a12e5076f427954febdb2d0366d5182f16b27f5155717ad878f08671098f8b1f9986c137ec053e1637bf
7
+ data.tar.gz: 260d4eccd57c623c966422cd256ab1485e1ce4bbaea05d2c6f615cdb644ab0147f00e8917b8165eba78651f279b66cde0a13da38b1c5cc9dc6a0e49822db2361
@@ -0,0 +1,55 @@
1
+ ---
2
+ name: CI
3
+
4
+ on:
5
+ - push
6
+ - pull_request
7
+
8
+ jobs:
9
+ rspec:
10
+ runs-on: ubuntu-20.04
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ ruby:
15
+ - '3.0'
16
+ - '2.7'
17
+ - '2.6'
18
+ - '2.5'
19
+ - '2.4'
20
+
21
+ services:
22
+ mongodb:
23
+ image: mongo
24
+ ports:
25
+ - 27017:27017
26
+
27
+ steps:
28
+ - name: Checkout
29
+ uses: actions/checkout@v2
30
+
31
+ - name: Setup Ruby
32
+ uses: ruby/setup-ruby@v1
33
+ with:
34
+ ruby-version: ${{ matrix.ruby }}
35
+
36
+ - name: Setup Ruby cache
37
+ uses: actions/cache@v2
38
+ with:
39
+ path: vendor/bundle
40
+ key: ${{ runner.os }}-gems-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
41
+ restore-keys: |
42
+ ${{ runner.os }}-gems-${{ matrix.ruby }}-
43
+
44
+ - name: Bundle
45
+ run: |
46
+ gem install bundler
47
+ bundle config path vendor/bundle
48
+ bundle install --jobs 4 --retry 3
49
+
50
+ - name: RSpec & publish code coverage
51
+ uses: paambaati/codeclimate-action@v2.7.5
52
+ env:
53
+ CC_TEST_REPORTER_ID: b7ba588af2a540fa96c267b3655a2afe31ea29976dc25905a668dd28d5e88915
54
+ with:
55
+ coverageCommand: bin/rake
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Draper Changelog
2
2
 
3
+ ## 4.0.2 - 2021-05-27
4
+
5
+ ### Fixes
6
+ * Fix kwargs usage for Ruby 3 compatibility [#885](https://github.com/drapergem/draper/pull/885)
7
+ * Fix ruby warnings for "ambiguous first argument" [#881](https://github.com/drapergem/draper/pull/881)
8
+ * Fix rake warnings in CI [#897](https://github.com/drapergem/draper/pull/897)
9
+ * Fix decoration spec [#895](https://github.com/drapergem/draper/pull/895)
10
+
11
+ ### Other Changes
12
+ * Migration from Travis CI to GitHub Actions [#893](https://github.com/drapergem/draper/pull/893), [#896](https://github.com/drapergem/draper/pull/896), [#903](https://github.com/drapergem/draper/pull/903)
13
+
3
14
  ## 4.0.1 - 2020-03-25
4
15
 
5
16
  ### Fixes
data/Gemfile CHANGED
@@ -17,6 +17,7 @@ end
17
17
 
18
18
  if RUBY_VERSION >= "2.5.0"
19
19
  gem "rails", "~> 6.0"
20
+ gem 'webrick'
20
21
  else
21
22
  gem "rails", "~> 5.0"
22
23
  end
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Draper: View Models for Rails
2
2
 
3
- [![TravisCI Build Status](https://travis-ci.org/drapergem/draper.svg?branch=master)](http://travis-ci.org/drapergem/draper)
3
+ [![Actions Status](https://github.com/drapergem/draper/workflows/CI/badge.svg?branch=master)](https://github.com/drapergem/draper/actions?query=workflow%3Aci+branch%3Amaster)
4
4
  [![Code Climate](https://codeclimate.com/github/drapergem/draper.svg)](https://codeclimate.com/github/drapergem/draper)
5
5
  [![Test Coverage](https://api.codeclimate.com/v1/badges/0d40c43951d516bf6985/test_coverage)](https://codeclimate.com/github/drapergem/draper/test_coverage)
6
6
  [![Inline docs](http://inch-ci.org/github/drapergem/draper.svg?branch=master)](http://inch-ci.org/github/drapergem/draper)
data/bin/bundle ADDED
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m = Module.new do
14
+ module_function
15
+
16
+ def invoked_as_script?
17
+ File.expand_path($0) == File.expand_path(__FILE__)
18
+ end
19
+
20
+ def env_var_version
21
+ ENV["BUNDLER_VERSION"]
22
+ end
23
+
24
+ def cli_arg_version
25
+ return unless invoked_as_script? # don't want to hijack other binstubs
26
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
+ bundler_version = nil
28
+ update_index = nil
29
+ ARGV.each_with_index do |a, i|
30
+ if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
+ bundler_version = a
32
+ end
33
+ next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
+ bundler_version = $1
35
+ update_index = i
36
+ end
37
+ bundler_version
38
+ end
39
+
40
+ def gemfile
41
+ gemfile = ENV["BUNDLE_GEMFILE"]
42
+ return gemfile if gemfile && !gemfile.empty?
43
+
44
+ File.expand_path("../../Gemfile", __FILE__)
45
+ end
46
+
47
+ def lockfile
48
+ lockfile =
49
+ case File.basename(gemfile)
50
+ when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
+ else "#{gemfile}.lock"
52
+ end
53
+ File.expand_path(lockfile)
54
+ end
55
+
56
+ def lockfile_version
57
+ return unless File.file?(lockfile)
58
+ lockfile_contents = File.read(lockfile)
59
+ return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
+ Regexp.last_match(1)
61
+ end
62
+
63
+ def bundler_version
64
+ @bundler_version ||=
65
+ env_var_version || cli_arg_version ||
66
+ lockfile_version
67
+ end
68
+
69
+ def bundler_requirement
70
+ return "#{Gem::Requirement.default}.a" unless bundler_version
71
+
72
+ bundler_gem_version = Gem::Version.new(bundler_version)
73
+
74
+ requirement = bundler_gem_version.approximate_recommendation
75
+
76
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
77
+
78
+ requirement += ".a" if bundler_gem_version.prerelease?
79
+
80
+ requirement
81
+ end
82
+
83
+ def load_bundler!
84
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
85
+
86
+ activate_bundler
87
+ end
88
+
89
+ def activate_bundler
90
+ gem_error = activation_error_handling do
91
+ gem "bundler", bundler_requirement
92
+ end
93
+ return if gem_error.nil?
94
+ require_error = activation_error_handling do
95
+ require "bundler/version"
96
+ end
97
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99
+ exit 42
100
+ end
101
+
102
+ def activation_error_handling
103
+ yield
104
+ nil
105
+ rescue StandardError, LoadError => e
106
+ e
107
+ end
108
+ end
109
+
110
+ m.load_bundler!
111
+
112
+ if m.invoked_as_script?
113
+ load Gem.bin_path("bundler", "bundle")
114
+ end
data/bin/rake ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
data/draper.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- require File.join(__dir__, "lib", "draper", "version")
1
+ require_relative 'lib/draper/version'
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "draper"
@@ -12,7 +12,6 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = `git ls-files`.split("\n")
14
14
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
15
  s.require_paths = ["lib"]
17
16
 
18
17
  s.required_ruby_version = '>= 2.2.2'
@@ -22,6 +21,7 @@ Gem::Specification.new do |s|
22
21
  s.add_dependency 'request_store', '>= 1.0'
23
22
  s.add_dependency 'activemodel', '>= 5.0'
24
23
  s.add_dependency 'activemodel-serializers-xml', '>= 1.0'
24
+ s.add_dependency 'ruby2_keywords'
25
25
 
26
26
  s.add_development_dependency 'ammeter'
27
27
  s.add_development_dependency 'rake'
@@ -30,5 +30,5 @@ Gem::Specification.new do |s|
30
30
  s.add_development_dependency 'capybara'
31
31
  s.add_development_dependency 'active_model_serializers', '>= 0.10'
32
32
  s.add_development_dependency 'rubocop'
33
- s.add_development_dependency 'simplecov'
33
+ s.add_development_dependency 'simplecov', '0.17.1'
34
34
  end
data/lib/draper.rb CHANGED
@@ -8,6 +8,8 @@ require 'active_support/core_ext/hash/keys'
8
8
  require 'active_support/core_ext/hash/reverse_merge'
9
9
  require 'active_support/core_ext/name_error'
10
10
 
11
+ require 'ruby2_keywords'
12
+
11
13
  require 'draper/version'
12
14
  require 'draper/configuration'
13
15
  require 'draper/view_helpers'
@@ -6,7 +6,7 @@ module Draper
6
6
  # method calls to `object` as well. Calling `super` will first try to call the method on
7
7
  # the parent decorator class. If no method exists on the parent class, it will then try
8
8
  # to call the method on the `object`.
9
- def method_missing(method, *args, &block)
9
+ ruby2_keywords def method_missing(method, *args, &block)
10
10
  return super unless delegatable?(method)
11
11
 
12
12
  object.send(method, *args, &block)
@@ -27,7 +27,7 @@ module Draper
27
27
 
28
28
  module ClassMethods
29
29
  # Proxies missing class methods to the source class.
30
- def method_missing(method, *args, &block)
30
+ ruby2_keywords def method_missing(method, *args, &block)
31
31
  return super unless delegatable?(method)
32
32
 
33
33
  object_class.send(method, *args, &block)
@@ -8,7 +8,7 @@ module Draper
8
8
  end
9
9
 
10
10
  # Sends helper methods to the view context.
11
- def method_missing(method, *args, &block)
11
+ ruby2_keywords def method_missing(method, *args, &block)
12
12
  self.class.define_proxy method
13
13
  send(method, *args, &block)
14
14
  end
@@ -31,6 +31,7 @@ module Draper
31
31
  define_method name do |*args, &block|
32
32
  view_context.send(name, *args, &block)
33
33
  end
34
+ ruby2_keywords name
34
35
  end
35
36
  end
36
37
  end
@@ -4,7 +4,7 @@ module Draper
4
4
  # bazillion methods.
5
5
  module LazyHelpers
6
6
  # Sends missing methods to the {HelperProxy}.
7
- def method_missing(method, *args, &block)
7
+ ruby2_keywords def method_missing(method, *args, &block)
8
8
  helpers.send(method, *args, &block)
9
9
  rescue NoMethodError
10
10
  super
@@ -3,7 +3,7 @@ require_relative 'query_methods/load_strategy'
3
3
  module Draper
4
4
  module QueryMethods
5
5
  # Proxies missing query methods to the source class if the strategy allows.
6
- def method_missing(method, *args, &block)
6
+ ruby2_keywords def method_missing(method, *args, &block)
7
7
  return super unless strategy.allowed? method
8
8
 
9
9
  object.send(method, *args, &block).decorate(with: decorator_class, context: context)
@@ -1,3 +1,3 @@
1
1
  module Draper
2
- VERSION = '4.0.1'
2
+ VERSION = '4.0.2'
3
3
  end
@@ -28,7 +28,7 @@ module Draper
28
28
 
29
29
  # Alias for `helpers.localize`, since localize is something that's used
30
30
  # quite often. Further aliased to `l` for convenience.
31
- def localize(*args)
31
+ ruby2_keywords def localize(*args)
32
32
  helpers.localize(*args)
33
33
  end
34
34
 
@@ -60,10 +60,11 @@ module Draper
60
60
 
61
61
  context "when the collection has not yet been decorated" do
62
62
  it "does not trigger decoration" do
63
- decorator = CollectionDecorator.new([])
63
+ decorated = CollectionDecorator.new([]).tap(&:to_a)
64
+ undecorated = CollectionDecorator.new([])
64
65
 
65
- expect(decorator).not_to receive(:decorated_collection)
66
- decorator.context = {other: "context"}
66
+ expect(decorated.instance_variable_defined?(:@decorated_collection)).to be_truthy
67
+ expect(undecorated.instance_variable_defined?(:@decorated_collection)).to be_falsy
67
68
  end
68
69
 
69
70
  it "sets context after decoration is triggered" do
@@ -217,7 +218,7 @@ module Draper
217
218
  it "uses the custom class name" do
218
219
  decorator = ProductsDecorator.new([])
219
220
 
220
- expect(decorator.to_s).to match /ProductsDecorator/
221
+ expect(decorator.to_s).to match(/ProductsDecorator/)
221
222
  end
222
223
  end
223
224
  end
@@ -439,7 +439,7 @@ module Draper
439
439
  it "returns a detailed description of the decorator" do
440
440
  decorator = ProductDecorator.new(double)
441
441
 
442
- expect(decorator.inspect).to match /#<ProductDecorator:0x\h+ .+>/
442
+ expect(decorator.inspect).to match(/#<ProductDecorator:0x\h+ .+>/)
443
443
  end
444
444
 
445
445
  it "includes the object" do
@@ -693,7 +693,7 @@ module Draper
693
693
  decorator = decorator_class.new(object)
694
694
 
695
695
  # `print` private method is defined on `Object`
696
- expect{ decorator.print }.not_to raise_error NoMethodError
696
+ expect{ decorator.print }.not_to raise_error
697
697
  end
698
698
  end
699
699
  end
@@ -30,4 +30,6 @@ Dummy::Application.configure do
30
30
 
31
31
  # Expands the lines which load the assets
32
32
  # config.assets.debug = true
33
+
34
+ config.active_storage.service = :local
33
35
  end
@@ -54,4 +54,6 @@ Dummy::Application.configure do
54
54
  # Log the query plan for queries taking more than this (works
55
55
  # with SQLite, MySQL, and PostgreSQL)
56
56
  # config.active_record.auto_explain_threshold_in_seconds = 0.5
57
+
58
+ config.active_storage.service = :local
57
59
  end
@@ -30,4 +30,6 @@ Dummy::Application.configure do
30
30
  config.eager_load = false
31
31
 
32
32
  config.active_job.queue_adapter = :test
33
+
34
+ config.active_storage.service = :test
33
35
  end
@@ -0,0 +1,7 @@
1
+ test:
2
+ service: Disk
3
+ root: <%= Rails.root.join("tmp/storage") %>
4
+
5
+ local:
6
+ service: Disk
7
+ root: <%= Rails.root.join("storage") %>
@@ -40,7 +40,7 @@ describe Rails::Generators::DecoratorGenerator do
40
40
 
41
41
  context "with an ApplicationDecorator" do
42
42
  before do
43
- allow_any_instance_of(Object).to receive(:require)
43
+ allow_any_instance_of(Object).to receive(:require).and_call_original
44
44
  allow_any_instance_of(Object).to receive(:require).with("application_decorator").and_return(
45
45
  stub_const "ApplicationDecorator", Class.new
46
46
  )
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: draper
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Casimir
8
8
  - Steve Klabnik
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-03-25 00:00:00.000000000 Z
12
+ date: 2021-05-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -81,6 +81,20 @@ dependencies:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '1.0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: ruby2_keywords
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: ammeter
86
100
  requirement: !ruby/object:Gem::Requirement
@@ -183,16 +197,16 @@ dependencies:
183
197
  name: simplecov
184
198
  requirement: !ruby/object:Gem::Requirement
185
199
  requirements:
186
- - - ">="
200
+ - - '='
187
201
  - !ruby/object:Gem::Version
188
- version: '0'
202
+ version: 0.17.1
189
203
  type: :development
190
204
  prerelease: false
191
205
  version_requirements: !ruby/object:Gem::Requirement
192
206
  requirements:
193
- - - ">="
207
+ - - '='
194
208
  - !ruby/object:Gem::Version
195
- version: '0'
209
+ version: 0.17.1
196
210
  description: Draper adds an object-oriented layer of presentation logic to your Rails
197
211
  apps.
198
212
  email:
@@ -204,10 +218,10 @@ extra_rdoc_files: []
204
218
  files:
205
219
  - ".codeclimate.yml"
206
220
  - ".github/PULL_REQUEST_TEMPLATE.md"
221
+ - ".github/workflows/ci.yml"
207
222
  - ".gitignore"
208
223
  - ".rspec"
209
224
  - ".rubocop.yml"
210
- - ".travis.yml"
211
225
  - ".yardopts"
212
226
  - CHANGELOG.md
213
227
  - CONTRIBUTING.md
@@ -216,6 +230,8 @@ files:
216
230
  - LICENSE
217
231
  - README.md
218
232
  - Rakefile
233
+ - bin/bundle
234
+ - bin/rake
219
235
  - draper.gemspec
220
236
  - lib/draper.rb
221
237
  - lib/draper/automatic_delegation.rb
@@ -319,6 +335,7 @@ files:
319
335
  - spec/dummy/config/locales/en.yml
320
336
  - spec/dummy/config/mongoid.yml
321
337
  - spec/dummy/config/routes.rb
338
+ - spec/dummy/config/storage.yml
322
339
  - spec/dummy/db/migrate/20121019115657_create_posts.rb
323
340
  - spec/dummy/db/schema.rb
324
341
  - spec/dummy/db/seeds.rb
@@ -369,7 +386,7 @@ homepage: http://github.com/drapergem/draper
369
386
  licenses:
370
387
  - MIT
371
388
  metadata: {}
372
- post_install_message:
389
+ post_install_message:
373
390
  rdoc_options: []
374
391
  require_paths:
375
392
  - lib
@@ -385,7 +402,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
385
402
  version: '0'
386
403
  requirements: []
387
404
  rubygems_version: 3.0.8
388
- signing_key:
405
+ signing_key:
389
406
  specification_version: 4
390
407
  summary: View Models for Rails
391
408
  test_files:
@@ -449,6 +466,7 @@ test_files:
449
466
  - spec/dummy/config/locales/en.yml
450
467
  - spec/dummy/config/mongoid.yml
451
468
  - spec/dummy/config/routes.rb
469
+ - spec/dummy/config/storage.yml
452
470
  - spec/dummy/db/migrate/20121019115657_create_posts.rb
453
471
  - spec/dummy/db/schema.rb
454
472
  - spec/dummy/db/seeds.rb
data/.travis.yml DELETED
@@ -1,28 +0,0 @@
1
- env:
2
- global:
3
- - CC_TEST_REPORTER_ID=b7ba588af2a540fa96c267b3655a2afe31ea29976dc25905a668dd28d5e88915
4
-
5
- language: ruby
6
- cache: bundler
7
-
8
- services:
9
- - mongodb
10
-
11
- rvm:
12
- - 2.4.9
13
- - 2.5.7
14
- - 2.6.5
15
- - 2.7.0
16
- - ruby-head
17
-
18
- matrix:
19
- allow_failures:
20
- - rvm: ruby-head
21
-
22
- before_script:
23
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
24
- - chmod +x ./cc-test-reporter
25
- - ./cc-test-reporter before-build
26
-
27
- after_script:
28
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT