wrapup 0.0.1 → 0.0.2
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.travis.yml +12 -0
- data/README.md +1 -0
- data/Rakefile +10 -0
- data/lib/wrapup.rb +1 -1
- data/lib/wrapup/version.rb +1 -1
- data/lib/wrapup/wrap.rb +10 -2
- data/spec/wrapup/wrap_spec.rb +26 -25
- data/wrapup.gemspec +1 -0
- metadata +51 -14
- metadata.gz.sig +3 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: aa247bce470572bdd3dba9eff16e6bd36221219d
|
4
|
+
data.tar.gz: 5a760385d9b034583ae4c4bf1db42fc9a20587ab
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9d69c368d1f683991a7ec565743c64a3a9f050dacce8dae68920a6b8d0f8486010a3bad3e48335328d4a386b8dd2872014ad0be9e4d2c37b6e4235475ec7c5a1
|
7
|
+
data.tar.gz: 6cd926062ea71c44015a0be9d0eec05c76dc3d16cff25181d2a65cd53cc12a99a762d8ff90da3dbdfbd4349811ebffed0238b10dcaa8633e8f5852e5bb8612d9
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
data/.travis.yml
ADDED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/lib/wrapup.rb
CHANGED
data/lib/wrapup/version.rb
CHANGED
data/lib/wrapup/wrap.rb
CHANGED
@@ -2,15 +2,23 @@ module WrapUp
|
|
2
2
|
class Wrap
|
3
3
|
include Enumerable
|
4
4
|
|
5
|
-
def initialize
|
5
|
+
def initialize collection, wrapper_constant
|
6
6
|
@collection = collection
|
7
7
|
@wrapper = wrapper_constant
|
8
8
|
end
|
9
9
|
|
10
|
-
def each
|
10
|
+
def each &block
|
11
11
|
@collection.each do |item|
|
12
12
|
block.call @wrapper.new item
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
def size
|
17
|
+
@collection.size
|
18
|
+
end
|
19
|
+
|
20
|
+
def [] key
|
21
|
+
@wrapper.new @collection[key]
|
22
|
+
end
|
15
23
|
end
|
16
24
|
end
|
data/spec/wrapup/wrap_spec.rb
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
require 'wrapup/wrap'
|
2
2
|
module WrapUp
|
3
3
|
describe Wrap do
|
4
|
+
class WrapperClass < Struct.new(:original)
|
5
|
+
end
|
6
|
+
|
7
|
+
let(:item_1) { double "item" }
|
8
|
+
let(:item_2) { double "item" }
|
9
|
+
let(:wrap) { described_class.new [item_1, item_2], WrapperClass }
|
10
|
+
|
4
11
|
describe "#initialize" do
|
5
12
|
it "takes a collection and a constant in which to wrap the collection" do
|
6
|
-
described_class.new [],
|
13
|
+
described_class.new [], WrapperClass
|
7
14
|
end
|
8
15
|
end
|
9
16
|
|
@@ -13,35 +20,29 @@ module WrapUp
|
|
13
20
|
end
|
14
21
|
end
|
15
22
|
|
16
|
-
describe
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
before do
|
22
|
-
constant.stub(:new).and_return do |item|
|
23
|
-
case item
|
24
|
-
when item_1 then wrap_1
|
25
|
-
when item_2 then wrap_2
|
26
|
-
end
|
27
|
-
end
|
23
|
+
describe '#[]' do
|
24
|
+
it 'allows access to an individual via a wrapper' do
|
25
|
+
expect( wrap[1] ).to be_a WrapperClass
|
26
|
+
expect( wrap[1].original ).to eq item_2
|
28
27
|
end
|
28
|
+
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
it "iterates over the collection" do
|
34
|
-
collection.should_receive(:each)
|
35
|
-
subject
|
30
|
+
describe '#size' do
|
31
|
+
it 'measure the internal collection size' do
|
32
|
+
expect( wrap.size ).to eq 2
|
36
33
|
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#each" do
|
37
|
+
let(:output) { [] }
|
38
|
+
|
39
|
+
before { wrap.each { |i| output << i } }
|
40
|
+
|
37
41
|
it "wraps the items in constant" do
|
38
|
-
|
39
|
-
constant.should_receive(:new).with(item_2).and_return(wrap_2)
|
40
|
-
subject
|
42
|
+
expect( output.all? { |item| item.is_a? WrapperClass } ).to eq true
|
41
43
|
end
|
42
|
-
it
|
43
|
-
|
44
|
-
output.should == [wrap_1,wrap_2]
|
44
|
+
it 'wraps them in order' do
|
45
|
+
expect( output.map(&:original) ).to eq [item_1,item_2]
|
45
46
|
end
|
46
47
|
end
|
47
48
|
end
|
data/wrapup.gemspec
CHANGED
metadata
CHANGED
@@ -1,27 +1,64 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wrapup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jon Rowe
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
|
-
cert_chain:
|
12
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDVjCCAj6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBRMQ4wDAYDVQQDDAVoZWxs
|
14
|
+
bzEXMBUGCgmSJomT8ixkARkWB2pvbnJvd2UxEjAQBgoJkiaJk/IsZAEZFgJjbzES
|
15
|
+
MBAGCgmSJomT8ixkARkWAnVrMB4XDTEzMDIwMzA4MTgwNloXDTE0MDIwMzA4MTgw
|
16
|
+
NlowUTEOMAwGA1UEAwwFaGVsbG8xFzAVBgoJkiaJk/IsZAEZFgdqb25yb3dlMRIw
|
17
|
+
EAYKCZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJ1azCCASIwDQYJKoZI
|
18
|
+
hvcNAQEBBQADggEPADCCAQoCggEBAMhs6ng/SRrYfG7RtQx8liJTZs8tpz7PBnlH
|
19
|
+
qyOwuU0weJc7nh6C9C8LGyJzpkbjJJo1rfTMg7huDyL14Py82dfMDomApif8jNNI
|
20
|
+
8KtviAgB1DrWq0fCDLtu/M77+yuVV3OhDdrAFaBkT/euvdJ8cAKrLxbJ+klgvrcB
|
21
|
+
FK+c4PUV3/zBKghe0l7FuDhyQCsuLNDbWyFvDS97tPjeN6yWuszwg22vZMDdsuzN
|
22
|
+
Cj3M4LLSkbrt+AOUcysEJxI4t6uv2U1bRzHsDfAF0RI/Q7OMtUr+Dtz/2YJ47KKs
|
23
|
+
51ZRjLLGHd10XrIfFSfGyJj1dMbDgLsEBj1sFH4e6dy7gau8TaUCAwEAAaM5MDcw
|
24
|
+
CQYDVR0TBAIwADAdBgNVHQ4EFgQULu5JH2g7RAjoXaZt+fbrfNDI9IkwCwYDVR0P
|
25
|
+
BAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IBAQAf5A4kB769DPKGjPZ++v42FwVi7X7v
|
26
|
+
RpufPs6R4YHyzHXaJmAqnhleZhVJijBgsdb2SigNRbg+IK8XYHg7jkonMgO8OS3D
|
27
|
+
C6w8VB5bI0PqyDOwCGcQkYHYlZZWCghAyBTSBowHAekMb9V3QjJtJ8XkizjshETO
|
28
|
+
ZCVI2AObjlJi8I10aK2tSo9sv2riCKZ92BVSM13zYWn+C/eCP/m9BDiw37UQtuQq
|
29
|
+
2feWfO4gCNmvfFjULOAYHq9JHEjN5SLSXvj5HdSnDcCyIfJKn5Ya3JahWQaWIsXf
|
30
|
+
/NPE/mB57TOwj+d7XUa2NC4HUadF8R51IYEcIB0PpIEzJlKtfXFcOZxO
|
31
|
+
-----END CERTIFICATE-----
|
32
|
+
date: 2013-04-29 00:00:00.000000000 Z
|
13
33
|
dependencies:
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: rake
|
36
|
+
requirement: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
type: :development
|
42
|
+
prerelease: false
|
43
|
+
version_requirements: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
14
48
|
- !ruby/object:Gem::Dependency
|
15
49
|
name: rspec
|
16
|
-
requirement:
|
17
|
-
none: false
|
50
|
+
requirement: !ruby/object:Gem::Requirement
|
18
51
|
requirements:
|
19
|
-
- -
|
52
|
+
- - '>='
|
20
53
|
- !ruby/object:Gem::Version
|
21
54
|
version: '0'
|
22
55
|
type: :development
|
23
56
|
prerelease: false
|
24
|
-
version_requirements:
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
25
62
|
description: WrapUp, a simple wrapper gem for collections
|
26
63
|
email:
|
27
64
|
- hello@jonrowe.co.uk
|
@@ -31,6 +68,7 @@ extra_rdoc_files: []
|
|
31
68
|
files:
|
32
69
|
- .gitignore
|
33
70
|
- .rspec
|
71
|
+
- .travis.yml
|
34
72
|
- Gemfile
|
35
73
|
- LICENSE
|
36
74
|
- README.md
|
@@ -42,27 +80,26 @@ files:
|
|
42
80
|
- wrapup.gemspec
|
43
81
|
homepage: https://github.com/JonRowe/wrapup
|
44
82
|
licenses: []
|
83
|
+
metadata: {}
|
45
84
|
post_install_message:
|
46
85
|
rdoc_options: []
|
47
86
|
require_paths:
|
48
87
|
- lib
|
49
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
89
|
requirements:
|
52
|
-
- -
|
90
|
+
- - '>='
|
53
91
|
- !ruby/object:Gem::Version
|
54
92
|
version: '0'
|
55
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
94
|
requirements:
|
58
|
-
- -
|
95
|
+
- - '>='
|
59
96
|
- !ruby/object:Gem::Version
|
60
97
|
version: '0'
|
61
98
|
requirements: []
|
62
99
|
rubyforge_project:
|
63
|
-
rubygems_version:
|
100
|
+
rubygems_version: 2.0.3
|
64
101
|
signing_key:
|
65
|
-
specification_version:
|
102
|
+
specification_version: 4
|
66
103
|
summary: WrapUp, a simple wrapper gem for collections
|
67
104
|
test_files:
|
68
105
|
- spec/wrapup/wrap_spec.rb
|
metadata.gz.sig
ADDED