bisu 1.4.3 → 1.4.4

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: 446a726b593e73b165a48ac438000b7599964496
4
- data.tar.gz: 8dcf59ab1e303d41eaf2d748e52d62faa1fe8fe4
3
+ metadata.gz: 33b84e9bf0f3646a3679b0f9dddf54d8fc037fe3
4
+ data.tar.gz: d3ef51a9fb26c9f0850a215fbfc2f86bd128b7e7
5
5
  SHA512:
6
- metadata.gz: e0da63cddc2297390bf8a3e3d6d292946f4c59fd82ed50d3d4e86f87a99ceee26d443921d77d2d876c9863352b5470f9affa30e882e42366f4927b8b7d57cc3a
7
- data.tar.gz: d9c5b5038f8068379fd06a6e320e504903014e99d2bc129c27da2fa8ff2c51f971bc89376350feb11e78b26c1146bae5a2f0de846138b8dbc800aee03aca9c0b
6
+ metadata.gz: efeae832bf35b4dea2bd76933527260ed93d8da737ff6e7a8d386351531dab1b362ddcf2563cf630429920e2ec43c4a3e8dbd6ee33f107531c6bc5e3be3aef5b
7
+ data.tar.gz: d3aef119028db40c390020ed8f3f16c26adc364928e1e3ed150e6d75b114d9197728cdb3440955d59e5aad40a8076cfeedf1edb91b50461c4c8df44bfa68069a
data/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  `Bisu` adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## [1.4.4](https://github.com/hole19/bisu/releases/tag/v1.4.4)
6
+ Released on 2017/03/13
7
+
8
+ #### Added
9
+ - Removed dependency from onesky-ruby gem
10
+
11
+ ## [1.4.3](https://github.com/hole19/bisu/releases/tag/v1.4.3)
12
+ Released on 2016/12/22
13
+
14
+ #### Added
15
+ - Fixed a bug related to OneSky integration related to new line character handling
16
+
17
+ ## [1.4.2](https://github.com/hole19/bisu/releases/tag/v1.4.2)
18
+ Released on 2016/12/12
19
+
20
+ #### Added
21
+ - Fixed a missing gem dependency
22
+
5
23
  ## [1.4.1](https://github.com/hole19/bisu/releases/tag/v1.4.1)
6
24
  Released on 2016/12/01
7
25
 
data/Gemfile CHANGED
@@ -4,7 +4,6 @@ ruby '2.3.1'
4
4
  gem 'safe_yaml', '~> 1.0'
5
5
  gem 'colorize', '~> 0.7'
6
6
  gem 'xml-simple', '~> 1.1'
7
- gem 'onesky-ruby'
8
7
 
9
8
  gem 'webmock', '~> 1.20'
10
9
  gem 'rspec'
data/Gemfile.lock CHANGED
@@ -6,19 +6,7 @@ GEM
6
6
  crack (0.4.3)
7
7
  safe_yaml (~> 1.0.0)
8
8
  diff-lcs (1.2.5)
9
- domain_name (0.5.20161021)
10
- unf (>= 0.0.5, < 1.0.0)
11
9
  hashdiff (0.3.0)
12
- http-cookie (1.0.3)
13
- domain_name (~> 0.5)
14
- mime-types (2.99.3)
15
- netrc (0.11.0)
16
- onesky-ruby (1.0.1)
17
- rest-client (~> 1.8)
18
- rest-client (1.8.0)
19
- http-cookie (>= 1.0.2, < 2.0)
20
- mime-types (>= 1.16, < 3.0)
21
- netrc (~> 0.7)
22
10
  rspec (3.5.0)
23
11
  rspec-core (~> 3.5.0)
24
12
  rspec-expectations (~> 3.5.0)
@@ -36,9 +24,6 @@ GEM
36
24
  rspec-support (~> 3.5.0)
37
25
  rspec-support (3.5.0)
38
26
  safe_yaml (1.0.4)
39
- unf (0.1.4)
40
- unf_ext
41
- unf_ext (0.0.7.2)
42
27
  webmock (1.24.6)
43
28
  addressable (>= 2.3.6)
44
29
  crack (>= 0.3.2)
@@ -50,7 +35,6 @@ PLATFORMS
50
35
 
51
36
  DEPENDENCIES
52
37
  colorize (~> 0.7)
53
- onesky-ruby
54
38
  rspec
55
39
  rspec-its
56
40
  safe_yaml (~> 1.0)
@@ -61,4 +45,4 @@ RUBY VERSION
61
45
  ruby 2.3.1p112
62
46
 
63
47
  BUNDLED WITH
64
- 1.12.5
48
+ 1.14.3
data/bisu.gemspec CHANGED
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
19
19
  s.add_runtime_dependency 'safe_yaml', '~> 1.0'
20
20
  s.add_runtime_dependency 'colorize', '~> 0.7'
21
21
  s.add_runtime_dependency 'xml-simple', '~> 1.1'
22
- s.add_runtime_dependency 'onesky-ruby', '~> 1.0'
23
22
 
24
23
  s.add_development_dependency 'webmock', '~> 1.20'
25
24
  end
data/lib/bisu/one_sky.rb CHANGED
@@ -1,9 +1,11 @@
1
- require 'onesky'
1
+ require 'net/https'
2
+ require 'json'
2
3
 
3
4
  module Bisu
4
5
  class OneSky
5
6
  def initialize(api_key, api_secret, project_id, file_name)
6
- @client = Onesky::Client.new(api_key, api_secret)
7
+ @api_key = api_key
8
+ @api_secret = api_secret
7
9
  @project_id = project_id
8
10
  @file_name = file_name
9
11
  end
@@ -11,8 +13,8 @@ module Bisu
11
13
  def to_i18
12
14
  Logger.info("Downloading dictionary from OneSky...")
13
15
 
14
- proj = @client.project(@project_id)
15
- file = proj.export_multilingual(source_file_name: @file_name, file_format: "I18NEXT_MULTILINGUAL_JSON")
16
+ path = "https://platform.api.onesky.io/1/projects/#{@project_id}/translations/multilingual"
17
+ file = get(path, source_file_name: @file_name, file_format: "I18NEXT_MULTILINGUAL_JSON")
16
18
 
17
19
  hash = JSON.parse(file)
18
20
  hash.each do |lang, v|
@@ -28,5 +30,32 @@ module Bisu
28
30
 
29
31
  hash
30
32
  end
33
+
34
+ private
35
+
36
+ def get(url, params)
37
+ uri = URI(url)
38
+ uri.query = URI.encode_www_form(authenticated_params(params))
39
+
40
+ http = Net::HTTP.new(uri.host, uri.port)
41
+ http.use_ssl = true
42
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
43
+
44
+ request = Net::HTTP::Get.new(uri.request_uri)
45
+ response = http.request(request)
46
+
47
+ raise "OneSky: Http Error #{JSON.parse(response.body)}" if response.code.to_i >= 400
48
+
49
+ response.body
50
+ end
51
+
52
+ def authenticated_params(params)
53
+ now = Time.now.to_i
54
+
55
+ { api_key: @api_key,
56
+ timestamp: now,
57
+ dev_hash: Digest::MD5.hexdigest(now.to_s + @api_secret)
58
+ }.merge(params)
59
+ end
31
60
  end
32
61
  end
data/lib/bisu/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Bisu
2
- VERSION = '1.4.3'
3
- VERSION_UPDATED_AT = '2016-12-22'
2
+ VERSION = '1.4.4'
3
+ VERSION_UPDATED_AT = '2017-03-13'
4
4
  end
@@ -8,12 +8,14 @@ describe Bisu::OneSky do
8
8
 
9
9
  let(:os_response) { File.read("spec/fixtures/sample_one_sky_response.txt") }
10
10
 
11
- before do
12
- project = double("OSProject")
13
- allow_any_instance_of(Onesky::Client).to receive(:project).with(project_id).and_return(project)
14
- allow(project).to receive(:export_multilingual).with(source_file_name: file_name, file_format: "I18NEXT_MULTILINGUAL_JSON").and_return(os_response)
11
+ def stub_multilingual(status:, response:)
12
+ stub_request(:get, "https://platform.api.onesky.io/1/projects/#{project_id}/translations/multilingual").
13
+ with(query: hash_including(api_key: api_key, file_format: "I18NEXT_MULTILINGUAL_JSON", source_file_name: file_name)).
14
+ to_return(:status => status, :body => response, :headers => {})
15
15
  end
16
16
 
17
+ before { stub_multilingual(status: 200, response: os_response) }
18
+
17
19
  it { expect { to_i18 }.not_to raise_error }
18
20
 
19
21
  it "returns an hash in i18 format" do
@@ -27,7 +29,7 @@ describe Bisu::OneSky do
27
29
  end
28
30
 
29
31
  context "when OneSky raises an error" do
30
- before { allow_any_instance_of(Onesky::Client).to receive(:project).and_raise("ups... not allowed!") }
32
+ before { stub_multilingual(status: 400, response: { error: "ups... not allowed!" }.to_json) }
31
33
 
32
34
  it "raises that same error" do
33
35
  expect { to_i18 }.to raise_error /not allowed/
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bisu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - joaoffcosta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-22 00:00:00.000000000 Z
11
+ date: 2017-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: safe_yaml
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.1'
55
- - !ruby/object:Gem::Dependency
56
- name: onesky-ruby
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: webmock
71
57
  requirement: !ruby/object:Gem::Requirement