that_language-service 0.1.0.pre3 → 0.1.0

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: d63c06c2f42b1746e07690a0e571f4d8deb3e420
4
- data.tar.gz: 4d4dfe0f19be9ce65f03930f9639bca44105b774
3
+ metadata.gz: fdac55053ce4beeca722594f232c14ddf74e158f
4
+ data.tar.gz: 1c94d5ccb87b000c077905e98a426377930ae367
5
5
  SHA512:
6
- metadata.gz: 1f14931cd5a50778974ff20873b52a9ec4d51cfe631f891e047d92d9dce5de48a4ae5a089736d1fc16b24428e9392b523807628a2e83ca62fdccde68cc3bf7e0
7
- data.tar.gz: b5919ba9f6656a21e9ba8d72203db23424b8d47eac532053265c9dd77fafb8e9ad913290fd4b7798b2d42ddd2e046ee4ae6a205fd5d1a8dde56103656d5dea85
6
+ metadata.gz: 78e1ef777ba3f4848df131f09bd8bc2387dc3274510c990dfe3353ebc143145aff93183f14d2da4c9317bcb2e0f5f3a40282366bf8e9c9e6f0fc0b8aa6e31408
7
+ data.tar.gz: 21c266097bdd623d7ef47b43deebd159fdb0f841ba8de960906ffc47ac8b8984c947454eb522ef21e97b86ab71aef19bac69109103aa7b5e8181bae0f271980a
@@ -1,57 +1,61 @@
1
1
  require "sinatra"
2
+ require "sinatra/multi_route"
2
3
  require "that_language"
3
4
 
4
5
  module ThatLanguage
5
6
  module Service
6
7
  class Application < Sinatra::Application
7
- get '/language_code' do
8
- render_json language_code: language_code
8
+ route :get, :post, '/language' do
9
+ render_json language: ThatLanguage.language(text)
9
10
  end
10
11
 
11
- post '/language_code' do
12
- render_json language_code: language_code
12
+ route :get, :post, '/language_code' do
13
+ render_json language_code: ThatLanguage.language_code(text)
13
14
  end
14
15
 
15
- get '/detect' do
16
+ route :get, :post, '/detect' do
16
17
  render_json({
18
+ language: ThatLanguage::Iso639[detect.language_code], # TODO: detect.language
17
19
  language_code: detect.language_code,
18
20
  confidence: detect.confidence
19
21
  })
20
22
  end
21
23
 
22
- post '/detect' do
24
+ route :get, :post, '/details' do
25
+ render_json ThatLanguage.details(text)
26
+ end
27
+
28
+ get '/available' do
29
+ render_json available: ThatLanguage.available
30
+ end
31
+
32
+ get '/available_languages' do
23
33
  render_json({
24
- language_code: detect.language_code,
25
- confidence: detect.confidence
34
+ available_languages: ThatLanguage.available_languages
26
35
  })
27
36
  end
28
37
 
29
- get '/details' do
30
- render_json details: details
38
+ get '/available_language_codes' do
39
+ render_json({
40
+ available_language_codes: ThatLanguage.available_language_codes
41
+ })
31
42
  end
32
43
 
33
- post '/details' do
34
- render_json details: details
44
+ get '/version' do
45
+ render_json version: ThatLanguage::VERSION
35
46
  end
36
47
 
37
48
  private
38
49
 
39
- def render_json(hash)
40
- hash.to_json
41
- end
42
-
43
- def language_code
44
- @language_code ||= ThatLanguage.language_code(text)
50
+ def render_json(obj)
51
+ content_type :json
52
+ obj.to_json
45
53
  end
46
54
 
47
55
  def detect
48
56
  @detect ||= ThatLanguage.detect(text)
49
57
  end
50
58
 
51
- def details
52
- @details ||= ThatLanguage.details(text)
53
- end
54
-
55
59
  def text
56
60
  params['text']
57
61
  end
@@ -2,6 +2,6 @@ require 'sinatra'
2
2
 
3
3
  module ThatLanguage
4
4
  module Service
5
- VERSION = "0.1.0.pre3"
5
+ VERSION = "0.1.0"
6
6
  end
7
7
  end
@@ -9,9 +9,9 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Patrick Helm"]
10
10
  spec.email = ["me@patrick-helm.de"]
11
11
 
12
- spec.summary = %q{Write a short summary, because Rubygems requires one.}
13
- spec.description = %q{Write a longer description or delete this line.}
14
- spec.homepage = "http://gitlab.patrick-helm.de/Ruby/that_language-service"
12
+ spec.summary = %q{Simple Sinatra wrapper for ThatLanguage.}
13
+ # spec.description = %q{Write a longer description or delete this line.}
14
+ spec.homepage = "https://github.com/Deradon/that_language-service"
15
15
  spec.license = "MIT"
16
16
 
17
17
  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
@@ -27,11 +27,13 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_dependency "that_language", "~> 0.1.0.pre"
30
+ spec.add_dependency "that_language", "~> 0.1.0"
31
31
  spec.add_dependency "sinatra", "~> 1.4.6"
32
+ spec.add_dependency "sinatra-contrib"
32
33
  spec.add_dependency "thin", "~> 1.6.4"
33
34
 
34
35
  spec.add_development_dependency "bundler", "~> 1.10"
36
+ spec.add_development_dependency "pry"
35
37
  spec.add_development_dependency "rack-test"
36
38
  spec.add_development_dependency "rake", "~> 10.0"
37
39
  spec.add_development_dependency "rspec"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: that_language-service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Helm
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-01 00:00:00.000000000 Z
11
+ date: 2015-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: that_language
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.0.pre
19
+ version: 0.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.0.pre
26
+ version: 0.1.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sinatra
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.4.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: sinatra-contrib
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: thin
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,20 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '1.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  - !ruby/object:Gem::Dependency
70
98
  name: rack-test
71
99
  requirement: !ruby/object:Gem::Requirement
@@ -122,7 +150,7 @@ dependencies:
122
150
  - - ">="
123
151
  - !ruby/object:Gem::Version
124
152
  version: '0'
125
- description: Write a longer description or delete this line.
153
+ description:
126
154
  email:
127
155
  - me@patrick-helm.de
128
156
  executables: []
@@ -144,7 +172,7 @@ files:
144
172
  - lib/that_language/service/application.rb
145
173
  - lib/that_language/service/version.rb
146
174
  - that_language-service.gemspec
147
- homepage: http://gitlab.patrick-helm.de/Ruby/that_language-service
175
+ homepage: https://github.com/Deradon/that_language-service
148
176
  licenses:
149
177
  - MIT
150
178
  metadata: {}
@@ -159,13 +187,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
159
187
  version: '0'
160
188
  required_rubygems_version: !ruby/object:Gem::Requirement
161
189
  requirements:
162
- - - ">"
190
+ - - ">="
163
191
  - !ruby/object:Gem::Version
164
- version: 1.3.1
192
+ version: '0'
165
193
  requirements: []
166
194
  rubyforge_project:
167
195
  rubygems_version: 2.4.6
168
196
  signing_key:
169
197
  specification_version: 4
170
- summary: Write a short summary, because Rubygems requires one.
198
+ summary: Simple Sinatra wrapper for ThatLanguage.
171
199
  test_files: []