yaml_enumeration 0.2.1 → 0.2.2

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: 8747c00cb3c5721cdcae63a2cffd0de025b3e6f9e0904b82dc25b61f6487bf70
4
- data.tar.gz: 48f1a23d176f9e2800aa8d2dd90de53a9f6a8470792aed732a3c9e198fbb42e9
3
+ metadata.gz: d42b540fe754657e4e982b3324efcc67aaf7726019311dc574ec0035ee7b76ea
4
+ data.tar.gz: c046de0c21e60c0f0bed6be8f276b60988182ecb793893ce4433d8cfbccfa1af
5
5
  SHA512:
6
- metadata.gz: 42a5619fe9bb3f8b17267da4ee6d98d3a870eb782241f4a33bf44bb026e7fadf10ff8d3ae76cb4a37d729a47e90b3a04e4cfb3d26bbc4c572d3e836e1ddd9a9e
7
- data.tar.gz: 24ab6e4d7a6f5216ce2aa1f6ae5c95085ac7f5a982ac0d24626a1196a4cd4de676dbb17022269b6296263cf6732f26d6dca8f72d56e9e1ea44ad3139d874201f
6
+ metadata.gz: d4b52ee6c9b97391eb0d3aea409595c2d3ef253a7b364222d47020da7fa4e017802029556b50d4e0d997ea08a14f8b2c6d6287d334f0a56d94f874c87fe37974
7
+ data.tar.gz: ec4e04994a577354f8fd360601a5f4b07ba3153193a356dac69c8a89b162431451f75dd4addc7477be5cff26fe7cad968481f84ef1b374dd9649b8df744f3fb1
data/.travis.yml CHANGED
@@ -2,4 +2,6 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.5.3
5
+ - 2.6.5
6
+ - 2.7.1
5
7
  before_install: gem install bundler
data/CHANGELOG.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
- ## 0.2.1
3
+ ## 0.2.2
4
+ * enhance find-by methods [#4])(https://github.com/alto/yaml_enumeration/pull/4)
5
+ * add support for Ruby `2.6` and `2.7` [#3])(https://github.com/alto/yaml_enumeration/pull/3)
4
6
 
7
+ ## 0.2.1
5
8
  * add support for Ruby `2.5.3` [#2])(https://github.com/alto/yaml_enumeration/pull/2)
6
9
 
7
10
  ## 0.2.0
8
-
9
11
  * support _ActiveRecord_ methods `where`, `find_by` [#1])(https://github.com/alto/yaml_enumeration/pull/1), thanks to [@richdrich](https://github.com/richdrich)
10
12
 
11
13
  ## 0.1.0
12
-
13
14
  * initial version
@@ -90,8 +90,28 @@ module YamlEnumeration
90
90
  end
91
91
  alias_method :find_by_id, :find
92
92
 
93
- def find_by(column, value)
94
- all.find {|item| item.send(column) == value }
93
+ def find_by(column, value=nil)
94
+ case column
95
+ when Hash
96
+ raise "Hashes with multiple filters are not support so far" if column.keys.size > 1
97
+
98
+ key = column.keys[0]
99
+ all.find {|item| item.send(key) == column[key] }
100
+ else
101
+ all.find {|item| item.send(column) == value }
102
+ end
103
+ end
104
+
105
+ def find_all_by(column, value=nil)
106
+ case column
107
+ when Hash
108
+ raise "Hashes with multiple filters are not support so far" if column.keys.size > 1
109
+
110
+ key = column.keys[0]
111
+ all.select {|item| item.send(key) == column[key] }
112
+ else
113
+ all.select {|item| item.send(column) == value }
114
+ end
95
115
  end
96
116
 
97
117
  def find_by_type(type)
@@ -1,3 +1,3 @@
1
1
  module YamlEnumeration
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -20,11 +20,11 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_development_dependency "bundler", "~> 1.12"
23
+ spec.add_development_dependency "bundler"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "maxitest", '~> 1'
25
+ spec.add_development_dependency "maxitest"
26
26
  spec.add_development_dependency "shoulda-context"
27
27
 
28
- spec.add_dependency "activesupport", '>= 4'
29
- spec.add_dependency "railties", '>= 4'
28
+ spec.add_dependency "activesupport", '>= 6'
29
+ spec.add_dependency "railties", '>= 6'
30
30
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml_enumeration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thorsten Boettger
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-23 00:00:00.000000000 Z
11
+ date: 2021-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.12'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.12'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: maxitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1'
47
+ version: '0'
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: '1'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: shoulda-context
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '4'
75
+ version: '6'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '4'
82
+ version: '6'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: railties
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '4'
89
+ version: '6'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '4'
96
+ version: '6'
97
97
  description: |-
98
98
  Create classes which work like ActiveRecord classes,
99
99
  but are defined as fixed enumerations based on YAML files.
@@ -123,7 +123,7 @@ homepage: https://github.com/alto/yaml_enumeration
123
123
  licenses:
124
124
  - MIT
125
125
  metadata: {}
126
- post_install_message:
126
+ post_install_message:
127
127
  rdoc_options: []
128
128
  require_paths:
129
129
  - lib
@@ -138,9 +138,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  requirements: []
141
- rubyforge_project:
142
- rubygems_version: 2.7.7
143
- signing_key:
141
+ rubygems_version: 3.2.17
142
+ signing_key:
144
143
  specification_version: 4
145
144
  summary: Create ActiveRecord enumerations based on YAML files.
146
145
  test_files: []