active_enum 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66c4c41a89eb9ab6b433bd74195b5da31f5e6f77ffd2bf6e4d71152f6f37ff43
4
- data.tar.gz: 78f1bfd4039e743136f0258c84a042f13397f89629fd7fb324e501db15068b3d
3
+ metadata.gz: cef2baaca824d0aabf253fc18b8316ee90c0cb55f4ab9c1d64d636ad32da8fdd
4
+ data.tar.gz: a5e4fbed89a43e84520cf82561b92be85ef4165a444c3f4406f5f234f06fc336
5
5
  SHA512:
6
- metadata.gz: cb0f30bd0ea8655166dc74c44f7e8748d49c131676fb5ebea4e5529d2c2117a305f806601a770fc659bef3254a9f9b324e0eac89f94738dd2221c4a80def2707
7
- data.tar.gz: 91ed0d9875049d3453ea00e745f4e594c0fb7e7c36cb018d2e170da24e4b4a00007e856d2146d0fa07840d81941a34a830832817269e2f69ca55753ce72b1778
6
+ metadata.gz: 65517f34358ae160cadfe3ef4154bc9e4af1354dbe3b0f1d214322f53fbc11e4b53a63f77cb11bf1c7f418448bd9dce168bc4fb004b68b636764b6adf4ce691b
7
+ data.tar.gz: 6324aa433ff7737a0d1a2092d7d288bbd64a17ddbdeb3f9a646de24230e2eb869f2d38a6b86aa1bc5f5f32a4a01b4a8cbba72a5033a5e36d7d67a2b28789e6e6
data/Appraisals ADDED
@@ -0,0 +1,19 @@
1
+ appraise "rails_7_0" do
2
+ gem "rails", "~> 7.0.0"
3
+ gem 'sqlite3', '~> 1.7.0'
4
+ end
5
+
6
+ appraise "rails_7_1" do
7
+ gem "rails", "~> 7.1.0"
8
+ gem 'sqlite3', '~> 2.6.0'
9
+ end
10
+
11
+ appraise "rails_7_2" do
12
+ gem "rails", "~> 7.2.0"
13
+ gem 'sqlite3', '~> 2.6.0'
14
+ end
15
+
16
+ appraise "rails_8_0" do
17
+ gem "rails", "~> 8.0.0"
18
+ gem 'sqlite3', '~> 2.6.0'
19
+ end
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rails", "~> 6.1.0"
7
+ gem "sqlite3", "~> 1.4.0"
8
+ gem "combustion"
9
+ gem "rake"
10
+ gem "simple_form", "~> 5.0.0"
11
+ gem "debug"
12
+ gem "rspec", "~> 3.4"
13
+ gem "rspec-rails", "~> 6.0"
14
+ gem "capybara"
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rails", "~> 7.0.0"
7
+ gem "sqlite3", "~> 1.7.0"
8
+ gem "combustion"
9
+ gem "rake"
10
+ gem "simple_form", "~> 5.0.0"
11
+ gem "debug"
12
+ gem "rspec", "~> 3.4"
13
+ gem "rspec-rails", "~> 6.0"
14
+ gem "capybara"
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rails", "~> 7.1.0"
7
+ gem "sqlite3", "~> 2.6.0"
8
+ gem "combustion"
9
+ gem "rake"
10
+ gem "simple_form", "~> 5.0.0"
11
+ gem "debug"
12
+ gem "rspec", "~> 3.4"
13
+ gem "rspec-rails", "~> 6.0"
14
+ gem "capybara"
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rails", "~> 7.2.0"
7
+ gem "sqlite3", "~> 2.6.0"
8
+ gem "combustion"
9
+ gem "rake"
10
+ gem "simple_form", "~> 5.0.0"
11
+ gem "debug"
12
+ gem "rspec", "~> 3.4"
13
+ gem "rspec-rails", "~> 6.0"
14
+ gem "capybara"
15
+
16
+ gemspec path: "../"
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rails", "~> 8.0.0"
7
+ gem "sqlite3", "~> 2.6.0"
8
+ gem "combustion"
9
+ gem "rake"
10
+ gem "simple_form", "~> 5.0.0"
11
+ gem "debug"
12
+ gem "rspec", "~> 3.4"
13
+ gem "rspec-rails", "~> 6.0"
14
+ gem "capybara"
15
+
16
+ gemspec path: "../"
@@ -7,14 +7,16 @@ module ActiveEnum
7
7
  extend ClassMethods
8
8
  class_attribute :active_enum_options
9
9
  self.active_enum_options = options.reverse_merge(name_column: 'name')
10
- scope :enum_values, proc { select(Arel.sql("#{primary_key}, #{active_enum_options[:name_column]}")).
11
- where(active_enum_options[:conditions]).
12
- order(Arel.sql("#{primary_key} #{active_enum_options[:order]}")) }
13
10
  end
14
11
 
15
12
  end
16
13
 
17
14
  module ClassMethods
15
+ def enum_values
16
+ select(Arel.sql("#{primary_key}, #{active_enum_options[:name_column]}"))
17
+ .where(active_enum_options[:conditions])
18
+ .order(Arel.sql("#{primary_key} #{active_enum_options[:order]}"))
19
+ end
18
20
 
19
21
  def values
20
22
  enum_values.map { |v| [ v.id, v.send(active_enum_options[:name_column]) ] }
@@ -68,7 +70,7 @@ module ActiveEnum
68
70
  if index.is_a?(Integer)
69
71
  enum_values.where(id: index)
70
72
  else
71
- enum_values.where("lower(#{active_enum_options[:name_column]}) = lower(?)", Arel.sql(index.to_s))
73
+ enum_values.where("lower(#{active_enum_options[:name_column]}) = lower(:name)", name: index.to_s)
72
74
  end
73
75
  end
74
76
  end
@@ -5,7 +5,7 @@ module ActiveEnum
5
5
 
6
6
  class Base
7
7
  class << self
8
- attr_accessor :store
8
+ attr_reader :store
9
9
 
10
10
  def inherited(subclass)
11
11
  ActiveEnum.enum_classes << subclass
@@ -43,7 +43,7 @@ module ActiveEnum
43
43
 
44
44
  define_active_enum_methods_for_attribute(attribute, options) unless options[:skip_accessors]
45
45
  rescue NameError => e
46
- raise e unless e.message =~ /uninitialized constant/
46
+ raise e unless e.message.match?(/uninitialized constant/)
47
47
  raise ActiveEnum::EnumNotFound, "Enum class could not be found for attribute '#{attribute}' in class #{self}. Specify the enum class using the :with option."
48
48
  end
49
49
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveEnum
2
- VERSION = '1.2.1'
2
+ VERSION = '1.3.0'
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  ENV["RAILS_ENV"] ||= 'test'
2
- require 'spec_helper'
3
2
 
3
+ require 'logger'
4
4
  require 'rails'
5
5
  require 'active_record'
6
6
  require 'action_controller/railtie'
@@ -9,21 +9,16 @@ require 'action_mailer'
9
9
 
10
10
  require 'active_enum'
11
11
  require 'active_enum/acts_as_enum'
12
- require 'securerandom'
13
- require 'byebug'
14
12
 
15
- module ActiveEnum
13
+ module ActiveEnum
16
14
  class Application < Rails::Application
17
15
  config.generators do |g|
18
16
  g.orm :active_record
19
17
  g.test_framework :rspec, :fixture => false
20
18
  end
21
19
  config.active_support.deprecation = :notify
22
- config.eager_load = false if Rails.version >= "4.0"
23
- config.secret_key_base = SecureRandom.hex(10) if Rails.version >= "4.0"
24
20
  end
25
21
  end
26
- ActiveEnum::Application.initialize!
27
22
 
28
23
  I18n.enforce_available_locales = false
29
24
  I18n.available_locales = ['en', 'ja']
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_enum
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Meehan
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-03-19 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -29,20 +28,22 @@ email: adam.meehan@gmail.com
29
28
  executables: []
30
29
  extensions: []
31
30
  extra_rdoc_files:
32
- - README.rdoc
33
31
  - CHANGELOG
34
32
  - MIT-LICENSE
33
+ - README.rdoc
35
34
  files:
36
35
  - ".travis.yml"
36
+ - Appraisals
37
37
  - CHANGELOG
38
38
  - MIT-LICENSE
39
39
  - README.rdoc
40
40
  - Rakefile
41
41
  - active_enum.gemspec
42
- - gemfiles/rails_4_2.gemfile
43
- - gemfiles/rails_5_0.gemfile
44
- - gemfiles/rails_5_1.gemfile
45
- - gemfiles/rails_5_2.gemfile
42
+ - gemfiles/rails_6_1.gemfile
43
+ - gemfiles/rails_7_0.gemfile
44
+ - gemfiles/rails_7_1.gemfile
45
+ - gemfiles/rails_7_2.gemfile
46
+ - gemfiles/rails_8_0.gemfile
46
47
  - init.rb
47
48
  - lib/active_enum.rb
48
49
  - lib/active_enum/acts_as_enum.rb
@@ -72,7 +73,6 @@ files:
72
73
  homepage: http://github.com/adzap/active_enum
73
74
  licenses: []
74
75
  metadata: {}
75
- post_install_message:
76
76
  rdoc_options: []
77
77
  require_paths:
78
78
  - lib
@@ -87,8 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  requirements: []
90
- rubygems_version: 3.5.6
91
- signing_key:
90
+ rubygems_version: 3.6.8
92
91
  specification_version: 4
93
92
  summary: Define enum classes in Rails and use them to enumerate ActiveRecord attributes
94
93
  test_files:
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 4.2.11"
6
-
7
- gem 'sqlite3', '~> 1.3.0'
8
-
9
- gem 'rake'
10
- gem 'simple_form', '~> 3.0'
11
- gem 'byebug'
12
- gem 'rspec', '~> 3.4'
13
- gem 'rspec-rails', '~> 3.4'
14
- gem 'capybara'
15
-
16
- gemspec path: "../"
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 5.1.0"
6
-
7
- gem 'sqlite3', '~> 1.3.0'
8
-
9
- gem 'rake'
10
- gem 'simple_form', '~> 5.0'
11
- gem 'byebug'
12
- gem 'rspec', '~> 3.4'
13
- gem 'rspec-rails', '~> 3.4'
14
- gem 'capybara'
15
-
16
- gemspec path: "../"
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 5.1.0"
6
-
7
- gem 'sqlite3', '~> 1.3.0'
8
-
9
- gem 'rake'
10
- gem 'simple_form', '~> 5.0'
11
- gem 'byebug'
12
- gem 'rspec', '~> 3.4'
13
- gem 'rspec-rails', '~> 3.4'
14
- gem 'capybara'
15
-
16
- gemspec path: "../"
@@ -1,16 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "rails", "~> 5.2.0"
6
-
7
- gem 'sqlite3', '~> 1.3.0'
8
-
9
- gem 'rake'
10
- gem 'simple_form', '~> 5.0'
11
- gem 'byebug'
12
- gem 'rspec', '~> 3.4'
13
- gem 'rspec-rails', '~> 3.4'
14
- gem 'capybara'
15
-
16
- gemspec path: "../"