simplespotify 0.0.4 → 0.0.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 275c077915e94bbc77954da7a3f52086605ada5c
4
- data.tar.gz: 3305af0e9ce1c4ce0173e4e105066a480d7be994
3
+ metadata.gz: f74a271d3c09a36dff2bbcf1f885b74996311ffc
4
+ data.tar.gz: eb05cb0c632776bf4a1576c4ef604aa496734d8a
5
5
  SHA512:
6
- metadata.gz: f0fb7b7d11c2036e19b8b1ef5a9570ba7ae3a438e83d8909d490764a7d46bc4dc2eccc8bc3b5d2ff30924128779f7951f9e1f850a488cf8a93f22378c269640b
7
- data.tar.gz: b36f4600f047f90f1c4d787af5e14ef557e9956ac0d541f6d3f72b8c392f37be4e88c927625e938c282d43a72db4c73de7f3486c32f1f6f405d5a0dd69b409db
6
+ metadata.gz: da712eb964a698edebfa530e8386f4cacdb5463360263f4a51c22ea0dbf2525abcd9bfd16f65f765b2a5f1cd1ec43467ca8df358cbf9168e3776c97fa0c17988
7
+ data.tar.gz: a59ee19b1730933aa0cc8f5ebed6e444ae26791b065152a4b97ef6bf68cdf587c5747dd80fbc6ed2d635954ce4125169ca51fda2c5178a12b1f7df02f8899a7c
@@ -0,0 +1,42 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ docker:
5
+ - image: circleci/ruby:2.4.1-node-browsers
6
+ working_directory: ~/repo
7
+
8
+ steps:
9
+ - checkout
10
+
11
+ - restore_cache:
12
+ keys:
13
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
14
+ - v1-dependencies-
15
+
16
+ - run:
17
+ name: install dependencies
18
+ command: |
19
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
20
+
21
+ - save_cache:
22
+ paths:
23
+ - ./vendor/bundle
24
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
25
+ - run:
26
+ name: run tests
27
+ command: |
28
+ mkdir /tmp/test-results
29
+ TEST_FILES="$(circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings)"
30
+
31
+ bundle exec rspec --format progress \
32
+ --format RspecJunitFormatter \
33
+ --out /tmp/test-results/rspec.xml \
34
+ --format progress \
35
+ ${TEST_FILES}
36
+
37
+ - store_test_results:
38
+ path: /tmp/test-results
39
+
40
+ - store_artifacts:
41
+ path: /tmp/test-results
42
+ destination: test-results
@@ -1,6 +1,6 @@
1
1
  # SimpleSpotify
2
2
  [![Gem Version](https://badge.fury.io/rb/simplespotify.svg)](http://badge.fury.io/rb/simplespotify)
3
- [![Travis Build](https://travis-ci.org/unRob/simplespotify.svg)](https://travis-ci.org/unRob/simplespotify)
3
+ [![Test status](https://circleci.com/gh/unRob/simplespotify.png)](https://circleci.com/gh/unRob/simplespotify)
4
4
 
5
5
  A lousy and very badly programmed Spotify API Client written in Ruby.
6
6
 
@@ -42,7 +42,7 @@ end
42
42
 
43
43
  #### API
44
44
 
45
- It's all syntactic sugar, but not the right kind that makes you happy and stuff, but the distasteful one that comes with coffee in an airplane. Seriously, it's not even properly tested!
45
+ It's all syntactic sugar, but not the right kind that makes you happy and stuff, but the distasteful one that comes with coffee in an airplane. Seriously, it's not even [properly tested](https://github.com/unRob/simplespotify/blob/master/spec/simplespotify/album_spec.rb)!
46
46
 
47
47
  ```ruby
48
48
  playlist = client.playlist(some_user_id, some_playlist_id)
data/bin/console CHANGED
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "spotify"
4
+ require "simplespotify"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
9
+ if File.exists? '../cli-initializer.rb'
10
+ require_relative '../cli-initializer.rb'
11
+ end
12
12
 
13
- require "irb"
14
- IRB.start
13
+ # (If you use this, don't forget to add pry to your Gemfile!)
14
+ require "pry"
15
+ Pry.start
@@ -0,0 +1,18 @@
1
+ module SimpleSpotify
2
+ module Actions
3
+ module Player
4
+
5
+ def recently_played limit=50, after=nil, before=nil
6
+ query = {
7
+ limit: limit,
8
+ }
9
+ query[:after] = after if after
10
+ query[:before] = before if before
11
+ response = get "me/player/recently-played", query: query
12
+
13
+ Model::Collection.of(SimpleSpotify::Model::PlayEvent, response.body)
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -3,8 +3,8 @@ module SimpleSpotify
3
3
 
4
4
  attr_accessor :id, :secret, :session, :market
5
5
 
6
- [:Albums, :Tracks, :Artists, :Users, :Browse, :Playlists].each do |action|
7
- require "simplespotify/actions/#{action.downcase}"
6
+ [:Albums, :Tracks, :Artists, :Users, :Browse, :Player, :Playlists].each do |action|
7
+ require_relative "actions/#{action.downcase}.rb"
8
8
  include Actions.const_get(action)
9
9
  end
10
10
 
@@ -25,7 +25,6 @@ module SimpleSpotify
25
25
  end
26
26
  end
27
27
 
28
-
29
28
  def search type, term, market: nil, limit: 20, offset: 0, filters: {}
30
29
  type = type.to_s.gsub(/s$/, '').to_sym
31
30
  types = [:album, :artist, :playlist, :track]
@@ -5,7 +5,7 @@ module SimpleSpotify
5
5
 
6
6
  attr_accessor :total
7
7
 
8
- def self.of type, data
8
+ def self.of type, collection
9
9
  if type.is_a? Class
10
10
  model = type;
11
11
  prop = type.to_s.split('::').last.downcase+'s'
@@ -15,12 +15,11 @@ module SimpleSpotify
15
15
  prop = model_name+'s'
16
16
  end
17
17
 
18
- prop = prop.to_sym
19
- data = {items: data} unless data.is_a? Hash
20
- prop = :items unless data.has_key?(prop)
18
+ collection = {items: collection} unless collection.is_a? Hash
19
+ prop = collection.has_key?(prop.to_sym) ? prop.to_sym : :items
21
20
 
22
- data[prop].map! {|item| model.new(item) }
23
- self.new(data)
21
+ collection[prop].map! {|item| model.new(item) }
22
+ self.new(collection)
24
23
  end
25
24
 
26
25
 
@@ -0,0 +1,19 @@
1
+ require 'time'
2
+
3
+ module SimpleSpotify
4
+ module Model
5
+
6
+ class PlayEvent
7
+ include Resource
8
+
9
+ prop :played_at
10
+ one :track
11
+
12
+ def initialize data
13
+ data[:played_at] = Time.parse(data[:played_at]) if data[:played_at].is_a? String
14
+ super data
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module SimpleSpotify
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/simplespotify.rb CHANGED
@@ -1,17 +1,17 @@
1
1
  require "simplespotify/version"
2
2
  require "simplespotify/constants"
3
+ require 'simplespotify/client'
3
4
  require 'httparty'
4
5
 
5
6
  module SimpleSpotify
6
7
  autoload :Authorization, 'simplespotify/authorization'
7
- autoload :Client, 'simplespotify/client'
8
8
  autoload :Request, 'simplespotify/request'
9
9
  autoload :Response, 'simplespotify/response'
10
10
  autoload :Error, 'simplespotify/errors'
11
11
  autoload :Resource, 'simplespotify/resource/resource'
12
12
 
13
13
  module Model
14
- [:Album, :Artist, :Image, :Track, :Collection, :Playlist, :Category, :User].each do |model|
14
+ [:Album, :Artist, :Image, :Track, :Collection, :PlayEvent, :Playlist, :Category, :User].each do |model|
15
15
  autoload model, "simplespotify/models/#{model.to_s.downcase}"
16
16
  end
17
17
  end
@@ -19,9 +19,11 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
- spec.add_development_dependency "bundler", "~> 1.8"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "rspec"
22
+ spec.add_development_dependency "bundler"
23
+ spec.add_development_dependency "pry"
24
+ spec.add_development_dependency "rake", "~> 12.0"
25
+ spec.add_development_dependency "rspec", "~> 3.6"
26
+ spec.add_development_dependency "rspec_junit_formatter"
25
27
 
26
28
  spec.add_runtime_dependency 'httparty'
27
29
  end
metadata CHANGED
@@ -1,45 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplespotify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Hidalgo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-05 00:00:00.000000000 Z
11
+ date: 2017-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
25
39
  - !ruby/object:Gem::Version
26
- version: '1.8'
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '10.0'
47
+ version: '12.0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '10.0'
54
+ version: '12.0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec_junit_formatter
43
71
  requirement: !ruby/object:Gem::Requirement
44
72
  requirements:
45
73
  - - ">="
@@ -73,11 +101,12 @@ executables: []
73
101
  extensions: []
74
102
  extra_rdoc_files: []
75
103
  files:
104
+ - ".circleci/config.yml"
76
105
  - ".gitignore"
77
106
  - ".rspec"
78
- - ".travis.yml"
79
107
  - Gemfile
80
108
  - LICENSE.md
109
+ - README.md
81
110
  - Rakefile
82
111
  - bin/console
83
112
  - bin/setup
@@ -85,6 +114,7 @@ files:
85
114
  - lib/simplespotify/actions/albums.rb
86
115
  - lib/simplespotify/actions/artists.rb
87
116
  - lib/simplespotify/actions/browse.rb
117
+ - lib/simplespotify/actions/player.rb
88
118
  - lib/simplespotify/actions/playlists.rb
89
119
  - lib/simplespotify/actions/tracks.rb
90
120
  - lib/simplespotify/actions/users.rb
@@ -97,6 +127,7 @@ files:
97
127
  - lib/simplespotify/models/category.rb
98
128
  - lib/simplespotify/models/collection.rb
99
129
  - lib/simplespotify/models/image.rb
130
+ - lib/simplespotify/models/playevent.rb
100
131
  - lib/simplespotify/models/playlist.rb
101
132
  - lib/simplespotify/models/track.rb
102
133
  - lib/simplespotify/models/user.rb
@@ -106,7 +137,6 @@ files:
106
137
  - lib/simplespotify/resource/resource.rb
107
138
  - lib/simplespotify/response.rb
108
139
  - lib/simplespotify/version.rb
109
- - readme.md
110
140
  - simplespotify.gemspec
111
141
  homepage: https://github.com/unRob/simplespotify
112
142
  licenses:
@@ -129,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
159
  version: '0'
130
160
  requirements: []
131
161
  rubyforge_project:
132
- rubygems_version: 2.4.6
162
+ rubygems_version: 2.6.11
133
163
  signing_key:
134
164
  specification_version: 4
135
165
  summary: Yet another Spotify client
data/.travis.yml DELETED
@@ -1,3 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.1