musicgraph 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.
@@ -0,0 +1,8 @@
1
+ module MusicGraph
2
+ describe Album do
3
+
4
+ it "exists" do
5
+ expect(MusicGraph::Album)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,258 @@
1
+ module MusicGraph
2
+ describe Artist do
3
+
4
+ it "exists" do
5
+ expect(MusicGraph::Artist)
6
+ end
7
+
8
+ describe "#search" do
9
+ it "returns artist name search results" do
10
+ VCR.use_cassette("artist", record: :new_episodes) do
11
+ artist_name = "wilco"
12
+ artists = MusicGraph::Artist.search(artist_name)
13
+
14
+ expect(artists).to_not be_empty
15
+ expect(artists.first).to be_a Artist
16
+ expect(artists.first.name).to eql("Wilco")
17
+ end
18
+ end
19
+
20
+ it "accepts hash and returns artist name search results" do
21
+ VCR.use_cassette("artist", record: :new_episodes) do
22
+ params = {
23
+ name: "local natives"
24
+ }
25
+ artists = MusicGraph::Artist.search(params)
26
+
27
+ expect(artists).to_not be_empty
28
+ expect(artists.first).to be_a Artist
29
+ expect(artists.first.name).to eql("Local Natives")
30
+ end
31
+ end
32
+
33
+ it "accepts hash and returns similar to search results" do
34
+ VCR.use_cassette("artist", record: :new_episodes) do
35
+ params = {
36
+ similar_to: "Pink Floyd"
37
+ }
38
+ artists = MusicGraph::Artist.search(params)
39
+
40
+ expect(artists).to_not be_empty
41
+ expect(artists.length).to eql(20)
42
+ expect(artists.first).to be_a Artist
43
+ expect(artists.first.name).to eql("David Gilmour")
44
+ expect(artists.last.name).to eql("Eric Clapton")
45
+ end
46
+ end
47
+
48
+ it "accepts hash and returns decade results" do
49
+ VCR.use_cassette("artist", record: :new_episodes) do
50
+ params = {
51
+ decade: "1990s"
52
+ }
53
+ artists = MusicGraph::Artist.search(params)
54
+
55
+ expect(artists).to_not be_empty
56
+ expect(artists.length).to eql(20)
57
+ expect(artists.first).to be_a Artist
58
+ expect(artists.first.name).to eql("Lil Wayne")
59
+ expect(artists.last.name).to eql("Juicy J")
60
+ end
61
+ end
62
+
63
+ it "accepts hash and returns genre results" do
64
+ VCR.use_cassette("artist", record: :new_episodes) do
65
+ params = {
66
+ genre: "Soul/R&B"
67
+ }
68
+ artists = MusicGraph::Artist.search(params)
69
+
70
+ expect(artists).to_not be_empty
71
+ expect(artists.length).to eql(20)
72
+ expect(artists.first).to be_a Artist
73
+ expect(artists.first.name).to eql("Chris Brown")
74
+ expect(artists.last.name).to eql("Amy Winehouse")
75
+ end
76
+ end
77
+
78
+ it "accepts hash and returns gender results" do
79
+ VCR.use_cassette("artist", record: :new_episodes) do
80
+ params = {
81
+ gender: "female"
82
+ }
83
+ artists = MusicGraph::Artist.search(params)
84
+
85
+ expect(artists).to_not be_empty
86
+ expect(artists.length).to eql(20)
87
+ expect(artists.first).to be_a Artist
88
+ expect(artists.first.name).to eql("Sasha")
89
+ expect(artists.last.name).to eql("Shakira")
90
+ end
91
+ end
92
+
93
+ it "accepts hash and returns country results" do
94
+ VCR.use_cassette("artist", record: :new_episodes) do
95
+ params = {
96
+ country: "america"
97
+ }
98
+ artists = MusicGraph::Artist.search(params)
99
+
100
+ expect(artists).to_not be_empty
101
+ expect(artists.length).to eql(20)
102
+ expect(artists.first).to be_a Artist
103
+ expect(artists.first.name).to eql("Lil Wayne")
104
+ expect(artists.last.name).to eql("Juicy J")
105
+ end
106
+ end
107
+
108
+ it "accepts hash and returns limited results" do
109
+ VCR.use_cassette("artist", record: :new_episodes) do
110
+ params = {
111
+ similar_to: "Pink Floyd",
112
+ limit: 5
113
+ }
114
+ artists = MusicGraph::Artist.search(params)
115
+
116
+ expect(artists).to_not be_empty
117
+ expect(artists.length).to eql(5)
118
+ expect(artists.first).to be_a Artist
119
+ expect(artists.first.name).to eql("David Gilmour")
120
+ expect(artists.last.name).to_not eql("Eric Clapton")
121
+ end
122
+ end
123
+
124
+ it "accepts hash and returns offset results" do
125
+ VCR.use_cassette("artist", record: :new_episodes) do
126
+ params = {
127
+ similar_to: "Pink Floyd",
128
+ offset: 5
129
+ }
130
+ artists = MusicGraph::Artist.search(params)
131
+
132
+ expect(artists).to_not be_empty
133
+ expect(artists.length).to eql(7)
134
+ expect(artists.first).to be_a Artist
135
+ expect(artists.first.name).to_not eql("David Gilmour")
136
+ expect(artists.last.name).to eql("Hess Is More")
137
+ end
138
+ end
139
+ end
140
+
141
+ describe "#suggest" do
142
+ it "returns a list of matches" do
143
+ VCR.use_cassette("artist", record: :new_episodes) do
144
+ query = "gree"
145
+ artists = MusicGraph::Artist.suggest(query)
146
+
147
+ expect(artists.length).to eql(20)
148
+ expect(artists).to be_a Array
149
+ expect(artists.first).to be_a Artist
150
+ expect(artists.first.name).to eql("Green Day")
151
+ end
152
+ end
153
+ end
154
+
155
+ it "accepts hash and returns suggestions" do
156
+ VCR.use_cassette("artist", record: :new_episodes) do
157
+ params = {
158
+ prefix: "gree"
159
+ }
160
+ artists = MusicGraph::Artist.suggest(params)
161
+
162
+ expect(artists.length).to eql(20)
163
+ expect(artists).to be_a Array
164
+ expect(artists.first).to be_a Artist
165
+ expect(artists.first.name).to eql("Green Day")
166
+ end
167
+ end
168
+ end
169
+
170
+ describe "#find" do
171
+ it "returns a single artist" do
172
+ VCR.use_cassette("artist", record: :new_episodes) do
173
+ artist_id = "e4de0d41-a6b5-11e0-b446-00251188dd67"
174
+ artist = MusicGraph::Artist.find(artist_id)
175
+
176
+ expect(artist).to be_a Artist
177
+ expect(artist.seven_digital_id).to eql("5843")
178
+ expect(artist.main_genre).to eql("alternative/indie")
179
+ expect(artist.country_of_origin).to eql("United States of America")
180
+ expect(artist.entity_type).to eql("artist")
181
+ expect(artist.artist_ref_id).to eql("2918")
182
+ expect(artist.vevo_id).to eql("05158a95-fe62-42df-8359-e4b6a2c8bf5d")
183
+ expect(artist.sort_name).to eql("Beck")
184
+ expect(artist.gender).to eql("Male")
185
+ expect(artist.rhapsody_id).to eql("7053")
186
+ expect(artist.id).to eql("e4de0d41-a6b5-11e0-b446-00251188dd67")
187
+ expect(artist.decade).to eql("1990s / 2000s / 2010s")
188
+ expect(artist.name).to eql("Beck")
189
+ end
190
+ end
191
+ end
192
+
193
+
194
+ describe "#edges" do
195
+ it "returns edges for an artist" do
196
+ VCR.use_cassette("artist", record: :new_episodes) do
197
+ artist = MusicGraph::Artist.find("e4de0d41-a6b5-11e0-b446-00251188dd67")
198
+
199
+ expect(artist.edges).to be_a Array
200
+ expect(artist.edges).to eql(["albums", "similar", "tracks"])
201
+ end
202
+ end
203
+ end
204
+
205
+ describe "#metadata" do
206
+ it "returns avilable metadata for an artist" do
207
+ VCR.use_cassette("artist", record: :new_episodes) do
208
+ artist = MusicGraph::Artist.find("e4de0d41-a6b5-11e0-b446-00251188dd67")
209
+
210
+ expect(artist.metadata).to be_a Hash
211
+ end
212
+ end
213
+
214
+ it "filters by given fields" do
215
+ VCR.use_cassette("artist", record: :new_episodes) do
216
+ filters = ["id", "name"]
217
+ artist = MusicGraph::Artist.find("e4de0d41-a6b5-11e0-b446-00251188dd67", filters)
218
+
219
+ expect(artist.name).to eql("Beck")
220
+ expect(artist.gender).to be(nil)
221
+ end
222
+ end
223
+ end
224
+
225
+ describe "#similar" do
226
+ it "returns similar artists for an artist" do
227
+ VCR.use_cassette("artist", record: :new_episodes) do
228
+ artist = MusicGraph::Artist.find("e4de0d41-a6b5-11e0-b446-00251188dd67")
229
+
230
+ expect(artist.similar).to be_a Array
231
+ expect(artist.similar.first).to be_a Artist
232
+ expect(artist.similar.first.name).to eql("Bob Forrest")
233
+ end
234
+ end
235
+ end
236
+
237
+ describe "#albums" do
238
+ it "returns albums for an artist" do
239
+ VCR.use_cassette("artist", record: :new_episodes) do
240
+ artist = MusicGraph::Artist.find("e4de0d41-a6b5-11e0-b446-00251188dd67")
241
+
242
+ expect(artist.albums).to be_a Array
243
+ expect(artist.albums.first).to be_a Album
244
+ end
245
+ end
246
+ end
247
+
248
+ describe "#tracks" do
249
+ it "returns tracks for an artist" do
250
+ VCR.use_cassette("artist", record: :new_episodes) do
251
+ artist = MusicGraph::Artist.find("e4de0d41-a6b5-11e0-b446-00251188dd67")
252
+
253
+ expect(artist.tracks).to be_a Array
254
+ expect(artist.tracks.first).to be_a Track
255
+ end
256
+ end
257
+ end
258
+ end
@@ -0,0 +1,8 @@
1
+ module MusicGraph
2
+ describe Track do
3
+
4
+ it "exists" do
5
+ expect(MusicGraph::Track)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ module MusicGraph
2
+ describe "api key" do
3
+
4
+ it "must be assignable" do
5
+ MusicGraph.api_key = 'new_key'
6
+ expect(MusicGraph.api_key).to eql('new_key')
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,104 @@
1
+ require 'musicgraph'
2
+ require 'vcr'
3
+ require 'dotenv'
4
+
5
+ Dotenv.load
6
+ MusicGraph.api_key = ENV["MUSICGRAPH_API_KEY"]
7
+
8
+ # This file was generated by the `rspec --init` command. Conventionally, all
9
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
10
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
11
+ # this file to always be loaded, without a need to explicitly require it in any
12
+ # files.
13
+ #
14
+ # Given that it is always loaded, you are encouraged to keep this file as
15
+ # light-weight as possible. Requiring heavyweight dependencies from this file
16
+ # will add to the boot time of your test suite on EVERY test run, even for an
17
+ # individual file that may not need all of that loaded. Instead, consider making
18
+ # a separate helper file that requires the additional dependencies and performs
19
+ # the additional setup, and require it from the spec files that actually need
20
+ # it.
21
+ #
22
+ # The `.rspec` file also contains a few flags that are not defaults but that
23
+ # users commonly want.
24
+ #
25
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
26
+ RSpec.configure do |config|
27
+ # rspec-expectations config goes here. You can use an alternate
28
+ # assertion/expectation library such as wrong or the stdlib/minitest
29
+ # assertions if you prefer.
30
+ config.expect_with :rspec do |expectations|
31
+ # This option will default to `true` in RSpec 4. It makes the `description`
32
+ # and `failure_message` of custom matchers include text for helper methods
33
+ # defined using `chain`, e.g.:
34
+ # be_bigger_than(2).and_smaller_than(4).description
35
+ # # => "be bigger than 2 and smaller than 4"
36
+ # ...rather than:
37
+ # # => "be bigger than 2"
38
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
39
+ end
40
+
41
+ # rspec-mocks config goes here. You can use an alternate test double
42
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
43
+ config.mock_with :rspec do |mocks|
44
+ # Prevents you from mocking or stubbing a method that does not exist on
45
+ # a real object. This is generally recommended, and will default to
46
+ # `true` in RSpec 4.
47
+ mocks.verify_partial_doubles = true
48
+ end
49
+
50
+ # The settings below are suggested to provide a good initial experience
51
+ # with RSpec, but feel free to customize to your heart's content.
52
+ =begin
53
+ # These two settings work together to allow you to limit a spec run
54
+ # to individual examples or groups you care about by tagging them with
55
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
56
+ # get run.
57
+ config.filter_run :focus
58
+ config.run_all_when_everything_filtered = true
59
+
60
+ # Limits the available syntax to the non-monkey patched syntax that is
61
+ # recommended. For more details, see:
62
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
63
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
64
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
65
+ config.disable_monkey_patching!
66
+
67
+ # This setting enables warnings. It's recommended, but in some cases may
68
+ # be too noisy due to issues in dependencies.
69
+ config.warnings = true
70
+
71
+ # Many RSpec users commonly either run the entire suite or an individual
72
+ # file, and it's useful to allow more verbose output when running an
73
+ # individual spec file.
74
+ if config.files_to_run.one?
75
+ # Use the documentation formatter for detailed output,
76
+ # unless a formatter has already been configured
77
+ # (e.g. via a command-line flag).
78
+ config.default_formatter = 'doc'
79
+ end
80
+
81
+ # Print the 10 slowest examples and example groups at the
82
+ # end of the spec run, to help surface which specs are running
83
+ # particularly slow.
84
+ config.profile_examples = 10
85
+
86
+ # Run specs in random order to surface order dependencies. If you find an
87
+ # order dependency and want to debug it, you can fix the order by providing
88
+ # the seed, which is printed after each run.
89
+ # --seed 1234
90
+ config.order = :random
91
+
92
+ # Seed global randomization in this process using the `--seed` CLI option.
93
+ # Setting this allows you to use `--seed` to deterministically reproduce
94
+ # test failures related to randomization by passing the same `--seed` value
95
+ # as the one that triggered the failure.
96
+ Kernel.srand config.seed
97
+ =end
98
+
99
+ VCR.configure do |c|
100
+ c.cassette_library_dir = "spec/cassettes"
101
+ c.hook_into :webmock
102
+ c.filter_sensitive_data("<API_KEY>") { ENV["MUSICGRAPH_API_KEY"] }
103
+ end
104
+ end
metadata ADDED
@@ -0,0 +1,194 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: musicgraph
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dave Powers
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: dotenv
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: faraday
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: json
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Web service wrapper for MusicGraph API
140
+ email:
141
+ - djpowers89@gmail.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - Gemfile
149
+ - LICENSE.txt
150
+ - README.md
151
+ - Rakefile
152
+ - lib/musicgraph.rb
153
+ - lib/musicgraph/album.rb
154
+ - lib/musicgraph/artist.rb
155
+ - lib/musicgraph/track.rb
156
+ - lib/musicgraph/version.rb
157
+ - musicgraph.gemspec
158
+ - spec/cassettes/artist.yml
159
+ - spec/musicgraph/album_spec.rb
160
+ - spec/musicgraph/artist_spec.rb
161
+ - spec/musicgraph/track_spec.rb
162
+ - spec/musicgraph_spec.rb
163
+ - spec/spec_helper.rb
164
+ homepage: https://github.com/djpowers/musicgraph
165
+ licenses:
166
+ - MIT
167
+ metadata: {}
168
+ post_install_message:
169
+ rdoc_options: []
170
+ require_paths:
171
+ - lib
172
+ required_ruby_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ required_rubygems_version: !ruby/object:Gem::Requirement
178
+ requirements:
179
+ - - ">="
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ requirements: []
183
+ rubyforge_project:
184
+ rubygems_version: 2.4.4
185
+ signing_key:
186
+ specification_version: 4
187
+ summary: Web service wrapper for MusicGraph API
188
+ test_files:
189
+ - spec/cassettes/artist.yml
190
+ - spec/musicgraph/album_spec.rb
191
+ - spec/musicgraph/artist_spec.rb
192
+ - spec/musicgraph/track_spec.rb
193
+ - spec/musicgraph_spec.rb
194
+ - spec/spec_helper.rb