enumerate_it 1.6.1 → 1.7.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
- SHA1:
3
- metadata.gz: 9ad333269f935566eb9da374a8ea85983503241c
4
- data.tar.gz: 854d42aea0246c5a71975b440afe2bff426b14f3
2
+ SHA256:
3
+ metadata.gz: 1d4ae76c51d155d1805ae3f30687471dcde4354e7e28a0b5b4a67c1fec61833a
4
+ data.tar.gz: b2ffcc7e088b1a77b8c8002c923ae8e6283557d179eb03e1ebe4cc183e6d9293
5
5
  SHA512:
6
- metadata.gz: 99c994cb23ba95457d4f1838be1c8f87e4a19b0c80316bf520a1489c11756556e114c8ac55a78b4a8025534cc674c5356fc30f9f5d1e4431f40b27a5c9a6676c
7
- data.tar.gz: 4947235c8dc943e21af7100b5a048247f878bd274249731eaa84aadf68c2b3d294ae6e0d0936f7e415cb352142650db1229b816726c1dd51f6854941b1d3e524
6
+ metadata.gz: 3f78959342d203d10c9a21d00472292d08c291da985e1b37c8bf5fa91fb8d5b960d5c2bcea660e61bbae57ee1638070abcb63e1359311f07168caa753256a637
7
+ data.tar.gz: b78fbe58f60eba4819056e81d49d7a31dc286051a6255e4b1a9bad9939be55aa13e98db2c19a8e59df93490e269ce86dbf6a5a9384aa0b1d13a8d680acd43681
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /.bundle/
2
2
  /pkg/
3
3
  /gemfiles/*.lock
4
+ /gemfiles/.bundle/
4
5
  .ruby-gemset
data/.rubocop.yml CHANGED
@@ -11,6 +11,9 @@ AllCops:
11
11
  - 'lib/generators/enumerate_it/enum/templates/**/*'
12
12
  - 'gemfiles/vendor/**/*'
13
13
 
14
+ Gemspec/RequiredRubyVersion:
15
+ Enabled: false
16
+
14
17
  Lint/EndAlignment:
15
18
  Enabled: false
16
19
 
@@ -39,13 +42,13 @@ Style/FrozenStringLiteralComment:
39
42
  Style/Documentation:
40
43
  Enabled: false
41
44
 
42
- Style/PredicateName:
43
- Exclude:
44
- - 'lib/enumerate_it/class_methods.rb'
45
-
46
45
  Style/GuardClause:
47
46
  MinBodyLength: 3
48
47
 
48
+ Naming/PredicateName:
49
+ Exclude:
50
+ - 'lib/enumerate_it/class_methods.rb'
51
+
49
52
  RSpec/MultipleExpectations:
50
53
  Enabled: false
51
54
 
@@ -57,3 +60,6 @@ RSpec/MessageExpectation:
57
60
 
58
61
  RSpec/MessageSpies:
59
62
  Enabled: false
63
+
64
+ RSpec/ContextWording:
65
+ Enabled: false
data/.travis.yml CHANGED
@@ -4,16 +4,20 @@ sudo: false
4
4
 
5
5
  cache: bundler
6
6
 
7
+ before_install:
8
+ - gem update --system
9
+
7
10
  script:
8
- - "ruby -e \"RUBY_VERSION == '2.4.1' ? system('bundle exec rubocop') : exit(0)\""
9
- - bundle exec rake spec
11
+ - "ruby -e \"RUBY_VERSION == '2.5.0' ? system('bundle exec rubocop') : exit(0)\""
12
+ - bundle exec rake spec
10
13
 
11
14
  rvm:
12
15
  - 2.0.0
13
16
  - 2.1.10
14
- - 2.2.7
15
- - 2.3.4
16
- - 2.4.1
17
+ - 2.2.9
18
+ - 2.3.6
19
+ - 2.4.3
20
+ - 2.5.0
17
21
 
18
22
  gemfile:
19
23
  - gemfiles/rails_3.0.gemfile
@@ -39,11 +43,20 @@ matrix:
39
43
 
40
44
  # Rails 4.0 and 4.1 requires an old version of `json` gem, which isn't compatible with Ruby 2.4+
41
45
  # https://github.com/flori/json/issues/308
42
- - rvm: 2.4.1
46
+ - rvm: 2.4.3
47
+ gemfile: gemfiles/rails_4.0.gemfile
48
+ - rvm: 2.4.3
49
+ gemfile: gemfiles/rails_4.1.gemfile
50
+ - rvm: 2.5.0
43
51
  gemfile: gemfiles/rails_4.0.gemfile
44
- - rvm: 2.4.1
52
+ - rvm: 2.5.0
45
53
  gemfile: gemfiles/rails_4.1.gemfile
46
54
 
55
+ # Rails 3.0 doesn't work with Ruby 2.5
56
+ # (`undefined method `yaml_as' for BigDecimal:Class`)
57
+ - rvm: 2.5.0
58
+ gemfile: gemfiles/rails_3.0.gemfile
59
+
47
60
  addons:
48
61
  code_climate:
49
62
  repo_token: 60e4a18e2a4bc86a98f92847f16756876c13d1e772058a9b3296643b04a697d7
data/Appraisals CHANGED
@@ -6,7 +6,10 @@ rails_versions = JSON.parse(Net::HTTP.get(URI('https://rubygems.org/api/v1/versi
6
6
 
7
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
- current_version = rails_versions.select { |key| key.match(/\A#{version}/) }.max
9
+ current_version = rails_versions
10
+ .select { |key| key.match(/\A#{version}/) }
11
+ .sort { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) }
12
+ .last
10
13
 
11
14
  gem 'activesupport', "~> #{current_version}"
12
15
  gem 'activerecord', "~> #{current_version}"
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enumerate_it (1.6.1)
4
+ enumerate_it (1.7.0)
5
5
  activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (5.1.3)
10
+ activesupport (5.1.5)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (~> 0.7)
13
13
  minitest (~> 5.1)
@@ -16,51 +16,49 @@ GEM
16
16
  bundler
17
17
  rake
18
18
  thor (>= 0.14.0)
19
- ast (2.3.0)
20
- coderay (1.1.1)
19
+ ast (2.4.0)
20
+ coderay (1.1.2)
21
21
  concurrent-ruby (1.0.5)
22
22
  diff-lcs (1.3)
23
- i18n (0.8.6)
24
- method_source (0.8.2)
25
- minitest (5.10.3)
26
- parallel (1.12.0)
27
- parser (2.4.0.0)
28
- ast (~> 2.2)
23
+ i18n (0.9.5)
24
+ concurrent-ruby (~> 1.0)
25
+ method_source (0.9.0)
26
+ minitest (5.11.3)
27
+ parallel (1.12.1)
28
+ parser (2.5.0.3)
29
+ ast (~> 2.4.0)
29
30
  powerpack (0.1.1)
30
- pry (0.10.4)
31
+ pry (0.11.3)
31
32
  coderay (~> 1.1.0)
32
- method_source (~> 0.8.1)
33
- slop (~> 3.4)
34
- rainbow (2.2.2)
35
- rake
36
- rake (12.0.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)
33
+ method_source (~> 0.9.0)
34
+ rainbow (3.0.0)
35
+ rake (12.3.0)
36
+ rspec (3.7.0)
37
+ rspec-core (~> 3.7.0)
38
+ rspec-expectations (~> 3.7.0)
39
+ rspec-mocks (~> 3.7.0)
40
+ rspec-core (3.7.1)
41
+ rspec-support (~> 3.7.0)
42
+ rspec-expectations (3.7.0)
44
43
  diff-lcs (>= 1.2.0, < 2.0)
45
- rspec-support (~> 3.6.0)
46
- rspec-mocks (3.6.0)
44
+ rspec-support (~> 3.7.0)
45
+ rspec-mocks (3.7.0)
47
46
  diff-lcs (>= 1.2.0, < 2.0)
48
- rspec-support (~> 3.6.0)
49
- rspec-support (3.6.0)
50
- rubocop (0.49.1)
47
+ rspec-support (~> 3.7.0)
48
+ rspec-support (3.7.1)
49
+ rubocop (0.53.0)
51
50
  parallel (~> 1.10)
52
- parser (>= 2.3.3.1, < 3.0)
51
+ parser (>= 2.5)
53
52
  powerpack (~> 0.1)
54
- rainbow (>= 1.99.1, < 3.0)
53
+ rainbow (>= 2.2.2, < 4.0)
55
54
  ruby-progressbar (~> 1.7)
56
55
  unicode-display_width (~> 1.0, >= 1.0.1)
57
- rubocop-rspec (1.15.1)
58
- rubocop (>= 0.42.0)
59
- ruby-progressbar (1.8.1)
60
- slop (3.6.0)
56
+ rubocop-rspec (1.24.0)
57
+ rubocop (>= 0.53.0)
58
+ ruby-progressbar (1.9.0)
61
59
  thor (0.20.0)
62
60
  thread_safe (0.3.6)
63
- tzinfo (1.2.3)
61
+ tzinfo (1.2.5)
64
62
  thread_safe (~> 0.1)
65
63
  unicode-display_width (1.3.0)
66
64
  wwtd (1.3.0)
@@ -80,4 +78,4 @@ DEPENDENCIES
80
78
  wwtd
81
79
 
82
80
  BUNDLED WITH
83
- 1.15.4
81
+ 1.16.1
data/LICENSE CHANGED
@@ -1,4 +1,8 @@
1
- Copyright (c) 2010-2017 Cássio Marques and Lucas Caton
1
+ LICENSE
2
+
3
+ The MIT License
4
+
5
+ Copyright (c) 2010-2018 Cássio Marques and Lucas Caton
2
6
 
3
7
  Permission is hereby granted, free of charge, to any person obtaining
4
8
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,11 +1,12 @@
1
1
  # EnumerateIt
2
2
 
3
- Ruby Enumerations with magic powers! 🎩
3
+ Enumerations for Ruby with some 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)
7
7
  [![Dependency Status](https://gemnasium.com/badges/github.com/lucascaton/enumerate_it.svg)](https://gemnasium.com/github.com/lucascaton/enumerate_it)
8
8
  [![Code Climate](https://codeclimate.com/github/lucascaton/enumerate_it/badges/gpa.svg)](https://codeclimate.com/github/lucascaton/enumerate_it)
9
+ [![Downloads](https://img.shields.io/gem/dt/enumerate_it.svg)](https://rubygems.org/gems/enumerate_it)
9
10
  [![Changelog](https://img.shields.io/badge/changelog--brightgreen.svg?style=flat)](https://github.com/lucascaton/enumerate_it/releases)
10
11
 
11
12
  **EnumerateIt** helps you to declare and use enumerations in a very simple and flexible way.
@@ -402,8 +403,8 @@ You sure can! 😄
402
403
 
403
404
  #### What versions of Ruby and Rails are supported?
404
405
 
405
- * **Ruby** `2.0` - `2.4`
406
- * **Rails** `3.0` - `5.1`
406
+ * **Ruby** from `2.0` to `2.4`
407
+ * **Rails** from `3.0` to `5.1`
407
408
 
408
409
  All versions are tested via
409
410
  [Travis](https://github.com/lucascaton/enumerate_it/blob/master/.travis.yml).
@@ -507,7 +508,7 @@ You can also sort it by its **value** using `sort_by :value`.
507
508
 
508
509
  ## Changelog
509
510
 
510
- Changes are maintained under [Releases](https://github.com/lucascaton/enumerate_it/releases).
511
+ Changes are maintained under [Releases page](https://github.com/lucascaton/enumerate_it/releases).
511
512
 
512
513
  ## Note on Patches/Pull Requests
513
514
 
@@ -521,4 +522,4 @@ Changes are maintained under [Releases](https://github.com/lucascaton/enumerate_
521
522
 
522
523
  ## Copyright
523
524
 
524
- Copyright (c) 2010-2017 Cássio Marques and Lucas Caton. See `LICENSE` file for details.
525
+ Copyright (c) 2010-2018 Cássio Marques and Lucas Caton. See `LICENSE` file for details.
data/enumerate_it.gemspec CHANGED
@@ -1,10 +1,11 @@
1
- require File.expand_path('../lib/enumerate_it/version', __FILE__)
1
+ require File.expand_path('lib/enumerate_it/version', __dir__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.authors = ['Cássio Marques', 'Lucas Caton']
5
5
  gem.summary = 'Ruby Enumerations'
6
6
  gem.description = 'Enumerations for Ruby with some magic powers!'
7
7
  gem.homepage = 'https://github.com/lucascaton/enumerate_it'
8
+ gem.license = 'MIT'
8
9
 
9
10
  gem.files = `git ls-files`.split("\n")
10
11
  gem.test_files = `git ls-files -- spec/*`.split("\n")
@@ -1,8 +1,8 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
- gem "activesupport", "~> 3.0.9"
6
- gem "activerecord", "~> 3.0.9"
5
+ gem 'activerecord', '~> 3.0.20'
6
+ gem 'activesupport', '~> 3.0.20'
7
7
 
8
- gemspec path: "../"
8
+ gemspec path: '../'
@@ -1,8 +1,8 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
- gem "activesupport", "~> 3.1.9"
6
- gem "activerecord", "~> 3.1.9"
5
+ gem 'activerecord', '~> 3.1.12'
6
+ gem 'activesupport', '~> 3.1.12'
7
7
 
8
- gemspec path: "../"
8
+ gemspec path: '../'
@@ -1,8 +1,8 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
- gem "activesupport", "~> 3.2.9"
6
- gem "activerecord", "~> 3.2.9"
5
+ gem 'activerecord', '~> 3.2.22.5'
6
+ gem 'activesupport', '~> 3.2.22.5'
7
7
 
8
- gemspec path: "../"
8
+ gemspec path: '../'
@@ -1,8 +1,8 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
- gem "activesupport", "~> 4.0.9"
6
- gem "activerecord", "~> 4.0.9"
5
+ gem 'activerecord', '~> 4.0.13'
6
+ gem 'activesupport', '~> 4.0.13'
7
7
 
8
- gemspec path: "../"
8
+ gemspec path: '../'
@@ -1,8 +1,8 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
- gem "activesupport", "~> 4.1.9"
6
- gem "activerecord", "~> 4.1.9"
5
+ gem 'activerecord', '~> 4.1.16'
6
+ gem 'activesupport', '~> 4.1.16'
7
7
 
8
- gemspec path: "../"
8
+ gemspec path: '../'
@@ -1,8 +1,8 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
- gem "activesupport", "~> 4.2.9"
6
- gem "activerecord", "~> 4.2.9"
5
+ gem 'activerecord', '~> 4.2.10'
6
+ gem 'activesupport', '~> 4.2.10'
7
7
 
8
- gemspec path: "../"
8
+ gemspec path: '../'
@@ -1,8 +1,8 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
- gem "activesupport", "~> 5.0.5"
6
- gem "activerecord", "~> 5.0.5"
5
+ gem 'activerecord', '~> 5.0.6'
6
+ gem 'activesupport', '~> 5.0.6'
7
7
 
8
- gemspec path: "../"
8
+ gemspec path: '../'
@@ -1,8 +1,8 @@
1
1
  # This file was generated by Appraisal
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
- gem "activesupport", "~> 5.1.3"
6
- gem "activerecord", "~> 5.1.3"
5
+ gem 'activerecord', '~> 5.1.5'
6
+ gem 'activesupport', '~> 5.1.5'
7
7
 
8
- gemspec path: "../"
8
+ gemspec path: '../'
@@ -116,7 +116,7 @@ module EnumerateIt
116
116
  end
117
117
 
118
118
  def define_enumeration_constant(name, value)
119
- const_set name.to_s.tr('-', '_').upcase, value
119
+ const_set name.to_s.tr('-', '_').gsub(/\p{blank}/, '_').upcase, value
120
120
  end
121
121
 
122
122
  def values_hash(args)
@@ -42,7 +42,7 @@ module EnumerateIt
42
42
  prefix_name = "#{attribute_name}_" if helpers.is_a?(Hash) && helpers[:prefix]
43
43
 
44
44
  class_eval do
45
- klass.enumeration.keys.each do |option|
45
+ klass.enumeration.each_key do |option|
46
46
  define_method "#{prefix_name}#{option}?" do
47
47
  send(attribute_name) == klass.enumeration[option].first
48
48
  end
@@ -55,7 +55,7 @@ module EnumerateIt
55
55
 
56
56
  prefix_name = "#{attribute_name}_" if helpers.is_a?(Hash) && helpers[:prefix]
57
57
 
58
- klass.enumeration.keys.each do |key|
58
+ klass.enumeration.each_key do |key|
59
59
  scope("#{prefix_name}#{key}", -> { where(attribute_name => klass.enumeration[key].first) })
60
60
  end
61
61
  end
@@ -1,3 +1,3 @@
1
1
  module EnumerateIt
2
- VERSION = '1.6.1'.freeze
2
+ VERSION = '1.7.0'.freeze
3
3
  end
@@ -1,7 +1,7 @@
1
1
  module EnumerateIt
2
2
  module Generators
3
3
  class EnumGenerator < Rails::Generators::NamedBase
4
- source_root File.expand_path('../templates', __FILE__)
4
+ source_root File.expand_path('templates', __dir__)
5
5
 
6
6
  argument :attributes, type: 'array'
7
7
 
@@ -17,6 +17,10 @@ describe EnumerateIt::Base do
17
17
  expect(TestEnumerationWithDash::PT_BR).to eq('pt-BR')
18
18
  end
19
19
 
20
+ it 'creates constants for values with spaces' do
21
+ expect(TestEnumerationWithSpaces::SPA_CES).to eq('spa ces')
22
+ end
23
+
20
24
  describe '.list' do
21
25
  it "creates a method that returns the allowed values in the enumeration's class" do
22
26
  expect(TestEnumeration.list).to eq(%w[1 2 3])
@@ -247,7 +251,7 @@ describe EnumerateIt::Base do
247
251
  attr_accessor :bla
248
252
 
249
253
  class << self
250
- def validates_inclusion_of(_)
254
+ def validates_inclusion_of(_attribute)
251
255
  true
252
256
  end
253
257
 
@@ -259,7 +259,7 @@ describe EnumerateIt do
259
259
  end
260
260
 
261
261
  it 'creates a scope for each enumeration value' do
262
- TestEnumeration.enumeration.keys.each do |symbol|
262
+ TestEnumeration.enumeration.each_key do |symbol|
263
263
  expect(TestClassWithScope).to respond_to(symbol)
264
264
  end
265
265
  end
@@ -295,7 +295,7 @@ describe EnumerateIt do
295
295
  end
296
296
 
297
297
  it 'creates a scope with prefix for each enumeration value' do
298
- TestEnumerationWithReservedWords.enumeration.keys.each do |symbol|
298
+ TestEnumerationWithReservedWords.enumeration.each_key do |symbol|
299
299
  expect(OtherTestClass).to respond_to(:"foobar_#{symbol}")
300
300
  end
301
301
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
1
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
2
2
 
3
3
  require 'enumerate_it'
4
4
 
@@ -34,6 +34,10 @@ class TestEnumerationWithCamelCase < EnumerateIt::Base
34
34
  associate_values 'iPhone'
35
35
  end
36
36
 
37
+ class TestEnumerationWithSpaces < EnumerateIt::Base
38
+ associate_values 'spa ces'
39
+ end
40
+
37
41
  class Foobar < EnumerateIt::Base
38
42
  associate_values bar: 'foo'
39
43
  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.6.1
4
+ version: 1.7.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-08-21 00:00:00.000000000 Z
12
+ date: 2018-03-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -155,7 +155,6 @@ files:
155
155
  - README.md
156
156
  - Rakefile
157
157
  - enumerate_it.gemspec
158
- - gemfiles/.bundle/config
159
158
  - gemfiles/rails_3.0.gemfile
160
159
  - gemfiles/rails_3.1.gemfile
161
160
  - gemfiles/rails_3.2.gemfile
@@ -179,7 +178,8 @@ files:
179
178
  - spec/spec_helper.rb
180
179
  - spec/support/test_classes.rb
181
180
  homepage: https://github.com/lucascaton/enumerate_it
182
- licenses: []
181
+ licenses:
182
+ - MIT
183
183
  metadata: {}
184
184
  post_install_message:
185
185
  rdoc_options: []
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  version: '0'
198
198
  requirements: []
199
199
  rubyforge_project:
200
- rubygems_version: 2.6.12
200
+ rubygems_version: 2.7.6
201
201
  signing_key:
202
202
  specification_version: 4
203
203
  summary: Ruby Enumerations
@@ -1,2 +0,0 @@
1
- ---
2
- BUNDLE_RETRY: "1"