ongaku_ryoho_server 0.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,18 +1,6 @@
1
- *.gem
2
- *.rbc
1
+ .DS_Store
3
2
  .bundle
4
- .config
5
- .yardoc
6
3
  Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- *.pid
4
+ pkg/
5
+ tmp/
6
+ log/
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 [Ongaku Ryoho client](https://github.com/icidasset/ongaku_ryoho).
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
- (rvmsudo) ongaku_ryoho_server (-p 80)
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
- Some Sinatra options, that is.
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
- ```
@@ -1,29 +1,45 @@
1
1
  #!/usr/bin/env ruby
2
- require_relative "../lib/ongaku_ryoho_server.rb"
2
+ require "rubygems"
3
+ require "thin"
4
+
3
5
 
4
6
  #
5
- # Look for some of the Sinatra options and pass them along
7
+ # Thin CLI
6
8
 
7
- options = {}
9
+ gem_dir = File.dirname(__FILE__)
10
+ current_directory_name = File.basename(Dir.pwd)
8
11
 
9
- if ARGV.any?
10
- require "optparse"
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
- # Build list
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
- OngakuRyohoServer::List.save
23
- puts "Collection saved at #{OngakuRyohoServer::List.config_file_path}\n\n"
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
@@ -0,0 +1,5 @@
1
+ === 0.3.0 / 2012-11-10
2
+
3
+ * use thin cli (ability to daemonize)
4
+ * added m4a to supported extensions
5
+ * does not process the directory except when needed or requested (instead of always)
@@ -9,9 +9,9 @@ module OngakuRyohoServer
9
9
 
10
10
  class Application < Sinatra::Base
11
11
  set :environment, :production
12
- set :server, :puma
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])
@@ -2,5 +2,5 @@ module OngakuRyohoServer
2
2
  #
3
3
  # { VERSION }
4
4
 
5
- VERSION = "0.2"
5
+ VERSION = "0.3.0"
6
6
  end
@@ -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
@@ -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 'puma'
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: '0.2'
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-25 00:00:00.000000000 Z
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: puma
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: '0'
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: '0'
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: 819011088545897320
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: 819011088545897320
139
+ hash: 3827745549629188482
138
140
  requirements: []
139
141
  rubyforge_project:
140
142
  rubygems_version: 1.8.24