cinch-spotify 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Victor Bergöö
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,18 @@
1
+ = cinch-spotify
2
+
3
+ A Spotify plugin for the IRC bot library Cinch.
4
+
5
+ == Usage
6
+
7
+ bot = Cinch::Bot.new do
8
+ configure do |c|
9
+ c.nick = "Spotibot"
10
+ c.server = "irc.freenode.org"
11
+ c.channels = ["#cinch-bots"]
12
+ c.plugins.plugins = [Cinch::Plugins::Netfeed::Spotify]
13
+ end
14
+ end
15
+
16
+ == Copyright
17
+
18
+ Copyright (c) 2010 Victor Bergöö. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "cinch-spotify"
8
+ gem.summary = %Q{Spotify plugin for the Cinch IRC framework}
9
+ gem.description = %Q{A spotify plugin for the Cinch IRC framework}
10
+ gem.email = "victor.bergoo@gmail.com"
11
+ gem.homepage = "http://github.com/netfeed/cinch-spotify"
12
+ gem.authors = ["Victor Bergoo"]
13
+ gem.add_dependency "cinch"
14
+ gem.add_dependency "nokogiri"
15
+ gem.add_dependency "httpclient"
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/cinch-spotify ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ # Copyright (c) 2010 Victor Bergöö
4
+ # This program is made available under the terms of the MIT License.
5
+
6
+ require 'rubygems'
7
+ require File.expand_path('../../lib/cinch-spotify', __FILE__)
8
+
9
+ bot = Cinch::Bot.new do
10
+ configure do |c|
11
+ c.nick = "Spotibot"
12
+ c.server = "irc.freenode.org"
13
+ c.channels = ["#cinch-bots"]
14
+ c.plugins.plugins = [Cinch::Plugins::Netfeed::Spotify]
15
+ end
16
+ end
17
+
18
+ bot.start
@@ -0,0 +1,59 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{cinch-spotify}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Victor Bergoo"]
12
+ s.date = %q{2010-10-21}
13
+ s.default_executable = %q{cinch-spotify}
14
+ s.description = %q{A spotify plugin for the Cinch IRC framework}
15
+ s.email = %q{victor.bergoo@gmail.com}
16
+ s.executables = ["cinch-spotify"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "bin/cinch-spotify",
27
+ "cinch-spotify.gemspec",
28
+ "lib/cinch-spotify.rb"
29
+ ]
30
+ s.homepage = %q{http://github.com/netfeed/cinch-spotify}
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.require_paths = ["lib"]
33
+ s.rubygems_version = %q{1.3.7}
34
+ s.summary = %q{Spotify plugin for the Cinch IRC framework}
35
+ s.test_files = [
36
+ "test/helper.rb",
37
+ "test/test_cinch-spotify.rb"
38
+ ]
39
+
40
+ if s.respond_to? :specification_version then
41
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
42
+ s.specification_version = 3
43
+
44
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
+ s.add_runtime_dependency(%q<cinch>, [">= 0"])
46
+ s.add_runtime_dependency(%q<nokogiri>, [">= 0"])
47
+ s.add_runtime_dependency(%q<httpclient>, [">= 0"])
48
+ else
49
+ s.add_dependency(%q<cinch>, [">= 0"])
50
+ s.add_dependency(%q<nokogiri>, [">= 0"])
51
+ s.add_dependency(%q<httpclient>, [">= 0"])
52
+ end
53
+ else
54
+ s.add_dependency(%q<cinch>, [">= 0"])
55
+ s.add_dependency(%q<nokogiri>, [">= 0"])
56
+ s.add_dependency(%q<httpclient>, [">= 0"])
57
+ end
58
+ end
59
+
@@ -0,0 +1,60 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ # Copyright (c) 2010 Victor Bergöö
4
+ # This program is made available under the terms of the MIT License.
5
+
6
+ require 'cinch'
7
+ require 'nokogiri'
8
+ require 'httpclient'
9
+
10
+ module Cinch
11
+ module Plugins
12
+ module Netfeed
13
+ class Spotify
14
+ include Cinch::Plugin
15
+
16
+ match /(spotify:(album|track|artist):[a-zA-Z0-9]+)/, :use_prefix => false
17
+ match /(http:\/\/open.spotify.com\/(album|track|artist)\/[a-zA-Z0-9]+)/, :use_prefix => false
18
+
19
+ def execute m, uri, type
20
+ msg = case type
21
+ when /artist/ then _artist uri
22
+ when /album/ then _album uri
23
+ when /track/ then _track uri
24
+ else 'something went wrong'
25
+ end
26
+
27
+ m.reply("Spotify: #{msg}")
28
+ end
29
+
30
+ def _artist uri
31
+ p = Nokogiri::XML _data(uri)
32
+ artist = p.xpath("//xmlns:artist/xmlns:name").first.content
33
+ "Artist: #{artist}"
34
+ end
35
+
36
+ def _album uri
37
+ p = Nokogiri::XML _data(uri)
38
+ artist = p.xpath("//xmlns:artist/xmlns:name").first.content
39
+ album = p.xpath("//xmlns:album/xmlns:name").first.content
40
+ "Album: #{album} by #{artist}"
41
+ end
42
+
43
+ def _track uri
44
+ p = Nokogiri::XML _data(uri)
45
+ artist = p.xpath("//xmlns:artist/xmlns:name").first.content
46
+ album = p.xpath("//xmlns:album/xmlns:name").first.content
47
+ track = p.xpath("//xmlns:track/xmlns:name").first.content
48
+ "Album: #{track} by #{artist} (#{album})"
49
+ end
50
+
51
+ def _data spotify_uri
52
+ client = HTTPClient.new
53
+ resp = client.get("http://ws.spotify.com/lookup/1/", { :uri => spotify_uri })
54
+ puts resp.content
55
+ resp.content
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'cinch-spotify'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestCinchSpotify < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cinch-spotify
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Victor Bergoo
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-10-21 00:00:00 +02:00
18
+ default_executable: cinch-spotify
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: cinch
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: nokogiri
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 0
43
+ version: "0"
44
+ type: :runtime
45
+ version_requirements: *id002
46
+ - !ruby/object:Gem::Dependency
47
+ name: httpclient
48
+ prerelease: false
49
+ requirement: &id003 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ type: :runtime
58
+ version_requirements: *id003
59
+ description: A spotify plugin for the Cinch IRC framework
60
+ email: victor.bergoo@gmail.com
61
+ executables:
62
+ - cinch-spotify
63
+ extensions: []
64
+
65
+ extra_rdoc_files:
66
+ - LICENSE
67
+ - README.rdoc
68
+ files:
69
+ - LICENSE
70
+ - README.rdoc
71
+ - Rakefile
72
+ - VERSION
73
+ - bin/cinch-spotify
74
+ - cinch-spotify.gemspec
75
+ - lib/cinch-spotify.rb
76
+ - test/helper.rb
77
+ - test/test_cinch-spotify.rb
78
+ has_rdoc: true
79
+ homepage: http://github.com/netfeed/cinch-spotify
80
+ licenses: []
81
+
82
+ post_install_message:
83
+ rdoc_options:
84
+ - --charset=UTF-8
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ requirements: []
104
+
105
+ rubyforge_project:
106
+ rubygems_version: 1.3.7
107
+ signing_key:
108
+ specification_version: 3
109
+ summary: Spotify plugin for the Cinch IRC framework
110
+ test_files:
111
+ - test/helper.rb
112
+ - test/test_cinch-spotify.rb