rosette 0.3.1 → 0.3.3

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: 7d06214ac63c9666ca0fd74730175cc9eb308dbd16bd83e3fca8e9336d7123dc
4
- data.tar.gz: d7521ae037801fa8c83d74dd2a22f6aa11f3269f90e60fc117746429b238564b
3
+ metadata.gz: 514d0d011935666b1e2a7455cd29df13f12b2cd2130cd9625349f9f9013198d3
4
+ data.tar.gz: 637e017006a28f72e16a19a457f1760cae3c1a428a2f3e5efa0921fae2f1e7c5
5
5
  SHA512:
6
- metadata.gz: 2118244884e6269ae5b3ef2146037ca7086fe32bad51f4bc4be5ab9ba3a12c262cb9244ef48d564537f3223185b3f4f563787b1b14bbc4439a078e2a0dff6267
7
- data.tar.gz: 62c3f6715880adb58917f3a69544673b4110c8b47f0f1e7192e4858919104e2679925f86bba89370410c049379f56de7c72818fe67f6752789617651c85828fe
6
+ metadata.gz: 272ae0fe075b3a4927806cc5ec1e28331673b35d652acb7af746964bbe844c7478b650d0468c1b6d16f0f65724faf4dad0de5707bf813703988e07e9e5a88708
7
+ data.tar.gz: 07fefd534e3d8be9822c3a6f5d293deba54042af6f1744981e97fd245e6e399b6ccd3772c6efaef518da0d9144708ce318ec1ec67c83b99b65edc15ab777d01c
@@ -6,8 +6,6 @@ module Rosette
6
6
  def create
7
7
  available_locales.each { |locale, translation| Manager.create(locale, key, translation) }
8
8
 
9
- Manager.normalize!
10
-
11
9
  redirect_to redirect_path, notice: "Translation(s) added"
12
10
  rescue StandardError => e
13
11
  @error_message = e.message
data/lib/rosette/cli.rb CHANGED
@@ -12,23 +12,27 @@ 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 if exit?
16
18
 
17
- return help if command == "help"
19
+ next display_help if help?
18
20
 
19
- ask_for_key
20
- send command
21
+ ask_for_key
22
+ send command
23
+ end
21
24
  end
22
25
 
23
26
  private
24
27
 
25
28
  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")
29
+ @prompt = TTY::Prompt.new
30
+ @command = select("\nWhat do you want to achieve?") do |menu|
31
+ menu.choice("1. Read a translation", "read")
32
+ menu.choice("2. Add a translation", "add")
33
+ menu.choice("3. Remove a translation", "remove")
34
+ menu.choice("4. Help", "help")
35
+ menu.choice("5. Exit", "exit")
32
36
  end
33
37
  end
34
38
 
@@ -43,6 +47,14 @@ module Rosette
43
47
  end
44
48
  end
45
49
 
50
+ def help?
51
+ command == "help"
52
+ end
53
+
54
+ def exit?
55
+ command == "exit"
56
+ end
57
+
46
58
  # COMMANDS
47
59
 
48
60
  def read
@@ -65,10 +77,10 @@ module Rosette
65
77
  end
66
78
  end
67
79
 
68
- def help
80
+ def display_help
69
81
  puts <<~HELP
70
82
 
71
- For each command you must provide a key pointing to the translation.
83
+ For commands read/add/remove you must provide a key pointing to the translation.
72
84
  It can begin with or without the locale. These are all valid keys:
73
85
 
74
86
  fr.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.1"
5
+ VERSION = "0.3.3"
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.1
4
+ version: 0.3.3
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