itunes-client 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -0
- data/README.md +4 -0
- data/lib/itunes/track.rb +17 -3
- data/lib/itunes/version.rb +1 -1
- data/scripts/track/finder.tmpl.scpt +3 -4
- data/spec/itunes/track_spec.rb +24 -2
- metadata +30 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c734a94d492657fc1f459a7a04a5374cf3a27418
|
4
|
+
data.tar.gz: 03d40ce03b83d8d4040730d4e01a897a16ed650c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abe758fd74dde2e01b2546673d6dbbc20d1422d529bfbcd9f2594f8347bd0d079bf1e1fdeafb21a75fe93b6c40a2d1db1a54ff6f49017f36629fa14cd119c73e
|
7
|
+
data.tar.gz: a33cb6a4d4b094d3b25e55aeddbdc4fac3ac68ca7224ff5e5a64908420d21edf4a240a462d3378f81bda5e41dba431c45f5672d38442857746a9d74c2f4aeb15
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.1.0
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -68,3 +68,7 @@ track.stop
|
|
68
68
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
69
69
|
4. Push to the branch (`git push origin my-new-feature`)
|
70
70
|
5. Create new Pull Request
|
71
|
+
|
72
|
+
|
73
|
+
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/katsuma/itunes-client/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
74
|
+
|
data/lib/itunes/track.rb
CHANGED
@@ -59,7 +59,7 @@ module Itunes
|
|
59
59
|
self
|
60
60
|
end
|
61
61
|
|
62
|
-
def
|
62
|
+
def update(attributes)
|
63
63
|
raise ArgumentError.new('Invalid argument is given') unless attributes.is_a?(Hash)
|
64
64
|
|
65
65
|
records = update_attribute_records(attributes)
|
@@ -69,6 +69,7 @@ module Itunes
|
|
69
69
|
attributes.each { |key, val| send("#{key}=", val) }
|
70
70
|
self
|
71
71
|
end
|
72
|
+
alias_method :update_attributes, :update
|
72
73
|
|
73
74
|
def assign_attributes_by(track_attributes)
|
74
75
|
ATTRIBUTES.each { |attr| send("#{attr}=", track_attributes[attr.to_s]) }
|
@@ -77,8 +78,17 @@ module Itunes
|
|
77
78
|
def self.find_by(arg)
|
78
79
|
raise ArgumentError.new('nil argument is given') if arg.nil?
|
79
80
|
|
80
|
-
|
81
|
-
|
81
|
+
if arg.is_a?(Hash)
|
82
|
+
conditions = find_conditions(arg)
|
83
|
+
whose = 'whose'
|
84
|
+
elsif arg == :all
|
85
|
+
conditions = ''
|
86
|
+
whose = ''
|
87
|
+
else
|
88
|
+
raise ArgumentError.new('unsupported rgument is given')
|
89
|
+
end
|
90
|
+
|
91
|
+
script_name = generate_script_from_template('track/finder.tmpl.scpt', whose: whose, conditions: conditions)
|
82
92
|
track_response = execute_template_based_script(script_name)
|
83
93
|
|
84
94
|
tracks_attributes = ::JSON.parse(track_response)
|
@@ -89,6 +99,10 @@ module Itunes
|
|
89
99
|
end
|
90
100
|
end
|
91
101
|
|
102
|
+
def self.all
|
103
|
+
find_by(:all)
|
104
|
+
end
|
105
|
+
|
92
106
|
def self.find_conditions(args)
|
93
107
|
conditions = []
|
94
108
|
args.each do |key, val|
|
data/lib/itunes/version.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
tell application "iTunes"
|
2
|
-
set specified_tracks to (every track whose #{conditions})
|
3
|
-
|
4
|
-
|
2
|
+
set specified_tracks to (every track #{whose} #{conditions})
|
5
3
|
set json to "["
|
6
4
|
|
7
5
|
repeat with specified_track in specified_tracks
|
@@ -13,7 +11,8 @@ tell application "iTunes"
|
|
13
11
|
set end of props to ("\"album\":\"" & my escape_quote(album of specified_track) & "\",")
|
14
12
|
set end of props to ("\"artist\":\"" & my escape_quote(artist of specified_track) & "\",")
|
15
13
|
set end of props to ("\"track_count\":\"" & track count of specified_track & "\",")
|
16
|
-
set end of props to ("\"track_number\":\"" & track number of specified_track & "\"")
|
14
|
+
set end of props to ("\"track_number\":\"" & track number of specified_track & "\",")
|
15
|
+
set end of props to ("\"year\":\"" & year of specified_track & "\"")
|
17
16
|
set end of props to "}"
|
18
17
|
|
19
18
|
set json to json & props as string & ","
|
data/spec/itunes/track_spec.rb
CHANGED
@@ -87,8 +87,8 @@ describe Track do
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
describe '#
|
91
|
-
subject(:update) { track.
|
90
|
+
describe '#update' do
|
91
|
+
subject(:update) { track.update(attributes) }
|
92
92
|
|
93
93
|
context 'when nil argument is given' do
|
94
94
|
let(:attributes) { nil }
|
@@ -134,6 +134,13 @@ describe Track do
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
+
context 'when unsupported symbol is given' do
|
138
|
+
let(:arg) { :first }
|
139
|
+
it 'raises an ArgumentError' do
|
140
|
+
expect { find }.to raise_error(ArgumentError)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
137
144
|
context 'when hash argument is given' do
|
138
145
|
let(:arg) { { name: name } }
|
139
146
|
let(:new_scpt) { 'new.scpt' }
|
@@ -155,4 +162,19 @@ describe Track do
|
|
155
162
|
end
|
156
163
|
end
|
157
164
|
end
|
165
|
+
|
166
|
+
describe '.all' do
|
167
|
+
subject(:all) { Track.all }
|
168
|
+
|
169
|
+
it 'calls find_by(:all)' do
|
170
|
+
Track.stub(:generate_script_from_template).
|
171
|
+
and_return('new.scpt')
|
172
|
+
|
173
|
+
Track.stub(:execute_template_based_script).
|
174
|
+
with('new.scpt').
|
175
|
+
and_return([].to_json)
|
176
|
+
|
177
|
+
all
|
178
|
+
end
|
179
|
+
end
|
158
180
|
end
|
metadata
CHANGED
@@ -1,153 +1,153 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itunes-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ryo katsuma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 10.0.3
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 10.0.3
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 2.13.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.13.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rb-fsevent
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 0.9.3
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.9.3
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: guard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.8.1
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.8.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: guard-rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 3.0.2
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 3.0.2
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: growl
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 1.0.3
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 1.0.3
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: fakefs
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 0.4.2
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.4.2
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: simplecov
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: 0.7.1
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - ~>
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 0.7.1
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: coveralls
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - ~>
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: 0.6.6
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - ~>
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 0.6.6
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: pry
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - ~>
|
143
|
+
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: 0.9.12.2
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - ~>
|
150
|
+
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: 0.9.12.2
|
153
153
|
description: iTunes client with high level API
|
@@ -157,11 +157,11 @@ executables: []
|
|
157
157
|
extensions: []
|
158
158
|
extra_rdoc_files: []
|
159
159
|
files:
|
160
|
-
- .coveralls.yml
|
161
|
-
- .gitignore
|
162
|
-
- .rspec
|
163
|
-
- .ruby-version
|
164
|
-
- .travis.yml
|
160
|
+
- ".coveralls.yml"
|
161
|
+
- ".gitignore"
|
162
|
+
- ".rspec"
|
163
|
+
- ".ruby-version"
|
164
|
+
- ".travis.yml"
|
165
165
|
- Gemfile
|
166
166
|
- Guardfile
|
167
167
|
- LICENSE.txt
|
@@ -201,17 +201,17 @@ require_paths:
|
|
201
201
|
- lib
|
202
202
|
required_ruby_version: !ruby/object:Gem::Requirement
|
203
203
|
requirements:
|
204
|
-
- -
|
204
|
+
- - ">="
|
205
205
|
- !ruby/object:Gem::Version
|
206
206
|
version: '0'
|
207
207
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
208
208
|
requirements:
|
209
|
-
- -
|
209
|
+
- - ">="
|
210
210
|
- !ruby/object:Gem::Version
|
211
211
|
version: '0'
|
212
212
|
requirements: []
|
213
213
|
rubyforge_project:
|
214
|
-
rubygems_version: 2.0
|
214
|
+
rubygems_version: 2.2.0
|
215
215
|
signing_key:
|
216
216
|
specification_version: 4
|
217
217
|
summary: itunes-client provides a high level API like ActiveRecord style to control
|