enumerate_it 1.5.0 → 1.6.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
  SHA1:
3
- metadata.gz: 73ff26eab60abc3e49c03132a0c3e069fc985da4
4
- data.tar.gz: 2681588dd7bc52233d62f47023dee81c7fc3724a
3
+ metadata.gz: 1558c3ef8bfaf0bfe9ec496af98f6fd794b04dde
4
+ data.tar.gz: bf56fe8d302929046e3acb21d246fe3a25745bdc
5
5
  SHA512:
6
- metadata.gz: b08595f1b91a21a996b6bf1b36ea41e8235d516b9c99b96416b1149dae08a0097b7e47c7c5522d6ef63a15bdb278b7ff7727c7e3d2dd3e410e3f331dd770ed89
7
- data.tar.gz: 400d30edda48484eec9eac387e64fe7d30c929a84a25cecea3e2f85a6f7264b636dde7d03d4686889f612e73b2dcbcb47e5993f0a773a37c2f83759a5d99f01a
6
+ metadata.gz: a39df4cbd269760cbbd1b0d7dc0176c49253f781fa587202307dacc56d3c020c6e37e02b447ec179fb64857df39f9d75d31cb6642d395ab34a6ef5eb1ad03b49
7
+ data.tar.gz: 43d0aab4b4753bdd6af81131f57b4e1ca766f3ee48182c20ff8513b5c4c6d24a051787420ec499e9eddadbda66cb6e5ffa052c0036695d07cc7b074af00efd2e
@@ -21,24 +21,24 @@ Metrics/BlockLength:
21
21
  Exclude:
22
22
  - 'spec/**/*'
23
23
 
24
- Style/AlignHash:
24
+ Layout/AlignHash:
25
25
  EnforcedLastArgumentHashStyle: ignore_implicit
26
26
 
27
- Style/Documentation:
27
+ Layout/ElseAlignment:
28
28
  Enabled: false
29
29
 
30
- Style/ElseAlignment:
30
+ Layout/IndentationWidth:
31
31
  Enabled: false
32
32
 
33
+ Layout/MultilineMethodCallIndentation:
34
+ EnforcedStyle: indented
35
+
33
36
  Style/FrozenStringLiteralComment:
34
37
  Enabled: false
35
38
 
36
- Style/IndentationWidth:
39
+ Style/Documentation:
37
40
  Enabled: false
38
41
 
39
- Style/MultilineMethodCallIndentation:
40
- EnforcedStyle: indented
41
-
42
42
  Style/PredicateName:
43
43
  Exclude:
44
44
  - 'lib/enumerate_it/class_methods.rb'
@@ -23,14 +23,19 @@ gemfile:
23
23
  - gemfiles/rails_4.1.gemfile
24
24
  - gemfiles/rails_4.2.gemfile
25
25
  - gemfiles/rails_5.0.gemfile
26
+ - gemfiles/rails_5.1.gemfile
26
27
 
27
28
  matrix:
28
29
  exclude:
29
- # Rails 5 requires Ruby version 2.2+
30
+ # Rails 5+ requires Ruby 2.2+
30
31
  - rvm: 2.0.0
31
32
  gemfile: gemfiles/rails_5.0.gemfile
33
+ - rvm: 2.0.0
34
+ gemfile: gemfiles/rails_5.1.gemfile
32
35
  - rvm: 2.1.10
33
36
  gemfile: gemfiles/rails_5.0.gemfile
37
+ - rvm: 2.1.10
38
+ gemfile: gemfiles/rails_5.1.gemfile
34
39
 
35
40
  # Rails 4.0 and 4.1 requires an old version of `json` gem, which isn't compatible with Ruby 2.4+
36
41
  # https://github.com/flori/json/issues/308
data/Appraisals CHANGED
@@ -4,7 +4,7 @@ require 'json'
4
4
  rails_versions = JSON.parse(Net::HTTP.get(URI('https://rubygems.org/api/v1/versions/rails.json')))
5
5
  .group_by { |version| version['number'] }.keys.reject { |key| key =~ /rc|racecar|beta|pre/ }
6
6
 
7
- %w[3.0 3.1 3.2 4.0 4.1 4.2 5.0].each do |version|
7
+ %w[3.0 3.1 3.2 4.0 4.1 4.2 5.0 5.1].each do |version|
8
8
  appraise "rails_#{version}" do
9
9
  current_version = rails_versions.select { |key| key.match(/\A#{version}/) }.max
10
10
 
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enumerate_it (1.5.0)
4
+ enumerate_it (1.6.0)
5
5
  activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (5.0.2)
10
+ activesupport (5.1.3)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (~> 0.7)
13
13
  minitest (~> 5.1)
@@ -20,9 +20,10 @@ GEM
20
20
  coderay (1.1.1)
21
21
  concurrent-ruby (1.0.5)
22
22
  diff-lcs (1.3)
23
- i18n (0.8.1)
23
+ i18n (0.8.6)
24
24
  method_source (0.8.2)
25
- minitest (5.10.1)
25
+ minitest (5.10.3)
26
+ parallel (1.12.0)
26
27
  parser (2.4.0.0)
27
28
  ast (~> 2.2)
28
29
  powerpack (0.1.1)
@@ -33,34 +34,35 @@ GEM
33
34
  rainbow (2.2.2)
34
35
  rake
35
36
  rake (12.0.0)
36
- rspec (3.5.0)
37
- rspec-core (~> 3.5.0)
38
- rspec-expectations (~> 3.5.0)
39
- rspec-mocks (~> 3.5.0)
40
- rspec-core (3.5.4)
41
- rspec-support (~> 3.5.0)
42
- rspec-expectations (3.5.0)
37
+ rspec (3.6.0)
38
+ rspec-core (~> 3.6.0)
39
+ rspec-expectations (~> 3.6.0)
40
+ rspec-mocks (~> 3.6.0)
41
+ rspec-core (3.6.0)
42
+ rspec-support (~> 3.6.0)
43
+ rspec-expectations (3.6.0)
43
44
  diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.5.0)
45
- rspec-mocks (3.5.0)
45
+ rspec-support (~> 3.6.0)
46
+ rspec-mocks (3.6.0)
46
47
  diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.5.0)
48
- rspec-support (3.5.0)
49
- rubocop (0.48.1)
48
+ rspec-support (~> 3.6.0)
49
+ rspec-support (3.6.0)
50
+ rubocop (0.49.1)
51
+ parallel (~> 1.10)
50
52
  parser (>= 2.3.3.1, < 3.0)
51
53
  powerpack (~> 0.1)
52
54
  rainbow (>= 1.99.1, < 3.0)
53
55
  ruby-progressbar (~> 1.7)
54
56
  unicode-display_width (~> 1.0, >= 1.0.1)
55
- rubocop-rspec (1.15.0)
57
+ rubocop-rspec (1.15.1)
56
58
  rubocop (>= 0.42.0)
57
59
  ruby-progressbar (1.8.1)
58
60
  slop (3.6.0)
59
- thor (0.19.4)
61
+ thor (0.20.0)
60
62
  thread_safe (0.3.6)
61
63
  tzinfo (1.2.3)
62
64
  thread_safe (~> 0.1)
63
- unicode-display_width (1.2.1)
65
+ unicode-display_width (1.3.0)
64
66
  wwtd (1.3.0)
65
67
 
66
68
  PLATFORMS
@@ -78,4 +80,4 @@ DEPENDENCIES
78
80
  wwtd
79
81
 
80
82
  BUNDLED WITH
81
- 1.14.6
83
+ 1.15.4
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # EnumerateIt
2
2
 
3
- 💎 Ruby Enumerations with magic powers! 🎩
3
+ Ruby Enumerations with magic powers! 🎩
4
4
 
5
5
  [![Build Status](https://travis-ci.org/lucascaton/enumerate_it.svg?branch=master)](https://travis-ci.org/lucascaton/enumerate_it)
6
6
  [![Gem Version](https://badge.fury.io/rb/enumerate_it.svg)](https://rubygems.org/gems/enumerate_it)
@@ -47,13 +47,7 @@ Add the gem to your Gemfile:
47
47
  gem 'enumerate_it'
48
48
  ```
49
49
 
50
- Run the install generator:
51
-
52
- ```bash
53
- rails generate enumerate_it:install
54
- ```
55
-
56
- There is also a Rails Generator which generates enumerations and their locale files:
50
+ You can use a Rails generator, which generates enumerations and their locale files:
57
51
 
58
52
  ```bash
59
53
  rails generate enumerate_it:enum --help
@@ -183,10 +177,17 @@ The `sort_by` method accepts one of the following values:
183
177
 
184
178
  ## Using enumerations
185
179
 
186
- The cool part is that you can use these enumerations with any class, be it an `ActiveRecord`
187
- instance or not.
180
+ The cool part is that you can use these enumerations with any class:
181
+
182
+ ```ruby
183
+ # ActiveRecord instance
184
+ class Person < ApplicationRecord
185
+ has_enumeration_for :relationship_status
186
+ end
187
+ ```
188
188
 
189
189
  ```ruby
190
+ # Non-ActiveRecord instance
190
191
  class Person
191
192
  extend EnumerateIt
192
193
  attr_accessor :relationship_status
@@ -231,7 +232,7 @@ This will create:
231
232
  * A helper method for each enumeration option, if you pass the `create_helpers` option as `true`:
232
233
 
233
234
  ```ruby
234
- class Person < ActiveRecord::Base
235
+ class Person < ApplicationRecord
235
236
  has_enumeration_for :relationship_status, with: RelationshipStatus, create_helpers: true
236
237
  end
237
238
 
@@ -249,7 +250,7 @@ This will create:
249
250
  option. This can be useful when two or more of the enumerations used share the same constants:
250
251
 
251
252
  ```ruby
252
- class Person < ActiveRecord::Base
253
+ class Person < ApplicationRecord
253
254
  has_enumeration_for :relationship_status,
254
255
  with: RelationshipStatus, create_helpers: { prefix: true }
255
256
  end
@@ -279,12 +280,12 @@ This will create:
279
280
 
280
281
  class Single
281
282
  def saturday_night
282
- 'Party Hard!'
283
+ 'Party hard!'
283
284
  end
284
285
  end
285
286
  end
286
287
 
287
- class Person < ActiveRecord::Base
288
+ class Person < ApplicationRecord
288
289
  has_enumeration_for :relationship_status,
289
290
  with: RelationshipStatus, create_helpers: { polymorphic: true }
290
291
  end
@@ -296,13 +297,13 @@ This will create:
296
297
 
297
298
  p.relationship_status = RelationshipStatus::SINGLE
298
299
  p.relationship_status_object.saturday_night
299
- #=> 'Party Hard!'
300
+ #=> 'Party hard!'
300
301
  ```
301
302
 
302
303
  You can also change the suffix `_object`, using the `suffix` option:
303
304
 
304
305
  ```ruby
305
- class Person < ActiveRecord::Base
306
+ class Person < ApplicationRecord
306
307
  has_enumeration_for :relationship_status,
307
308
  with: RelationshipStatus, create_helpers: { polymorphic: { suffix: '_mode' } }
308
309
  end
@@ -324,7 +325,7 @@ This will create:
324
325
  * A scope method for each enumeration option if you pass the `create_scopes` option as `true`:
325
326
 
326
327
  ```ruby
327
- class Person < ActiveRecord::Base
328
+ class Person < ApplicationRecord
328
329
  has_enumeration_for :relationship_status, with: RelationshipStatus, create_scopes: true
329
330
  end
330
331
 
@@ -335,7 +336,7 @@ This will create:
335
336
  The `:create_scopes` also accepts `prefix` option.
336
337
 
337
338
  ```ruby
338
- class Person < ActiveRecord::Base
339
+ class Person < ApplicationRecord
339
340
  has_enumeration_for :relationship_status,
340
341
  with: RelationshipStatus, create_scopes: { prefix: true }
341
342
  end
@@ -347,7 +348,7 @@ This will create:
347
348
  `validates_inclusion_of`):
348
349
 
349
350
  ```ruby
350
- class Person < ActiveRecord::Base
351
+ class Person < ApplicationRecord
351
352
  has_enumeration_for :relationship_status, with: RelationshipStatus
352
353
  end
353
354
 
@@ -358,11 +359,11 @@ This will create:
358
359
  #=> 'is not included in the list'
359
360
  ```
360
361
 
361
- * An presence validation (if your class can manage validations and responds to
362
+ * A presence validation (if your class can manage validations and responds to
362
363
  `validates_presence_of` and you pass the `required` options as `true`):
363
364
 
364
365
  ```ruby
365
- class Person < ActiveRecord::Base
366
+ class Person < ApplicationRecord
366
367
  has_enumeration_for :relationship_status, required: true
367
368
  end
368
369
 
@@ -376,7 +377,7 @@ This will create:
376
377
  If you pass the `skip_validation` option as `true`, it will not create any validations:
377
378
 
378
379
  ```ruby
379
- class Person < ActiveRecord::Base
380
+ class Person < ApplicationRecord
380
381
  has_enumeration_for :relationship_status, with: RelationshipStatus, skip_validation: true
381
382
  end
382
383
 
@@ -385,8 +386,7 @@ This will create:
385
386
  #=> true
386
387
  ```
387
388
 
388
- Remember that you can add validations to any kind of class and not only to those derived from
389
- `ActiveRecord::Base`.
389
+ Remember that you can add validations to any kind of class and not only `ActiveRecord` ones.
390
390
 
391
391
  ## FAQ
392
392
 
@@ -402,8 +402,8 @@ You sure can! 😄
402
402
 
403
403
  #### What versions of Ruby and Rails are supported?
404
404
 
405
- * **Ruby** `2.0` or higher
406
- * **Rails** `3.0` or higher
405
+ * **Ruby** `2.0` - `2.4`
406
+ * **Rails** `3.0` - `5.1`
407
407
 
408
408
  All versions are tested via
409
409
  [Travis](https://github.com/lucascaton/enumerate_it/blob/master/.travis.yml).
@@ -514,7 +514,7 @@ Changes are maintained under [Releases](https://github.com/lucascaton/enumerate_
514
514
  * Fork the project.
515
515
  * Make your feature addition or bug fix.
516
516
  * Add tests for it. This is important so we don't break it in a future version unintentionally.
517
- * [Optional] Run the tests agaist a specific Gemfile: `$ bundle exec appraisal rails_5.0 rake spec`.
517
+ * [Optional] Run the tests agaist a specific Gemfile: `$ bundle exec appraisal rails_5.1 rake spec`.
518
518
  * Run the tests agaist all supported versions: `$ bundle exec rake` (or `$ bundle exec wwtd`)
519
519
  * Commit, but please do not mess with `Rakefile`, version, or history.
520
520
  * Send a Pull Request. Bonus points for topic branches.
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'bundler/gem_tasks'
4
2
 
5
3
  if ENV['APPRAISAL_INITIALIZED'] || ENV['TRAVIS'] || RUBY_VERSION < '2.0.0'
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activesupport", "~> 4.2.8"
6
- gem "activerecord", "~> 4.2.8"
5
+ gem "activesupport", "~> 4.2.9"
6
+ gem "activerecord", "~> 4.2.9"
7
7
 
8
8
  gemspec path: "../"
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activesupport", "~> 5.0.2"
6
- gem "activerecord", "~> 5.0.2"
5
+ gem "activesupport", "~> 5.0.5"
6
+ gem "activerecord", "~> 5.0.5"
7
7
 
8
8
  gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 5.1.3"
6
+ gem "activerecord", "~> 5.1.3"
7
+
8
+ gemspec path: "../"
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'active_support/core_ext/class/attribute'
4
2
  require 'active_support/inflector'
5
3
  require 'enumerate_it/base'
@@ -13,3 +11,5 @@ module EnumerateIt
13
11
  receiver.extend ClassMethods
14
12
  end
15
13
  end
14
+
15
+ ActiveSupport.on_load(:active_record) { ActiveRecord::Base.extend EnumerateIt }
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module EnumerateIt
4
2
  class Base
5
3
  class << self
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module EnumerateIt
4
2
  module ClassMethods
5
3
  def has_enumeration_for(attribute, options = {})
@@ -1,3 +1,3 @@
1
1
  module EnumerateIt
2
- VERSION = '1.5.0'.freeze
2
+ VERSION = '1.6.0'.freeze
3
3
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
2
 
5
3
  describe EnumerateIt::Base do
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
2
 
5
3
  describe EnumerateIt do
@@ -256,7 +254,6 @@ describe EnumerateIt do
256
254
  Object.send :remove_const, 'TestClassWithScope' if defined?(TestClassWithScope)
257
255
 
258
256
  class TestClassWithScope < ActiveRecord::Base
259
- extend EnumerateIt
260
257
  has_enumeration_for :foobar, with: TestEnumeration, create_scopes: true
261
258
  end
262
259
  end
@@ -292,7 +289,6 @@ describe EnumerateIt do
292
289
  context 'with :prefix option' do
293
290
  before do
294
291
  class OtherTestClass < ActiveRecord::Base
295
- extend EnumerateIt
296
292
  has_enumeration_for :foobar, with: TestEnumerationWithReservedWords,
297
293
  create_scopes: { prefix: true }
298
294
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enumerate_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cássio Marques
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-04-25 00:00:00.000000000 Z
12
+ date: 2017-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -163,6 +163,7 @@ files:
163
163
  - gemfiles/rails_4.1.gemfile
164
164
  - gemfiles/rails_4.2.gemfile
165
165
  - gemfiles/rails_5.0.gemfile
166
+ - gemfiles/rails_5.1.gemfile
166
167
  - lib/enumerate_it.rb
167
168
  - lib/enumerate_it/base.rb
168
169
  - lib/enumerate_it/class_methods.rb
@@ -171,9 +172,6 @@ files:
171
172
  - lib/generators/enumerate_it/enum/enum_generator.rb
172
173
  - lib/generators/enumerate_it/enum/templates/enumerate_it.rb
173
174
  - lib/generators/enumerate_it/enum/templates/locale.yml
174
- - lib/generators/enumerate_it/install/USAGE
175
- - lib/generators/enumerate_it/install/install_generator.rb
176
- - lib/generators/enumerate_it/install/templates/enumerate_it_initializer.rb
177
175
  - spec/enumerate_it/base_spec.rb
178
176
  - spec/enumerate_it_spec.rb
179
177
  - spec/i18n/en.yml
@@ -199,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
197
  version: '0'
200
198
  requirements: []
201
199
  rubyforge_project:
202
- rubygems_version: 2.6.11
200
+ rubygems_version: 2.6.12
203
201
  signing_key:
204
202
  specification_version: 4
205
203
  summary: Ruby Enumerations
@@ -1,8 +0,0 @@
1
- Description:
2
- Creates an initializer file for EnumerateIt
3
-
4
- Example:
5
- rails generate enumerate_it:install
6
-
7
- This will create:
8
- config/initializers/enumerate_it.rb
@@ -1,11 +0,0 @@
1
- module EnumerateIt
2
- module Generators
3
- class InstallGenerator < Rails::Generators::Base
4
- source_root File.expand_path('../templates', __FILE__)
5
-
6
- def copy_initializer_file
7
- template 'enumerate_it_initializer.rb', File.join('config/initializers/', 'enumerate_it.rb')
8
- end
9
- end
10
- end
11
- end
@@ -1 +0,0 @@
1
- ActiveRecord::Base.extend EnumerateIt