rosette 0.3.2 → 0.3.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: 907b0d5391095f5c4b97469838db2c65d209e1a2ff5fceb268a485f0687cf43f
4
- data.tar.gz: 7a04c08f02a42c13e1706c72426f7c231291092d790b4f526466a4e57a312cf7
3
+ metadata.gz: 7a6d97a97a755feb6b3d7a69bb1059ca61a4d13775feee044bd984bd2d676c9a
4
+ data.tar.gz: ac18c0186280744399171f29f64a2f63e36b027c9e2147227dfac4690d1387a7
5
5
  SHA512:
6
- metadata.gz: 7c050ce5890468ac5f80400ea6167fc9b778b34c3921f31c6ffb48423f2adf5d12b23c569712ec66909dc622bb13e06dc02ed3cd9821fbc912368709c7bbd2f6
7
- data.tar.gz: 4a957561060865b20c39cd6bb5bf3fc3e6a3c8b933d287c9f2476f3bd56a5c037dcced15ea7d33022af1e9e6f360f2d937713657fff63c735b0ffe5bad275b39
6
+ metadata.gz: a3fc87c9790ff2227446db2c29b91b238b7b9de9c25a172e98afc4663f291977301dc0dd66d70f35ceff0eee0adc5a6e14864ec1b7dca1e5a0009951308b6065
7
+ data.tar.gz: 8f5fa5333bde31e318d9d1da5f3cd73889073d0210c08185c0380caa909aec93c00d390be151274ce38c6a56e81f321e24c7b777c8cbbb9076ab828c582a3dd0
data/lib/rosette/cli.rb CHANGED
@@ -12,23 +12,29 @@ module Rosette
12
12
  delegate :select, :ask, to: :@prompt
13
13
 
14
14
  def run
15
- ask_for_command
15
+ loop do
16
+ ask_for_command
17
+ return exit 0 if exit_cli?
16
18
 
17
- return help if command == "help"
19
+ next display_help if help?
20
+ next normalize! if normalize?
18
21
 
19
- ask_for_key
20
- send command
22
+ ask_for_key
23
+ send command
24
+ end
21
25
  end
22
26
 
23
27
  private
24
28
 
25
29
  def ask_for_command
26
- @prompt = TTY::Prompt.new
27
- @command = select("What do you want to achieve?") do |menu|
28
- menu.choice("Read a translation", "read")
29
- menu.choice("Add a translation", "add")
30
- menu.choice("Remove a translation", "remove")
31
- menu.choice("Display help", "help")
30
+ @prompt = TTY::Prompt.new
31
+ @command = select("\nWhat do you want to achieve?") do |menu|
32
+ menu.choice("1. Read a translation", "read")
33
+ menu.choice("2. Add a translation", "add")
34
+ menu.choice("3. Remove a translation", "remove")
35
+ menu.choice("4. Normalize locales", "normalize")
36
+ menu.choice("5. Help", "help")
37
+ menu.choice("6. Exit", "exit_cli")
32
38
  end
33
39
  end
34
40
 
@@ -43,6 +49,10 @@ module Rosette
43
49
  end
44
50
  end
45
51
 
52
+ def exit_cli? = command == "exit_cli"
53
+ def help? = command == "help"
54
+ def normalize? = command == "normalize"
55
+
46
56
  # COMMANDS
47
57
 
48
58
  def read
@@ -65,11 +75,15 @@ module Rosette
65
75
  end
66
76
  end
67
77
 
68
- def help
78
+ def normalize!
79
+ Manager.normalize!
80
+ end
81
+
82
+ def display_help
69
83
  puts <<~HELP
70
84
 
71
- For each command you must provide a key pointing to the translation.
72
- It can begin with or without the locale. These are all valid keys:
85
+ For commands read/add/remove you must provide a key pointing to the translation.
86
+ It can begin with or without the locale. These keys are all considered equivalent:
73
87
 
74
88
  fr.activemodel.errors.blank
75
89
  en.activemodel.errors.blank
@@ -10,6 +10,10 @@ class Manager
10
10
  METHOD
11
11
  end
12
12
 
13
+ def self.normalize!
14
+ I18n::Tasks::CLI.start(["normalize"]) if Rosette.normalize
15
+ end
16
+
13
17
  private
14
18
 
15
19
  def initialize(locale, key, translation = nil)
@@ -68,8 +72,4 @@ class Manager
68
72
  key.split(".").map(&:to_sym)
69
73
  end
70
74
 
71
- def self.normalize!
72
- I18n::Tasks::CLI.start(["normalize"]) if Rosette.normalize
73
- end
74
-
75
75
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rosette
4
4
 
5
- VERSION = "0.3.2"
5
+ VERSION = "0.3.4"
6
6
 
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rosette
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandre Platteeuw
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-19 00:00:00.000000000 Z
11
+ date: 2023-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n-tasks