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.
@@ -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
Binary file
Binary file
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - 1.9.2
6
+ - jruby-18mode
7
+ - jruby-19mode
8
+ - rbx-18mode
9
+ - rbx-19mode
10
+ - ruby-head
11
+ - 1.8.7
12
+ - ree
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ [![Build Status](https://secure.travis-ci.org/JonRowe/wrapup.png)](http://travis-ci.org/JonRowe/wrapup)
1
2
  # WrapUp
2
3
 
3
4
  Simple wrapper gem. Found myself writing this in too many projects.
data/Rakefile CHANGED
@@ -1,2 +1,12 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+
4
+ require 'rspec'
5
+ require 'rspec/core/rake_task'
6
+
7
+ desc "Run specs"
8
+ RSpec::Core::RakeTask.new :spec do |task|
9
+ task.pattern = 'spec/**/*_spec.rb'
10
+ end
11
+
12
+ task :default => [:spec]
@@ -1,5 +1,5 @@
1
1
  require "wrapup/version"
2
+ require "wrapup/wrap"
2
3
 
3
4
  module WrapUp
4
- # Your code goes here...
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module WrapUp
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -2,15 +2,23 @@ module WrapUp
2
2
  class Wrap
3
3
  include Enumerable
4
4
 
5
- def initialize(collection,wrapper_constant)
5
+ def initialize collection, wrapper_constant
6
6
  @collection = collection
7
7
  @wrapper = wrapper_constant
8
8
  end
9
9
 
10
- def each(&block)
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
@@ -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 [], double
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 "#each" do
17
- [:item_1,:item_2,:wrap_1,:wrap_2,:constant].each { |name| let(name) { double name } }
18
- let(:collection) { [item_1,item_2] }
19
- let(:output) { [] }
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
- let(:wrap) { described_class.new collection, constant }
31
- subject { wrap.each { |i| output << i } }
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
- constant.should_receive(:new).with(item_1).and_return(wrap_1)
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 "yields wrapped items to block" do
43
- subject
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
@@ -15,5 +15,6 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = WrapUp::VERSION
17
17
 
18
+ gem.add_development_dependency 'rake'
18
19
  gem.add_development_dependency 'rspec'
19
20
  end
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.1
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
- date: 2012-07-15 00:00:00.000000000 Z
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: &70242471053300 !ruby/object:Gem::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: *70242471053300
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: 1.8.10
100
+ rubygems_version: 2.0.3
64
101
  signing_key:
65
- specification_version: 3
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
@@ -0,0 +1,3 @@
1
+ �֣�N�/���(Gd �:²|B�U�<B����x�|Sk�A�X��^��[/�����!�d���z`*�Q�7Z%�z��3�
2
+ %U��{p�GS�P库��]��(��Gi�x��`�C����� �H���/ىŷ$���<k�7��ϯ�HH�ڿ�vo׋6����H�ş��It�����2���
3
+ �����9�/%l�S���>GLE���z �Q����-��Q6�B��8i��#�Z �b4H��Ƈ�(xcG��|