/
play.rb
73 lines (62 loc) · 1.7 KB
/
play.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))
require "rubygems"
require "bundler/setup"
require 'active_record'
require 'audioinfo'
require 'sinatra/base'
require 'mustache/sinatra'
require 'digest'
require 'yajl'
require 'play/core_ext/hash'
require 'play/app'
require 'play/artist'
require 'play/album'
require 'play/client'
require 'play/history'
require 'play/library'
require 'play/office'
require 'play/song'
require 'play/views/layout'
require 'play/user'
require 'play/vote'
module Play
VERSION = '0.0.2'
# The path to your music library. All of the music underneath this directory
# will be added to the internal library.
#
# path - a String absolute path to your music
#
# Returns nothing.
def self.path=(path)
@path = path
end
# The path of the music library on-disk.
#
# Returns a String absolute path on the local file system.
def self.path
config['path']
end
# The song that's currently playing.
#
# Returns the Song object from the database that's currently playing.
def self.now_playing
Song.where(:now_playing => true).first
end
# The path to play.yml.
#
# Returns the String path to the configuration file.
def self.config_path
"#{ENV['HOME']}/.play.yml"
end
# The configuration object for Play.
#
# Returns the Hash containing the configuration for Play. This includes:
#
# path - the String path to where your music is located
# gh_key - the Client ID from your GitHub app's OAuth settings
# gh_secret - the Client Secret from your GitHub app's OAuth settings
# office_url - the URL to an endpoint where we can see who's in your office
def self.config
YAML::load(File.open(config_path))
end
end