ongaku_ryoho_server 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7de0168f5720bba9e90009b42988c9dbb9d1cc2a
4
- data.tar.gz: 1985ef84ad0aa83a0d690961ec0cd41897397ff9
3
+ metadata.gz: f602d4f4c2636375c55d96254285e61b6c6a785a
4
+ data.tar.gz: e49ac7fd3e6e594ba9e787e43d7c6ecc7f34fe7c
5
5
  SHA512:
6
- metadata.gz: 1dd31f2434a4d21c01b604bbf988a1f8885e25d515216d3df7426ec8a423c3c32592b2f9fe1cc13619029ababf8b1c12db63e27c3690672d24b447cda52c554b
7
- data.tar.gz: a983c63d1281ea398f47cadc4be5f6283dd6e573514f4d0b35c49aa5198db8b0230ca5372d38f65db09b739803e07de2807a6380823b304ef1457fb1f60ea2cd
6
+ metadata.gz: 92c0daffb408b9d566a72289e1133d5345fd0d021b255aa887420ee058178272a98474719aa0a6eafc4ec9401efbf1b39b63c83aa635ca20b50e8eb617a09ede
7
+ data.tar.gz: f2ece7fe3c9ac856ab0ca2e0609fb16df610b593605dd5e69605cd272f58aeafb885f83f6e0ddaa037606360168e3d5b502903dffe65d1e13a0f0962dd480fc3
data/history.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 0.5.1 / 2013-07-04
2
+
3
+ * enable cors
4
+ * fixed utf-8 encoding issue
5
+
6
+
1
7
  === 0.5.0 / 2013-07-02
2
8
 
3
9
  * tests
@@ -10,6 +10,14 @@ module OngakuRyohoServer
10
10
  class Application < Sinatra::Base
11
11
  set :environment, :production
12
12
 
13
+ # CORS
14
+ register Sinatra::CrossOrigin
15
+
16
+ configure do
17
+ enable :cross_origin
18
+ end
19
+
20
+ # allowed file formats
13
21
  FILE_FORMATS = %w{ mp3 mp4 m4a ogg flac wav wma }
14
22
 
15
23
  # root
@@ -131,7 +131,7 @@ module OngakuRyohoServer
131
131
  #
132
132
  def self.encode_string(string, replace_value="?")
133
133
  return string unless string.respond_to?(:force_encoding)
134
- new_string = string.force_encoding("cp1252")
134
+ new_string = string.force_encoding(::Encoding::UTF_8)
135
135
  new_string.encode("UTF-8", { :invalid => :replace, :undef => :replace, :replace => replace_value })
136
136
  end
137
137
 
@@ -2,6 +2,7 @@ require "rubygems"
2
2
  require "taglib"
3
3
  require "oj"
4
4
  require "sinatra/base"
5
+ require "sinatra/cross_origin"
5
6
 
6
7
  require "uri"
7
8
  require "digest/sha1"
@@ -10,4 +11,6 @@ require "ongaku_ryoho_server/process"
10
11
  require "ongaku_ryoho_server/list"
11
12
  require "ongaku_ryoho_server/application"
12
13
 
13
- module OngakuRyohoServer; end
14
+
15
+ module OngakuRyohoServer
16
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "ongaku_ryoho_server"
5
- s.version = "0.5.0"
5
+ s.version = "0.5.1"
6
6
 
7
7
  s.authors = ["Steven Vandevelde"]
8
8
  s.email = ["icid.asset@gmail.com"]
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.add_runtime_dependency "oj", "~> 2.0.14"
21
21
  s.add_runtime_dependency "taglib-ruby", "~> 0.6.0"
22
22
  s.add_runtime_dependency "sinatra", "~> 1.4.2"
23
+ s.add_runtime_dependency "sinatra-cross_origin", "~> 0.2.0"
23
24
  s.add_runtime_dependency "puma", "~> 2.0.1"
24
25
 
25
26
  s.add_development_dependency "rake", "~> 10.0.4"
@@ -22,6 +22,12 @@ describe "Application" do
22
22
  last_response.content_type.must_equal "application/javascript;charset=utf-8"
23
23
  end
24
24
 
25
+ it "should work cross domain" do
26
+ get "/", {}, { "HTTP_ORIGIN" => "http://localhost" }
27
+ last_response.must_be :ok?
28
+ last_response.headers["Access-Control-Allow-Origin"].must_equal "http://localhost"
29
+ end
30
+
25
31
  it "should have 3 items" do
26
32
  get "/"
27
33
  json = Oj.load(last_response.body)
@@ -52,6 +58,24 @@ describe "Application" do
52
58
  OngakuRyohoServer::List.save
53
59
  end
54
60
 
61
+ it "should return json" do
62
+ post "/check"
63
+ last_response.must_be :ok?
64
+ last_response.content_type.must_equal "application/json;charset=utf-8"
65
+ end
66
+
67
+ it "should return jsonp" do
68
+ post "/check", :callback => "test"
69
+ last_response.must_be :ok?
70
+ last_response.content_type.must_equal "application/javascript;charset=utf-8"
71
+ end
72
+
73
+ it "should work cross domain" do
74
+ post "/check", {}, { "HTTP_ORIGIN" => "http://localhost" }
75
+ last_response.must_be :ok?
76
+ last_response.headers["Access-Control-Allow-Origin"].must_equal "http://localhost"
77
+ end
78
+
55
79
  it "should have 2 parent keys" do
56
80
  post "/check"
57
81
  json = Oj.load(last_response.body)
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.0
4
+ version: 0.5.1
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-02 00:00:00.000000000 Z
11
+ date: 2013-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.4.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: sinatra-cross_origin
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.2.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.2.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: puma
57
71
  requirement: !ruby/object:Gem::Requirement