can_has_flagz 0.1.0
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.
- data/.gitignore +5 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.rdoc +30 -0
- data/Rakefile +12 -0
- data/can_has_flagz.gemspec +24 -0
- data/lib/can_has_flagz.rb +8 -0
- data/lib/can_has_flagz/hook.rb +5 -0
- data/lib/can_has_flagz/instance_methods.rb +5 -0
- data/lib/can_has_flagz/version.rb +3 -0
- data/spec/.rspec +2 -0
- data/spec/can_has_flagz_spec.rb +24 -0
- data/spec/spec_helper.rb +13 -0
- metadata +92 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Naomi Kyoto
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
= can_has_flagz
|
2
|
+
|
3
|
+
Provides handy flags hash for your models
|
4
|
+
|
5
|
+
== Example Usage
|
6
|
+
|
7
|
+
User Model
|
8
|
+
|
9
|
+
class User < ActiveRecord::Base
|
10
|
+
can_has_flagz
|
11
|
+
|
12
|
+
after_save :send_confirmation_email
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def send_confirmation_email
|
17
|
+
UserMailer.deliver_confirmation_mail(self) unless flag[:skip_confirmation_email]
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
Some Controller Method
|
23
|
+
|
24
|
+
@user = User.new(params[:user])
|
25
|
+
@user.flag[:skip_confirmation_email] = true
|
26
|
+
@user.save
|
27
|
+
|
28
|
+
== Copyright
|
29
|
+
|
30
|
+
Copyright (c) 2011 Naomi Kyoto. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
# ------------------------------------------------------------
|
5
|
+
# rspec
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
|
8
|
+
RSpec::Core::RakeTask.new('spec') do |t|
|
9
|
+
t.rspec_opts = ['--options', "spec/.rspec"]
|
10
|
+
end
|
11
|
+
|
12
|
+
task :default => :spec
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "can_has_flagz/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
|
7
|
+
s.add_development_dependency "rspec"
|
8
|
+
|
9
|
+
s.name = "can_has_flagz"
|
10
|
+
s.version = CanHasFlagz::VERSION
|
11
|
+
s.platform = Gem::Platform::RUBY
|
12
|
+
s.authors = ["Naomi Kyoto"]
|
13
|
+
s.email = ["nakyoto@gmail.com"]
|
14
|
+
s.homepage = "http://github.com/naomik/can_has_flagz"
|
15
|
+
s.summary = %q{Let's you set flags on your models}
|
16
|
+
s.description = %q{Provides a convenient hash for setting flags on your ActiveRecord models}
|
17
|
+
|
18
|
+
s.rubyforge_project = "can_has_flagz"
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
s.require_paths = ["lib"]
|
24
|
+
end
|
data/spec/.rspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe :some_model do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@model = SomeModel.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should load the hook in ActiveRecord::Base" do
|
10
|
+
ActiveRecord::Base.should respond_to(:can_has_flagz)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be able to set flag" do
|
14
|
+
@model.flag[:foo] = "bar"
|
15
|
+
@model.flag[:foo].should == "bar"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should get default value for unset flag" do
|
19
|
+
@model.flag[:some_unset_flag].should == false
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: can_has_flagz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Naomi Kyoto
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-20 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
description: Provides a convenient hash for setting flags on your ActiveRecord models
|
35
|
+
email:
|
36
|
+
- nakyoto@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- Gemfile
|
46
|
+
- LICENSE
|
47
|
+
- README.rdoc
|
48
|
+
- Rakefile
|
49
|
+
- can_has_flagz.gemspec
|
50
|
+
- lib/can_has_flagz.rb
|
51
|
+
- lib/can_has_flagz/hook.rb
|
52
|
+
- lib/can_has_flagz/instance_methods.rb
|
53
|
+
- lib/can_has_flagz/version.rb
|
54
|
+
- spec/.rspec
|
55
|
+
- spec/can_has_flagz_spec.rb
|
56
|
+
- spec/spec_helper.rb
|
57
|
+
homepage: http://github.com/naomik/can_has_flagz
|
58
|
+
licenses: []
|
59
|
+
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
hash: 3
|
80
|
+
segments:
|
81
|
+
- 0
|
82
|
+
version: "0"
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project: can_has_flagz
|
86
|
+
rubygems_version: 1.7.2
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Let's you set flags on your models
|
90
|
+
test_files:
|
91
|
+
- spec/can_has_flagz_spec.rb
|
92
|
+
- spec/spec_helper.rb
|