i18n-migrations 1.1.2 → 1.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f6b1e9a88178e490e8baba639086d36979b29d071c21fa370fb735ba50bb59b5
4
- data.tar.gz: 8e7d1a53fa84cb226edec7bd5fdf60149b4935cf3d0030ebef6cc8d75846f815
3
+ metadata.gz: e0f8d5372c9541fdf212f771cbf6fa9f8159fb4f6fb5dab37beca63862cf2deb
4
+ data.tar.gz: 6f6d8dc7c053da0500415dbe8999bd015eec3023d92898c177b54af5962b4fc6
5
5
  SHA512:
6
- metadata.gz: 43f7eddfd78658cc5f25ba43d7169928e9f53505ab01df23fb2e83310c05954d9b997827cfad186fc7abf76a7183c5addc8b13d156f80b5efad523743975d14a
7
- data.tar.gz: dab17959080db63b69f5a8ed32733b2769bd35592c52334c3e6624db16c96719ce38d82a3a91ff7f915d623652817dffe4447806d2b56c81bc837637453c05cc
6
+ metadata.gz: 905e9f53dda1e46c7a169ffe869260854964fa323baf030d71f8c9d76d16ba40db658b0235da346256123c8a3e21d0805beef3c055c6efc733e8070a02f0403f
7
+ data.tar.gz: f3f1cec60dfb164bc0d61e9a81004eb9ebd527568613af170f9d3429e15bf9ddc1803f8258476c5c621e299e3ee87354067e361e34ee29b37937dc8ee74827f3
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.6.4
1
+ ruby-2.6.5
data/Gemfile CHANGED
@@ -9,4 +9,4 @@ gem 'ruby-gmail'
9
9
  gem 'activesupport'
10
10
  gem 'rspec'
11
11
  gem 'colorize'
12
- gem 'rest-client'
12
+ gem 'faraday'
data/bin/i18n-migrate CHANGED
@@ -46,10 +46,10 @@ case ARGV.shift
46
46
  force = extract_option('-f')
47
47
  migrator.push(ARGV[0] || 'all', force)
48
48
 
49
- when 'exp-pull'
49
+ when 'ct-pull'
50
50
  migrator.exp_pull(ARGV[0] || 'all')
51
51
 
52
- when 'exp-push'
52
+ when 'ct-push'
53
53
  force = extract_option('-f')
54
54
  migrator.exp_push(ARGV[0] || 'all', force)
55
55
 
@@ -84,6 +84,9 @@ Commands:
84
84
  new_locale - Copy your current main locale file to a new language, translating all keys.
85
85
  version - Print version of locales.
86
86
 
87
+ ct-pull - Pull from CrowdTranslate
88
+ ct-push - Push to CrowdTranslate
89
+
87
90
  i18n-migrations version #{I18n::Migrations::VERSION}
88
91
  USAGE
89
92
  end
@@ -27,6 +27,6 @@ Gem::Specification.new do |spec|
27
27
 
28
28
  spec.add_dependency 'google_drive'
29
29
  spec.add_dependency 'activesupport'
30
- spec.add_dependency 'rest-client'
30
+ spec.add_dependency 'faraday'
31
31
  spec.add_dependency 'colorize'
32
32
  end
@@ -1,21 +1,38 @@
1
- require 'rest_client'
1
+ require 'faraday'
2
2
 
3
3
  module I18n
4
4
  module Migrations
5
5
  class CrowdTranslateClient
6
+ def initialize
7
+ token = ENV['CROWD_TRANSLATE_API_TOKEN']
8
+ raise("You must define CROWD_TRANSLATE_API_TOKEN in order to talk to Crowd Translate") unless token.present?
9
+
10
+ server = ENV['CROWD_TRANSLATE_SERVER'] || 'https://crowd-translate.herokuapp.com'
11
+ @faraday = Faraday.new(
12
+ url: "#{server}/api/v1",
13
+ headers: { 'X-CrowdTranslateApiToken' => token },
14
+ )
15
+ end
16
+
6
17
  def sync_migrations(migrations)
7
18
  local_versions = migrations.all_versions
8
- remote_versions = JSON.parse(get('/migrations.json'))
19
+ remote_versions = JSON.parse(get('migrations.json'))
9
20
 
10
21
  if (extra_versions = remote_versions - local_versions).present?
11
22
  raise("You may not upload migrations to the server because it has migrations not found locally: " +
12
- "#{extra_versions.join(', ')}")
23
+ "#{extra_versions.join(', ')}")
13
24
  end
14
25
 
15
26
  if (versions_to_add = local_versions - remote_versions).present?
16
27
  versions_to_add.each do |version|
17
- put("/migrations/#{version}.json",
18
- ruby: migrations.get_migration(version: version))
28
+ begin
29
+ put("migrations/#{version}.json",
30
+ migration: { ruby_file: migrations.get_migration(version: version) })
31
+ rescue
32
+ puts "There was an error updating migration:".red
33
+ puts " #{migrations.migration_file(version: version)}".bold
34
+ raise
35
+ end
19
36
  end
20
37
  end
21
38
  end
@@ -25,20 +42,32 @@ module I18n
25
42
  end
26
43
 
27
44
  def get_locale_file(locale_code)
28
- get("/locales/#{locale_code}.yml")
45
+ get("locales/#{locale_code}.yml")
29
46
  end
30
47
 
31
48
  private
32
49
 
33
- def get(url)
34
- response = RestClient.get "https://crowd-translate.herokuapp.com#{url}"
35
- response.body
50
+ def get(path)
51
+ puts "GET #{path}".bold
52
+ parse_response @faraday.get path
36
53
  end
37
54
 
38
- def put(url, params = {})
39
- response = RestClient.put "https://crowd-translate.herokuapp.com#{url}",
40
- params: params
41
- response.body
55
+ def put(path, params = {})
56
+ puts "PUT #{path} #{params}".bold
57
+ parse_response @faraday.put path, params
58
+ end
59
+
60
+ def parse_response(response)
61
+ if response.success?
62
+ response.body
63
+ else
64
+ error = begin
65
+ JSON.parse(response.body)['error']
66
+ rescue
67
+ response.body
68
+ end
69
+ raise error
70
+ end
42
71
  end
43
72
  end
44
73
  end
@@ -2,7 +2,6 @@ require 'fileutils'
2
2
  require 'yaml'
3
3
  require 'active_support'
4
4
  require 'colorize'
5
- require 'rest_client'
6
5
 
7
6
  # this class does all the work, but doesn't hold config or do more than one locale
8
7
  module I18n
@@ -12,7 +12,11 @@ module I18n
12
12
  end
13
13
 
14
14
  def get_migration(version:)
15
- File.read(File.join(@migration_dir, "#{version}.rb"))
15
+ File.read(migration_file(version: version))
16
+ end
17
+
18
+ def migration_file(version:)
19
+ File.join(@migration_dir, "#{version}.rb")
16
20
  end
17
21
 
18
22
  def play_migration(version:, locale:, data:, notes:, dictionary:, direction:)
@@ -11,7 +11,7 @@ require 'i18n/migrations/locale'
11
11
  require 'i18n/migrations/migration_factory'
12
12
  require 'i18n/migrations/crowd_translate_client'
13
13
 
14
- CONCURRENT_THREADS = 4
14
+ CONCURRENT_THREADS = 3
15
15
 
16
16
  # this class knows how to do all the things the cli needs done.
17
17
  # it mostly delegates to locale to do it, often asking multiple locales to do the same thing
@@ -1,5 +1,5 @@
1
1
  module I18n
2
2
  module Migrations
3
- VERSION = "1.1.2"
3
+ VERSION = "1.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Lightsmith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-18 00:00:00.000000000 Z
11
+ date: 2020-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,7 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rest-client
70
+ name: faraday
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -106,7 +106,6 @@ files:
106
106
  - ".gitignore"
107
107
  - ".i18n-migrations.default.yml"
108
108
  - ".rspec"
109
- - ".ruby-gemset"
110
109
  - ".ruby-version"
111
110
  - ".travis.yml"
112
111
  - CODE_OF_CONDUCT.md
@@ -152,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
151
  - !ruby/object:Gem::Version
153
152
  version: '0'
154
153
  requirements: []
155
- rubygems_version: 3.0.3
154
+ rubygems_version: 3.0.6
156
155
  signing_key:
157
156
  specification_version: 4
158
157
  summary: Migrations for doing i18n.