actionview-component 1.8.1 → 1.9.0

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: d236db5b36182b7b47553a9d5edcba890edcda2c1dc09e12a483f59fcad1e43c
4
- data.tar.gz: 83d47a9e35480a4d30f2f8ba2e2759ecd17423513a8500e3a656c5e83c600735
3
+ metadata.gz: 67d62ba2c307963de0523a13f554d1e78b9e76990ace76c36b7d982ec83ef2cb
4
+ data.tar.gz: 66682a57cd5504b054c7c21227bbfb6cdc2c14f0ac151f2d6bb136a1f2e7a6cb
5
5
  SHA512:
6
- metadata.gz: d437983458628e9b66587bcecd015bece3728391275b82453e14085f2461806c97501353725d9866c8aae62a75481aa7cd1a2db46206e1cdaf15ffff824b8a30
7
- data.tar.gz: 6573fe5fe6ca95259145e37e12011c10e3956df14a31597a5ebbf59f1114f85854049c1e7e98af6f176f422c452c49da05449be509a2ec5fe8d2e5a9c9adcd07
6
+ metadata.gz: 0f5b33cb1dfff517ae58afb9167a5f0370f40902eef1ecfef1d6ee0e9f589a255826b92cbccf3bec5fd0a91d487601ec273f6238ddc029a3daade14aa5cd8a5a
7
+ data.tar.gz: f2f58364fba2269e40bf5bd1040872f826365f67e09679996c79999a0755a1ffdbe06f89bb661f80e7a23a2b4791dff6618b28da9a9cf062b1ca41f65ee69dfa
@@ -8,7 +8,7 @@ jobs:
8
8
  strategy:
9
9
  matrix:
10
10
  rails_version: [5.0.0, 5.2.3, 6.0.0, master]
11
- ruby_version: [2.4.x, 2.5.x, 2.6.x]
11
+ ruby_version: [2.5.x, 2.6.x, 2.7.x]
12
12
  exclude:
13
13
  - rails_version: master
14
14
  ruby_version: 2.4.x
@@ -22,7 +22,7 @@ jobs:
22
22
  ruby-version: ${{ matrix.ruby_version }}
23
23
  - name: Build and test with Rake
24
24
  run: |
25
- gem install bundler:1.14.0
25
+ gem install bundler:1.17.3
26
26
  bundle update
27
27
  bundle install --jobs 4 --retry 3
28
28
  bundle exec rake
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # v1.9.0
2
+
3
+ * Remove initializer requirement for Ruby 2.7+
4
+
5
+ *Dylan Clark*
6
+
1
7
  # v1.8.1
2
8
 
3
9
  * Run validation checks before calling `#render?`.
data/CONTRIBUTING.md CHANGED
@@ -34,7 +34,7 @@ Here are a few things you can do that will increase the likelihood of your pull
34
34
  If you are the current maintainer of this gem:
35
35
 
36
36
  1. Create a branch for the release: `git checkout -b release-vxx.xx.xx`
37
- 1. Bump gem version in `lib/action_view/component/version.rb`.
37
+ 1. Bump gem version in `lib/action_view/component/version.rb`. Try to adhere to SemVer.
38
38
  1. Add version heading/entries to `CHANGELOG.md`.
39
39
  1. Make sure your local dependencies are up to date: `bundle`
40
40
  1. Ensure that tests are green: `bundle exec rake`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- actionview-component (1.8.1)
4
+ actionview-component (1.9.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -15,7 +15,7 @@ As the goal of this gem is to be upstreamed into Rails, it is designed to integr
15
15
 
16
16
  ## Compatibility
17
17
 
18
- `actionview-component` is tested for compatibility with combinations of Ruby `2.4`/`2.5`/`2.6` and Rails `5.0.0`/`5.2.3`/`6.0.0`/`6.1.0.alpha`.
18
+ `actionview-component` is tested for compatibility with combinations of Ruby `2.5`/`2.6` and Rails `5.0.0`/`5.2.3`/`6.0.0`/`6.1.0.alpha`.
19
19
 
20
20
  ## Installation
21
21
  Add this line to your application's Gemfile:
@@ -528,6 +528,11 @@ To use component previews, set the following in `config/application.rb`:
528
528
  config.action_view_component.preview_path = "#{Rails.root}/spec/components/previews"
529
529
  ```
530
530
 
531
+ ### Initializer requirement
532
+
533
+ In Ruby 2.6.x and below, ActionView::Component requires the presence of an `initialize` method in each component.
534
+ However, `initialize` is no longer required for projects using 2.7.x and above.
535
+
531
536
  ## Frequently Asked Questions
532
537
 
533
538
  ### Can I use other templating languages besides ERB?
@@ -142,15 +142,11 @@ module ActionView
142
142
 
143
143
  def source_location
144
144
  @source_location ||=
145
- begin
146
- # Require #initialize to be defined so that we can use
147
- # method#source_location to look up the file name
148
- # of the component.
149
- #
150
- # If we were able to only support Ruby 2.7+,
151
- # We could just use Module#const_source_location,
152
- # rendering this unnecessary.
153
- #
145
+ if const_source_location_supported?
146
+ const_source_location(self.name)[0]
147
+ else
148
+ # Require `#initialize` to be defined so that we can use `method#source_location`
149
+ # to look up the filename of the component.
154
150
  initialize_method = instance_method(:initialize)
155
151
  initialize_method.source_location[0] if initialize_method.owner == self
156
152
  end
@@ -210,6 +206,10 @@ module ActionView
210
206
 
211
207
  private
212
208
 
209
+ def const_source_location_supported?
210
+ respond_to? :const_source_location # introduced in Ruby 2.7
211
+ end
212
+
213
213
  def matching_views_in_source_location
214
214
  return [] unless source_location
215
215
  (Dir["#{source_location.chomp(File.extname(source_location))}.*{#{ActionView::Template.template_handler_extensions.join(',')}}"] - [source_location])
@@ -232,7 +232,12 @@ module ActionView
232
232
  @template_errors ||=
233
233
  begin
234
234
  errors = []
235
- errors << "#{self} must implement #initialize." if source_location.nil?
235
+ if source_location.nil? && !const_source_location_supported?
236
+ # Require `#initialize` to be defined so that we can use `method#source_location`
237
+ # to look up the filename of the component.
238
+ errors << "#{self} must implement #initialize."
239
+ end
240
+
236
241
  errors << "Could not find a template file for #{self}." if templates.empty?
237
242
 
238
243
  if templates.count { |template| template[:variant].nil? } > 1
@@ -4,8 +4,8 @@ module ActionView
4
4
  module Component
5
5
  module VERSION
6
6
  MAJOR = 1
7
- MINOR = 8
8
- PATCH = 1
7
+ MINOR = 9
8
+ PATCH = 0
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH].join(".")
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionview-component
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Open Source
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-24 00:00:00.000000000 Z
11
+ date: 2020-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler