ongaku_ryoho_server 0.5.1 → 0.5.2
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/history.txt +5 -0
- data/lib/ongaku_ryoho_server/process.rb +11 -13
- data/lib/ongaku_ryoho_server.rb +3 -3
- data/ongaku_ryoho_server.gemspec +1 -1
- data/spec/application_spec.rb +17 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 420c159644d71253d839dc8c45539931e8fcc56f
|
4
|
+
data.tar.gz: 3bef5f4bc768e8f733c40da1e30cbdc3d210eb6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e27cfd66fc816785430541ffbcb7cac4d18f6ac63ae9cee2dd67c3d555a326691913f3b5c05a45499cb60276755e8aa4c5283f623c2fe3fdda5de59e451bce5
|
7
|
+
data.tar.gz: ef5d506ba3b15ca20b0da83d3f6515ac6120cce540a8db432fdb71c00a804ea71d255fa84f8e23b9301bf15ceb4b4a65bcd7f02a5bd94a011da85cbed14d1848
|
data/history.txt
CHANGED
@@ -45,7 +45,7 @@ module OngakuRyohoServer
|
|
45
45
|
other_file_list = Oj.load(other_file_list)
|
46
46
|
else
|
47
47
|
other_file_list = Oj.load(OngakuRyohoServer::List.get)
|
48
|
-
other_file_list.map! { |obj| obj[
|
48
|
+
other_file_list.map! { |obj| obj["location"] }
|
49
49
|
end
|
50
50
|
|
51
51
|
# determine which files are missing and which are new
|
@@ -53,14 +53,12 @@ module OngakuRyohoServer
|
|
53
53
|
new_files = other_file_list - file_list
|
54
54
|
|
55
55
|
# process new files
|
56
|
-
new_tracks = OngakuRyohoServer::Process.files(
|
57
|
-
new_files, { :last_modified => Time.now }
|
58
|
-
)
|
56
|
+
new_tracks = OngakuRyohoServer::Process.files(new_files)
|
59
57
|
|
60
58
|
# return missing and new tracks
|
61
59
|
return {
|
62
|
-
|
63
|
-
|
60
|
+
"missing_files" => missing_files,
|
61
|
+
"new_tracks" => new_tracks
|
64
62
|
}
|
65
63
|
end
|
66
64
|
|
@@ -94,19 +92,19 @@ module OngakuRyohoServer
|
|
94
92
|
tag = fileref.tag
|
95
93
|
|
96
94
|
tags = {
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
95
|
+
"title" => tag.title,
|
96
|
+
"artist" => tag.artist,
|
97
|
+
"album" => tag.album,
|
98
|
+
"year" => tag.year,
|
99
|
+
"track" => tag.track,
|
100
|
+
"genre" => tag.genre
|
103
101
|
}
|
104
102
|
|
105
103
|
tags.each do |key, value|
|
106
104
|
tags[key] = "Unknown" if value.nil? or (value.respond_to?(:empty) and value.empty?)
|
107
105
|
end
|
108
106
|
|
109
|
-
tags.merge!({
|
107
|
+
tags.merge!({ "filename" => filename, "location" => location })
|
110
108
|
|
111
109
|
tags.each do |k, v|
|
112
110
|
tags[k] = OngakuRyohoServer::Process.encode_string(v) if v.is_a? String
|
data/lib/ongaku_ryoho_server.rb
CHANGED
@@ -7,9 +7,9 @@ require "sinatra/cross_origin"
|
|
7
7
|
require "uri"
|
8
8
|
require "digest/sha1"
|
9
9
|
|
10
|
-
require "ongaku_ryoho_server/process"
|
11
|
-
require "ongaku_ryoho_server/list"
|
12
|
-
require "ongaku_ryoho_server/application"
|
10
|
+
require "#{File.dirname(__FILE__)}/ongaku_ryoho_server/process"
|
11
|
+
require "#{File.dirname(__FILE__)}/ongaku_ryoho_server/list"
|
12
|
+
require "#{File.dirname(__FILE__)}/ongaku_ryoho_server/application"
|
13
13
|
|
14
14
|
|
15
15
|
module OngakuRyohoServer
|
data/ongaku_ryoho_server.gemspec
CHANGED
data/spec/application_spec.rb
CHANGED
@@ -40,12 +40,12 @@ describe "Application" do
|
|
40
40
|
json = Oj.load(last_response.body)
|
41
41
|
first_item = json.first
|
42
42
|
|
43
|
-
first_item.has_key?(
|
44
|
-
first_item.has_key?(
|
45
|
-
first_item.has_key?(
|
46
|
-
first_item.has_key?(
|
47
|
-
first_item.has_key?(
|
48
|
-
first_item.has_key?(
|
43
|
+
first_item.has_key?("title").must_equal true
|
44
|
+
first_item.has_key?("artist").must_equal true
|
45
|
+
first_item.has_key?("album").must_equal true
|
46
|
+
first_item.has_key?("year").must_equal true
|
47
|
+
first_item.has_key?("track").must_equal true
|
48
|
+
first_item.has_key?("genre").must_equal true
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -79,33 +79,33 @@ describe "Application" do
|
|
79
79
|
it "should have 2 parent keys" do
|
80
80
|
post "/check"
|
81
81
|
json = Oj.load(last_response.body)
|
82
|
-
json[
|
83
|
-
json[
|
82
|
+
json["missing_files"].must_be_kind_of Array
|
83
|
+
json["new_tracks"].must_be_kind_of Array
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should have 3 new tracks when given empty file list" do
|
87
87
|
post "/check", :file_list => Oj.dump([])
|
88
88
|
json = Oj.load(last_response.body)
|
89
|
-
json[
|
89
|
+
json["new_tracks"].length.must_equal 3
|
90
90
|
end
|
91
91
|
|
92
92
|
it "should have 0 new tracks when given same file list" do
|
93
93
|
file_list = [
|
94
|
-
{
|
95
|
-
{
|
96
|
-
{
|
94
|
+
{ "location" => "spec/data/a.mp3" },
|
95
|
+
{ "location" => "spec/data/b.mp3" },
|
96
|
+
{ "location" => "spec/data/c.mp3" }
|
97
97
|
]
|
98
98
|
|
99
99
|
post "/check", :file_list => Oj.dump(file_list)
|
100
100
|
json = Oj.load(last_response.body)
|
101
|
-
json[
|
101
|
+
json["new_tracks"].length.must_equal 3
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should have 3 missing files" do
|
105
105
|
file_list = [
|
106
|
-
{
|
107
|
-
{
|
108
|
-
{
|
106
|
+
{ "location" => "spec/data/a.mp3" },
|
107
|
+
{ "location" => "spec/data/b.mp3" },
|
108
|
+
{ "location" => "spec/data/c.mp3" }
|
109
109
|
]
|
110
110
|
|
111
111
|
post "/check",
|
@@ -113,7 +113,7 @@ describe "Application" do
|
|
113
113
|
:other_file_list => Oj.dump([])
|
114
114
|
|
115
115
|
json = Oj.load(last_response.body)
|
116
|
-
json[
|
116
|
+
json["missing_files"].length.must_equal 3
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ongaku_ryoho_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Vandevelde
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|