hallon 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.rspec CHANGED
@@ -2,6 +2,4 @@
2
2
  -fs
3
3
  -Ilib
4
4
  -Ispec
5
- --fail-fast
6
- --require cover_me
7
5
  --require spec_helper
data/CHANGELOG CHANGED
@@ -1,6 +1,20 @@
1
1
  Hallon’s Changelog
2
2
  ==================
3
3
 
4
+ v0.2.1
5
+ ------------------
6
+ - Fix compatibility with v1.8
7
+
8
+ v0.2.0
9
+ ------------------
10
+ - Alias Session#process_events_on to Session#wait_until
11
+ - Have Error.maybe_raise return error code
12
+ - Use mockspotify gem (https://rubygems.org/gems/mockspotify) for testing
13
+
14
+ v0.1.1
15
+ ------------------
16
+ Don’t show the README in the gem description.
17
+
4
18
  v0.1.0
5
19
  ------------------
6
20
  Initial, first, release! This version is merely made to
data/Gemfile CHANGED
@@ -1,2 +1,4 @@
1
1
  source :rubygems
2
- gemspec
2
+ gemspec
3
+
4
+ gem 'cover_me', :platform => :ruby_19
data/Rakefile CHANGED
@@ -8,7 +8,9 @@ require 'yard'
8
8
  YARD::Rake::YardocTask.new
9
9
 
10
10
  require 'rspec/core/rake_task'
11
- RSpec::Core::RakeTask.new('spec')
11
+ RSpec::Core::RakeTask.new('spec') do |task|
12
+ task.ruby_opts = '-W2'
13
+ end
12
14
 
13
15
  desc "Run the full test suite and generate a coverage report"
14
16
  task 'spec:cov' => ['clean', 'spec:full'] do
@@ -16,15 +16,14 @@ Gem::Specification.new do |gem|
16
16
 
17
17
  gem.version = Hallon::VERSION
18
18
  gem.platform = Gem::Platform::RUBY
19
- gem.required_ruby_version = '~> 1.9'
19
+ gem.required_ruby_version = '~> 1.8'
20
20
 
21
21
  gem.add_dependency 'spotify', '~> 8.0.5'
22
- gem.add_development_dependency 'mockspotify', '~> 0.1.2'
22
+ gem.add_development_dependency 'mockspotify', '~> 0.1.4'
23
23
  gem.add_development_dependency 'rake', '~> 0.8'
24
24
  gem.add_development_dependency 'rspec', '~> 2'
25
25
  gem.add_development_dependency 'autotest-standalone'
26
26
  gem.add_development_dependency 'autotest-growl'
27
- gem.add_development_dependency 'cover_me'
28
27
  gem.add_development_dependency 'yard'
29
28
  gem.add_development_dependency 'rdiscount'
30
29
  end
@@ -2,6 +2,7 @@
2
2
  require 'spotify'
3
3
  require 'hallon/ext/spotify'
4
4
  require 'hallon/ext/ffi'
5
+ require 'hallon/ext/object'
5
6
 
6
7
  require 'hallon/synchronizable'
7
8
  require 'hallon/observable'
@@ -43,7 +43,7 @@ module Hallon
43
43
  return symbol if symbol == :ok
44
44
 
45
45
  message = []
46
- message << "[#{symbol.upcase}]"
46
+ message << "[#{symbol.to_s.upcase}]"
47
47
  message << explain(error)
48
48
  message << "(#{error})"
49
49
  raise Hallon::Error, message.join(' ')
@@ -18,9 +18,7 @@ module FFI
18
18
  #
19
19
  # @param [Integer] count how many to read
20
20
  # @return a type of appropriate size
21
- define_method(:read_size_t) do |*args|
22
- public_send("read_#{type}", *args)
23
- end
21
+ alias_method :read_size_t, "read_#{type}"
24
22
  end
25
23
  end
26
24
  end
@@ -0,0 +1,13 @@
1
+ class Object
2
+ unless defined?(singleton_class)
3
+ def singleton_class
4
+ class << self; self; end
5
+ end
6
+ end
7
+
8
+ unless method_defined?(:define_singleton_method)
9
+ def define_singleton_method(*args, &b)
10
+ singleton_class.send(:define_method, *args, &b)
11
+ end
12
+ end
13
+ end
@@ -76,7 +76,17 @@ module Hallon
76
76
  # @param [#to_str] other
77
77
  # @return [Integer]
78
78
  def <=>(other)
79
- to_str <=> String.try_convert(other)
79
+ if other.respond_to?(:to_str)
80
+ to_str <=> other.to_str
81
+ end
82
+ end
83
+
84
+ # True if this link equals `other.to_str`
85
+ #
86
+ # @param [#to_str] other
87
+ # @return [Boolean]
88
+ def ==(other)
89
+ (self <=> other) == 0
80
90
  end
81
91
 
82
92
  # String representation of the given Link.
@@ -3,5 +3,5 @@ module Hallon
3
3
  # Current release version of Hallon
4
4
  #
5
5
  # @see http://semver.org/
6
- VERSION = [0, 2, 0].join('.')
6
+ VERSION = [0, 2, 1].join('.')
7
7
  end
@@ -1,5 +1,5 @@
1
1
  describe FFI::Pointer do
2
2
  it "should have a #read_size_t" do
3
- described_class.instance_methods.should include :read_size_t
3
+ described_class.method_defined?(:read_size_t).should be_true
4
4
  end
5
5
  end
@@ -2,35 +2,53 @@
2
2
  require 'ostruct'
3
3
 
4
4
  describe Hallon::Image, :session => true do
5
- let(:session) { double.stub(:pointer).and_return(nil) }
6
- let(:image) do
7
- Hallon::Session.should_receive(:instance).and_return double.stub(:pointer => nil)
8
-
9
- image = Spotify.mock_image(
10
- "3ad93423add99766e02d563605c6e76ed2b0e450".gsub(/../) { |x| x.to_i(16).chr },
11
- :jpeg,
12
- File.size(fixture_image_path),
13
- File.read(fixture_image_path),
14
- :ok
15
- )
16
-
17
- Hallon::Image.new(image)
18
- end
5
+ let(:session) { OpenStruct.new(:pointer => nil) }
19
6
 
20
- subject { image }
7
+ describe "an image instance" do
8
+ let(:image) do
9
+ Hallon::Session.should_receive(:instance).and_return session
21
10
 
22
- its(:status) { should be :ok }
23
- its(:format) { should be :jpeg }
24
- its(:id) { should eq "3ad93423add99766e02d563605c6e76ed2b0e450" }
11
+ image = Spotify.mock_image(
12
+ "3ad93423add99766e02d563605c6e76ed2b0e450".gsub(/../) { |x| x.to_i(16).chr },
13
+ :jpeg,
14
+ File.size(fixture_image_path),
15
+ File.read(fixture_image_path),
16
+ :ok
17
+ )
25
18
 
26
- describe "#data" do
27
- it "should correspond to the fixture image" do
28
- image.data.should eq File.read(fixture_image_path, :encoding => 'binary')
19
+ Hallon::Image.new(image)
29
20
  end
30
21
 
31
- it "should have a binary encoding" do
32
- image.data.encoding.name.should eq 'ASCII-8BIT'
22
+ subject { image }
23
+
24
+ its(:status) { should be :ok }
25
+ its(:format) { should be :jpeg }
26
+ its(:id) { should eq "3ad93423add99766e02d563605c6e76ed2b0e450" }
27
+
28
+ describe "#data" do
29
+ subject { image.data }
30
+
31
+ it "should correspond to the fixture image" do
32
+ should eq File.open(fixture_image_path, 'r:binary', &:read)
33
+ end
34
+
35
+ it "should have a binary encoding" do
36
+ pending "ruby 1.8 does not support String#encoding" unless subject.respond_to?(:encoding)
37
+ subject.encoding.name.should eq 'ASCII-8BIT'
38
+ end
33
39
  end
40
+
41
+ describe "#to_link" do
42
+ it "should retrieve the Spotify URI" do
43
+ image.to_link.should eq Hallon::Link.new("spotify:image:#{image.id}")
44
+ end
45
+ end
46
+ end
47
+
48
+ context "created from an uri" do
49
+ let(:image) { Hallon::Image.new("spotify:image:c78f091482e555bd2ffacfcd9cbdc0714b221663", session) }
50
+ subject { image }
51
+ its(:id) { should eq "c78f091482e555bd2ffacfcd9cbdc0714b221663" }
34
52
  end
35
53
 
36
54
  describe "callbacks" do
@@ -4,10 +4,8 @@ describe Hallon::Observable do
4
4
  end
5
5
 
6
6
  describe "instance methods" do
7
- subject { described_class.instance_methods }
8
-
9
- it { should include :on }
10
- it { should include :trigger }
7
+ it { should respond_to :on }
8
+ it { should respond_to :trigger }
11
9
  end
12
10
 
13
11
  describe "#on" do
@@ -1,4 +1,11 @@
1
1
  # coding: utf-8
2
+
3
+ begin
4
+ require 'cover_me'
5
+ rescue LoadError
6
+ # ignore, only for development, it’s in the Gemfile
7
+ end
8
+
2
9
  require 'mockspotify'
3
10
  require 'hallon'
4
11
 
@@ -1,5 +1,7 @@
1
- CoverMe.config do |c|
2
- c.project.root = Dir.pwd
3
- c.at_exit = proc {} # default hook opens coverage/ folder, ANNOYING!
4
- c.file_pattern = [%r"#{c.project.root}/lib/.+\.rb"]
1
+ if defined?(CoverMe)
2
+ CoverMe.config do |c|
3
+ c.project.root = Dir.pwd
4
+ c.at_exit = proc {} # default hook opens coverage/ folder, ANNOYING!
5
+ c.file_pattern = [%r"#{c.project.root}/lib/.+\.rb"]
6
+ end
5
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hallon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-21 00:00:00.000000000Z
12
+ date: 2011-07-22 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spotify
16
- requirement: &2153174180 !ruby/object:Gem::Requirement
16
+ requirement: &2157240440 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: 8.0.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153174180
24
+ version_requirements: *2157240440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mockspotify
27
- requirement: &2153173600 !ruby/object:Gem::Requirement
27
+ requirement: &2157239880 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 0.1.2
32
+ version: 0.1.4
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2153173600
35
+ version_requirements: *2157239880
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &2153172780 !ruby/object:Gem::Requirement
38
+ requirement: &2157239180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.8'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2153172780
46
+ version_requirements: *2157239180
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &2153171860 !ruby/object:Gem::Requirement
49
+ requirement: &2157232320 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '2'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2153171860
57
+ version_requirements: *2157232320
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: autotest-standalone
60
- requirement: &2153171320 !ruby/object:Gem::Requirement
60
+ requirement: &2157231660 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2153171320
68
+ version_requirements: *2157231660
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: autotest-growl
71
- requirement: &2153170600 !ruby/object:Gem::Requirement
71
+ requirement: &2157230760 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,21 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2153170600
80
- - !ruby/object:Gem::Dependency
81
- name: cover_me
82
- requirement: &2153169940 !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
- type: :development
89
- prerelease: false
90
- version_requirements: *2153169940
79
+ version_requirements: *2157230760
91
80
  - !ruby/object:Gem::Dependency
92
81
  name: yard
93
- requirement: &2153169300 !ruby/object:Gem::Requirement
82
+ requirement: &2157230240 !ruby/object:Gem::Requirement
94
83
  none: false
95
84
  requirements:
96
85
  - - ! '>='
@@ -98,10 +87,10 @@ dependencies:
98
87
  version: '0'
99
88
  type: :development
100
89
  prerelease: false
101
- version_requirements: *2153169300
90
+ version_requirements: *2157230240
102
91
  - !ruby/object:Gem::Dependency
103
92
  name: rdiscount
104
- requirement: &2153168620 !ruby/object:Gem::Requirement
93
+ requirement: &2157229660 !ruby/object:Gem::Requirement
105
94
  none: false
106
95
  requirements:
107
96
  - - ! '>='
@@ -109,7 +98,7 @@ dependencies:
109
98
  version: '0'
110
99
  type: :development
111
100
  prerelease: false
112
- version_requirements: *2153168620
101
+ version_requirements: *2157229660
113
102
  description:
114
103
  email: kim@burgestrand.se
115
104
  executables: []
@@ -134,6 +123,7 @@ files:
134
123
  - lib/hallon.rb
135
124
  - lib/hallon/error.rb
136
125
  - lib/hallon/ext/ffi.rb
126
+ - lib/hallon/ext/object.rb
137
127
  - lib/hallon/ext/spotify.rb
138
128
  - lib/hallon/image.rb
139
129
  - lib/hallon/link.rb
@@ -172,7 +162,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
172
162
  requirements:
173
163
  - - ~>
174
164
  - !ruby/object:Gem::Version
175
- version: '1.9'
165
+ version: '1.8'
176
166
  required_rubygems_version: !ruby/object:Gem::Requirement
177
167
  none: false
178
168
  requirements: