active_flag 1.5.0 → 1.5.1
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 +4 -4
- data/.travis.yml +6 -3
- data/LICENSE +21 -0
- data/README.md +1 -1
- data/gemfiles/5.0.gemfile +12 -0
- data/gemfiles/5.1.gemfile +12 -0
- data/lib/active_flag/definition.rb +6 -5
- data/lib/active_flag/value.rb +3 -3
- data/lib/active_flag/version.rb +1 -1
- data/lib/active_flag.rb +1 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e4a88c02a655b6b16a83ffd290972fb07c8aa9dfa3b3576a3ba8f610b500891a
|
4
|
+
data.tar.gz: 1574b03e53e7d06d5bfba726e893a9ee57216f683fef7b964c119fe439feab42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d896dd686fc5aef5020c0f1042534c9e8764ae3c7fe1fcc66785a3655bf9b5745e874bbba177f5d5d379bfc5902b8c98344bf2f6d8f7be7ea3784080095fce1
|
7
|
+
data.tar.gz: 4ca09aeaa35f658ce10ce29a760a8c2844c074413d2629b9509056de0263a0771d57997a144caf8de61cb3e7be1125e454bcde24df5a93d20e8ff7267a637139
|
data/.travis.yml
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
-
sudo: false
|
2
1
|
language: ruby
|
3
2
|
rvm:
|
4
|
-
- 2.5
|
5
|
-
|
3
|
+
- 2.5
|
4
|
+
- 2.6
|
5
|
+
- 2.7
|
6
|
+
before_install: gem install bundler -v 1.16.2
|
6
7
|
gemfile:
|
8
|
+
- gemfiles/5.0.gemfile
|
9
|
+
- gemfiles/5.1.gemfile
|
7
10
|
- gemfiles/5.2.gemfile
|
8
11
|
- gemfiles/6.0.gemfile
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2016 Kenn Ejima
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -5,14 +5,14 @@ module ActiveFlag
|
|
5
5
|
def initialize(column, keys, klass)
|
6
6
|
@column = column
|
7
7
|
@keys = keys.freeze
|
8
|
-
@maps = Hash[keys.map.with_index{|key, i| [key, 2**i] }].freeze
|
8
|
+
@maps = Hash[keys.map.with_index{ |key, i| [key, 2**i] }].freeze
|
9
9
|
@klass = klass
|
10
10
|
end
|
11
11
|
|
12
12
|
def humans
|
13
13
|
@humans ||= {}
|
14
14
|
@humans[I18n.locale] ||= begin
|
15
|
-
@keys.map{|key| [key, human(key)] }.to_h
|
15
|
+
@keys.map { |key| [key, human(key)] }.to_h
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -34,7 +34,8 @@ module ActiveFlag
|
|
34
34
|
|
35
35
|
def to_i(arg)
|
36
36
|
arg = [arg] unless arg.is_a?(Enumerable)
|
37
|
-
arg
|
37
|
+
arg = arg.uniq
|
38
|
+
arg.map { |s| s && @maps[s.to_s.to_sym] || 0 }.sum
|
38
39
|
end
|
39
40
|
|
40
41
|
def to_value(instance, integer)
|
@@ -42,7 +43,7 @@ module ActiveFlag
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def to_array(integer)
|
45
|
-
@maps.map{|key, mask| (integer & mask > 0) ? key : nil }.compact
|
46
|
+
@maps.map { |key, mask| (integer & mask > 0) ? key : nil }.compact
|
46
47
|
end
|
47
48
|
|
48
49
|
private
|
@@ -58,7 +59,7 @@ module ActiveFlag
|
|
58
59
|
defaults << :"active_flag.#{@column}.#{key}"
|
59
60
|
defaults << options.delete(:default) if options[:default]
|
60
61
|
defaults << key.to_s.humanize
|
61
|
-
I18n.translate defaults.shift, options.reverse_merge(count: 1, default: defaults)
|
62
|
+
I18n.translate defaults.shift, **options.reverse_merge(count: 1, default: defaults)
|
62
63
|
end
|
63
64
|
end
|
64
65
|
end
|
data/lib/active_flag/value.rb
CHANGED
@@ -8,7 +8,7 @@ module ActiveFlag
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def raw
|
11
|
-
@instance.read_attribute(@column)
|
11
|
+
@instance.read_attribute(@column).to_i
|
12
12
|
end
|
13
13
|
|
14
14
|
def to_human
|
@@ -29,12 +29,12 @@ module ActiveFlag
|
|
29
29
|
|
30
30
|
def set!(key, options={})
|
31
31
|
set(key)
|
32
|
-
@instance.save!(options)
|
32
|
+
@instance.save!(**options)
|
33
33
|
end
|
34
34
|
|
35
35
|
def unset!(key, options={})
|
36
36
|
unset(key)
|
37
|
-
@instance.save!(options)
|
37
|
+
@instance.save!(**options)
|
38
38
|
end
|
39
39
|
|
40
40
|
def set?(key)
|
data/lib/active_flag/version.rb
CHANGED
data/lib/active_flag.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_flag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenn Ejima
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -90,11 +90,14 @@ files:
|
|
90
90
|
- ".gitignore"
|
91
91
|
- ".travis.yml"
|
92
92
|
- Gemfile
|
93
|
+
- LICENSE
|
93
94
|
- README.md
|
94
95
|
- Rakefile
|
95
96
|
- active_flag.gemspec
|
96
97
|
- bin/console
|
97
98
|
- bin/setup
|
99
|
+
- gemfiles/5.0.gemfile
|
100
|
+
- gemfiles/5.1.gemfile
|
98
101
|
- gemfiles/5.2.gemfile
|
99
102
|
- gemfiles/6.0.gemfile
|
100
103
|
- lib/active_flag.rb
|
@@ -105,7 +108,7 @@ files:
|
|
105
108
|
homepage: https://github.com/kenn/active_flag
|
106
109
|
licenses: []
|
107
110
|
metadata: {}
|
108
|
-
post_install_message:
|
111
|
+
post_install_message:
|
109
112
|
rdoc_options: []
|
110
113
|
require_paths:
|
111
114
|
- lib
|
@@ -120,8 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
123
|
- !ruby/object:Gem::Version
|
121
124
|
version: '0'
|
122
125
|
requirements: []
|
123
|
-
rubygems_version: 3.0.
|
124
|
-
signing_key:
|
126
|
+
rubygems_version: 3.0.9
|
127
|
+
signing_key:
|
125
128
|
specification_version: 4
|
126
129
|
summary: Bit array for ActiveRecord
|
127
130
|
test_files: []
|