sc-core-ext 1.1.1 → 1.2.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.
@@ -1,39 +1,53 @@
1
- require 'spec_helper'
2
-
3
- describe Hash do
4
- it "#without" do
5
- { :a => 1, :b => 2, :c => 3 }.without(:a, :b).should == {:c => 3}
6
- end
7
-
8
- it "#without_values" do
9
- { :a => 1, :b => 1, :c => 2, :d => 2}.without_values(1).should == {:c => 2, :d => 2}
10
- end
11
-
12
- it "#optionalize" do
13
- { :a => nil, :b => nil, :c => 1, :d => 2 }.optionalize.should == { :c => 1, :d => 2}
14
- end
15
-
16
- it "#camelize_keys" do
17
- { :hello_world => 1, :goodbye_john => 2}.camelize_keys.should == { 'HelloWorld' => 1, 'GoodbyeJohn' => 2 }
18
- end
19
-
20
- it "#rename" do
21
- { :a => 1, :b => 2 }.rename(:a => :b, :b => :c).should == { :b => 1, :c => 2 }
22
- end
23
-
24
- context "#deep_dup" do
25
- subject { { 'baz' => '42' } }
26
-
27
- it "is not itself" do
28
- subject.deep_dup.should_not equal(subject)
29
- end
30
-
31
- it "keys are not themselves" do
32
- subject.deep_dup.keys[0].should_not equal(subject.keys[0])
33
- end
34
-
35
- it "values are not themselves" do
36
- subject.deep_dup.values[0].should_not equal(subject.values[0])
37
- end
38
- end
39
- end
1
+ require 'spec_helper'
2
+
3
+ describe Hash do
4
+ it "#without" do
5
+ { :a => 1, :b => 2, :c => 3 }.without(:a, :b).should == {:c => 3}
6
+ end
7
+
8
+ it "#stringify_values" do
9
+ { :a => 1, :b => 2 }.stringify_values.should == { :a => '1', :b => '2' }
10
+ end
11
+
12
+ context "#keys?" do
13
+ it "should be true" do
14
+ { :a => 1, :b => 2, :c => 3 }.keys?(:b, :c).should == true
15
+ end
16
+
17
+ it "should be false" do
18
+ { :a => 1, :b => 2, :c => 3 }.keys?(:a, :d).should == false
19
+ end
20
+ end
21
+
22
+ it "#without_values" do
23
+ { :a => 1, :b => 1, :c => 2, :d => 2}.without_values(1).should == {:c => 2, :d => 2}
24
+ end
25
+
26
+ it "#optionalize" do
27
+ { :a => nil, :b => nil, :c => 1, :d => 2 }.optionalize.should == { :c => 1, :d => 2}
28
+ end
29
+
30
+ it "#camelize_keys" do
31
+ { :hello_world => 1, :goodbye_john => 2}.camelize_keys.should == { 'HelloWorld' => 1, 'GoodbyeJohn' => 2 }
32
+ end
33
+
34
+ it "#rename" do
35
+ { :a => 1, :b => 2 }.rename(:a => :b, :b => :c).should == { :b => 1, :c => 2 }
36
+ end
37
+
38
+ context "#deep_dup" do
39
+ subject { { 'baz' => '42' } }
40
+
41
+ it "is not itself" do
42
+ subject.deep_dup.should_not equal(subject)
43
+ end
44
+
45
+ it "keys are not themselves" do
46
+ subject.deep_dup.keys[0].should_not equal(subject.keys[0])
47
+ end
48
+
49
+ it "values are not themselves" do
50
+ subject.deep_dup.values[0].should_not equal(subject.values[0])
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Numeric do
4
+ context "#max" do
5
+ it "returns the argument if the argument is greater" do
6
+ 1.max(2).should == 2
7
+ end
8
+
9
+ it "returns itself if the argument is less" do
10
+ 1.max(2).should == 2
11
+ end
12
+ end
13
+
14
+ context "#min" do
15
+ it "returns itself if the argument is greater" do
16
+ 1.min(2).should == 1
17
+ end
18
+
19
+ it "returns the argument if the argument is less" do
20
+ 1.min(2).should == 1
21
+ end
22
+ end
23
+ end
24
+
@@ -1,28 +1,28 @@
1
- require 'spec_helper'
2
-
3
- describe Object do
4
- context "#attr_boolean" do
5
- subject do
6
- obj = Object.new
7
- klass = (class << obj; self; end)
8
- klass.send(:attr_boolean, :new_record)
9
- obj
10
- end
11
-
12
- it("responds_to? accessor?") { subject.should respond_to(:new_record?) }
13
- it("responds_to? accessor=") { subject.should respond_to(:new_record=) }
14
- end
15
-
16
- context "#dup?" do
17
- context "with an undupable object" do
18
- subject { nil }
19
- it("returns itself") { subject.dup?.should be_equal(nil) }
20
- end
21
-
22
- context "with a dupable object" do
23
- subject { "hello" }
24
- it("does not return itself") { subject.dup?.should_not be_equal(subject) }
25
- it("== itself") { subject.dup?.should == subject }
26
- end
27
- end
28
- end
1
+ require 'spec_helper'
2
+
3
+ describe Object do
4
+ context "#attr_boolean" do
5
+ subject do
6
+ obj = Object.new
7
+ klass = (class << obj; self; end)
8
+ klass.send(:attr_boolean, :new_record)
9
+ obj
10
+ end
11
+
12
+ it("responds_to? accessor?") { subject.should respond_to(:new_record?) }
13
+ it("responds_to? accessor=") { subject.should respond_to(:new_record=) }
14
+ end
15
+
16
+ context "#dup?" do
17
+ context "with an undupable object" do
18
+ subject { nil }
19
+ it("returns itself") { subject.dup?.should be_equal(nil) }
20
+ end
21
+
22
+ context "with a dupable object" do
23
+ subject { "hello" }
24
+ it("does not return itself") { subject.dup?.should_not be_equal(subject) }
25
+ it("== itself") { subject.dup?.should == subject }
26
+ end
27
+ end
28
+ end
@@ -1,17 +1,17 @@
1
- require 'spec_helper'
2
-
3
- describe Regexp do
4
- before(:each) { @demo_text = "123abc\n asdf0987 \na1234"}
5
-
6
- it "should yield all matches in a multiline regexp" do
7
- @rx = /([0-9]+)/m
8
- yielded = 0
9
- @rx.each_match(@demo_text) { |y| yielded += 1 }
10
- yielded.should == 3
11
- end
12
-
13
- it "should return all matches in a multiline regexp" do
14
- @rx = /([0-9]+)/m
15
- @rx.each_match(@demo_text).collect { |m| m[0] }.should == %w(123 0987 1234)
16
- end
17
- end
1
+ require 'spec_helper'
2
+
3
+ describe Regexp do
4
+ before(:each) { @demo_text = "123abc\n asdf0987 \na1234"}
5
+
6
+ it "should yield all matches in a multiline regexp" do
7
+ @rx = /([0-9]+)/m
8
+ yielded = 0
9
+ @rx.each_match(@demo_text) { |y| yielded += 1 }
10
+ yielded.should == 3
11
+ end
12
+
13
+ it "should return all matches in a multiline regexp" do
14
+ @rx = /([0-9]+)/m
15
+ @rx.each_match(@demo_text).collect { |m| m[0] }.should == %w(123 0987 1234)
16
+ end
17
+ end
@@ -1,56 +1,56 @@
1
- require 'spec_helper'
2
-
3
- describe String do
4
- it "#dehumanize" do
5
- "say_hello_to_the_world".camelize.dehumanize.should == "sayHelloToTheWorld"
6
- "Say hello to the world".dehumanize.should == "say_hello_to_the_world"
7
- end
8
-
9
- context "#hex_to_bin" do
10
- subject { "61 62 63" }
11
-
12
- it "converts hex to binary" do
13
- subject.hex_to_bin.should == "abc"
14
- end
15
- end
16
-
17
- context "#indent" do
18
- subject { "hello\nworld".indent }
19
-
20
- it "indents the first character" do
21
- subject[0].should == ?\t
22
- end
23
-
24
- it "indents after newline characters" do
25
- subject[subject.index(?\n) + 1].should == ?\t
26
- end
27
- end
28
-
29
- context "#parenthesize" do
30
- it "parenthesizes with one character" do
31
- 'text'.parenthesize(':').should == ":text:"
32
- end
33
-
34
- it "parenthesizes with two characters" do
35
- 'text'.parenthesize('[]').should == "[text]"
36
- end
37
-
38
- it "parenthesizes with defaults" do
39
- "text".parenthesize.should == "(text)"
40
- end
41
- end
42
-
43
- context "#depunctuate" do
44
- it "does not include question marks" do
45
- "kind_of?".depunctuate.should == "is_kind_of"
46
- end
47
-
48
- it "does not include exclamation points" do
49
- "save!".depunctuate.should == "force_save"
50
- end
51
-
52
- it "returns itself if no punctuation is found" do
53
- "save".depunctuate.should == "save"
54
- end
55
- end
56
- end
1
+ require 'spec_helper'
2
+
3
+ describe String do
4
+ it "#dehumanize" do
5
+ "say_hello_to_the_world".camelize.dehumanize.should == "sayHelloToTheWorld"
6
+ "Say hello to the world".dehumanize.should == "say_hello_to_the_world"
7
+ end
8
+
9
+ context "#hex_to_bin" do
10
+ subject { "61 62 63" }
11
+
12
+ it "converts hex to binary" do
13
+ subject.hex_to_bin.should == "abc"
14
+ end
15
+ end
16
+
17
+ context "#indent" do
18
+ subject { "hello\nworld".indent }
19
+
20
+ it "indents the first character" do
21
+ subject[0].should == ?\t
22
+ end
23
+
24
+ it "indents after newline characters" do
25
+ subject[subject.index(?\n) + 1].should == ?\t
26
+ end
27
+ end
28
+
29
+ context "#parenthesize" do
30
+ it "parenthesizes with one character" do
31
+ 'text'.parenthesize(':').should == ":text:"
32
+ end
33
+
34
+ it "parenthesizes with two characters" do
35
+ 'text'.parenthesize('[]').should == "[text]"
36
+ end
37
+
38
+ it "parenthesizes with defaults" do
39
+ "text".parenthesize.should == "(text)"
40
+ end
41
+ end
42
+
43
+ context "#depunctuate" do
44
+ it "does not include question marks" do
45
+ "kind_of?".depunctuate.should == "is_kind_of"
46
+ end
47
+
48
+ it "does not include exclamation points" do
49
+ "save!".depunctuate.should == "force_save"
50
+ end
51
+
52
+ it "returns itself if no punctuation is found" do
53
+ "save".depunctuate.should == "save"
54
+ end
55
+ end
56
+ end
@@ -1,4 +1,4 @@
1
- --colour
2
- --format progress
3
- --loadby mtime
4
- --reverse
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 1
8
- - 1
9
- version: 1.1.1
7
+ - 2
8
+ - 0
9
+ version: 1.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Colin MacKenzie IV
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-30 00:00:00 -04:00
17
+ date: 2010-04-30 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -68,9 +68,9 @@ dependencies:
68
68
  - !ruby/object:Gem::Version
69
69
  segments:
70
70
  - 2
71
- - 4
71
+ - 5
72
72
  - 0
73
- version: 2.4.0
73
+ version: 2.5.0
74
74
  type: :development
75
75
  version_requirements: *id004
76
76
  description: A collection of core extensions that I have come to rely on in more than one package
@@ -97,6 +97,7 @@ files:
97
97
  - lib/sc-core-ext/dependencies.rb
98
98
  - lib/sc-core-ext/float.rb
99
99
  - lib/sc-core-ext/hash.rb
100
+ - lib/sc-core-ext/numeric.rb
100
101
  - lib/sc-core-ext/object.rb
101
102
  - lib/sc-core-ext/regexp.rb
102
103
  - lib/sc-core-ext/string.rb
@@ -109,13 +110,14 @@ files:
109
110
  - spec/sc-core-ext/date_time_spec.rb
110
111
  - spec/sc-core-ext/float_spec.rb
111
112
  - spec/sc-core-ext/hash_spec.rb
113
+ - spec/sc-core-ext/numeric_spec.rb
112
114
  - spec/sc-core-ext/object_spec.rb
113
115
  - spec/sc-core-ext/regexp_spec.rb
114
116
  - spec/sc-core-ext/string_spec.rb
115
117
  - spec/spec.opts
116
118
  - spec/spec_helper.rb
117
119
  has_rdoc: true
118
- homepage: http://github.com/sinisterchipmunk/core-ext
120
+ homepage: http://github.com/sinisterchipmunk/core-ext
119
121
  licenses: []
120
122
 
121
123
  post_install_message: