ios_polyglot_cli 2.0.1 → 2.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
  SHA256:
3
- metadata.gz: c70a269cb650575390a356bd3e4868c03cedf3a0f9bb4f6a3742f9d205c25d9a
4
- data.tar.gz: 9da347e54fbe271f21821718ad21e8a7f7e7dfdefb6aacc9bf74d1b60213c1e8
3
+ metadata.gz: ff13c894f3a53ed38713832b4951f7fa3387d55c6574efcdda8d966424025336
4
+ data.tar.gz: 73737df0540b355583b685313b61e679e58a4996fa4d06d65ed73fb0161e9cf5
5
5
  SHA512:
6
- metadata.gz: 657216588118ea21a532ddddcfb1b7e1f39499c5e58e1e94bfb02c49d127ee950533f94011f587b9dfec9d68bd1636e28848ea39b513313727e216e0a556ac97
7
- data.tar.gz: 0410ba10fab8373e94b3328fdbc4a0125f4e536c2563bdb11455669cd1ba8add6a2b384f2c7cac99faf47907c9cab58a7f5d9d68fcaacc6ea894a1ade83b9be0
6
+ metadata.gz: ddb5da4c2b5a447cbcc8785310d07c8e04a7286581851d30b651c6c8da42c978eb16183f278e38a2f3f11237f0074684c23ca731eb38567d91232be3de7ee232
7
+ data.tar.gz: 93faba5757552a946f8ef5f92fb0a5dc78a3f4ffb09d8c641c9e09dd7b835e96d5d419338905cc7f677f5562b0d795ba88bdef31b6fab1503212989f09856902
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ios_polyglot_cli (2.0.1)
4
+ ios_polyglot_cli (2.1.0)
5
5
  activesupport
6
6
  commander
7
7
  json_api_client
data/README.md CHANGED
@@ -7,12 +7,20 @@ Polyglot client for iOS development
7
7
 
8
8
  If you use old polyglot-cli or native polyglot please uninstall them first:
9
9
 
10
- $ sudo gem uninstall polyglot-cli
11
- $ brew uninstall --force infinum/formulae/polyglot
10
+ sudo gem uninstall polyglot-cli
11
+ brew uninstall --force infinum/formulae/polyglot
12
12
 
13
13
  Then to install polyglot simply run:
14
14
 
15
- $ gem install ios_polyglot_cli
15
+ gem install ios_polyglot_cli
16
+
17
+ If you have any issues with above command, please consult this [thread](https://stackoverflow.com/questions/2119064/sudo-gem-install-or-gem-install-and-gem-locations).
18
+
19
+ You can check if everything is OK running:
20
+
21
+ polyglot --help
22
+
23
+ You should see output with all commands and their description.
16
24
 
17
25
  ## Usage
18
26
 
@@ -20,7 +28,7 @@ Then to install polyglot simply run:
20
28
 
21
29
  You will have to login with your Infinum ID if you want to use polyglot:
22
30
 
23
- $ polyglot login
31
+ polyglot login
24
32
 
25
33
  If your login action is successful, polyglot will ask you to access Keychain. There it will save your access token, so you don’t have to enter your credentials every time when you use `polyglot` command.
26
34
 
@@ -28,12 +36,20 @@ If your login action is successful, polyglot will ask you to access Keychain. Th
28
36
 
29
37
  To setup polyglot in your Xcode project use:
30
38
 
31
- $ polyglot init
39
+ polyglot init
32
40
 
33
41
  It will prompt you with project list to select one you are setting up. You can provide source language (Swift/ObjC), translations path and resources path. It will create `polyglot.yml` file which you can edit later and add additional Polyglot projects.
34
42
 
35
43
  Also, you can pass optional parameter `--query` or `-q`. It will prompt you with a list of all projects that match specified query.
36
44
 
45
+ ### Projects
46
+
47
+ If you want to see all polyglot projects and their `IDs` enter:
48
+
49
+ polyglot projects
50
+
51
+ Also, you can pass optional parameter `--query` or `-q`. It will prompt you with a list of all projects that match specified query.
52
+
37
53
  ### Legacy projects
38
54
 
39
55
  New style translations will create files names `en_US.strings` for example, and some old projects still use old naming in the style of `en.strings`. To get around this issue, you either need to migrate your project to use the new naming (be mindful of existing app's settings), or add this line under your path value:
data/exe/polyglot CHANGED
@@ -22,7 +22,7 @@ end
22
22
  command :init do |c|
23
23
  c.syntax = 'polyglot init [options]'
24
24
  c.description = 'Sets up a polyglot.yml config for selected project.'
25
- c.option '--query STRING', String, 'Only shows projects that matches string'
25
+ c.option '--query STRING', String, 'Only show projects which name matches query string.'
26
26
  c.action do |_args, options|
27
27
  PolyglotIos::ErrorHandler.rescuable do
28
28
  PolyglotIos::Command::Setup.init(options)
@@ -30,6 +30,17 @@ command :init do |c|
30
30
  end
31
31
  end
32
32
 
33
+ command :projects do |c|
34
+ c.syntax = 'polyglot projects [options]'
35
+ c.description = 'Lists all available polyglot projects with their IDs.'
36
+ c.option '--query STRING', String, 'Only show projects which name matches query string.'
37
+ c.action do |_args, options|
38
+ PolyglotIos::ErrorHandler.rescuable do
39
+ PolyglotIos::Command::Projects.init(options)
40
+ end
41
+ end
42
+ end
43
+
33
44
  command :pull do |c|
34
45
  c.syntax = 'polyglot pull'
35
46
  c.description = 'Pulls all translations from Polyglot and generates necessary files'
@@ -30,6 +30,7 @@ require 'ios_polyglot_cli/serializers/sources/sources_serializer_swift'
30
30
 
31
31
  # Commands
32
32
  require 'ios_polyglot_cli/commands/login'
33
+ require 'ios_polyglot_cli/commands/projects'
33
34
  require 'ios_polyglot_cli/commands/setup'
34
35
  require 'ios_polyglot_cli/commands/pull'
35
36
 
@@ -0,0 +1,60 @@
1
+ require 'commander/blank'
2
+ require 'commander/command'
3
+
4
+ module PolyglotIos
5
+ module Command
6
+ class Projects
7
+ include Helper::Terminal
8
+ include Helper::General
9
+
10
+ attr_accessor :options
11
+
12
+ def self.init(options = Commander::Command::Options.new)
13
+ new(options).call
14
+ end
15
+
16
+ def initialize(options = Commander::Command::Options.new)
17
+ @options = options
18
+ end
19
+
20
+ def call
21
+ list_projects
22
+ end
23
+
24
+ def filtered_projects
25
+ projects
26
+ .select { |key, _id| key[/^(.*?(#{option_query})[^$]*)$/i] }
27
+ .sort_by { |p| p[0].downcase }
28
+ .to_h
29
+ end
30
+
31
+ def projects
32
+ prompt.say('Getting projects...')
33
+ PolyglotIos::Resource::Project.token(token).depaginate.each_with_object({}) do |r, hash|
34
+ hash[r.name] = r.id
35
+ end
36
+ end
37
+
38
+ def option_query
39
+ @option_query ||= @options.__hash__.fetch(:query, '')
40
+ end
41
+
42
+ private
43
+
44
+ def list_projects
45
+ projects = filtered_projects
46
+ selection = projects
47
+ .each_with_object({}) do |project, hash|
48
+ project_name = project[0]
49
+ project_id = project[1]
50
+ display_name = "#{project_name} => #{project_id}"
51
+ hash[display_name] = project_id
52
+ end
53
+ prompt.say(" Name - ID: \n ----------")
54
+ selected_id = prompt
55
+ .select("", selection)
56
+ end
57
+
58
+ end
59
+ end
60
+ end
@@ -3,7 +3,7 @@ require 'commander/command'
3
3
 
4
4
  module PolyglotIos
5
5
  module Command
6
- class Setup
6
+ class Setup < Projects
7
7
  include Helper::Terminal
8
8
  include Helper::General
9
9
 
@@ -40,22 +40,7 @@ module PolyglotIos
40
40
  def project_id_prompt
41
41
  prompt.select('Choose a project: ', filtered_projects)
42
42
  end
43
-
44
- def projects
45
- prompt.say('Getting projects...')
46
- PolyglotIos::Resource::Project.token(token).depaginate.each_with_object({}) do |r, hash|
47
- hash[r.name] = r.id
48
- end
49
- end
50
-
51
- def filtered_projects
52
- projects.select { |key, _id| key[/^(.*?(#{option_query})[^$]*)$/i] }.sort_by { |p| p[0].downcase }.to_h
53
- end
54
-
55
- def option_query
56
- @option_query ||= @options.__hash__.fetch(:query, '')
57
- end
58
-
43
+
59
44
  # Language
60
45
 
61
46
  def language_prompt
@@ -1,3 +1,3 @@
1
1
  module PolyglotIos
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ios_polyglot_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Filip Gulan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-17 00:00:00.000000000 Z
11
+ date: 2019-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -149,6 +149,7 @@ files:
149
149
  - lib/ios_polyglot_cli/api/translation.rb
150
150
  - lib/ios_polyglot_cli/api/translation_key.rb
151
151
  - lib/ios_polyglot_cli/commands/login.rb
152
+ - lib/ios_polyglot_cli/commands/projects.rb
152
153
  - lib/ios_polyglot_cli/commands/pull.rb
153
154
  - lib/ios_polyglot_cli/commands/setup.rb
154
155
  - lib/ios_polyglot_cli/error_handler.rb