arrayish 0.0.2 → 0.0.3
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.
- checksums.yaml +7 -0
- data/lib/arrayish/string.rb +1 -0
- data/lib/arrayish/version.rb +1 -1
- data/spec/lib/arrayish/string_spec.rb +30 -0
- data/spec/shared_examples/arrayish_string.rb +34 -0
- metadata +5 -16
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 10e2b37303aa57050a6a156b77d1867e5505e7c0
|
4
|
+
data.tar.gz: 245f5834dbebf8602b1dfb2be3f40b0445c55ea7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: da2631db95351772ebf5474459c2f6a32fb0192c4530b0ee4c3631ff33a6fa689e53288780d5e41a0ac021719565c630a31ab96c31187df7428a7ed63994a9c2
|
7
|
+
data.tar.gz: 5b858ba4430b679d3ee8e9e0ecfce30e8a373d0d6e920ab39b2e4b5d96a1b9c7ca251831e58409441057bb612e8898a54f915cd8be360b858ec5440b0a1d12ac
|
data/lib/arrayish/string.rb
CHANGED
data/lib/arrayish/version.rb
CHANGED
@@ -23,6 +23,36 @@ module Arrayish
|
|
23
23
|
it_behaves_like 'an arrayish string'
|
24
24
|
end
|
25
25
|
|
26
|
+
context 'initialised with an empty string' do
|
27
|
+
let(:a_string) { '' }
|
28
|
+
subject{ described_class.new(a_string) }
|
29
|
+
|
30
|
+
specify 'it equals the string' do
|
31
|
+
expect( subject ).to eql(a_string)
|
32
|
+
end
|
33
|
+
|
34
|
+
specify '#to_a returns an empty array' do
|
35
|
+
expect( subject.to_a ).to eql( [] )
|
36
|
+
end
|
37
|
+
|
38
|
+
it_behaves_like 'a nil arrayish string'
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'initialised with nil' do
|
42
|
+
let(:a_string) { nil }
|
43
|
+
subject{ described_class.new(a_string) }
|
44
|
+
|
45
|
+
specify 'it equals an empty string' do
|
46
|
+
expect( subject ).to eql('')
|
47
|
+
end
|
48
|
+
|
49
|
+
specify '#to_a returns an empty array' do
|
50
|
+
expect( subject.to_a ).to eql( [] )
|
51
|
+
end
|
52
|
+
|
53
|
+
it_behaves_like 'a nil arrayish string'
|
54
|
+
end
|
55
|
+
|
26
56
|
context 'initialised with an array of two strings' do
|
27
57
|
subject{ described_class.new([a_string, x_string]) }
|
28
58
|
|
@@ -5,6 +5,16 @@ shared_examples 'an arrayish string' do
|
|
5
5
|
expect( subject + added_string ).to eql( "#{subject},#{added_string}" )
|
6
6
|
end
|
7
7
|
|
8
|
+
it '+ with an empty string makes no change' do
|
9
|
+
added_string = ''
|
10
|
+
expect( subject + added_string ).to eql( "#{subject}" )
|
11
|
+
end
|
12
|
+
|
13
|
+
it '+ with nil makes no change' do
|
14
|
+
added_string = nil
|
15
|
+
expect( subject + added_string ).to eql( "#{subject}" )
|
16
|
+
end
|
17
|
+
|
8
18
|
it '+ with an array adds the array elements with separators' do
|
9
19
|
added_array = [ '1234', '789' ]
|
10
20
|
expect( subject + added_array ).to eql( "#{subject},#{added_array[0]},#{added_array[1]}" )
|
@@ -19,3 +29,27 @@ shared_examples 'an arrayish string' do
|
|
19
29
|
end
|
20
30
|
|
21
31
|
end
|
32
|
+
|
33
|
+
shared_examples 'a nil arrayish string' do
|
34
|
+
|
35
|
+
it '+ with a string gives the added string' do
|
36
|
+
added_string = '1234'
|
37
|
+
expect( subject + added_string ).to eql( "#{added_string}" )
|
38
|
+
end
|
39
|
+
|
40
|
+
it '+ with an empty string makes no change' do
|
41
|
+
added_string = ''
|
42
|
+
expect( subject + added_string ).to eql( "#{subject}" )
|
43
|
+
end
|
44
|
+
|
45
|
+
it '+ with nil makes no change' do
|
46
|
+
added_string = nil
|
47
|
+
expect( subject + added_string ).to eql( "#{subject}" )
|
48
|
+
end
|
49
|
+
|
50
|
+
it '+ with an array gives the array elements with separators' do
|
51
|
+
added_array = [ '1234', '789' ]
|
52
|
+
expect( subject + added_array ).to eql( "#{added_array[0]},#{added_array[1]}" )
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arrayish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- baob
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-11-12 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rspec
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: pry
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ! '>='
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ! '>='
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -99,31 +90,29 @@ files:
|
|
99
90
|
homepage: ''
|
100
91
|
licenses:
|
101
92
|
- MIT
|
93
|
+
metadata: {}
|
102
94
|
post_install_message:
|
103
95
|
rdoc_options: []
|
104
96
|
require_paths:
|
105
97
|
- lib
|
106
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
-
none: false
|
108
99
|
requirements:
|
109
100
|
- - ! '>='
|
110
101
|
- !ruby/object:Gem::Version
|
111
102
|
version: '0'
|
112
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
104
|
requirements:
|
115
105
|
- - ! '>='
|
116
106
|
- !ruby/object:Gem::Version
|
117
107
|
version: '0'
|
118
108
|
requirements: []
|
119
109
|
rubyforge_project:
|
120
|
-
rubygems_version: 1.
|
110
|
+
rubygems_version: 2.1.11
|
121
111
|
signing_key:
|
122
|
-
specification_version:
|
112
|
+
specification_version: 4
|
123
113
|
summary: Arrayish::String simplifies and DRYs code where an array appears in a string
|
124
114
|
with delimiters.
|
125
115
|
test_files:
|
126
116
|
- spec/lib/arrayish/string_spec.rb
|
127
117
|
- spec/shared_examples/arrayish_string.rb
|
128
118
|
- spec/spec_helper.rb
|
129
|
-
has_rdoc:
|