ongaku_ryoho_server 0.2 → 0.3.0
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.
- data/.gitignore +4 -16
- data/README.md +10 -8
- data/bin/ongaku_ryoho_server +34 -18
- data/history.txt +5 -0
- data/lib/ongaku_ryoho_server/application.rb +2 -2
- data/lib/ongaku_ryoho_server/config.ru +17 -0
- data/lib/ongaku_ryoho_server/version.rb +1 -1
- data/lib/ongaku_ryoho_server.rb +4 -8
- data/ongaku_ryoho_server.gemspec +1 -1
- metadata +11 -9
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# Ongaku Ryoho Server
|
2
2
|
|
3
|
-
A little Sinatra web server wrapped in a gem specifically for the
|
3
|
+
A little Sinatra web server (with Thin) wrapped in a gem specifically for the Ongaku Ryoho client.
|
4
4
|
|
5
5
|
## How to use
|
6
6
|
|
7
7
|
### Requirements
|
8
8
|
|
9
|
-
`Ruby 1.9.2`
|
9
|
+
`Ruby 1.9.2 (or higher)`
|
10
10
|
|
11
11
|
### Installation
|
12
12
|
|
@@ -20,15 +20,17 @@ Go to a music directory and run the web server.
|
|
20
20
|
|
21
21
|
```bash
|
22
22
|
cd ~/Music
|
23
|
-
|
23
|
+
ongaku_ryoho_server start
|
24
|
+
ongaku_ryoho_server stop (must be in the same directory)
|
24
25
|
```
|
25
26
|
|
26
27
|
### Options
|
27
28
|
|
28
|
-
|
29
|
+
```
|
30
|
+
-p set the port (default: 3000)
|
31
|
+
-d daemonize
|
32
|
+
|
33
|
+
--update update the cached collection
|
29
34
|
|
35
|
+
+ all the other thin cli options
|
30
36
|
```
|
31
|
-
-p port set the port (default is 4567)
|
32
|
-
-o addr set the host (default is 0.0.0.0)
|
33
|
-
-x turn on the mutex lock (default is off)
|
34
|
-
```
|
data/bin/ongaku_ryoho_server
CHANGED
@@ -1,29 +1,45 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
require "rubygems"
|
3
|
+
require "thin"
|
4
|
+
|
3
5
|
|
4
6
|
#
|
5
|
-
#
|
7
|
+
# Thin CLI
|
6
8
|
|
7
|
-
|
9
|
+
gem_dir = File.dirname(__FILE__)
|
10
|
+
current_directory_name = File.basename(Dir.pwd)
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
OptionParser.new { |op|
|
12
|
-
op.on("-p port", "set the port (default is 4567)") { |val| options[:port] = Integer(val) }
|
13
|
-
op.on("-o addr", "set the host (default is 0.0.0.0)") { |val| options[:bind] = val }
|
14
|
-
op.on("-x", "turn on the mutex lock (default is off)") { options[:lock] = true }
|
15
|
-
}.parse!(ARGV.dup)
|
16
|
-
end
|
12
|
+
# require library
|
13
|
+
require "#{gem_dir}/../lib/ongaku_ryoho_server.rb"
|
17
14
|
|
15
|
+
# files
|
16
|
+
rackup_file = "#{gem_dir}/../lib/ongaku_ryoho_server/config.ru"
|
17
|
+
log_file = "#{gem_dir}/../log/#{current_directory_name}.log"
|
18
|
+
pid_file = "#{gem_dir}/../tmp/#{current_directory_name}.pid"
|
18
19
|
|
19
|
-
#
|
20
|
-
|
20
|
+
# thin arguments
|
21
|
+
argv = ARGV
|
22
|
+
argv << ["--tag", "Ongaku Ryoho Server"]
|
23
|
+
argv << ["-R", rackup_file] unless ARGV.include?("-R")
|
24
|
+
argv << ["-P", pid_file] unless ARGV.include?("-P")
|
25
|
+
argv << ["-l", log_file] unless ARGV.include?("-l")
|
26
|
+
argv << ["-e", "production"] unless ARGV.include?("-e")
|
27
|
+
argv << ["-p", "3000"] unless ARGV.include?("-p")
|
21
28
|
|
22
|
-
|
23
|
-
|
29
|
+
# special arguments
|
30
|
+
update_collection = argv.include?("--update")
|
31
|
+
argv.delete("--update") if update_collection
|
24
32
|
|
33
|
+
# thin cli
|
34
|
+
thin_runner = Thin::Runner.new(argv.flatten)
|
35
|
+
|
36
|
+
# keep options
|
37
|
+
OngakuRyohoServer::OPTIONS = {
|
38
|
+
update_collection: update_collection,
|
39
|
+
thin: thin_runner.options
|
40
|
+
}
|
41
|
+
|
42
|
+
# exec thin
|
43
|
+
thin_runner.run!
|
25
44
|
|
26
|
-
#
|
27
|
-
# Run the server
|
28
45
|
|
29
|
-
OngakuRyohoServer.run(options)
|
data/history.txt
ADDED
@@ -9,9 +9,9 @@ module OngakuRyohoServer
|
|
9
9
|
|
10
10
|
class Application < Sinatra::Base
|
11
11
|
set :environment, :production
|
12
|
-
set :server, :
|
12
|
+
set :server, :thin
|
13
13
|
|
14
|
-
FILE_FORMATS = %w{ mp3 mp4 ogg flac wav wma }
|
14
|
+
FILE_FORMATS = %w{ mp3 mp4 m4a ogg flac wav wma }
|
15
15
|
|
16
16
|
# root
|
17
17
|
get "/" do
|
@@ -0,0 +1,17 @@
|
|
1
|
+
options = OngakuRyohoServer::OPTIONS
|
2
|
+
|
3
|
+
|
4
|
+
#
|
5
|
+
# Build file list (only if needed or request)
|
6
|
+
|
7
|
+
config_file_path = OngakuRyohoServer::List.config_file_path
|
8
|
+
if !File.file?(config_file_path) or options[:update_collection]
|
9
|
+
OngakuRyohoServer::List.save
|
10
|
+
puts "Collection saved at #{config_file_path}\n\n"
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
#
|
15
|
+
# Run the application
|
16
|
+
|
17
|
+
run OngakuRyohoServer::Application.new(options[:thin])
|
data/lib/ongaku_ryoho_server.rb
CHANGED
@@ -1,17 +1,13 @@
|
|
1
|
+
require "sinatra/base"
|
2
|
+
require "taglib"
|
3
|
+
|
1
4
|
require "json"
|
2
5
|
require "uri"
|
3
6
|
require "digest/sha1"
|
4
|
-
require "puma"
|
5
|
-
require "sinatra"
|
6
|
-
require "taglib"
|
7
7
|
|
8
8
|
require_relative "ongaku_ryoho_server/version"
|
9
9
|
require_relative "ongaku_ryoho_server/process"
|
10
10
|
require_relative "ongaku_ryoho_server/list"
|
11
11
|
require_relative "ongaku_ryoho_server/application"
|
12
12
|
|
13
|
-
module OngakuRyohoServer
|
14
|
-
def self.run(options)
|
15
|
-
OngakuRyohoServer::Application.run!(options)
|
16
|
-
end
|
17
|
-
end
|
13
|
+
module OngakuRyohoServer; end
|
data/ongaku_ryoho_server.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.add_dependency 'json', '~> 1.7.5'
|
19
19
|
gem.add_dependency 'taglib-ruby', '~> 0.5.2'
|
20
20
|
gem.add_dependency 'sinatra', '~> 1.3.3'
|
21
|
-
gem.add_dependency '
|
21
|
+
gem.add_dependency 'thin', '~> 1.5.0'
|
22
22
|
|
23
23
|
gem.add_development_dependency 'rake'
|
24
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ongaku_ryoho_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10
|
12
|
+
date: 2012-11-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -60,21 +60,21 @@ dependencies:
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.3.3
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
63
|
+
name: thin
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 1.5.0
|
70
70
|
type: :runtime
|
71
71
|
prerelease: false
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ~>
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
77
|
+
version: 1.5.0
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
79
|
name: rake
|
80
80
|
requirement: !ruby/object:Gem::Requirement
|
@@ -105,8 +105,10 @@ files:
|
|
105
105
|
- README.md
|
106
106
|
- Rakefile
|
107
107
|
- bin/ongaku_ryoho_server
|
108
|
+
- history.txt
|
108
109
|
- lib/ongaku_ryoho_server.rb
|
109
110
|
- lib/ongaku_ryoho_server/application.rb
|
111
|
+
- lib/ongaku_ryoho_server/config.ru
|
110
112
|
- lib/ongaku_ryoho_server/list.rb
|
111
113
|
- lib/ongaku_ryoho_server/process.rb
|
112
114
|
- lib/ongaku_ryoho_server/version.rb
|
@@ -125,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
127
|
version: '0'
|
126
128
|
segments:
|
127
129
|
- 0
|
128
|
-
hash:
|
130
|
+
hash: 3827745549629188482
|
129
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
132
|
none: false
|
131
133
|
requirements:
|
@@ -134,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
136
|
version: '0'
|
135
137
|
segments:
|
136
138
|
- 0
|
137
|
-
hash:
|
139
|
+
hash: 3827745549629188482
|
138
140
|
requirements: []
|
139
141
|
rubyforge_project:
|
140
142
|
rubygems_version: 1.8.24
|