phish_dot_net_client 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile +1 -9
- data/History.md +9 -0
- data/README.md +4 -1
- data/Rakefile +14 -11
- data/lib/phish_dot_net_client.rb +77 -53
- data/lib/phish_dot_net_client/set.rb +15 -1
- data/lib/phish_dot_net_client/setlist.rb +53 -17
- data/lib/phish_dot_net_client/song.rb +42 -1
- data/lib/phish_dot_net_client/song_transition.rb +21 -1
- data/lib/phish_dot_net_client/version.rb +5 -1
- data/phish_dot_net_client.gemspec +11 -9
- data/spec/phish_dot_net_client/setlist_spec.rb +1 -0
- data/spec/phish_dot_net_client_spec.rb +1 -1
- data/spec/spec_helper.rb +8 -1
- metadata +42 -12
- data/Gemfile.lock +0 -32
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/History.md
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Phish.net API Client
|
2
2
|
|
3
|
+
<a href="http://badge.fury.io/rb/phish_dot_net_client"><img src="https://badge.fury.io/rb/phish_dot_net_client@2x.png" alt="Gem Version" height="18"></a>
|
4
|
+
|
3
5
|
A Phish.net API client, with support for parsing the 'setlistdata' field. Inspired by the other Ruby Phish.net API [client](http://api.phish.net/wrappers/ruby.php) written by [Stephen Blackstone](http://phish.net/user/steveb3210).
|
4
6
|
|
5
7
|
[rdoc](http://rubydoc.info/github/alexebird/phish_dot_net_client/master/frames/file/README.md)
|
@@ -34,7 +36,8 @@ Rubygems:
|
|
34
36
|
PhishDotNetClient.shows_query :month => '7', :country => 'USA', :state => 'CA'
|
35
37
|
|
36
38
|
# Arguments are not checked for validity before being passed
|
37
|
-
PhishDotNetClient.shows_setlists_get :fluff => 'head'
|
39
|
+
PhishDotNetClient.shows_setlists_get :fluff => 'head'
|
40
|
+
# => returns {"success" => 0,"reason" => "General API Error"}
|
38
41
|
|
39
42
|
# All methods return JSON parsed into Ruby Hashes/Arrays
|
40
43
|
tweez = PhishDotNetClient.shows_setlists_get :showdate => '2013-07-31'
|
data/Rakefile
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'rspec/core/rake_task'
|
2
2
|
|
3
|
-
|
4
3
|
desc "Parse the documentation from Phish.net to get the current method calls"
|
5
4
|
task :parse_method_docs do
|
6
5
|
# require 'nokogiri'
|
@@ -38,18 +37,22 @@ RSpec::Core::RakeTask.new(:spec) do |t|
|
|
38
37
|
# t.verbose = false
|
39
38
|
end
|
40
39
|
|
41
|
-
desc "Run specs in spec/units"
|
42
|
-
RSpec::Core::RakeTask.new('spec:units') do |t|
|
43
|
-
t.pattern = "./spec/units/**/*_spec.rb"
|
44
|
-
end
|
45
|
-
|
46
|
-
desc "Run specs in spec/integration"
|
47
|
-
RSpec::Core::RakeTask.new('spec:integration') do |t|
|
48
|
-
t.pattern = "./spec/integration/**/*_spec.rb"
|
49
|
-
end
|
50
|
-
|
51
40
|
desc "Generate documentation"
|
52
41
|
task :doc do
|
53
42
|
require 'yard'
|
54
43
|
sh "yard"
|
55
44
|
end
|
45
|
+
|
46
|
+
desc "Instructions for releasing a new version"
|
47
|
+
task :"release:instructions" do
|
48
|
+
version = PhishDotNetClient::VERSION
|
49
|
+
gem_name = File.basename Dir.glob(File.join(File.expand_path('../', __FILE__), '*.gemspec')).first.sub('.gemspec', '')
|
50
|
+
last_release = `git tag | grep --color=never -e "v\\d\\+\\." | sort | tail -n1`.strip
|
51
|
+
|
52
|
+
puts "1. update version.rb"
|
53
|
+
puts "2. update History.md"
|
54
|
+
puts " git log #{last_release}..HEAD --no-merges --format=%B"
|
55
|
+
puts "3. git commit, git tag v#{version}, git push origin v#{version}"
|
56
|
+
puts "4. gem build #{gem_name}.gemspec ; mv #{gem_name}-#{version}.gem ~/gems/"
|
57
|
+
puts "5. gem push ~/gems/#{gem_name}-#{version}.gem"
|
58
|
+
end
|
data/lib/phish_dot_net_client.rb
CHANGED
@@ -1,99 +1,121 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'restclient'
|
4
|
-
require '
|
4
|
+
require 'oj'
|
5
5
|
require 'nokogiri'
|
6
6
|
|
7
|
+
require 'phish_dot_net_client/version'
|
7
8
|
require 'phish_dot_net_client/set'
|
8
9
|
require 'phish_dot_net_client/setlist'
|
9
10
|
require 'phish_dot_net_client/song'
|
10
11
|
require 'phish_dot_net_client/song_transition'
|
11
|
-
require 'phish_dot_net_client/version'
|
12
12
|
|
13
|
-
#
|
13
|
+
# This module encapsulates interaction with the Phish.net API. It allows you to
|
14
|
+
# call any API method and will parse "setlistdata" fields in the JSON responses.
|
14
15
|
module PhishDotNetClient
|
15
16
|
extend self
|
16
17
|
|
17
18
|
# The possible API methods. Generated from +rake parse_method_docs+.
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
19
|
+
API_METHODS =
|
20
|
+
{
|
21
|
+
"pnet.api.authkey.get" => { :scope => "protected" },
|
22
|
+
"pnet.api.authorize" => { :scope => "protected" },
|
23
|
+
"pnet.api.authorized.check" => { :scope => "protected" },
|
24
|
+
"pnet.api.isAuthorized" => { :scope => "protected" },
|
25
|
+
"pnet.artists.get" => { :scope => "public" },
|
26
|
+
"pnet.blog.get" => { :scope => "public" },
|
27
|
+
"pnet.blog.item.get" => { :scope => "public" },
|
28
|
+
"pnet.collections.get" => { :scope => "protected" },
|
29
|
+
"pnet.collections.query" => { :scope => "protected" },
|
30
|
+
"pnet.forum.canpost" => { :scope => "protected" },
|
31
|
+
"pnet.forum.get" => { :scope => "public" },
|
32
|
+
"pnet.forum.thread.get" => { :scope => "protected" },
|
33
|
+
"pnet.forum.thread.new" => { :scope => "protected" },
|
34
|
+
"pnet.forum.thread.respond" => { :scope => "protected" },
|
35
|
+
"pnet.news.comments.get" => { :scope => "public" },
|
36
|
+
"pnet.news.get" => { :scope => "public" },
|
37
|
+
"pnet.reviews.query" => { :scope => "protected" },
|
38
|
+
"pnet.reviews.recent" => { :scope => "public" },
|
39
|
+
"pnet.shows.links.get" => { :scope => "protected" },
|
40
|
+
"pnet.shows.query" => { :scope => "protected" },
|
41
|
+
"pnet.shows.setlists.get" => { :scope => "protected" },
|
42
|
+
"pnet.shows.setlists.latest" => { :scope => "public" },
|
43
|
+
"pnet.shows.setlists.random" => { :scope => "public" },
|
44
|
+
"pnet.shows.setlists.recent" => { :scope => "public" },
|
45
|
+
"pnet.shows.setlists.tiph" => { :scope => "public" },
|
46
|
+
"pnet.shows.upcoming" => { :scope => "public" },
|
47
|
+
"pnet.user.get" => { :scope => "protected" },
|
48
|
+
"pnet.user.myshows.add" => { :scope => "protected" },
|
49
|
+
"pnet.user.myshows.get" => { :scope => "protected" },
|
50
|
+
"pnet.user.myshows.remove" => { :scope => "protected" },
|
51
|
+
"pnet.user.register" => { :scope => "protected" },
|
52
|
+
"pnet.user.shows.rate" => { :scope => "protected" },
|
53
|
+
"pnet.user.uid.get" => { :scope => "protected" },
|
54
|
+
"pnet.user.username.check" => { :scope => "protected" }
|
55
|
+
}
|
55
56
|
|
56
57
|
# The base URL for API calls
|
57
58
|
BASE_URL = "https://api.phish.net/api.js"
|
58
59
|
|
59
60
|
# "https://api.phish.net/api.js?api=2.0&method=pnet.shows.query&format=json&apikey=920FF765772E442F3E22&year=2011"
|
60
61
|
|
61
|
-
|
62
|
-
|
62
|
+
DEFAULT_PARAMS = { api: "2.0",
|
63
|
+
format: "json" }
|
63
64
|
|
65
|
+
# Set the apikey. The "private api key" from your Phish.net account should be
|
66
|
+
# used.
|
67
|
+
#
|
68
|
+
# @param private_api_key [String] the apikey
|
69
|
+
# @return [void]
|
64
70
|
def apikey=(private_api_key)
|
65
|
-
|
71
|
+
DEFAULT_PARAMS.merge!(:apikey => private_api_key)
|
66
72
|
end
|
67
73
|
|
68
|
-
|
69
|
-
|
74
|
+
# Calls pnet.api.authorize with the specified username and password, then stores
|
75
|
+
# the username and returned authkey if the call was successful. The password is
|
76
|
+
# not stored.
|
77
|
+
#
|
78
|
+
# @param username [String] the username
|
79
|
+
# @param password [String] the password
|
80
|
+
#
|
81
|
+
# @return [void]
|
82
|
+
def authorize(username, password)
|
83
|
+
resp = call_api_method("pnet.api.authorize", :username => username, :passwd => password)
|
70
84
|
|
71
85
|
if resp['success'] == 1 && resp.has_key?('authkey')
|
72
|
-
|
86
|
+
DEFAULT_PARAMS.merge!(:username => username, :authkey => resp['authkey'])
|
73
87
|
end
|
74
88
|
end
|
75
89
|
|
90
|
+
# Clears the stored API authentication parameters (apikey, username, authkey)
|
91
|
+
#
|
92
|
+
# @return [void]
|
76
93
|
def clear_auth
|
77
|
-
[:apikey, :username, :authkey].each { |key|
|
94
|
+
[:apikey, :username, :authkey].each { |key| DEFAULT_PARAMS.delete(key) }
|
78
95
|
end
|
79
96
|
|
97
|
+
# @api private
|
98
|
+
#
|
99
|
+
# Calls the specified Phish.net api method.
|
100
|
+
#
|
80
101
|
# @param api_method [String] the method to call
|
81
102
|
# @param params [Hash] the url parameters for the api call
|
82
103
|
#
|
104
|
+
# @raise [RuntimeError] if the http response status is a 2xx
|
105
|
+
#
|
83
106
|
# @return [Hash, Array] the parsed JSON of API response
|
84
|
-
# @api private
|
85
107
|
def call_api_method(api_method, params={})
|
86
108
|
# method_data = API_METHODS[api_method]
|
87
109
|
# ensure_api_key if method_data[:scope] == "protected"
|
88
110
|
|
89
111
|
params.merge!(:method => api_method)
|
90
|
-
response = RestClient.get BASE_URL, { :params =>
|
112
|
+
response = RestClient.get BASE_URL, { :params => DEFAULT_PARAMS.merge(params) }
|
91
113
|
|
92
114
|
if response.code < 200 || response.code > 299
|
93
115
|
raise "non 2xx reponse: status=#{response.code}"
|
94
116
|
end
|
95
117
|
|
96
|
-
parsed =
|
118
|
+
parsed = Oj.load(response)
|
97
119
|
|
98
120
|
if parsed.is_a?(Array)
|
99
121
|
parsed.each do |obj|
|
@@ -106,6 +128,8 @@ module PhishDotNetClient
|
|
106
128
|
return parsed
|
107
129
|
end
|
108
130
|
|
131
|
+
# Override method_missing to provide mapping of Ruby methods to API method names.
|
132
|
+
#
|
109
133
|
# @api private
|
110
134
|
def method_missing(name, *args)
|
111
135
|
api_method = get_api_method(name)
|
@@ -117,9 +141,9 @@ module PhishDotNetClient
|
|
117
141
|
end
|
118
142
|
end
|
119
143
|
|
120
|
-
# private
|
121
|
-
|
122
144
|
# @api private
|
145
|
+
# @param rb_method_name [Symbol] the Ruby method name
|
146
|
+
# @return [String] the api method name
|
123
147
|
def get_api_method(rb_method_name)
|
124
148
|
api_method_name = rb_method_name.to_s.gsub("_", ".")
|
125
149
|
|
@@ -137,6 +161,6 @@ module PhishDotNetClient
|
|
137
161
|
end
|
138
162
|
|
139
163
|
# def ensure_api_key
|
140
|
-
# raise "api key is required" if
|
164
|
+
# raise "api key is required" if DEFAULT_PARAMS[:apikey].nil?
|
141
165
|
# end
|
142
166
|
end
|
@@ -1,13 +1,27 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
# @api private
|
4
3
|
module PhishDotNetClient
|
4
|
+
|
5
|
+
# This class represents a set from the 'setlistdata' field.
|
5
6
|
class Set
|
6
7
|
|
8
|
+
# @!attribute [r] position
|
9
|
+
# @return [Integer] the position of the set, indexed starting at 0
|
7
10
|
attr_reader :position
|
11
|
+
|
12
|
+
# @!attribute [r] name
|
13
|
+
# @return [String] the name of the set
|
8
14
|
attr_reader :name
|
15
|
+
|
16
|
+
# @!attribute [r] songs
|
17
|
+
# @return [Array<Song>] the songs belonging to the set
|
9
18
|
attr_reader :songs
|
10
19
|
|
20
|
+
# @param attrs [Hash] the attributes hash
|
21
|
+
# @option attrs [Integer] :position the set position
|
22
|
+
# @option attrs [Integer] :name the set name
|
23
|
+
#
|
24
|
+
# @api private
|
11
25
|
def initialize(attrs={})
|
12
26
|
@songs = []
|
13
27
|
@position = attrs[:position]
|
@@ -1,21 +1,37 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
# @api private
|
4
3
|
module PhishDotNetClient
|
4
|
+
|
5
|
+
# This class represents the parsed data from the 'setlistdata' field.
|
5
6
|
class Setlist
|
6
7
|
|
8
|
+
# @!attribute [r] sets
|
9
|
+
# @return [Array<Set>] the setlist's sets
|
7
10
|
attr_reader :sets
|
11
|
+
|
12
|
+
# @!attribute [r] footnotes
|
13
|
+
# @return [Hash<Integer, Hash<Symbol, String>>] the setlist's footnotes
|
8
14
|
attr_reader :footnotes
|
9
15
|
|
16
|
+
# @param setlistdata [String] the setlistdata string
|
17
|
+
#
|
18
|
+
# @api private
|
10
19
|
def initialize(setlistdata)
|
11
20
|
@sets, @footnotes = self.class.parse_setlistdata(setlistdata)
|
12
21
|
end
|
13
22
|
|
23
|
+
# @return [Array<Song>] all songs in the setlist
|
14
24
|
def songs
|
15
25
|
return @sets.map(&:songs).reduce([]){|memo,songs| memo += songs }
|
16
26
|
end
|
17
27
|
|
18
28
|
# @api private
|
29
|
+
#
|
30
|
+
# Does the work of parsing the setlistdata.
|
31
|
+
#
|
32
|
+
# @param setlistdata [String] the setlistdata string
|
33
|
+
#
|
34
|
+
# @return [Array<(Array<Set>, Hash)>] the parsed sets and footnotes
|
19
35
|
def self.parse_setlistdata(setlistdata)
|
20
36
|
doc = Nokogiri::HTML(setlistdata)
|
21
37
|
|
@@ -36,14 +52,14 @@ module PhishDotNetClient
|
|
36
52
|
slug_instances = {}
|
37
53
|
|
38
54
|
setnodes = doc.css(".pnetset")
|
39
|
-
position_in_show =
|
55
|
+
position_in_show = 0
|
40
56
|
|
41
57
|
setnodes.each_with_index do |n,set_index|
|
42
58
|
setname = n.css(".pnetsetlabel").first.content
|
43
|
-
set = Set.new(:name => setname.sub!(/:\z/, ''), :position => set_index
|
59
|
+
set = Set.new(:name => setname.sub!(/:\z/, ''), :position => set_index)
|
44
60
|
songs_doc = n.css("a")
|
45
61
|
songs_doc.each_with_index do |song,song_index|
|
46
|
-
position_in_set = song_index
|
62
|
+
position_in_set = song_index
|
47
63
|
title = song.content
|
48
64
|
url = song.attr('href')
|
49
65
|
slug = URI.parse(url).path
|
@@ -63,7 +79,7 @@ module PhishDotNetClient
|
|
63
79
|
position_in_show += 1
|
64
80
|
end
|
65
81
|
|
66
|
-
transitions_text = n.content
|
82
|
+
transitions_text = n.content # strips html tags
|
67
83
|
transitions_tokens += tokenize_transitions_text(transitions_text, transitions_tokens)
|
68
84
|
|
69
85
|
sets << set
|
@@ -75,6 +91,15 @@ module PhishDotNetClient
|
|
75
91
|
end
|
76
92
|
|
77
93
|
# @api private
|
94
|
+
#
|
95
|
+
# Adds footnotes to their associated songs and adds transition information
|
96
|
+
# between songs.
|
97
|
+
#
|
98
|
+
# @param tokens [Array<Hash <Symbol, Object>>] the tokens to augment with
|
99
|
+
# @param songs [Array<Song>] the songs to augment
|
100
|
+
# @param footnotes [Hash<Integer, Hash<Symbol, String>>] the footnotes to augment with
|
101
|
+
#
|
102
|
+
# @return [void]
|
78
103
|
def self.augment_songs(tokens, songs, footnotes)
|
79
104
|
songs = Array.new(songs) # make a copy
|
80
105
|
|
@@ -113,8 +138,18 @@ module PhishDotNetClient
|
|
113
138
|
end
|
114
139
|
|
115
140
|
# @api private
|
141
|
+
#
|
142
|
+
# Tokenizes the html-stripped setlistdata text.
|
143
|
+
#
|
144
|
+
# @param transitions_text [String] the text to tokenize
|
145
|
+
# @param existing_tokens [Array<Hash<Symbol, Object>>] tokens of already
|
146
|
+
# parsed text, so that repeat songs can be detected.
|
147
|
+
#
|
148
|
+
# @raise [RuntimeError] if the transitions_text could not be parsed
|
149
|
+
#
|
150
|
+
# @return [Array<Hash<Symbol, Object>>]
|
116
151
|
def self.tokenize_transitions_text(transitions_text, existing_tokens=[])
|
117
|
-
|
152
|
+
rules = []
|
118
153
|
|
119
154
|
# Account for multiple songs with the same title in a song list
|
120
155
|
song_title_counts = {}
|
@@ -126,46 +161,47 @@ module PhishDotNetClient
|
|
126
161
|
end
|
127
162
|
end
|
128
163
|
|
129
|
-
|
164
|
+
rules.push(/\A[a-z0-9\s]+:/i => lambda do |match|
|
130
165
|
return { type: :set_name, name: match.to_s.strip.sub(':', '') }
|
131
166
|
end)
|
132
167
|
|
133
|
-
|
168
|
+
rules.push(/\A[äa-z0-9\-?\.!:\/'\s\(\)]+[a-z0-9\)?!']/i => lambda do |match|
|
134
169
|
title = match.to_s.strip
|
135
170
|
song_title_counts[title] ||= 0
|
136
171
|
song_title_counts[title] += 1
|
137
172
|
return { type: :song, title: title, instance: song_title_counts[title] }
|
138
173
|
end)
|
139
174
|
|
140
|
-
|
175
|
+
rules.push(/\A\[(?<num>\d+)\]/ => lambda do |match|
|
141
176
|
return { type: :note_ref, number: match[:num].to_i }
|
142
177
|
end)
|
143
178
|
|
144
|
-
|
179
|
+
rules.push(/\A,/ => lambda do |match|
|
145
180
|
return { type: :transition, transition_type: :no_segue }
|
146
181
|
end)
|
147
182
|
|
148
|
-
|
183
|
+
rules.push(/\A>/ => lambda do |match|
|
149
184
|
return { type: :transition, transition_type: :segue }
|
150
185
|
end)
|
151
186
|
|
152
|
-
|
187
|
+
rules.push(/\A->/ => lambda do |match|
|
153
188
|
return { type: :transition, transition_type: :deep_segue }
|
154
189
|
end)
|
155
190
|
|
156
|
-
|
191
|
+
rules.push(/\A\s+/ => lambda do |match|
|
157
192
|
return nil
|
158
193
|
end)
|
159
194
|
|
160
195
|
parsed_set = []
|
161
196
|
|
162
197
|
until transitions_text.empty?
|
163
|
-
matched = false
|
198
|
+
matched = false # keeps track of whether the transitions_text matched
|
199
|
+
# any rule. raise error if there no match.
|
164
200
|
|
165
|
-
|
166
|
-
|
201
|
+
rules.each do |rule|
|
202
|
+
rule_regex, processor = rule.keys.first, rule.values.first
|
167
203
|
|
168
|
-
if transitions_text.slice!(
|
204
|
+
if transitions_text.slice!(rule_regex)
|
169
205
|
matched = true
|
170
206
|
token = processor.call($~)
|
171
207
|
parsed_set.push(token) if token
|
@@ -1,18 +1,58 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
# @api private
|
4
3
|
module PhishDotNetClient
|
4
|
+
|
5
|
+
# This class represents a set from the 'setlistdata' field.
|
5
6
|
class Song
|
7
|
+
|
8
|
+
# @!attribute [r] title
|
9
|
+
# @return [String] the song title
|
6
10
|
attr_reader :title
|
11
|
+
|
12
|
+
# @!attribute [r] url
|
13
|
+
# @return [String] the song url
|
7
14
|
attr_reader :url
|
15
|
+
|
16
|
+
# @!attribute [r] slug
|
17
|
+
# @return [String] the song slug (not unique). slug+instance can be used to
|
18
|
+
# create a unique slug when the setlist has the same song more than once.
|
8
19
|
attr_reader :slug
|
20
|
+
|
21
|
+
# @!attribute [r] instance
|
22
|
+
# @return [Integer] the instance number of the song. Normally will be +1+ since
|
23
|
+
# most shows don't have multiple instances of the same song.
|
9
24
|
attr_reader :instance
|
25
|
+
|
26
|
+
# @!attribute [r] position_in_set
|
27
|
+
# @return [String] the position of the song in it's set, indexed starting at 0
|
10
28
|
attr_reader :position_in_set
|
29
|
+
|
30
|
+
# @!attribute [r] position_in_show
|
31
|
+
# @return [String] the position of the song in the show, indexed starting at 0
|
11
32
|
attr_reader :position_in_show
|
33
|
+
|
34
|
+
# @!attribute [r] footnotes
|
35
|
+
# @return [Array<Integer>] the song's foonote numbers, used to lookup footnotes
|
36
|
+
# via {Setlist#footnotes}.
|
12
37
|
attr_reader :footnotes
|
38
|
+
|
39
|
+
# @!attribute pre_transition
|
40
|
+
# @return [SongTransition] the transition to the previous song
|
13
41
|
attr_accessor :pre_transition
|
42
|
+
|
43
|
+
# @!attribute post_transition
|
44
|
+
# @return [SongTransition] the transition to the next song
|
14
45
|
attr_accessor :post_transition
|
15
46
|
|
47
|
+
# @api private
|
48
|
+
#
|
49
|
+
# @param attrs [Hash<Symbol, Object>] the song attributes
|
50
|
+
# @option attrs [String] :title the song title
|
51
|
+
# @option attrs [String] :url the song url
|
52
|
+
# @option attrs [String] :slug the song slug
|
53
|
+
# @option attrs [Integer] :instance the instance number of the song
|
54
|
+
# @option attrs [Integer] :position_in_set set position of the song
|
55
|
+
# @option attrs [Integer] :position_in_show show position of the song
|
16
56
|
def initialize(attrs={})
|
17
57
|
@title = attrs[:title]
|
18
58
|
@url = attrs[:url]
|
@@ -23,6 +63,7 @@ module PhishDotNetClient
|
|
23
63
|
@footnotes = []
|
24
64
|
end
|
25
65
|
|
66
|
+
# @return [String] the song along with pre and post transitions
|
26
67
|
def to_s
|
27
68
|
s = StringIO.new
|
28
69
|
|
@@ -1,13 +1,33 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
# @api private
|
4
3
|
module PhishDotNetClient
|
4
|
+
|
5
|
+
# This class represents a transition between two songs.
|
5
6
|
class SongTransition
|
6
7
|
|
8
|
+
# @!attribute [r] type
|
9
|
+
#
|
10
|
+
# Valid types:
|
11
|
+
# * :no_segue
|
12
|
+
# * :segue (aka '>')
|
13
|
+
# * :deep_segue (aka '->')
|
14
|
+
#
|
15
|
+
# @return [Symbol] the transition type
|
7
16
|
attr_reader :type
|
17
|
+
|
18
|
+
# @!attribute [r] from_song
|
19
|
+
# @return [Song] the song going into the transition
|
8
20
|
attr_reader :from_song
|
21
|
+
|
22
|
+
# @!attribute [r] to_song
|
23
|
+
# @return [Song] the song going out the transition
|
9
24
|
attr_reader :to_song
|
10
25
|
|
26
|
+
# @api private
|
27
|
+
#
|
28
|
+
# @param type [Symbol] the transition type
|
29
|
+
# @param from_song [Song] the from song
|
30
|
+
# @param to_song [Song] the to song
|
11
31
|
def initialize(type, from_song, to_song)
|
12
32
|
@type = type
|
13
33
|
@from_song = from_song
|
@@ -8,24 +8,26 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = PhishDotNetClient::VERSION
|
9
9
|
spec.date = Date.today.to_s
|
10
10
|
spec.licenses = ['MIT']
|
11
|
-
spec.authors = [
|
12
|
-
spec.email = [
|
13
|
-
spec.homepage =
|
11
|
+
spec.authors = ['Alexander Bird']
|
12
|
+
spec.email = ['alexebird@gmail.com']
|
13
|
+
spec.homepage = 'https://github.com/alexebird/phish_dot_net_client'
|
14
14
|
spec.summary = %q{Phish.net API client with setlist parsing}
|
15
15
|
spec.description = %q{Calls any Phish.net API method. Supports authentication. Parses 'setlistdata' fields.}
|
16
16
|
|
17
|
-
spec.required_ruby_version = '>= 1.9.
|
17
|
+
spec.required_ruby_version = '>= 1.9.2'
|
18
18
|
spec.required_rubygems_version = '>= 1.3.6'
|
19
19
|
|
20
|
-
spec.
|
21
|
-
spec.
|
22
|
-
spec.
|
23
|
-
spec.add_development_dependency 'rake'
|
20
|
+
spec.add_runtime_dependency 'rest-client', '~> 1.6.7'
|
21
|
+
spec.add_runtime_dependency 'oj', '~> 2.1.7'
|
22
|
+
spec.add_runtime_dependency 'nokogiri', '~> 1.6.0'
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
24
24
|
spec.add_development_dependency 'rspec', '~> 2.14'
|
25
25
|
spec.add_development_dependency 'yard', '~> 0.8'
|
26
|
+
spec.add_development_dependency 'redcarpet', '~> 3.0'
|
27
|
+
spec.add_development_dependency 'simplecov', '~> 0.7.1'
|
26
28
|
|
27
29
|
spec.files = `git ls-files`.split($/)
|
28
30
|
spec.test_files = spec.files.grep(%r{^spec/})
|
29
31
|
|
30
|
-
spec.require_paths = [
|
32
|
+
spec.require_paths = ['lib']
|
31
33
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,7 +1,14 @@
|
|
1
|
+
if ENV["COV"]
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.start
|
4
|
+
end
|
5
|
+
|
1
6
|
require 'bundler'
|
2
7
|
Bundler.require :development
|
3
8
|
|
4
|
-
|
9
|
+
lib = File.expand_path('../lib/', __FILE__)
|
10
|
+
$:.unshift lib unless $:.include?(lib)
|
11
|
+
require 'phish_dot_net_client'
|
5
12
|
|
6
13
|
RSpec.configure do |config|
|
7
14
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
- 0
|
8
7
|
- 1
|
9
|
-
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alexander Bird
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2013-10-
|
17
|
+
date: 2013-10-28 00:00:00 -04:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
36
|
+
name: oj
|
37
37
|
prerelease: false
|
38
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
@@ -41,10 +41,10 @@ dependencies:
|
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
segments:
|
44
|
+
- 2
|
44
45
|
- 1
|
45
|
-
-
|
46
|
-
|
47
|
-
version: 1.8.0
|
46
|
+
- 7
|
47
|
+
version: 2.1.7
|
48
48
|
type: :runtime
|
49
49
|
version_requirements: *id002
|
50
50
|
- !ruby/object:Gem::Dependency
|
@@ -68,11 +68,12 @@ dependencies:
|
|
68
68
|
requirement: &id004 !ruby/object:Gem::Requirement
|
69
69
|
none: false
|
70
70
|
requirements:
|
71
|
-
- -
|
71
|
+
- - ~>
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
segments:
|
74
|
+
- 10
|
74
75
|
- 0
|
75
|
-
version: "0"
|
76
|
+
version: "10.0"
|
76
77
|
type: :development
|
77
78
|
version_requirements: *id004
|
78
79
|
- !ruby/object:Gem::Dependency
|
@@ -103,6 +104,35 @@ dependencies:
|
|
103
104
|
version: "0.8"
|
104
105
|
type: :development
|
105
106
|
version_requirements: *id006
|
107
|
+
- !ruby/object:Gem::Dependency
|
108
|
+
name: redcarpet
|
109
|
+
prerelease: false
|
110
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
111
|
+
none: false
|
112
|
+
requirements:
|
113
|
+
- - ~>
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
segments:
|
116
|
+
- 3
|
117
|
+
- 0
|
118
|
+
version: "3.0"
|
119
|
+
type: :development
|
120
|
+
version_requirements: *id007
|
121
|
+
- !ruby/object:Gem::Dependency
|
122
|
+
name: simplecov
|
123
|
+
prerelease: false
|
124
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
125
|
+
none: false
|
126
|
+
requirements:
|
127
|
+
- - ~>
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
segments:
|
130
|
+
- 0
|
131
|
+
- 7
|
132
|
+
- 1
|
133
|
+
version: 0.7.1
|
134
|
+
type: :development
|
135
|
+
version_requirements: *id008
|
106
136
|
description: Calls any Phish.net API method. Supports authentication. Parses 'setlistdata' fields.
|
107
137
|
email:
|
108
138
|
- alexebird@gmail.com
|
@@ -116,7 +146,7 @@ files:
|
|
116
146
|
- .gitignore
|
117
147
|
- .rspec
|
118
148
|
- Gemfile
|
119
|
-
-
|
149
|
+
- History.md
|
120
150
|
- README.md
|
121
151
|
- Rakefile
|
122
152
|
- lib/phish_dot_net_client.rb
|
@@ -149,8 +179,8 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
179
|
segments:
|
150
180
|
- 1
|
151
181
|
- 9
|
152
|
-
-
|
153
|
-
version: 1.9.
|
182
|
+
- 2
|
183
|
+
version: 1.9.2
|
154
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
185
|
none: false
|
156
186
|
requirements:
|
data/Gemfile.lock
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: https://rubygems.org/
|
3
|
-
specs:
|
4
|
-
diff-lcs (1.2.4)
|
5
|
-
json (1.8.0)
|
6
|
-
mime-types (1.25)
|
7
|
-
mini_portile (0.5.1)
|
8
|
-
nokogiri (1.6.0)
|
9
|
-
mini_portile (~> 0.5.0)
|
10
|
-
rake (10.1.0)
|
11
|
-
rest-client (1.6.7)
|
12
|
-
mime-types (>= 1.16)
|
13
|
-
rspec (2.14.1)
|
14
|
-
rspec-core (~> 2.14.0)
|
15
|
-
rspec-expectations (~> 2.14.0)
|
16
|
-
rspec-mocks (~> 2.14.0)
|
17
|
-
rspec-core (2.14.5)
|
18
|
-
rspec-expectations (2.14.3)
|
19
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
20
|
-
rspec-mocks (2.14.3)
|
21
|
-
yard (0.8.7.2)
|
22
|
-
|
23
|
-
PLATFORMS
|
24
|
-
ruby
|
25
|
-
|
26
|
-
DEPENDENCIES
|
27
|
-
json (~> 1.8.0)
|
28
|
-
nokogiri (~> 1.6.0)
|
29
|
-
rake
|
30
|
-
rest-client (~> 1.6.7)
|
31
|
-
rspec
|
32
|
-
yard
|