ejaydj 0.0.4 → 0.0.5
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 +4 -4
- data/README.md +2 -2
- data/lib/ejaydj/dj.rb +7 -12
- data/lib/ejaydj/mixins.rb +10 -0
- data/lib/ejaydj/playlist.rb +9 -12
- data/lib/ejaydj/track.rb +5 -7
- data/lib/ejaydj/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5060bcb5ae6ef7ae2cf3a75627164313c76b918
|
4
|
+
data.tar.gz: 18994145135deecba2939b136452962cc60feeb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 852b21e0f4c8ddf64906343242cec4fef702376e315480dadfbb7c32feaaec73cbbaedaa025c165d07eceaccd9d76bbb440ec8aa365349f4cf01124f3c123c97
|
7
|
+
data.tar.gz: 9762aac22846b2805e9dd1c6aca7fa650b7e6ca2b8155fd863f548f995dfcf989363bbcd11386e2c5787b7c697c50d3651bdb6b1898f85d33e049149e1f6ee7e
|
data/README.md
CHANGED
@@ -21,8 +21,8 @@ Or install it yourself as:
|
|
21
21
|
## Configuration
|
22
22
|
|
23
23
|
### Prerequisites
|
24
|
-
1. [
|
25
|
-
2. [
|
24
|
+
1. [Spotify client id and secret](https://apps.twitter.com/)
|
25
|
+
2. [Twitter consumer and access token](https://developer.spotify.com/my-applications/#!/)
|
26
26
|
|
27
27
|
### Set the Spotify and Twitter credentials in your new TwitterBot DJ then add your playlists
|
28
28
|
|
data/lib/ejaydj/dj.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
require 'ejaydj/services/playlist_service'
|
2
2
|
require 'ejaydj/spotify/client'
|
3
|
+
require 'ejaydj/mixins'
|
3
4
|
|
4
5
|
module Ejaydj
|
5
6
|
class Dj
|
7
|
+
include Mixins
|
8
|
+
|
6
9
|
PLAYLIST_SCHEDULE = {
|
7
10
|
600..1159 => :morning_playlists, # 6AM - 12PM
|
8
11
|
1200..1759 => :noon_playlists, # 12PM - 5:59PM
|
@@ -20,7 +23,6 @@ module Ejaydj
|
|
20
23
|
:night_playlists,
|
21
24
|
:late_night_playlists
|
22
25
|
|
23
|
-
|
24
26
|
def initialize(attributes={})
|
25
27
|
instantiate_variables_from attributes
|
26
28
|
yield self if block_given?
|
@@ -36,23 +38,20 @@ module Ejaydj
|
|
36
38
|
|
37
39
|
def reload!
|
38
40
|
@playlists = all_playlists
|
39
|
-
@playlists.each
|
41
|
+
@playlists.each(&:reload!)
|
40
42
|
end
|
41
43
|
|
42
44
|
private
|
43
45
|
|
44
46
|
def current_playlist(time)
|
45
47
|
playlist_name = scheduled_playlist(time.strftime('%k%M').to_i)
|
46
|
-
playlist = playlists.
|
48
|
+
playlist = playlists.find do |playlist|
|
47
49
|
playlist.name == playlist_name
|
48
|
-
end
|
50
|
+
end
|
49
51
|
end
|
50
52
|
|
51
53
|
def scheduled_playlist(time)
|
52
|
-
scheduled_playlists = PLAYLIST_SCHEDULE.select
|
53
|
-
schedule.cover? time
|
54
|
-
end.values.first
|
55
|
-
|
54
|
+
scheduled_playlists = PLAYLIST_SCHEDULE.select {|sched| sched.cover? time}.values[0]
|
56
55
|
send(scheduled_playlists).sample
|
57
56
|
end
|
58
57
|
|
@@ -71,9 +70,5 @@ module Ejaydj
|
|
71
70
|
client_id: music_client_id,
|
72
71
|
client_secret: music_client_secret)
|
73
72
|
end
|
74
|
-
|
75
|
-
def instantiate_variables_from(attributes)
|
76
|
-
attributes.each {|key, val| instance_variable_set(:"@#{key}", val) }
|
77
|
-
end
|
78
73
|
end
|
79
74
|
end
|
data/lib/ejaydj/playlist.rb
CHANGED
@@ -1,21 +1,18 @@
|
|
1
1
|
require 'ejaydj/services/track_service'
|
2
|
+
require 'ejaydj/mixins'
|
2
3
|
|
3
4
|
module Ejaydj
|
4
5
|
class Playlist
|
5
|
-
|
6
|
-
:user_id,
|
7
|
-
:name,
|
8
|
-
:url,
|
9
|
-
:number_of_tracks
|
6
|
+
include Mixins
|
10
7
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
@number_of_tracks = attributes[:number_of_tracks]
|
8
|
+
attr_accessor :id,
|
9
|
+
:user_id,
|
10
|
+
:name,
|
11
|
+
:url,
|
12
|
+
:number_of_tracks
|
17
13
|
|
18
|
-
|
14
|
+
def initialize(attributes={})
|
15
|
+
instantiate_variables_from attributes
|
19
16
|
end
|
20
17
|
|
21
18
|
def next_track
|
data/lib/ejaydj/track.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
+
require 'ejaydj/mixins'
|
2
|
+
|
1
3
|
module Ejaydj
|
2
4
|
class Track
|
5
|
+
include Mixins
|
6
|
+
|
3
7
|
attr_accessor :name,
|
4
8
|
:album,
|
5
9
|
:artist,
|
@@ -8,13 +12,7 @@ module Ejaydj
|
|
8
12
|
:playlist
|
9
13
|
|
10
14
|
def initialize(attributes={})
|
11
|
-
|
12
|
-
@name = attributes[:name]
|
13
|
-
@album = attributes[:album]
|
14
|
-
@artist = attributes[:artist]
|
15
|
-
@playlist = attributes[:playlist]
|
16
|
-
@duration_ms = attributes[:duration_ms]
|
17
|
-
@url = attributes[:url]
|
15
|
+
instantiate_variables_from attributes
|
18
16
|
end
|
19
17
|
end
|
20
18
|
end
|
data/lib/ejaydj/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ejaydj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ejay Canaria
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- lib/ejaydj.rb
|
141
141
|
- lib/ejaydj/dj.rb
|
142
142
|
- lib/ejaydj/djs/twitter_bot.rb
|
143
|
+
- lib/ejaydj/mixins.rb
|
143
144
|
- lib/ejaydj/playlist.rb
|
144
145
|
- lib/ejaydj/services/playlist_service.rb
|
145
146
|
- lib/ejaydj/services/track_service.rb
|