flag_shih_tzu 0.3.11 → 0.3.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDhlNTc4NzQ0MDQ4Y2UxY2YwODM0ZTM0MzYzODZhNDZmY2JiMzU2ZQ==
5
- data.tar.gz: !binary |-
6
- YWZjMDBiZTE4YWRhZjI3MDhiYjRiMjk0NDBiOTJlNTE5NGUzOTk3OQ==
2
+ SHA1:
3
+ metadata.gz: 90b55064f920798177d3ca8c7eaf24141d275266
4
+ data.tar.gz: 4c56f730ebcd6de7721312f81809ecede06cbcd7
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- ZTlkMzY1YTc2YWZkZmVkZmRiMTQ4OTliYmIyYTg2NDBkZGFmYTlmMmNhOGQw
10
- MTZjZTYxY2IzMzc1ZThjMjZjYmRkMzc0Y2ZiYjkwNjE5ZTA2MjUxYWVlMDk5
11
- ZGE2MzRhNGFhNDU0ZWIwNDU4OTA5YzllZjAzMjMxYmY0NzljZDM=
12
- data.tar.gz: !binary |-
13
- MWVhM2NiYmU3ZjQ3NGExNzZmOGZiZDU2ZmM1OWZmZWNlZjk4MzYzNTQ5YmNj
14
- M2Q1YjE2ZjI2NDNkNzQ5YjhkZmNiZTNmYzFiOThiYTk1MGY1N2QzMGZmMTFh
15
- ZWJiY2UyZGJlMzM5YTlhMDg4MDRlZDhmNzFkNmY5Mjc1ODVjOTQ=
6
+ metadata.gz: 3b9a1d00be762409224b7cafd6244a93cf062ff721d218ea5c9b167ee6963cfa1a1a1ba8ce3b24ae71146df74e674771d58e9139b139eb4c822c7af0546f108b
7
+ data.tar.gz: e5438b3889ca9d3caf04d18b54ecc26587190368978fa8cc51626b41c30596fa051a08c02a43a98aa3ce36d4a8938845d1e01a4dc87e3d651f5ecc5ad64fd2a6
data/.travis.yml CHANGED
@@ -14,7 +14,9 @@ matrix:
14
14
  exclude:
15
15
  - rvm: 2.1.2
16
16
  gemfile: gemfiles/Gemfile.activerecord-2.3.x
17
+ - rvm: 2.1.2
17
18
  gemfile: gemfiles/Gemfile.activerecord-3.0.x
19
+ - rvm: 2.1.2
18
20
  gemfile: gemfiles/Gemfile.activerecord-3.1.x
19
21
  - rvm: 2.0.0
20
22
  gemfile: gemfiles/Gemfile.activerecord-2.3.x
@@ -22,4 +24,5 @@ matrix:
22
24
  gemfile: gemfiles/Gemfile.activerecord-4.1.x
23
25
  - rvm: 1.9.2
24
26
  gemfile: gemfiles/Gemfile.activerecord-4.0.x
27
+ - rvm: 1.9.2
25
28
  gemfile: gemfiles/Gemfile.activerecord-4.1.x
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ Version 0.3.12 - OCT.01.2014
2
+ * Improve testing instructions in readme by Peter Boling
3
+ * fix check_flag_column to return false after warn by Peter Boling
4
+ * bash script for running complete test suite on Ruby 1.9.3 and Ruby 2.1.2 by Peter Boling
5
+ * Improve documentation in readme by trliner
6
+ * use aliases to make attribute reader methods more DRY by trliner
7
+ * add negative attribute reader and writer methods for improved interoperability with simple_form and formtastic by trliner
8
+ * Adds specs for ActiveRecord version 4.1 by Peter Boling
9
+ * Use Kernel#warn instead of puts by Peter Boling
10
+
1
11
  Version 0.3.11 - JUL.09.2014
2
12
  * Rename some ambigously-named methods mixed into AR::Base by jdelStrother
3
13
  * Add dynamic ".*_values_for" helpers by atipugin
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Bit fields for ActiveRecord
4
4
 
5
- | Project | Sanitize Email |
5
+ | Project | FlagShihTzu |
6
6
  |------------------------ | ----------------- |
7
7
  | gem name | flag_shih_tzu |
8
8
  | license | MIT |
@@ -180,6 +180,9 @@ on Spaceship:
180
180
  Spaceship#warpdrive
181
181
  Spaceship#warpdrive?
182
182
  Spaceship#warpdrive=
183
+ Spaceship#not_warpdrive
184
+ Spaceship#not_warpdrive?
185
+ Spaceship#not_warpdrive=
183
186
  Spaceship#warpdrive_changed?
184
187
  Spaceship#all_warpdrives
185
188
  Spaceship#selected_warpdrives
@@ -191,6 +194,9 @@ on Spaceship:
191
194
  Spaceship#shields
192
195
  Spaceship#shields?
193
196
  Spaceship#shields=
197
+ Spaceship#not_shields
198
+ Spaceship#not_shields?
199
+ Spaceship#not_shields=
194
200
  Spaceship#shields_changed?
195
201
  Spaceship#all_shields
196
202
  Spaceship#selected_shields
@@ -202,6 +208,9 @@ on Spaceship:
202
208
  Spaceship#electrolytes
203
209
  Spaceship#electrolytes?
204
210
  Spaceship#electrolytes=
211
+ Spaceship#not_electrolytes
212
+ Spaceship#not_electrolytes?
213
+ Spaceship#not_electrolytes=
205
214
  Spaceship#electrolytes_changed?
206
215
  Spaceship#all_electrolytes
207
216
  Spaceship#selected_electrolytes
@@ -364,35 +373,29 @@ false to avoid it.
364
373
 
365
374
  ## Running the gem tests
366
375
 
367
- First, make sure all required gems are installed:
376
+ First, run some infrequent setup:
368
377
 
378
+ $ rvm use 1.9.3
369
379
  $ bundle install
370
-
371
- The default rake test task will run the tests against the currently locked
372
- ActiveRecord version (see `Gemfile.lock`):
373
-
374
- $ NOCOVER=true bundle exec rake test
375
-
376
- If you want to run the tests against all supported ActiveRecord versions:
377
-
378
- * you will need to use ruby 1.9.3 as it is the only version of ruby that bridges the gap between rails 2.3 and rails 4.0
379
- * you may need to run each bundle once:
380
-
381
-
382
380
  $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-2.3.x' bundle update --quiet
383
381
  $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-3.0.x' bundle update --quiet
384
382
  $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-3.1.x' bundle update --quiet
385
383
  $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-3.2.x' bundle update --quiet
386
384
  $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-4.0.x' bundle update --quiet
385
+ $ rvm use 2.1.2
386
+ $ bundle install
387
+ $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-3.2.x' bundle update --quiet
388
+ $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-4.0.x' bundle update --quiet
389
+ $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-4.1.x' bundle update --quiet
387
390
 
388
391
  Then just:
389
392
 
390
- $ NOCOVER=true bundle exec rake test:all
393
+ $ bundle exec rake test:all
391
394
 
392
- This will internally use bundler to load specific ActiveRecord versions
395
+ This will internally use rvm and bundler to load specific ActiveRecord versions
393
396
  before executing the tests (see `gemfiles/`), e.g.:
394
397
 
395
- $ NOCOVER=true BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-3.1.x' bundle exec rake test
398
+ $ NOCOVER=true BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-4.1.x' bundle exec rake test
396
399
 
397
400
  All tests will use an in-memory sqlite database by default.
398
401
  If you want to use a different database, see `test/database.yml`,
data/Rakefile CHANGED
@@ -40,9 +40,6 @@ end
40
40
  namespace :test do
41
41
  desc 'Test against all supported ActiveRecord versions'
42
42
  task :all do
43
- %w(2.3.x 3.0.x 3.1.x 3.2.x).each do |version|
44
- sh "BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-#{version}' bundle --quiet"
45
- sh "BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-#{version}' bundle exec rake test"
46
- end
43
+ sh "bin/test.bash"
47
44
  end
48
45
  end
data/bin/test.bash ADDED
@@ -0,0 +1,27 @@
1
+ #!/bin/bash --login
2
+
3
+ # First run the tests of all versions supported on Ruby 1.9.3
4
+ rvm use 1.9.3
5
+ bundle install --quiet
6
+ COMPATIBLE_VERSIONS=(2.3.x 3.0.x 3.1.x 3.2.x 4.0.x)
7
+ count=0
8
+ while [ "x${COMPATIBLE_VERSIONS[count]}" != "x" ]
9
+ do
10
+ version=${COMPATIBLE_VERSIONS[count]}
11
+ BUNDLE_GEMFILE="gemfiles/Gemfile.activerecord-$version" bundle install --quiet
12
+ NOCOVER=true BUNDLE_GEMFILE="gemfiles/Gemfile.activerecord-$version" bundle exec rake test
13
+ count=$(( $count + 1 ))
14
+ done
15
+
16
+ # Then run the tests of all versions supported on Ruby 2.1.2
17
+ rvm use 2.1.2
18
+ bundle install --quiet
19
+ COMPATIBLE_VERSIONS=(3.2.x 4.0.x 4.1.x)
20
+ count=0
21
+ while [ "x${COMPATIBLE_VERSIONS[count]}" != "x" ]
22
+ do
23
+ version=${COMPATIBLE_VERSIONS[count]}
24
+ BUNDLE_GEMFILE="gemfiles/Gemfile.activerecord-$version" bundle install --quiet
25
+ NOCOVER=true BUNDLE_GEMFILE="gemfiles/Gemfile.activerecord-$version" bundle exec rake test
26
+ count=$(( $count + 1 ))
27
+ done
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec :path => '..'
4
+
5
+ gem "activerecord", "~>4.1.0"
6
+ gem "test-unit"
data/lib/flag_shih_tzu.rb CHANGED
@@ -31,12 +31,12 @@ module FlagShihTzu
31
31
  }.update(opts)
32
32
  colmn = opts[:column].to_s
33
33
  if !is_valid_flag_column_name(opts[:column])
34
- puts "FlagShihTzu says: Please use a String to designate column names! I see you here: #{caller.first}"
34
+ warn "FlagShihTzu says: Please use a String to designate column names! I see you here: #{caller.first}"
35
35
  opts[:column] = opts[:column].to_s
36
36
  end
37
37
  colmn = opts[:column]
38
38
  if opts[:check_for_column] && !check_flag_column(colmn)
39
- puts "FlagShihTzu says: Flag column #{colmn} appears to be missing!\nTo turn off this warning set check_for_column: false in has_flags definition here: #{caller.first}"
39
+ warn "FlagShihTzu says: Flag column #{colmn} appears to be missing!\nTo turn off this warning set check_for_column: false in has_flags definition here: #{caller.first}"
40
40
  return
41
41
  end
42
42
 
@@ -67,15 +67,21 @@ module FlagShihTzu
67
67
  def #{flag_name}
68
68
  flag_enabled?(:#{flag_name}, '#{colmn}')
69
69
  end
70
-
71
- def #{flag_name}?
72
- flag_enabled?(:#{flag_name}, '#{colmn}')
73
- end
70
+ alias :#{flag_name}? :#{flag_name}
74
71
 
75
72
  def #{flag_name}=(value)
76
73
  FlagShihTzu::TRUE_VALUES.include?(value) ? enable_flag(:#{flag_name}, '#{colmn}') : disable_flag(:#{flag_name}, '#{colmn}')
77
74
  end
78
75
 
76
+ def not_#{flag_name}
77
+ !#{flag_name}
78
+ end
79
+ alias :not_#{flag_name}? :not_#{flag_name}
80
+
81
+ def not_#{flag_name}=(value)
82
+ FlagShihTzu::TRUE_VALUES.include?(value) ? disable_flag(:#{flag_name}, '#{colmn}') : enable_flag(:#{flag_name}, '#{colmn}')
83
+ end
84
+
79
85
  def #{flag_name}_changed?
80
86
  if colmn_changes = changes['#{colmn}']
81
87
  flag_bit = self.class.flag_mapping['#{colmn}'][:#{flag_name}]
@@ -271,22 +277,15 @@ module FlagShihTzu
271
277
  #If you have not yet run the migration that adds the 'flags' column then we don't want to fail, because we need to be able to run the migration
272
278
  #If the column is there but is of the wrong type, then we must fail, because flag_shih_tzu will not work
273
279
  if found_column.nil?
274
- if respond_to?(:logger)
275
- logger.warn("Error: Column '#{colmn}' doesn't exist on table '#{custom_table_name}'. Did you forget to run migrations?") and return false
276
- else
277
- puts("Error: Column '#{colmn}' doesn't exist on table '#{custom_table_name}'. Did you forget to run migrations?") and return false
278
- end
280
+ warn("Error: Column '#{colmn}' doesn't exist on table '#{custom_table_name}'. Did you forget to run migrations?")
281
+ return false
279
282
  elsif found_column.type != :integer
280
- raise IncorrectFlagColumnException.new("Table '#{custom_table_name}' must have an integer column named '#{colmn}' in order to use FlagShihTzu.") and return false
283
+ raise IncorrectFlagColumnException.new("Table '#{custom_table_name}' must have an integer column named '#{colmn}' in order to use FlagShihTzu.")
281
284
  end
282
285
  else
283
- # ActiveRecord gem probably hasn't loaded yet?
284
- if respond_to?(:logger)
285
- logger.warn("FlagShihTzu#has_flags: Table '#{custom_table_name}' doesn't exist. Have all migrations been run?") if has_ar
286
- return false
287
- #else
288
- # puts("FlagShihTzu#has_flags: Table '#{custom_table_name}' doesn't exist. Have all migrations been run?") and return false
289
- end
286
+ # ActiveRecord gem may not have loaded yet?
287
+ warn("FlagShihTzu#has_flags: Table '#{custom_table_name}' doesn't exist. Have all migrations been run?") if has_ar
288
+ return false
290
289
  end
291
290
 
292
291
  true
@@ -1,3 +1,3 @@
1
1
  module FlagShihTzu
2
- VERSION = "0.3.11"
2
+ VERSION = "0.3.12"
3
3
  end
@@ -579,6 +579,10 @@ class FlagShihTzuInstanceMethodsTest < Test::Unit::TestCase
579
579
  assert_equal false, @spaceship.warpdrive
580
580
  end
581
581
 
582
+ def test_should_define_a_negative_attribute_reader_method
583
+ assert_equal true, @spaceship.not_warpdrive
584
+ end
585
+
582
586
  # --------------------------------------------------
583
587
 
584
588
  def test_should_define_an_all_flags_reader_method_with_arity_1
@@ -863,11 +867,20 @@ class FlagShihTzuInstanceMethodsTest < Test::Unit::TestCase
863
867
  assert_equal false, @spaceship.warpdrive?
864
868
  end
865
869
 
870
+ def test_should_define_a_negative_attribute_reader_predicate_method
871
+ assert_equal true, @spaceship.not_warpdrive?
872
+ end
873
+
866
874
  def test_should_define_an_attribute_writer_method
867
875
  @spaceship.warpdrive = true
868
876
  assert @spaceship.warpdrive
869
877
  end
870
878
 
879
+ def test_should_define_a_negative_attribute_writer_method
880
+ @spaceship.not_warpdrive = false
881
+ assert @spaceship.warpdrive
882
+ end
883
+
871
884
  def test_should_define_dirty_suffix_changed?
872
885
  assert !@spaceship.warpdrive_changed?
873
886
  assert !@spaceship.shields_changed?
@@ -952,7 +965,7 @@ class FlagShihTzuInstanceMethodsTest < Test::Unit::TestCase
952
965
  EOF
953
966
  )
954
967
  end
955
-
968
+ assert !SpaceshipWithoutFlagsColumn2.send(:check_flag_column, 'flags')
956
969
  assert !SpaceshipWithoutFlagsColumn2.method_defined?(:warpdrive)
957
970
  end
958
971
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flag_shih_tzu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.11
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
@@ -12,152 +12,150 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-07-09 00:00:00.000000000 Z
15
+ date: 2014-10-01 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activerecord
19
19
  requirement: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - ! '>='
21
+ - - ">="
22
22
  - !ruby/object:Gem::Version
23
23
  version: 2.3.0
24
24
  type: :development
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
- - - ! '>='
28
+ - - ">="
29
29
  - !ruby/object:Gem::Version
30
30
  version: 2.3.0
31
31
  - !ruby/object:Gem::Dependency
32
32
  name: bundler
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  requirements:
35
- - - ! '>='
35
+ - - ">="
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - ! '>='
42
+ - - ">="
43
43
  - !ruby/object:Gem::Version
44
44
  version: '0'
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: rdoc
47
47
  requirement: !ruby/object:Gem::Requirement
48
48
  requirements:
49
- - - ! '>='
49
+ - - ">="
50
50
  - !ruby/object:Gem::Version
51
51
  version: 2.4.2
52
52
  type: :development
53
53
  prerelease: false
54
54
  version_requirements: !ruby/object:Gem::Requirement
55
55
  requirements:
56
- - - ! '>='
56
+ - - ">="
57
57
  - !ruby/object:Gem::Version
58
58
  version: 2.4.2
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: reek
61
61
  requirement: !ruby/object:Gem::Requirement
62
62
  requirements:
63
- - - ! '>='
63
+ - - ">="
64
64
  - !ruby/object:Gem::Version
65
65
  version: 1.2.8
66
66
  type: :development
67
67
  prerelease: false
68
68
  version_requirements: !ruby/object:Gem::Requirement
69
69
  requirements:
70
- - - ! '>='
70
+ - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: 1.2.8
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: roodi
75
75
  requirement: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - ! '>='
77
+ - - ">="
78
78
  - !ruby/object:Gem::Version
79
79
  version: 2.1.0
80
80
  type: :development
81
81
  prerelease: false
82
82
  version_requirements: !ruby/object:Gem::Requirement
83
83
  requirements:
84
- - - ! '>='
84
+ - - ">="
85
85
  - !ruby/object:Gem::Version
86
86
  version: 2.1.0
87
87
  - !ruby/object:Gem::Dependency
88
88
  name: rake
89
89
  requirement: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - ! '>='
91
+ - - ">="
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  type: :development
95
95
  prerelease: false
96
96
  version_requirements: !ruby/object:Gem::Requirement
97
97
  requirements:
98
- - - ! '>='
98
+ - - ">="
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: coveralls
103
103
  requirement: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - ! '>='
105
+ - - ">="
106
106
  - !ruby/object:Gem::Version
107
107
  version: '0'
108
108
  type: :development
109
109
  prerelease: false
110
110
  version_requirements: !ruby/object:Gem::Requirement
111
111
  requirements:
112
- - - ! '>='
112
+ - - ">="
113
113
  - !ruby/object:Gem::Version
114
114
  version: '0'
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: sqlite3
117
117
  requirement: !ruby/object:Gem::Requirement
118
118
  requirements:
119
- - - ! '>='
119
+ - - ">="
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  type: :development
123
123
  prerelease: false
124
124
  version_requirements: !ruby/object:Gem::Requirement
125
125
  requirements:
126
- - - ! '>='
126
+ - - ">="
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
- description: ! 'Bit fields for ActiveRecord:
130
-
129
+ description: |
130
+ Bit fields for ActiveRecord:
131
131
  This gem lets you use a single integer column in an ActiveRecord model
132
-
133
132
  to store a collection of boolean attributes (flags). Each flag can be used
134
-
135
133
  almost in the same way you would use any boolean attribute on an
136
-
137
134
  ActiveRecord object.
138
-
139
- '
140
135
  email: peter.boling@gmail.com
141
- executables: []
136
+ executables:
137
+ - test.bash
142
138
  extensions: []
143
139
  extra_rdoc_files: []
144
140
  files:
145
- - .DS_Store
146
- - .coveralls.yml
147
- - .gitignore
148
- - .travis.yml
141
+ - ".DS_Store"
142
+ - ".coveralls.yml"
143
+ - ".gitignore"
144
+ - ".travis.yml"
149
145
  - CHANGELOG
150
146
  - Gemfile
151
147
  - LICENSE
152
148
  - README.md
153
149
  - REEK
154
150
  - Rakefile
151
+ - bin/test.bash
155
152
  - flag_shih_tzu.gemspec
156
153
  - gemfiles/Gemfile.activerecord-2.3.x
157
154
  - gemfiles/Gemfile.activerecord-3.0.x
158
155
  - gemfiles/Gemfile.activerecord-3.1.x
159
156
  - gemfiles/Gemfile.activerecord-3.2.x
160
157
  - gemfiles/Gemfile.activerecord-4.0.x
158
+ - gemfiles/Gemfile.activerecord-4.1.x
161
159
  - lib/flag_shih_tzu.rb
162
160
  - lib/flag_shih_tzu/validators.rb
163
161
  - lib/flag_shih_tzu/version.rb
@@ -175,12 +173,12 @@ require_paths:
175
173
  - lib
176
174
  required_ruby_version: !ruby/object:Gem::Requirement
177
175
  requirements:
178
- - - ! '>='
176
+ - - ">="
179
177
  - !ruby/object:Gem::Version
180
178
  version: '0'
181
179
  required_rubygems_version: !ruby/object:Gem::Requirement
182
180
  requirements:
183
- - - ! '>='
181
+ - - ">="
184
182
  - !ruby/object:Gem::Version
185
183
  version: '0'
186
184
  requirements: []