subtle 1.1.0 → 1.1.1
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/.travis.yml +1 -0
- data/Gemfile +1 -0
- data/README.md +2 -2
- data/lib/subtle/param_constructor.rb +1 -0
- data/lib/subtle/version.rb +1 -1
- data/spec/spec_helper.rb +3 -0
- data/spec/subtle/params_constructor_spec.rb +69 -0
- metadata +6 -4
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Subtle [](http://travis-ci.org/darrencauthon/subtle)
|
2
|
-
[](https://codeclimate.com/github/darrencauthon/subtle)
|
3
|
+
[](https://coveralls.io/r/darrencauthon/subtle)
|
4
4
|
|
5
5
|
This library contains methods that seem to cut down a litle bit of the code that I write daily.
|
6
6
|
|
data/lib/subtle/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
class ParamConstructorTest
|
4
|
+
params_constructor
|
5
|
+
attr_accessor :first_name, :last_name
|
6
|
+
end
|
7
|
+
|
8
|
+
class SecondParamConstructorTest
|
9
|
+
params_constructor
|
10
|
+
attr_accessor :first_name, :last_name
|
11
|
+
end
|
12
|
+
|
13
|
+
class ThirdParamConstructorTest
|
14
|
+
params_constructor { self.first_name = "expected value" }
|
15
|
+
attr_accessor :first_name, :last_name
|
16
|
+
end
|
17
|
+
|
18
|
+
class FourthParamConstructorTest
|
19
|
+
params_constructor do
|
20
|
+
self.middle_name = 'm'
|
21
|
+
self.first_name = 'f'
|
22
|
+
self.last_name = 'l'
|
23
|
+
end
|
24
|
+
attr_accessor :first_name, :last_name, :middle_name
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "params_constructor" do
|
28
|
+
describe 'just the constructor itself' do
|
29
|
+
it "should let the object be instantiated with a hash" do
|
30
|
+
test = ParamConstructorTest.new(:first_name => "John", :last_name => "Galt")
|
31
|
+
test.first_name.must_equal "John"
|
32
|
+
test.last_name.must_equal "Galt"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should allow the object to be instantiated with no params" do
|
36
|
+
test = ParamConstructorTest.new
|
37
|
+
# should not throw an error
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'pass a block to the constructor' do
|
42
|
+
it "should let the object be instantiated with a hash" do
|
43
|
+
test = SecondParamConstructorTest.new(:first_name => "Dagny", :last_name => "Roark") do |o|
|
44
|
+
o.first_name = 'Howard'
|
45
|
+
end
|
46
|
+
test.first_name.must_equal 'Howard'
|
47
|
+
test.last_name.must_equal 'Roark'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe 'pass a block with the constructor' do
|
52
|
+
it "should let the object be instantiated with a hash" do
|
53
|
+
test = ThirdParamConstructorTest.new(:first_name => "Dagny", :last_name => "Roark")
|
54
|
+
test.first_name.must_equal 'expected value'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe 'pass a block with the constructor AND to the constructor' do
|
59
|
+
it "should run both and let the last one win" do
|
60
|
+
test = FourthParamConstructorTest.new(:first_name => "", :last_name => "") do |o|
|
61
|
+
o.last_name = "second"
|
62
|
+
o.first_name = "first"
|
63
|
+
end
|
64
|
+
test.first_name.must_equal 'first'
|
65
|
+
test.last_name.must_equal 'second'
|
66
|
+
test.middle_name.must_equal 'm'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: subtle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: blankslate
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- spec/subtle/lambda_to_object_spec.rb
|
92
92
|
- spec/subtle/lazy_cover_spec.rb
|
93
93
|
- spec/subtle/param_constructor_spec.rb
|
94
|
+
- spec/subtle/params_constructor_spec.rb
|
94
95
|
- spec/subtle/safety_proc_spec.rb
|
95
96
|
- subtle.gemspec
|
96
97
|
homepage: http://www.github.com/darrencauthon/subtle
|
@@ -107,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
108
|
version: '0'
|
108
109
|
segments:
|
109
110
|
- 0
|
110
|
-
hash:
|
111
|
+
hash: 4485186973684471807
|
111
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
113
|
none: false
|
113
114
|
requirements:
|
@@ -116,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
117
|
version: '0'
|
117
118
|
segments:
|
118
119
|
- 0
|
119
|
-
hash:
|
120
|
+
hash: 4485186973684471807
|
120
121
|
requirements: []
|
121
122
|
rubyforge_project:
|
122
123
|
rubygems_version: 1.8.24
|
@@ -132,4 +133,5 @@ test_files:
|
|
132
133
|
- spec/subtle/lambda_to_object_spec.rb
|
133
134
|
- spec/subtle/lazy_cover_spec.rb
|
134
135
|
- spec/subtle/param_constructor_spec.rb
|
136
|
+
- spec/subtle/params_constructor_spec.rb
|
135
137
|
- spec/subtle/safety_proc_spec.rb
|