flag_shih_tzu 0.3.10 → 0.3.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODkxZWY1MzkwNzBiMWY4NGEyZDM0MmEyZjkzOWJmMzY3NWU4ZGU2Zg==
4
+ MDhlNTc4NzQ0MDQ4Y2UxY2YwODM0ZTM0MzYzODZhNDZmY2JiMzU2ZQ==
5
5
  data.tar.gz: !binary |-
6
- NjYzMTcxYzI5Yzc5MDY5NDZmYjY0NmE2YmIyZDFhZTM3Njg3OTQzNw==
6
+ YWZjMDBiZTE4YWRhZjI3MDhiYjRiMjk0NDBiOTJlNTE5NGUzOTk3OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NWE0ZDBjODNlNTg2MmRiOWIxNjAyNzg0YmZmNzJkZTVlZTdjOTAzYTYzMTMy
10
- NjI1ZjJiNTc1MzM5YWZiZDRjZGYwZTQxODM4MmQ1NDQ1NGMwMDY2Y2M1Y2E0
11
- MGUyODQyZWE2ZGQ0NTY1NjFlNmE5YTYwNjJjYjc1ODk2N2UxNmI=
9
+ ZTlkMzY1YTc2YWZkZmVkZmRiMTQ4OTliYmIyYTg2NDBkZGFmYTlmMmNhOGQw
10
+ MTZjZTYxY2IzMzc1ZThjMjZjYmRkMzc0Y2ZiYjkwNjE5ZTA2MjUxYWVlMDk5
11
+ ZGE2MzRhNGFhNDU0ZWIwNDU4OTA5YzllZjAzMjMxYmY0NzljZDM=
12
12
  data.tar.gz: !binary |-
13
- YzQxZTZiZmQyOTNmMTQwYWQzZDEwYjA1ZDY4MDczNzU2YWM5NTVmMThhM2Nm
14
- MjFjMTJiZTk2ZDk2MzdmMTMwM2RkMDhmNTNhYzI1MDRmMTFlYTZmM2EyYjQz
15
- MTZlZmQ2MjFkMjA5YjZhNTkyNjQ5NjQ1N2UyNjU2ODIxNGMwZDY=
13
+ MWVhM2NiYmU3ZjQ3NGExNzZmOGZiZDU2ZmM1OWZmZWNlZjk4MzYzNTQ5YmNj
14
+ M2Q1YjE2ZjI2NDNkNzQ5YjhkZmNiZTNmYzFiOThiYTk1MGY1N2QzMGZmMTFh
15
+ ZWJiY2UyZGJlMzM5YTlhMDg4MDRlZDhmNzFkNmY5Mjc1ODVjOTQ=
data/.travis.yml CHANGED
@@ -1,19 +1,25 @@
1
1
  rvm:
2
- - 1.8.7
3
2
  - 1.9.2
4
3
  - 1.9.3
5
4
  - 2.0.0
5
+ - 2.1.2
6
6
  gemfile:
7
7
  - gemfiles/Gemfile.activerecord-2.3.x
8
8
  - gemfiles/Gemfile.activerecord-3.0.x
9
9
  - gemfiles/Gemfile.activerecord-3.1.x
10
10
  - gemfiles/Gemfile.activerecord-3.2.x
11
11
  - gemfiles/Gemfile.activerecord-4.0.x
12
+ - gemfiles/Gemfile.activerecord-4.1.x
12
13
  matrix:
13
14
  exclude:
15
+ - rvm: 2.1.2
16
+ gemfile: gemfiles/Gemfile.activerecord-2.3.x
17
+ gemfile: gemfiles/Gemfile.activerecord-3.0.x
18
+ gemfile: gemfiles/Gemfile.activerecord-3.1.x
14
19
  - rvm: 2.0.0
15
20
  gemfile: gemfiles/Gemfile.activerecord-2.3.x
16
- - rvm: 1.8.7
17
- gemfile: gemfiles/Gemfile.activerecord-4.0.x
21
+ - rvm: 1.9.3
22
+ gemfile: gemfiles/Gemfile.activerecord-4.1.x
18
23
  - rvm: 1.9.2
19
24
  gemfile: gemfiles/Gemfile.activerecord-4.0.x
25
+ gemfile: gemfiles/Gemfile.activerecord-4.1.x
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ Version 0.3.11 - JUL.09.2014
2
+ * Rename some ambigously-named methods mixed into AR::Base by jdelStrother
3
+ * Add dynamic ".*_values_for" helpers by atipugin
4
+
1
5
  Version 0.3.10 - NOV.26.2013
2
6
  * Can run tests without coverage by specifying NOCOVER=true by Peter Boling
3
7
  * Improved test coverage by Peter Boling
data/README.md CHANGED
@@ -6,9 +6,11 @@ Bit fields for ActiveRecord
6
6
  |------------------------ | ----------------- |
7
7
  | gem name | flag_shih_tzu |
8
8
  | license | MIT |
9
+ | moldiness | [![Maintainer Status](http://stillmaintained.com/pboling/flag_shih_tzu.png)](http://stillmaintained.com/pboling/flag_shih_tzu) |
9
10
  | version | [![Gem Version](https://badge.fury.io/rb/flag_shih_tzu.png)](http://badge.fury.io/rb/flag_shih_tzu) |
10
11
  | dependencies | [![Dependency Status](https://gemnasium.com/pboling/flag_shih_tzu.png)](https://gemnasium.com/pboling/flag_shih_tzu) |
11
12
  | code quality | [![Code Climate](https://codeclimate.com/github/pboling/flag_shih_tzu.png)](https://codeclimate.com/github/pboling/flag_shih_tzu) |
13
+ | inline documenation | [![Inline docs](http://inch-ci.org/github/pboling/flag_shih_tzu.png)](http://inch-ci.org/github/pboling/flag_shih_tzu) |
12
14
  | continuous integration | [![Build Status](https://secure.travis-ci.org/pboling/flag_shih_tzu.png?branch=master)](https://travis-ci.org/pboling/flag_shih_tzu) |
13
15
  | test coverage | [![Coverage Status](https://coveralls.io/repos/pboling/flag_shih_tzu/badge.png)](https://coveralls.io/r/pboling/flag_shih_tzu) |
14
16
  | homepage | [https://github.com/pboling/flag_shih_tzu][homepage] |
@@ -377,11 +379,11 @@ If you want to run the tests against all supported ActiveRecord versions:
377
379
  * you may need to run each bundle once:
378
380
 
379
381
 
380
- $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-2.3.x' bundle --quiet
381
- $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-3.0.x' bundle --quiet
382
- $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-3.1.x' bundle --quiet
383
- $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-3.2.x' bundle --quiet
384
- $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-4.0.x' bundle --quiet
382
+ $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-2.3.x' bundle update --quiet
383
+ $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-3.0.x' bundle update --quiet
384
+ $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-3.1.x' bundle update --quiet
385
+ $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-3.2.x' bundle update --quiet
386
+ $ BUNDLE_GEMFILE='gemfiles/Gemfile.activerecord-4.0.x' bundle update --quiet
385
387
 
386
388
  Then just:
387
389
 
@@ -503,3 +505,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
503
505
  [homepage]: https://github.com/pboling/flag_shih_tzu
504
506
  [bit_field]: http://en.wikipedia.org/wiki/Bit_field
505
507
  [bitwise_operation]: http://en.wikipedia.org/wiki/Bitwise_operation
508
+
509
+
510
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/pboling/flag_shih_tzu/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
511
+
data/lib/flag_shih_tzu.rb CHANGED
@@ -21,7 +21,7 @@ module FlagShihTzu
21
21
 
22
22
  module ClassMethods
23
23
  def has_flags(*args)
24
- flag_hash, opts = parse_options(*args)
24
+ flag_hash, opts = parse_flag_options(*args)
25
25
  opts = {
26
26
  :named_scopes => true,
27
27
  :column => DEFAULT_COLUMN_NAME,
@@ -30,7 +30,7 @@ module FlagShihTzu
30
30
  :check_for_column => true
31
31
  }.update(opts)
32
32
  colmn = opts[:column].to_s
33
- if !is_valid_column_name(opts[:column])
33
+ if !is_valid_flag_column_name(opts[:column])
34
34
  puts "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
@@ -100,6 +100,22 @@ module FlagShihTzu
100
100
  def self.unset_#{flag_name}_sql
101
101
  sql_set_for_flag(:#{flag_name}, '#{colmn}', false)
102
102
  end
103
+
104
+ def self.#{colmn.singularize}_values_for(*flag_names)
105
+ values = []
106
+ flag_names.each do |flag_name|
107
+ if respond_to?(flag_name)
108
+ values_for_flag = send(:sql_in_for_flag, flag_name, '#{colmn}')
109
+ values = if values.present?
110
+ values & values_for_flag
111
+ else
112
+ values_for_flag
113
+ end
114
+ end
115
+ end
116
+
117
+ values.sort
118
+ end
103
119
  EVAL
104
120
 
105
121
  if colmn != DEFAULT_COLUMN_NAME
@@ -231,7 +247,7 @@ module FlagShihTzu
231
247
  val
232
248
  end
233
249
 
234
- def parse_options(*args)
250
+ def parse_flag_options(*args)
235
251
  options = args.shift
236
252
  if args.size >= 1
237
253
  add_options = args.shift
@@ -312,7 +328,7 @@ module FlagShihTzu
312
328
  flag_name.is_a?(Symbol)
313
329
  end
314
330
 
315
- def is_valid_column_name(colmn)
331
+ def is_valid_flag_column_name(colmn)
316
332
  colmn.is_a?(String)
317
333
  end
318
334
 
@@ -1,3 +1,3 @@
1
1
  module FlagShihTzu
2
- VERSION = "0.3.10"
2
+ VERSION = "0.3.11"
3
3
  end
@@ -302,6 +302,11 @@ class FlagShihTzuClassMethodsTest < Test::Unit::TestCase
302
302
  assert_where_value "(spaceships.flags not in (4,5,6,7))", Spaceship.not_electrolytes
303
303
  end
304
304
 
305
+ def test_should_define_a_dynamic_column_value_helpers_for_flags
306
+ assert_equal Spaceship.flag_values_for(:warpdrive), [1, 3, 5, 7]
307
+ assert_equal Spaceship.flag_values_for(:warpdrive, :shields), [3, 7]
308
+ end
309
+
305
310
  def test_should_define_a_named_scope_for_flag_enabled_with_2_columns
306
311
  assert_where_value "(spaceships_with_2_custom_flags_column.bits in (1,3))", SpaceshipWith2CustomFlagsColumn.warpdrive
307
312
  assert_where_value "(spaceships_with_2_custom_flags_column.bits in (2,3))", SpaceshipWith2CustomFlagsColumn.hyperspace
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.10
4
+ version: 0.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Boling
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-11-26 00:00:00.000000000 Z
15
+ date: 2014-07-09 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activerecord
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
185
  version: '0'
186
186
  requirements: []
187
187
  rubyforge_project:
188
- rubygems_version: 2.1.11
188
+ rubygems_version: 2.2.2
189
189
  signing_key:
190
190
  specification_version: 4
191
191
  summary: Bit fields for ActiveRecord