localeapp 0.3.1 → 0.3.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.
- data/CHANGELOG.md +5 -0
- data/features/step_definitions/cli_steps.rb +4 -4
- data/lib/localeapp/cli/pull.rb +1 -1
- data/lib/localeapp/poller.rb +1 -1
- data/lib/localeapp/routes.rb +1 -1
- data/lib/localeapp/version.rb +1 -1
- data/spec/localeapp/poller_spec.rb +4 -4
- data/spec/localeapp/routes_spec.rb +3 -3
- metadata +4 -4
data/CHANGELOG.md
CHANGED
@@ -16,14 +16,14 @@ When /^I have a valid project on localeapp\.com but an incorrect api key "([^"]*
|
|
16
16
|
end
|
17
17
|
|
18
18
|
When /^I have a translations on localeapp\.com for the project with api key "([^"]*)"$/ do |api_key|
|
19
|
-
uri = "https://api.localeapp.com/v1/projects/#{api_key}/translations.
|
20
|
-
body = valid_translation_data.
|
19
|
+
uri = "https://api.localeapp.com/v1/projects/#{api_key}/translations.yml"
|
20
|
+
body = valid_translation_data.to_yaml
|
21
21
|
add_fake_web_uri(:get, uri, ['200', 'OK'], body)
|
22
22
|
end
|
23
23
|
|
24
24
|
When /^new translations for the api key "([^"]*)" since "([^"]*)" with time "([^"]*)"$/ do |api_key, update_time, new_time|
|
25
|
-
uri = "https://api.localeapp.com/v1/projects/#{api_key}/translations.
|
26
|
-
body = valid_translation_data.
|
25
|
+
uri = "https://api.localeapp.com/v1/projects/#{api_key}/translations.yml?updated_at=#{update_time}"
|
26
|
+
body = valid_translation_data.to_yaml
|
27
27
|
add_fake_web_uri(:get, uri, ['200', 'OK'], body, 'date' => Time.at(new_time.to_i).httpdate)
|
28
28
|
end
|
29
29
|
|
data/lib/localeapp/cli/pull.rb
CHANGED
@@ -21,7 +21,7 @@ module Localeapp
|
|
21
21
|
def update_backend(response)
|
22
22
|
@output.puts "Success!"
|
23
23
|
@output.puts "Updating backend:"
|
24
|
-
Localeapp.updater.update(
|
24
|
+
Localeapp.updater.update(YAML.load(response))
|
25
25
|
@output.puts "Success!"
|
26
26
|
Localeapp.poller.write_synchronization_data!(Time.now.to_i, Time.now.to_i)
|
27
27
|
end
|
data/lib/localeapp/poller.rb
CHANGED
@@ -50,7 +50,7 @@ module Localeapp
|
|
50
50
|
|
51
51
|
def handle_success(response)
|
52
52
|
@success = true
|
53
|
-
Localeapp.updater.update(
|
53
|
+
Localeapp.updater.update(YAML.load(response))
|
54
54
|
write_synchronization_data!(Time.now.to_i, Time.parse(response.headers[:date]).to_i)
|
55
55
|
end
|
56
56
|
|
data/lib/localeapp/routes.rb
CHANGED
@@ -12,7 +12,7 @@ module Localeapp
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def translations_url(options={})
|
15
|
-
options[:format] ||= '
|
15
|
+
options[:format] ||= 'yml'
|
16
16
|
url = http_scheme.build(base_options.merge(:path => translations_path(options[:format])))
|
17
17
|
url.query = options[:query].map { |k,v| "#{k}=#{v}" }.join('&') if options[:query]
|
18
18
|
url.to_s
|
data/lib/localeapp/version.rb
CHANGED
@@ -53,22 +53,22 @@ describe Localeapp::Poller do
|
|
53
53
|
|
54
54
|
describe "#poll!" do
|
55
55
|
it "returns false if get returns 304 Not Modified" do
|
56
|
-
FakeWeb.register_uri(:get, "https://api.localeapp.com/v1/projects/TEST_KEY/translations.
|
56
|
+
FakeWeb.register_uri(:get, "https://api.localeapp.com/v1/projects/TEST_KEY/translations.yml?updated_at=#{@updated_at}", :body => '', :status => ['304', 'Not Modified'])
|
57
57
|
@poller.poll!.should == false
|
58
58
|
end
|
59
59
|
|
60
60
|
it "returns false if get returns a 50x response" do
|
61
|
-
FakeWeb.register_uri(:get, "https://api.localeapp.com/v1/projects/TEST_KEY/translations.
|
61
|
+
FakeWeb.register_uri(:get, "https://api.localeapp.com/v1/projects/TEST_KEY/translations.yml?updated_at=#{@updated_at}", :body => '', :status => ['500', 'Internal Server Error'])
|
62
62
|
@poller.poll!.should == false
|
63
63
|
end
|
64
64
|
|
65
65
|
it "returns false if get returns 200 OK" do
|
66
|
-
FakeWeb.register_uri(:get, "https://api.localeapp.com/v1/projects/TEST_KEY/translations.
|
66
|
+
FakeWeb.register_uri(:get, "https://api.localeapp.com/v1/projects/TEST_KEY/translations.yml?updated_at=#{@updated_at}", :body => @hash.to_yaml, :status => ['200', 'OK'], :date => Time.now.httpdate)
|
67
67
|
@poller.poll!.should == true
|
68
68
|
end
|
69
69
|
|
70
70
|
it "passes the data through to the Updater" do
|
71
|
-
FakeWeb.register_uri(:get, "https://api.localeapp.com/v1/projects/TEST_KEY/translations.
|
71
|
+
FakeWeb.register_uri(:get, "https://api.localeapp.com/v1/projects/TEST_KEY/translations.yml?updated_at=#{@updated_at}", :body => @hash.to_yaml, :status => ['200', 'OK'], :date => Time.now.httpdate)
|
72
72
|
Localeapp.updater.should_receive(:update).with(@hash)
|
73
73
|
@poller.poll!
|
74
74
|
end
|
@@ -41,9 +41,9 @@ describe Localeapp::Routes do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
describe "#translations_url" do
|
44
|
-
it "it extends the project_url and defaults to
|
44
|
+
it "it extends the project_url and defaults to yml" do
|
45
45
|
with_configuration(@config) do
|
46
|
-
@routes.translations_url.should == "https://test.host/v1/projects/API_KEY/translations.
|
46
|
+
@routes.translations_url.should == "https://test.host/v1/projects/API_KEY/translations.yml"
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -57,7 +57,7 @@ describe Localeapp::Routes do
|
|
57
57
|
|
58
58
|
it "can be changed to another content type" do
|
59
59
|
with_configuration(@config) do
|
60
|
-
@routes.translations_url(:format => :
|
60
|
+
@routes.translations_url(:format => :json).should == 'https://test.host/v1/projects/API_KEY/translations.json'
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: localeapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christopher Dell
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-12-
|
19
|
+
date: 2011-12-20 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: i18n
|