liner 0.2.2 → 0.2.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 +4 -4
- data/.travis.yml +4 -2
- data/README.md +3 -0
- data/Rakefile +1 -1
- data/lib/liner.rb +3 -1
- data/lib/liner/version.rb +1 -1
- data/liner.gemspec +3 -1
- data/test/liner/base_test.rb +1 -1
- data/test/liner/equalizable_test.rb +5 -5
- data/test/liner/hashable_test.rb +6 -6
- data/test/liner/inspectable_test.rb +11 -3
- data/test/liner_test.rb +3 -3
- data/test/test_helper.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04e738b13c18717baf4af8a6fba875a9b10336ee
|
4
|
+
data.tar.gz: d5237a43626168160673d7415ec86267493922ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17b755696b49dda44fc5b4bda27205027a976b1f98a4c173dfc875b742ccd5c76a0ffa10c7ba738ec6546eeb13ad17d36ca235f46e68dc9988e509f8da28d97c
|
7
|
+
data.tar.gz: 79618b91225d393a1cd4b283fc34deb6d425280acce524188dee69a49eef772f3e1cfad80d82936806b90077a195c40b3c7d54b7f29410c266b611434cee71a4
|
data/.travis.yml
CHANGED
@@ -2,11 +2,13 @@ language: ruby
|
|
2
2
|
cache: bundler
|
3
3
|
bundler_args: --without yard pry
|
4
4
|
rvm:
|
5
|
+
- ree
|
6
|
+
- 1.8.7
|
7
|
+
- 1.9.2
|
5
8
|
- 1.9.3
|
6
9
|
- 2.0.0
|
7
10
|
- 2.1.0
|
8
11
|
- ruby-head
|
9
|
-
- rbx
|
10
12
|
- rbx-2
|
11
13
|
matrix:
|
12
14
|
include:
|
@@ -14,7 +16,7 @@ matrix:
|
|
14
16
|
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
15
17
|
- rvm: jruby-head
|
16
18
|
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
17
|
-
|
19
|
+
allow_failures:
|
18
20
|
- rvm: ruby-head
|
19
21
|
- rvm: jruby-head
|
20
22
|
fast_finish: true
|
data/README.md
CHANGED
@@ -179,11 +179,14 @@ Guitar.new('C', 6)
|
|
179
179
|
This library aims to support and is tested against the following Ruby
|
180
180
|
implementations:
|
181
181
|
|
182
|
+
* Ruby 1.8.7
|
183
|
+
* Ruby 1.9.2
|
182
184
|
* Ruby 1.9.3
|
183
185
|
* Ruby 2.0.0
|
184
186
|
* Ruby 2.1.0
|
185
187
|
* [JRuby](http://jruby.org/)
|
186
188
|
* [Rubinius](http://rubini.us/)
|
189
|
+
* [Ruby Enterprise Edition](http://www.rubyenterpriseedition.com/)
|
187
190
|
|
188
191
|
If something doesn't work on one of these versions, it's a bug.
|
189
192
|
|
data/Rakefile
CHANGED
data/lib/liner.rb
CHANGED
@@ -25,7 +25,9 @@ module Liner
|
|
25
25
|
def Liner.apply!(base, *keys)
|
26
26
|
keys = keys.map(&:to_sym).uniq
|
27
27
|
|
28
|
-
|
28
|
+
singleton = (class << base; self; end)
|
29
|
+
|
30
|
+
singleton.send(:define_method, :liner_keys) do
|
29
31
|
@liner_keys ||= begin
|
30
32
|
super() + keys
|
31
33
|
rescue NoMethodError
|
data/lib/liner/version.rb
CHANGED
data/liner.gemspec
CHANGED
@@ -18,8 +18,10 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_dependency "json" if RUBY_VERSION < '1.9.2'
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
24
|
spec.add_development_dependency "rake"
|
23
25
|
spec.add_development_dependency "minitest"
|
24
|
-
spec.add_development_dependency "coveralls"
|
26
|
+
spec.add_development_dependency "coveralls" if RUBY_VERSION > '1.8.7'
|
25
27
|
end
|
data/test/liner/base_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
describe Liner::Base do
|
2
2
|
describe :initialize do
|
3
3
|
it "should accept key/value pairs" do
|
4
|
-
beer = Beer.new(hops
|
4
|
+
beer = Beer.new(:hops => 'Cascade', :yeast => 'Top Fermenting')
|
5
5
|
beer.hops.must_equal 'Cascade'
|
6
6
|
beer.yeast.must_equal 'Top Fermenting'
|
7
7
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
describe Liner::Equalizable do
|
2
|
-
subject { Pizza.new(crust
|
2
|
+
subject { Pizza.new(:crust => 'thin', :sauce => 'tomato') }
|
3
3
|
describe "#==" do
|
4
4
|
it "should return true when hashes are equal" do
|
5
|
-
subject.must_be :==, Pizza.new(crust
|
5
|
+
subject.must_be :==, Pizza.new(:crust => 'thin', :sauce => 'tomato')
|
6
6
|
end
|
7
7
|
it "should return false when hashes are not equal" do
|
8
|
-
subject.wont_be :==, Pizza.new(crust
|
8
|
+
subject.wont_be :==, Pizza.new(:crust => 'thick', :sauce => 'alfredo')
|
9
9
|
end
|
10
10
|
end
|
11
11
|
describe "#eql?" do
|
12
12
|
it "should return true when hashes are equal" do
|
13
|
-
subject.must_be :eql?, Pizza.new(crust
|
13
|
+
subject.must_be :eql?, Pizza.new(:crust => 'thin', :sauce => 'tomato')
|
14
14
|
end
|
15
15
|
it "should return false when hashes are not equal" do
|
16
|
-
subject.wont_be :eql?, Pizza.new(crust
|
16
|
+
subject.wont_be :eql?, Pizza.new(:crust => 'thick', :sauce => 'alfredo')
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/test/liner/hashable_test.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
describe Liner::Hashable do
|
2
|
-
subject { Beer.new(hops
|
2
|
+
subject { Beer.new(:hops => 'Cascade') }
|
3
3
|
|
4
4
|
it "#[] should read attributes" do
|
5
5
|
subject[:hops].must_equal "Cascade"
|
@@ -7,7 +7,7 @@ describe Liner::Hashable do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it "[] should not read invalid attributes" do
|
10
|
-
|
10
|
+
Proc.new { subject[:foo] }.must_raise ArgumentError
|
11
11
|
end
|
12
12
|
|
13
13
|
it "#[]= should set attributes" do
|
@@ -16,21 +16,21 @@ describe Liner::Hashable do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "#[]= should not set invalid attributes" do
|
19
|
-
|
19
|
+
Proc.new { subject[:foo] = 'bar' }.must_raise ArgumentError
|
20
20
|
end
|
21
21
|
|
22
22
|
it "liner should be a hash of attributes" do
|
23
|
-
subject.liner.must_equal({ hops
|
23
|
+
subject.liner.must_equal({ :hops => 'Cascade', :yeast => nil })
|
24
24
|
end
|
25
25
|
|
26
26
|
it "liner= should set the attributes" do
|
27
|
-
hash = {hops
|
27
|
+
hash = {:hops => 'Columbus', :yeast => 'Bottom Fermenting' }
|
28
28
|
subject.liner = hash
|
29
29
|
subject.liner.must_equal(hash)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "#to_h should return the attribute hash" do
|
33
|
-
subject.to_h.must_equal({ hops
|
33
|
+
subject.to_h.must_equal({ :hops => 'Cascade', :yeast => nil })
|
34
34
|
end
|
35
35
|
|
36
36
|
end
|
@@ -1,9 +1,17 @@
|
|
1
1
|
describe Liner::Inspectable do
|
2
|
-
subject { Cheeseburger.new(meat
|
2
|
+
subject { Cheeseburger.new(:meat => 'turkey') }
|
3
3
|
it "#inspect must include all attributes" do
|
4
|
-
subject.
|
4
|
+
subject.to_s.must_include '#<Cheeseburger'
|
5
|
+
subject.to_s.must_include '>'
|
6
|
+
subject.to_s.must_include 'bun=nil'
|
7
|
+
subject.to_s.must_include 'meat="turkey"'
|
8
|
+
subject.to_s.must_include 'cheese=nil'
|
5
9
|
end
|
6
10
|
it "#to_s must include all attributes" do
|
7
|
-
subject.to_s.
|
11
|
+
subject.to_s.must_include '#<Cheeseburger'
|
12
|
+
subject.to_s.must_include '>'
|
13
|
+
subject.to_s.must_include 'bun=nil'
|
14
|
+
subject.to_s.must_include 'meat="turkey"'
|
15
|
+
subject.to_s.must_include 'cheese=nil'
|
8
16
|
end
|
9
17
|
end
|
data/test/liner_test.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
describe Liner do
|
2
2
|
describe :new do
|
3
|
-
let(:beer) { Beer.new(hops
|
4
|
-
let(:pizza) { Pizza.new(crust
|
5
|
-
let(:cheeseburger){ Cheeseburger.new(bun
|
3
|
+
let(:beer) { Beer.new(:hops => 'columbus') }
|
4
|
+
let(:pizza) { Pizza.new(:crust => 'thin') }
|
5
|
+
let(:cheeseburger){ Cheeseburger.new(:bun => 'sesame') }
|
6
6
|
|
7
7
|
it "should create a new class" do
|
8
8
|
[Beer, Pizza, Burger, Cheeseburger].all?{|klass| klass.is_a? Class }
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Lewis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|