subtle 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -2,6 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.2
4
4
  - 1.9.3
5
+ - 2.0.0
5
6
  - jruby-19mode
6
7
  - rbx-19mode
7
8
  - jruby-head
data/Gemfile CHANGED
@@ -10,4 +10,5 @@ group :development do
10
10
  gem 'guard'
11
11
  gem 'guard-minitest', :git => 'git://github.com/aspiers/guard-minitest.git'
12
12
  gem 'ruby_gntp'
13
+ gem 'coveralls'
13
14
  end
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Subtle [![Build Status](https://secure.travis-ci.org/darrencauthon/subtle.png?branch=master)](http://travis-ci.org/darrencauthon/subtle)
2
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/darrencauthon/subtle)
3
-
2
+ [![Code Climate](https://codeclimate.com/github/darrencauthon/subtle.png)](https://codeclimate.com/github/darrencauthon/subtle)
3
+ [![Coverage Status](https://coveralls.io/repos/darrencauthon/subtle/badge.png?branch=master)](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
 
@@ -15,4 +15,5 @@ class Object
15
15
  self.send(:define_method, :constructor_method, &block_for_each)
16
16
  end
17
17
  end
18
+ alias :params_constructor :param_constructor
18
19
  end
@@ -1,3 +1,3 @@
1
1
  module Subtle
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
1
4
  require 'mocha'
2
5
  require 'minitest/spec'
3
6
  require 'minitest/autorun'
@@ -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.0
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-02-14 00:00:00.000000000 Z
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: 787413255858231210
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: 787413255858231210
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