aigu-rails 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/aigu-rails.gemspec +2 -0
- data/lib/aigu-rails.rb +13 -1
- data/lib/aigu-rails/accent/locale_downloader.rb +13 -14
- data/lib/aigu-rails/version.rb +1 -1
- data/spec/aigu_rails_spec.rb +9 -2
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31daeefa84babf789c32645049c0cc85efce8838
|
4
|
+
data.tar.gz: 6bd907a9940be0c86eacb1f31f801a646088fc50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a3a379ace0f6f8e72ae5294f532455ade8f5d2ca80a8a696816b874142a5c3bf8e05511892c35bfd1b52b04310886d17ca87dba5cba845c94bd0be35350166d
|
7
|
+
data.tar.gz: 0f74023446f08429e7dfaeeac47d61dea08ce99facc343b6b607680580022bc82c129dfc25df2ccda8d9d38a9c2ab156947c77a8036282baee703b1f00af43de
|
data/aigu-rails.gemspec
CHANGED
data/lib/aigu-rails.rb
CHANGED
@@ -9,16 +9,28 @@ require 'aigu-rails/version'
|
|
9
9
|
|
10
10
|
module Aigu
|
11
11
|
module Rails
|
12
|
+
# Constants
|
13
|
+
API_URL = 'https://accent.mirego.com'.freeze
|
14
|
+
DEFAULT_PATH = '/public_api/latest_revision'.freeze
|
15
|
+
|
16
|
+
# Errors
|
17
|
+
Error = Class.new(StandardError)
|
18
|
+
|
12
19
|
def self.configure
|
13
20
|
yield(self.configuration)
|
14
21
|
end
|
15
22
|
|
16
23
|
def self.configuration
|
17
|
-
@configuration ||= OpenStruct.new
|
24
|
+
@configuration ||= OpenStruct.new(
|
25
|
+
api_url: API_URL,
|
26
|
+
default_path: DEFAULT_PATH
|
27
|
+
)
|
18
28
|
end
|
19
29
|
|
20
30
|
def self.reload_locales!(locale:)
|
21
31
|
Accent::LocaleReloader.new(locale: locale).reload!
|
32
|
+
rescue
|
33
|
+
raise Error
|
22
34
|
end
|
23
35
|
end
|
24
36
|
end
|
@@ -12,6 +12,10 @@ module Aigu
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
def self.connection
|
16
|
+
@connection ||= Faraday.new(url: Aigu::Rails.configuration.api_url)
|
17
|
+
end
|
18
|
+
|
15
19
|
protected
|
16
20
|
|
17
21
|
def parsed_response
|
@@ -22,21 +26,16 @@ module Aigu
|
|
22
26
|
"#{::Rails.root}/tmp/locales.json"
|
23
27
|
end
|
24
28
|
|
25
|
-
def api_key
|
26
|
-
Aigu::Rails.configuration.api_key
|
27
|
-
end
|
28
|
-
|
29
29
|
def response
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
http.request(req)
|
30
|
+
self.class.connection.get do |req|
|
31
|
+
req.url Aigu::Rails.configuration.default_path
|
32
|
+
req.headers['Authorization'] = Aigu::Rails.configuration.api_key
|
33
|
+
req.params = {
|
34
|
+
language: @locale,
|
35
|
+
render_format: 'json',
|
36
|
+
render_filename: 'locales.json'
|
37
|
+
}
|
38
|
+
end
|
40
39
|
end
|
41
40
|
end
|
42
41
|
end
|
data/lib/aigu-rails/version.rb
CHANGED
data/spec/aigu_rails_spec.rb
CHANGED
@@ -21,9 +21,16 @@ describe Aigu::Rails do
|
|
21
21
|
|
22
22
|
before do
|
23
23
|
expect(Aigu::Rails::Accent::LocaleReloader).to receive(:new).with(locale: locale).and_return(locale_reloader)
|
24
|
-
expect(locale_reloader).to receive(:reload!)
|
25
24
|
end
|
26
25
|
|
27
|
-
|
26
|
+
context 'without raised errors' do
|
27
|
+
before { expect(locale_reloader).to receive(:reload!) }
|
28
|
+
specify { base_class.reload_locales!(locale: locale) }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with raised error' do
|
32
|
+
before { expect(locale_reloader).to receive(:reload!) { raise StandardError } }
|
33
|
+
it { expect { base_class.reload_locales!(locale: locale) }.to raise_error(Aigu::Rails::Error) }
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aigu-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Garneau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.7'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: faraday
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.9'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.9'
|
83
97
|
description: Add support for Rails locales with aigu
|
84
98
|
email:
|
85
99
|
- sgarneau@mirego.com
|