acts_as_stubbable 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/LICENSE.txt +20 -0
  2. data/README.md +2 -0
  3. data/README.rdoc +19 -0
  4. data/lib/acts_as_stubbable.rb +39 -0
  5. metadata +144 -0
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Robbie Shepherd
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.md ADDED
@@ -0,0 +1,2 @@
1
+ acts_as_stubbable
2
+ =================
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = acts_as_stubbable
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to acts_as_stubbable
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2013 Robbie Shepherd. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,39 @@
1
+ module Stubbable
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ extend(ClassMethods)
6
+ before_save :make_stub
7
+ end
8
+
9
+ def make_stub
10
+ if !self.stub.blank?
11
+ self.stub = self.stub.parameterize
12
+ else
13
+ self.stub = self.send(self.column).parameterize
14
+ end
15
+ self.errors.add(:stub, "cannot be blank") if self.stub == ''
16
+ end
17
+
18
+ def column
19
+ # query the class this object belongs to to find the value
20
+ self.class.column
21
+ end
22
+
23
+
24
+ module ClassMethods
25
+
26
+ def acts_as_stubbable(options={})
27
+ @column = options[:column]
28
+ end
29
+
30
+ def column
31
+ @column
32
+ end
33
+
34
+ end
35
+
36
+
37
+
38
+
39
+ end
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: acts_as_stubbable
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Robbie Shepherd
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2013-01-24 00:00:00 +11:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ version_requirements: &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
+ name: shoulda
33
+ requirement: *id001
34
+ type: :development
35
+ - !ruby/object:Gem::Dependency
36
+ prerelease: false
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 31
43
+ segments:
44
+ - 3
45
+ - 12
46
+ version: "3.12"
47
+ name: rdoc
48
+ requirement: *id002
49
+ type: :development
50
+ - !ruby/object:Gem::Dependency
51
+ prerelease: false
52
+ version_requirements: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ name: bundler
62
+ requirement: *id003
63
+ type: :development
64
+ - !ruby/object:Gem::Dependency
65
+ prerelease: false
66
+ version_requirements: &id004 !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ hash: 63
72
+ segments:
73
+ - 1
74
+ - 8
75
+ - 4
76
+ version: 1.8.4
77
+ name: jeweler
78
+ requirement: *id004
79
+ type: :development
80
+ - !ruby/object:Gem::Dependency
81
+ prerelease: false
82
+ version_requirements: &id005 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ name: rcov
92
+ requirement: *id005
93
+ type: :development
94
+ description: create a url-friendly stub based on an activerecord column for your models
95
+ email: robbie.shepherd@gmail.com
96
+ executables: []
97
+
98
+ extensions: []
99
+
100
+ extra_rdoc_files:
101
+ - LICENSE.txt
102
+ - README.md
103
+ - README.rdoc
104
+ files:
105
+ - lib/acts_as_stubbable.rb
106
+ - LICENSE.txt
107
+ - README.md
108
+ - README.rdoc
109
+ has_rdoc: true
110
+ homepage: http://github.com/robbieshepherd/acts_as_stubbable
111
+ licenses:
112
+ - MIT
113
+ post_install_message:
114
+ rdoc_options: []
115
+
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ hash: 3
124
+ segments:
125
+ - 0
126
+ version: "0"
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ none: false
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ hash: 3
133
+ segments:
134
+ - 0
135
+ version: "0"
136
+ requirements: []
137
+
138
+ rubyforge_project:
139
+ rubygems_version: 1.3.7
140
+ signing_key:
141
+ specification_version: 3
142
+ summary: create a url-friendly stub
143
+ test_files: []
144
+