booleanize 0.3 → 0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/Rakefile +2 -3
- data/lib/booleanize.rb +13 -13
- data/spec/booleanize_spec.rb +1 -1
- metadata +18 -5
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
0.4.0 (03 Sep 2010)
|
2
|
+
* Updated to use Rspec2 (now to run the tests just do `rspec ./spec`)
|
3
|
+
* Changed the scope creation to use "scope" instead of "named_scope" so we no
|
4
|
+
longer warning messages in Rails 3.
|
5
|
+
* Please note that this release WILL NOT work with Rails 2.3.x, it's a Rails 3
|
6
|
+
specific release.
|
7
|
+
|
8
|
+
|
1
9
|
0.3.0 (06 May 2009)
|
2
10
|
* Ruby 1.9 Support
|
3
11
|
* Booleanize::Config class as Singleton
|
data/Rakefile
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
require 'rake'
|
2
|
-
require '
|
2
|
+
require 'rspec/core/rake_task'
|
3
3
|
require 'rake/rdoctask'
|
4
4
|
|
5
5
|
desc 'Default: run unit tests.'
|
6
6
|
task :default => :spec
|
7
7
|
|
8
|
-
|
9
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
8
|
+
RSpec::Core::RakeTask.new do |t|
|
10
9
|
t.spec_opts = ["--color", "--format", "specdoc"]
|
11
10
|
end
|
12
11
|
|
data/lib/booleanize.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
#
|
6
6
|
# = Description
|
7
7
|
#
|
8
|
-
# Creates two instance methods and two
|
8
|
+
# Creates two instance methods and two scopes for each of the received boolean attributes.
|
9
9
|
#
|
10
10
|
# == Instance methods
|
11
11
|
#
|
@@ -14,9 +14,9 @@
|
|
14
14
|
#
|
15
15
|
# == Named scopes
|
16
16
|
#
|
17
|
-
# Creates two
|
18
|
-
#
|
19
|
-
#
|
17
|
+
# Creates two scopes for esch boolean attribute:
|
18
|
+
# scope :attr_name, :conditions => {:attr_name => true}
|
19
|
+
# scope :not_attr_name, :conditions => {:attr_name => false}
|
20
20
|
#
|
21
21
|
# == How to use it
|
22
22
|
#
|
@@ -44,10 +44,10 @@
|
|
44
44
|
# u.active_humanize #=> "True"
|
45
45
|
# u.active? #=> true
|
46
46
|
#
|
47
|
-
# You'll also get two new
|
47
|
+
# You'll also get two new scope methods for your model
|
48
48
|
#
|
49
|
-
# active_users = User.active #=> same as
|
50
|
-
# disabled_users = User.not_active #=> same as
|
49
|
+
# active_users = User.active #=> same as scope :active, :conditions => {:active => true}
|
50
|
+
# disabled_users = User.not_active #=> same as scope :not_active, :conditions => {:active => false}
|
51
51
|
#
|
52
52
|
require 'singleton'
|
53
53
|
|
@@ -83,12 +83,12 @@ module Booleanize
|
|
83
83
|
|
84
84
|
private
|
85
85
|
|
86
|
-
def
|
87
|
-
|
86
|
+
def create_true_scope(attr_name)
|
87
|
+
scope attr_name, :conditions => { attr_name => true }
|
88
88
|
end
|
89
89
|
|
90
|
-
def
|
91
|
-
|
90
|
+
def create_false_scope(attr_name)
|
91
|
+
scope :"not_#{attr_name}", :conditions => { attr_name => false }
|
92
92
|
end
|
93
93
|
|
94
94
|
def create_humanize_method(attr_name, true_str, false_str)
|
@@ -99,8 +99,8 @@ module Booleanize
|
|
99
99
|
end
|
100
100
|
|
101
101
|
def create_methods(attr_name, true_str = nil, false_str = nil)
|
102
|
-
|
103
|
-
|
102
|
+
create_true_scope(attr_name)
|
103
|
+
create_false_scope(attr_name)
|
104
104
|
create_humanize_method(attr_name, true_str, false_str)
|
105
105
|
end
|
106
106
|
|
data/spec/booleanize_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: booleanize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 3
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 4
|
9
|
+
version: "0.4"
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- "C\xC3\xA1ssio Marques"
|
@@ -9,7 +14,7 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-09-03 00:00:00 -03:00
|
13
18
|
default_executable:
|
14
19
|
dependencies: []
|
15
20
|
|
@@ -28,6 +33,8 @@ files:
|
|
28
33
|
- Rakefile
|
29
34
|
- init.rb
|
30
35
|
- lib/booleanize.rb
|
36
|
+
- spec/booleanize_spec.rb
|
37
|
+
- spec/db/create_testing_structure.rb
|
31
38
|
has_rdoc: true
|
32
39
|
homepage: http://github.com/cassiomarques/booleanize
|
33
40
|
licenses: []
|
@@ -39,21 +46,27 @@ rdoc_options:
|
|
39
46
|
require_paths:
|
40
47
|
- lib
|
41
48
|
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
42
50
|
requirements:
|
43
51
|
- - ">="
|
44
52
|
- !ruby/object:Gem::Version
|
53
|
+
hash: 3
|
54
|
+
segments:
|
55
|
+
- 0
|
45
56
|
version: "0"
|
46
|
-
version:
|
47
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
48
59
|
requirements:
|
49
60
|
- - ">="
|
50
61
|
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
63
|
+
segments:
|
64
|
+
- 0
|
51
65
|
version: "0"
|
52
|
-
version:
|
53
66
|
requirements: []
|
54
67
|
|
55
68
|
rubyforge_project:
|
56
|
-
rubygems_version: 1.3.
|
69
|
+
rubygems_version: 1.3.7
|
57
70
|
signing_key:
|
58
71
|
specification_version: 3
|
59
72
|
summary: A Rails plugin that adds some new methods for boolean attributes in Active Record models.
|