simple_flaggable_column 0.0.1 → 0.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b85577a3634dae66307e60d277336bcc50e9fa8c
|
4
|
+
data.tar.gz: 627f79aa1e5e2354fc7f855f20a9b8160b9c8e6a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b13f6be90bf09d96f52feffdb6475a6a29607233b98e6ac1d30474af450b01fe8d97a169916fdc392bb38a7465eef355845a3d8bc563c94a8b2377ee5cc2def
|
7
|
+
data.tar.gz: 781d196b0c8fa2326beb1defc35df4d5515ab1c0cde50519b11f3453a0ecf91c608985ba93e22118b25909f687599eb958b3ebf4d215d405df5967b2fa2db1a8
|
data/Guardfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
3
|
+
require "guard/rspec/dsl"
|
4
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
5
|
+
|
6
|
+
# Feel free to open issues for suggestions and improvements
|
7
|
+
|
8
|
+
# RSpec files
|
9
|
+
rspec = dsl.rspec
|
10
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
11
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
12
|
+
watch(rspec.spec_files)
|
13
|
+
|
14
|
+
# Ruby files
|
15
|
+
ruby = dsl.ruby
|
16
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
17
|
+
end
|
@@ -29,7 +29,13 @@ module SimpleFlaggableColumn
|
|
29
29
|
end
|
30
30
|
|
31
31
|
define_method "#{name}=" do |symbols|
|
32
|
-
|
32
|
+
if symbols.nil?
|
33
|
+
write_attribute name, 0
|
34
|
+
elsif symbols.kind_of? Array
|
35
|
+
write_attribute name, SimpleFlaggableColumn.symbols_to_flags(symbols, symbols_flags)
|
36
|
+
else # numeric, or anything else
|
37
|
+
write_attribute name, symbols
|
38
|
+
end
|
33
39
|
end
|
34
40
|
|
35
41
|
define_method name do
|
@@ -23,4 +23,6 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency 'rake', '~> 10.0'
|
24
24
|
spec.add_development_dependency 'with_model', '~> 1.2'
|
25
25
|
spec.add_development_dependency 'sqlite3', '~> 1.3'
|
26
|
+
spec.add_development_dependency 'guard', '~> 2.13'
|
27
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.6'
|
26
28
|
end
|
@@ -33,23 +33,39 @@ describe SimpleFlaggableColumn do
|
|
33
33
|
expect(game.platforms).to match_array [:mac, :linux]
|
34
34
|
end
|
35
35
|
|
36
|
-
it 'should
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
it 'should set the value to 0 when nil' do
|
37
|
+
game = GameModel.new
|
38
|
+
game.platforms = [:mac, :linux]
|
39
|
+
expect(game.platforms).to eq [:mac, :linux]
|
40
|
+
game.platforms = nil
|
41
|
+
expect(game.platforms).to eq []
|
42
42
|
end
|
43
43
|
|
44
|
-
it 'should
|
45
|
-
|
44
|
+
it 'should allow you to set numeric values directly' do
|
45
|
+
game = GameModel.new
|
46
|
+
game.platforms = 0b101
|
47
|
+
expect(game.platforms).to eq [:win, :linux]
|
46
48
|
end
|
47
49
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
describe 'flags lists' do
|
51
|
+
it 'should define the list of flags' do
|
52
|
+
expect(GameModel.platforms_flags).to eq({
|
53
|
+
win: 0b001,
|
54
|
+
mac: 0b010,
|
55
|
+
linux: 0b100
|
56
|
+
})
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should let you get a join list of flags' do
|
60
|
+
expect(GameModel.platforms_flags(:win, :linux)).to eq 0b101
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should define the reverse list of flags' do
|
64
|
+
expect(GameModel.flags_platforms).to eq({
|
65
|
+
0b001 => :win,
|
66
|
+
0b010 => :mac,
|
67
|
+
0b100 => :linux
|
68
|
+
})
|
69
|
+
end
|
54
70
|
end
|
55
71
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_flaggable_column
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zequez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.13'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.13'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '4.6'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '4.6'
|
83
111
|
description: This gem adds a concern to allow you to use binary flags columns in ActiveRecord
|
84
112
|
models
|
85
113
|
email:
|
@@ -91,6 +119,7 @@ files:
|
|
91
119
|
- ".gitignore"
|
92
120
|
- ".rspec"
|
93
121
|
- Gemfile
|
122
|
+
- Guardfile
|
94
123
|
- LICENSE.txt
|
95
124
|
- README.md
|
96
125
|
- lib/simple_flaggable_column.rb
|