play 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- play (0.0.4)
4
+ play (0.0.5)
5
5
  SystemTimer
6
6
  activerecord
7
+ fssm
7
8
  mustache
8
9
  mysql2
9
10
  oa-oauth
10
11
  rack (~> 1.2.2)
12
+ rb-fsevent
11
13
  ruby-audioinfo
12
14
  sinatra
13
15
  sqlite3
@@ -30,7 +32,7 @@ GEM
30
32
  addressable (2.2.5)
31
33
  apetag (1.1.2)
32
34
  cicphash (>= 1.0.0)
33
- arel (2.0.9)
35
+ arel (2.0.10)
34
36
  builder (2.1.2)
35
37
  cicphash (1.0.0)
36
38
  faraday (0.6.1)
@@ -38,27 +40,29 @@ GEM
38
40
  multipart-post (~> 1.1.0)
39
41
  rack (< 2, >= 1.1.0)
40
42
  flacinfo-rb (0.4)
43
+ fssm (0.2.7)
41
44
  i18n (0.5.0)
42
45
  mocha (0.9.12)
43
46
  mp4info (1.7.3)
44
47
  multi_json (1.0.1)
45
48
  multi_xml (0.2.2)
46
49
  multipart-post (1.1.0)
47
- mustache (0.99.3)
50
+ mustache (0.99.4)
48
51
  mysql2 (0.2.7)
49
- oa-core (0.2.5)
50
- oa-oauth (0.2.5)
52
+ oa-core (0.2.6)
53
+ oa-oauth (0.2.6)
51
54
  faraday (~> 0.6.1)
52
55
  multi_json (~> 1.0.0)
53
56
  multi_xml (~> 0.2.2)
54
- oa-core (= 0.2.5)
57
+ oa-core (= 0.2.6)
55
58
  oauth (~> 0.4.0)
56
59
  oauth2 (~> 0.4.1)
57
60
  oauth (0.4.4)
58
61
  oauth2 (0.4.1)
59
62
  faraday (~> 0.6.1)
60
63
  multi_json (>= 0.0.5)
61
- rack (1.2.2)
64
+ rack (1.2.3)
65
+ rb-fsevent (0.4.0)
62
66
  ruby-audioinfo (0.1.7)
63
67
  apetag (= 1.1.2)
64
68
  flacinfo-rb (>= 0.4)
@@ -73,7 +77,7 @@ GEM
73
77
  rack (~> 1.1)
74
78
  tilt (< 2.0, >= 1.2.2)
75
79
  sqlite3 (1.3.3)
76
- tilt (1.3)
80
+ tilt (1.3.2)
77
81
  tzinfo (0.3.27)
78
82
  wmainfo-rb (0.6)
79
83
  yajl-ruby (0.8.2)
data/README.md CHANGED
@@ -63,6 +63,11 @@ recursively when you run:
63
63
 
64
64
  play -i
65
65
 
66
+ Alternatively, you can just start up the web server (`play -w`) and it will
67
+ listen for any changes you make to your music directory. In other words, once
68
+ the web component has started, if you drop in a new directory of music, it'll
69
+ realize that and go ahead and index it.
70
+
66
71
  ## Play
67
72
 
68
73
  Once you're all set up, you can spin up the web app with:
@@ -124,8 +129,8 @@ of do differently in Play is we disable the GitHub OAuth callback (since your
124
129
  development URL is different than it would be in production).
125
130
 
126
131
  To actually use it locally, we'll automatically create a user called `user` for
127
- you when you first access the app. That way you can actually mess around
128
- without having to hit GitHub or create a user manually.
132
+ you when you first access the app. You can sign into this user by hitting
133
+ `/devlogin` on your running instance.
129
134
 
130
135
  None of this happens if you launch Play with `bin/play -d`.
131
136
 
data/bin/play CHANGED
@@ -27,6 +27,8 @@ parser = OptionParser.new do |opts|
27
27
  end
28
28
 
29
29
  opts.on("-w", "--web", "Run the web instance") do
30
+ pid = fork { Play::Library.monitor }
31
+ Process.detach(pid)
30
32
  system("rackup -p 5050 #{File.dirname(__FILE__)}/../config.ru")
31
33
  end
32
34
 
@@ -9,6 +9,8 @@ require 'sinatra/base'
9
9
  require 'mustache/sinatra'
10
10
  require 'digest'
11
11
  require 'yajl'
12
+ require 'rb-fsevent'
13
+ require 'fssm'
12
14
 
13
15
  require 'play/core_ext/hash'
14
16
 
@@ -26,7 +28,7 @@ require 'play/vote'
26
28
 
27
29
  module Play
28
30
 
29
- VERSION = '0.0.5'
31
+ VERSION = '0.0.6'
30
32
 
31
33
  # The path to your music library. All of the music underneath this directory
32
34
  # will be added to the internal library.
@@ -38,10 +38,6 @@ module Play
38
38
  redirect '/login' unless request.path_info =~ /\/login/ ||
39
39
  request.path_info =~ /\/auth/ ||
40
40
  request.path_info =~ /\/api/
41
- else
42
- # This will create a test user for you locally in development.
43
- session['user_id'] = User.create(:login => 'user',
44
- :email => 'play@example.com').id
45
41
  end
46
42
  end
47
43
  end
@@ -51,6 +47,12 @@ module Play
51
47
  mustache :index
52
48
  end
53
49
 
50
+ get "/devlogin" do
51
+ session['user_id'] = User.create(:login => 'user',
52
+ :email => 'play@example.com').id
53
+ redirect '/'
54
+ end
55
+
54
56
  get "/login" do
55
57
  redirect '/auth/github'
56
58
  end
@@ -1,17 +1,33 @@
1
1
  module Play
2
2
  class Library
3
+
4
+ # Monitors the music directory for any new music added to it. Once
5
+ # changed, Play will run through and reindex those directories.
6
+ #
7
+ # Returns nothing.
8
+ def self.monitor
9
+ FSSM.monitor(Play.path, '**/**/**', :directories => true) do
10
+ update {|base, relative| Library.import_songs("#{base}/#{relative}") }
11
+ delete {|base, relative| nil }
12
+ create {|base, relative| Library.import_songs("#{base}/#{relative}") }
13
+ end
14
+ end
15
+
3
16
  # Search a directory and return all of the files in it, recursively.
4
17
  #
5
18
  # Returns an Array of String file paths.
6
- def self.fs_songs
7
- `find "#{Play.path}" -type f ! -name '.*'`.split("\n")
19
+ def self.fs_songs(path)
20
+ `find "#{path}" -type f ! -name '.*'`.split("\n")
8
21
  end
9
22
 
10
23
  # Imports an array of songs into the database.
11
24
  #
25
+ # path = the String path of the directory to search in. Will default to the
26
+ # default Play path if not specified.
27
+ #
12
28
  # Returns nothing.
13
- def self.import_songs
14
- fs_songs.each do |path|
29
+ def self.import_songs(path=Play.path)
30
+ fs_songs(path).each do |path|
15
31
  import_song(path)
16
32
  end
17
33
  end
@@ -1,6 +1,9 @@
1
1
  module Play
2
2
  module Views
3
3
  class Layout < Mustache
4
+ def login
5
+ @login
6
+ end
4
7
  end
5
8
  end
6
9
  end
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'play'
16
- s.version = '0.0.5'
17
- s.date = '2011-05-27'
16
+ s.version = '0.0.6'
17
+ s.date = '2011-06-23'
18
18
  s.rubyforge_project = 'play'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -56,6 +56,8 @@ Gem::Specification.new do |s|
56
56
  s.add_dependency('oa-oauth')
57
57
  s.add_dependency('yajl-ruby')
58
58
  s.add_dependency('mysql2')
59
+ s.add_dependency('rb-fsevent')
60
+ s.add_dependency('fssm')
59
61
 
60
62
  ## List your development dependencies here. Development dependencies are
61
63
  ## those that are only needed during development
@@ -13,7 +13,6 @@ context "Library" do
13
13
  FileUtils.mkdir_p '/tmp/play'
14
14
  FileUtils.touch '/tmp/play/song_1'
15
15
  FileUtils.touch '/tmp/play/song_2'
16
- Play.stubs(:path).returns('/tmp/play')
17
- assert_equal 2, Library.fs_songs.size
16
+ assert_equal 2, Library.fs_songs('/tmp/play').size
18
17
  end
19
18
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: play
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Zach Holman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-27 00:00:00 -07:00
18
+ date: 2011-06-23 00:00:00 -07:00
19
19
  default_executable: play
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -161,7 +161,7 @@ dependencies:
161
161
  type: :runtime
162
162
  version_requirements: *id010
163
163
  - !ruby/object:Gem::Dependency
164
- name: running_man
164
+ name: rb-fsevent
165
165
  prerelease: false
166
166
  requirement: &id011 !ruby/object:Gem::Requirement
167
167
  none: false
@@ -172,10 +172,10 @@ dependencies:
172
172
  segments:
173
173
  - 0
174
174
  version: "0"
175
- type: :development
175
+ type: :runtime
176
176
  version_requirements: *id011
177
177
  - !ruby/object:Gem::Dependency
178
- name: mocha
178
+ name: fssm
179
179
  prerelease: false
180
180
  requirement: &id012 !ruby/object:Gem::Requirement
181
181
  none: false
@@ -186,8 +186,36 @@ dependencies:
186
186
  segments:
187
187
  - 0
188
188
  version: "0"
189
- type: :development
189
+ type: :runtime
190
190
  version_requirements: *id012
191
+ - !ruby/object:Gem::Dependency
192
+ name: running_man
193
+ prerelease: false
194
+ requirement: &id013 !ruby/object:Gem::Requirement
195
+ none: false
196
+ requirements:
197
+ - - ">="
198
+ - !ruby/object:Gem::Version
199
+ hash: 3
200
+ segments:
201
+ - 0
202
+ version: "0"
203
+ type: :development
204
+ version_requirements: *id013
205
+ - !ruby/object:Gem::Dependency
206
+ name: mocha
207
+ prerelease: false
208
+ requirement: &id014 !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ">="
212
+ - !ruby/object:Gem::Version
213
+ hash: 3
214
+ segments:
215
+ - 0
216
+ version: "0"
217
+ type: :development
218
+ version_requirements: *id014
191
219
  description: |-
192
220
  We want to play music at our office. Everyone has their own
193
221
  library on their own machines, and everyone except for me plays shitty music.