shoutcast_api 0.1.2 → 0.1.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.
data/README.rdoc CHANGED
@@ -18,11 +18,18 @@ Uses httparty and roxml for fetching and parsing data from http://yp.shoutcast.c
18
18
  # Genres
19
19
  Shoutcast.genres # => all genres
20
20
 
21
+ == Install via gemcutter
22
+ gem install gemcutter
23
+ gem tumble
24
+ gem install shoutcast_api
25
+
21
26
  == Command line
22
27
 
23
- shoutcast_api lib/shoutcast_api.rb # Genres
28
+ shoutcast_api # List genres
29
+
30
+ shoutcast_api name=Chronix # Search for station "Chronix"
24
31
 
25
- shoutcast_api name=Chronix
32
+ # Search for station with genre "metal", bitrate 128 and media type "audio/mpeg"
26
33
  shoutcast_api genre=metal br=128 mt=audio/mpeg
27
34
 
28
35
  == Authors
@@ -31,3 +38,4 @@ Uses httparty and roxml for fetching and parsing data from http://yp.shoutcast.c
31
38
  == TODO
32
39
 
33
40
  * command line options transformations
41
+ * Use mock-server for mocking API requests
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ task :default => :test
7
7
 
8
8
  require 'echoe'
9
9
  Echoe.new('shoutcast_api') do |gem|
10
- gem.version = '0.1.2'
10
+ gem.version = '0.1.3'
11
11
  gem.author = 'Peter Suschlik'
12
12
  gem.summary = 'Simple shoutcast.com API.'
13
13
  gem.email = 'peter-scapi@suschlik.de'
data/lib/shoutcast_api.rb CHANGED
@@ -62,7 +62,8 @@ module Shoutcast
62
62
  private
63
63
 
64
64
  def self.fetch(options={}, &block) # :nodoc:
65
- options.update(:nocache => Time.now.to_f) if options
65
+ options ||= {}
66
+ options.update(:nocache => Time.now.to_f) unless options.key?(:nocache)
66
67
  data = get("/sbin/newxml.phtml", :query => options).body
67
68
 
68
69
  block.call(data) unless data.empty?
@@ -2,29 +2,28 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{shoutcast_api}
5
- s.version = "0.1.2"
5
+ s.version = "0.1.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Peter Suschlik"]
9
- s.date = %q{2009-05-14}
9
+ s.date = %q{2009-11-04}
10
10
  s.default_executable = %q{shoutcast_search}
11
- s.description = %q{Simple Shoutcast.com API.}
11
+ s.description = %q{Simple shoutcast.com API.}
12
12
  s.email = %q{peter-scapi@suschlik.de}
13
13
  s.executables = ["shoutcast_search"]
14
- s.extra_rdoc_files = ["bin/shoutcast_search", "lib/shoutcast_api.rb", "README.rdoc"]
15
- s.files = ["Rakefile", "bin/shoutcast_search", "lib/shoutcast_api.rb", "README.rdoc", "Manifest", "test/test_xml.rb", "test/helper.rb", "test/test_fetcher.rb", "test/fixtures/genrelist.plain", "test/fixtures/search_death.plain", "test/fixtures/empty.plain", "test/test_basic.rb", "shoutcast_api.gemspec"]
16
- s.has_rdoc = true
14
+ s.extra_rdoc_files = ["lib/shoutcast_api.rb", "README.rdoc", "bin/shoutcast_search"]
15
+ s.files = ["lib/shoutcast_api.rb", "Rakefile", "test/test_xml.rb", "test/helper.rb", "test/test_basic.rb", "test/fixtures/empty.plain", "test/fixtures/genrelist.plain", "test/fixtures/search_death.plain", "test/test_fetcher.rb", "README.rdoc", "Manifest", "bin/shoutcast_search", "shoutcast_api.gemspec"]
17
16
  s.homepage = %q{http://github.com/splattael/shoutcast_api}
18
17
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Shoutcast_api", "--main", "README.rdoc"]
19
18
  s.require_paths = ["lib"]
20
19
  s.rubyforge_project = %q{shoutcast_api}
21
- s.rubygems_version = %q{1.3.1}
22
- s.summary = %q{Ruby API for Shoutcast.com.}
20
+ s.rubygems_version = %q{1.3.5}
21
+ s.summary = %q{Simple shoutcast.com API.}
23
22
  s.test_files = ["test/test_xml.rb", "test/test_fetcher.rb", "test/test_basic.rb"]
24
23
 
25
24
  if s.respond_to? :specification_version then
26
25
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
27
- s.specification_version = 2
26
+ s.specification_version = 3
28
27
 
29
28
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
30
29
  s.add_runtime_dependency(%q<httparty>, ["~> 0.4"])
data/test/test_fetcher.rb CHANGED
@@ -1,5 +1,21 @@
1
1
  require File.join(File.dirname(__FILE__), 'helper')
2
2
 
3
+ require 'ostruct'
4
+ class FakeResponse < OpenStruct
5
+ def initialize(&block)
6
+ super
7
+ block.call(self) if block
8
+ end
9
+
10
+ def empty?
11
+ false
12
+ end
13
+
14
+ def body
15
+ self
16
+ end
17
+ end
18
+
3
19
  class FetcherTest < Test::Unit::TestCase
4
20
  include Shoutcast
5
21
 
@@ -7,6 +23,36 @@ class FetcherTest < Test::Unit::TestCase
7
23
  assert_equal "http://yp.shoutcast.com", Stationlist.base_uri
8
24
  end
9
25
 
26
+ def test_nocache_paramater
27
+ fetcher = Fetcher.clone
28
+
29
+ def fetcher.get(path, options)
30
+ FakeResponse.new do |response|
31
+ response.options = options
32
+ end
33
+ end
34
+
35
+ # {}
36
+ response = fetcher.send(:fetch) { |response| response }
37
+ assert response
38
+ assert_instance_of Hash, response.options
39
+ assert_instance_of Hash, response.options[:query]
40
+ assert response.options[:query][:nocache]
41
+
42
+ # { :nocache => "random" }
43
+ response = fetcher.send(:fetch, :nocache => "random") { |response| response }
44
+ assert response
45
+ assert_instance_of Hash, response.options
46
+ assert_instance_of Hash, response.options[:query]
47
+ assert_equal "random", response.options[:query][:nocache]
48
+
49
+ # nil
50
+ response = fetcher.send(:fetch, nil) { |response| response }
51
+ assert_instance_of Hash, response.options
52
+ assert_instance_of Hash, response.options[:query]
53
+ assert response.options[:query][:nocache]
54
+ end
55
+
10
56
  def test_genres_list
11
57
  stub_http_response_with("genrelist.plain")
12
58
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoutcast_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Suschlik
@@ -9,8 +9,8 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-14 00:00:00 +02:00
13
- default_executable: shoutcast_search
12
+ date: 2009-11-04 00:00:00 +01:00
13
+ default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -32,29 +32,29 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: "2.5"
34
34
  version:
35
- description: Simple Shoutcast.com API.
35
+ description: Simple shoutcast.com API.
36
36
  email: peter-scapi@suschlik.de
37
37
  executables:
38
38
  - shoutcast_search
39
39
  extensions: []
40
40
 
41
41
  extra_rdoc_files:
42
- - bin/shoutcast_search
43
42
  - lib/shoutcast_api.rb
44
43
  - README.rdoc
45
- files:
46
- - Rakefile
47
44
  - bin/shoutcast_search
45
+ files:
48
46
  - lib/shoutcast_api.rb
49
- - README.rdoc
50
- - Manifest
47
+ - Rakefile
51
48
  - test/test_xml.rb
52
49
  - test/helper.rb
53
- - test/test_fetcher.rb
50
+ - test/test_basic.rb
51
+ - test/fixtures/empty.plain
54
52
  - test/fixtures/genrelist.plain
55
53
  - test/fixtures/search_death.plain
56
- - test/fixtures/empty.plain
57
- - test/test_basic.rb
54
+ - test/test_fetcher.rb
55
+ - README.rdoc
56
+ - Manifest
57
+ - bin/shoutcast_search
58
58
  - shoutcast_api.gemspec
59
59
  has_rdoc: true
60
60
  homepage: http://github.com/splattael/shoutcast_api
@@ -87,8 +87,8 @@ requirements: []
87
87
  rubyforge_project: shoutcast_api
88
88
  rubygems_version: 1.3.5
89
89
  signing_key:
90
- specification_version: 2
91
- summary: Ruby API for Shoutcast.com.
90
+ specification_version: 3
91
+ summary: Simple shoutcast.com API.
92
92
  test_files:
93
93
  - test/test_xml.rb
94
94
  - test/test_fetcher.rb