active_value 1.0.1 → 1.0.2

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: d7b6e5171d472898893d059bd6255cc328f09556e90648d57f2d50666db1df95
4
- data.tar.gz: 01ebd564d90d24b72d061fc9db40f975d930e86866b74b86fc6911c47745c548
3
+ metadata.gz: 1427365469e27374bc138221f4b407a579e048997821d4da98aba02f2886bf24
4
+ data.tar.gz: efdc46072d4740678a140ac133cc340f60d2c901e4cfdca706978cdf2170a6f6
5
5
  SHA512:
6
- metadata.gz: 24c684de542964f56c8ca398ccab44df65e959a7f40c5c2b9c3541db3064ac8433c0179b68bf571af1a97d2e8f74b18b92f974b90c5b949bb11aed98aada7482
7
- data.tar.gz: 79af7ce2312d5089fdc6d4ecf4b031917674e78d2d45b1832a8d9e8b4f5781ea5744cb5e2528854fa67fcb791b4274b4d2cd035815b0322d284351964e98fd70
6
+ metadata.gz: 3844219f8857f6a3c8cb6d87d97e5490d914e9916128d5ee52a1789ed108a5c05e2d590f1a3566f557ae4f4ed9ec59a45f961992a7af48a229d4ad36124722ee
7
+ data.tar.gz: 87b08dd151e1563b63c5d17207832829cd2a207477b533b4812e5ef1ebcf925c4ec754ad452aa5ab2f96f048a148b55bd5827733d96bfd3e06dac39dc25eb96f
@@ -6,7 +6,9 @@ jobs:
6
6
  strategy:
7
7
  fail-fast: false
8
8
  matrix:
9
- ruby: [3.0, 2.7, 2.3]
9
+ ruby: [3.0, 2.7, 2.5, 2.3]
10
+ env:
11
+ BUNDLE_GEMFILE: gemfiles/ruby_${{ matrix.ruby }}.gemfile
10
12
  steps:
11
13
  - uses: actions/checkout@v2
12
14
  - uses: ruby/setup-ruby@v1
@@ -0,0 +1,19 @@
1
+ # Appraisal DSL File
2
+ # To test the library against different versions of dependencies
3
+ # `bundle exec appraisal install` command generates `gemfiles/ruby_3.0.gemfile` file etc.
4
+
5
+ appraise "ruby-3" do
6
+ gem "activesupport", "~> 6.1.0"
7
+ end
8
+
9
+ appraise "ruby-2.7" do
10
+ gem "activesupport", "~> 6.0.3"
11
+ end
12
+
13
+ appraise "ruby-2.5" do
14
+ gem "activesupport", "~> 5.2.4"
15
+ end
16
+
17
+ appraise "ruby-2.3" do
18
+ gem "activesupport", "~> 5.2.4"
19
+ end
data/README.md CHANGED
@@ -1,12 +1,19 @@
1
+ # ActiveValue
2
+
1
3
  ![TEST](https://img.shields.io/github/workflow/status/hiratai/active_value/Test?style=for-the-badge)
2
4
  ![RELEASE_VERSION](https://img.shields.io/github/v/release/hiratai/active_value?style=for-the-badge)
3
5
  ![GEM_VERSION](https://img.shields.io/gem/v/active_value?style=for-the-badge)
4
6
  ![LICENSE](https://img.shields.io/github/license/hiratai/active_value?style=for-the-badge)
5
7
 
6
- # ActiveValue
8
+ #### Overviews
7
9
 
8
10
  ActiveValue::Base is base class for immutable value object that has interfaces like ActiveRecord.
9
- In a class inherited this class, constant variables get the behavior like records of ActiveRecord.
11
+ In a class inherited this class, constant variables get the behavior like records of ActiveRecord.
12
+
13
+ #### Supported Verisons
14
+
15
+ Support Ruby 2.3 or later
16
+ Unit tests are passed with Ruby [2.3, 2.5, 2,7, 3.0] on GitHub Actions
10
17
 
11
18
  ## Installation
12
19
 
@@ -48,20 +55,37 @@ Then, constant variables in the class can be accessed by following methods.
48
55
  ```ruby
49
56
  FormCategory.find(1)
50
57
  => <#FormCategory id: 1, symbol: :checkbox, name: "Check Box" >
58
+ # Also can be accessed by FormCategory::CHECK_BOX
51
59
 
52
- FormCategory.find_by(symbol: :radio).name
53
- => "Radio Button"
60
+ FormCategory.find_by(symbol: :checkbox).name
61
+ => "Check Box"
54
62
 
55
63
  FormCategory.find(1).checkbox?
56
64
  => true
57
65
 
66
+ FormCategory.find(2).to_h
67
+ => { :id => 2, :symbol => :radio, :name => "Radio Button" }
68
+ ```
69
+ Getter methods for multiple objects are also provided.
70
+ ```ruby
71
+ FormCategory.all
72
+ => [<#FormCategory id: 1, symbol: :checkbox, name: "Check Box" >, <#FormCategory id: 2, symbol: :radio, name: "Radio Button" >, ...]
73
+
58
74
  FormCategory.pluck(:id, :name)
59
75
  => [[1, "Check Box"], [2, "Radio Button"], [3, "Select Box"], ...]
60
76
 
61
- FormCategory.find(2).to_h
62
- => { :id => 2, :symbol => :radio, :name => "Radio Button" }
77
+ # Undefined method calls delegate to the all method.
78
+ FormCateory.select { |category| category.name.start_with("Text") }
79
+ => [<#FormCategory id: 4, symbol: :text, name: "Text Box" >, <#FormCategory id: 5, symbol: :textarea, name: "Text Area" >]
63
80
  ```
64
81
 
82
+ ## Specified Attributes
83
+
84
+ `id` and `symbol` are specified attributes. (not required)
85
+ - If `id` attribute is defined, you can access a instance using `find` class method.
86
+ - If `symbol` attribute is defined, you can test a instance has the symbol like `FormCategory.find(1).checkbox?`.
87
+
88
+
65
89
 
66
90
  ## Contributing
67
91
 
@@ -25,7 +25,11 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_development_dependency "bundler", "> 1.0.0"
27
27
  spec.add_development_dependency "rake", "> 10.0"
28
- spec.add_development_dependency "minitest", "> 5.0"
28
+ spec.add_development_dependency "minitest", "~> 5.14"
29
+ spec.add_development_dependency "appraisal"
30
+ # For Version 1.1
31
+ # spec.add_development_dependency "activerecord", ">= 4.0.0"
32
+ # spec.add_development_dependency "sqlite3"
29
33
 
30
- spec.add_dependency "activesupport", "~> 5.2.4"
34
+ spec.add_dependency "activesupport", ">= 4.0.0"
31
35
  end
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 5.2.4"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 5.2.4"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 6.0.3"
6
+
7
+ gemspec path: "../"
@@ -0,0 +1,7 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activesupport", "~> 6.1.0"
6
+
7
+ gemspec path: "../"
@@ -1,3 +1,3 @@
1
1
  module ActiveValue
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_value
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taiki Hiramatsu
@@ -42,30 +42,44 @@ dependencies:
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">"
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5.0'
47
+ version: '5.14'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">"
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5.0'
54
+ version: '5.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: appraisal
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: activesupport
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: 5.2.4
75
+ version: 4.0.0
62
76
  type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: 5.2.4
82
+ version: 4.0.0
69
83
  description: In a class inherited this class, constant variables get the behavior
70
84
  like records of ActiveRecord.
71
85
  email:
@@ -78,6 +92,7 @@ files:
78
92
  - ".github/workflows/test.yml"
79
93
  - ".gitignore"
80
94
  - ".travis.yml"
95
+ - Appraisals
81
96
  - Gemfile
82
97
  - LICENSE.txt
83
98
  - README.md
@@ -85,6 +100,10 @@ files:
85
100
  - active_value.gemspec
86
101
  - bin/console
87
102
  - bin/setup
103
+ - gemfiles/ruby_2.3.gemfile
104
+ - gemfiles/ruby_2.5.gemfile
105
+ - gemfiles/ruby_2.7.gemfile
106
+ - gemfiles/ruby_3.gemfile
88
107
  - lib/active_value.rb
89
108
  - lib/active_value/base.rb
90
109
  - lib/active_value/version.rb