yamlfish 0.1.0.alpha1 → 0.1.0.rc1
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 +4 -4
- data/Gemfile.lock +37 -34
- data/exe/yamlfish +11 -0
- data/lib/yamlfish/cli/pull.rb +10 -2
- data/lib/yamlfish/cli/push.rb +7 -2
- data/lib/yamlfish/cli/version.rb +1 -1
- data/lib/yamlfish/cli.rb +4 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49157d9d4bd38be7815795f988ec8b7029099a624c461ddd0b10e56f901e1ca5
|
4
|
+
data.tar.gz: 761f1992eb5676261ca80a84a7b1b5b69690052f16ddb5b3445146738232ffd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cf03873a81a812551491e8bee607b0a0beefb4000a57de94f789b81cd66fbb76e1b221376e65c2380fa19b35eb56850b4f6c8ffa2313a8289d8d0b09204370d
|
7
|
+
data.tar.gz: 8b5ca3a399a3bed89c3edc87b001c886b6690cd3955ab6b8bd334a0aae155220d085236b858b3ebc892f1d7bc7c0d8203d7ee7d51516b7a0de6e003a96f6b8c7
|
data/Gemfile.lock
CHANGED
@@ -1,64 +1,67 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
yamlfish (0.1.0.
|
4
|
+
yamlfish (0.1.0.rc1)
|
5
5
|
activesupport (>= 6)
|
6
6
|
faraday (~> 2.0)
|
7
|
+
rainbow (~> 3.1)
|
7
8
|
thor (~> 1.2)
|
8
9
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
12
|
-
activesupport (7.1
|
13
|
+
activesupport (7.2.1)
|
13
14
|
base64
|
14
15
|
bigdecimal
|
15
|
-
concurrent-ruby (~> 1.0, >= 1.
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
16
17
|
connection_pool (>= 2.2.5)
|
17
18
|
drb
|
18
19
|
i18n (>= 1.6, < 2)
|
20
|
+
logger (>= 1.4.2)
|
19
21
|
minitest (>= 5.1)
|
20
|
-
|
21
|
-
tzinfo (~> 2.0)
|
22
|
+
securerandom (>= 0.3)
|
23
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
22
24
|
base64 (0.2.0)
|
23
|
-
bigdecimal (3.1.
|
24
|
-
concurrent-ruby (1.
|
25
|
+
bigdecimal (3.1.8)
|
26
|
+
concurrent-ruby (1.3.4)
|
25
27
|
connection_pool (2.4.1)
|
26
|
-
diff-lcs (1.5.
|
27
|
-
drb (2.2.
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
faraday-net_http (3.
|
28
|
+
diff-lcs (1.5.1)
|
29
|
+
drb (2.2.1)
|
30
|
+
faraday (2.11.0)
|
31
|
+
faraday-net_http (>= 2.0, < 3.4)
|
32
|
+
logger
|
33
|
+
faraday-net_http (3.3.0)
|
32
34
|
net-http
|
33
|
-
i18n (1.14.
|
35
|
+
i18n (1.14.5)
|
34
36
|
concurrent-ruby (~> 1.0)
|
35
|
-
|
36
|
-
|
37
|
+
logger (1.6.0)
|
38
|
+
minitest (5.25.1)
|
37
39
|
net-http (0.4.1)
|
38
40
|
uri
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
rspec-
|
43
|
-
rspec-
|
44
|
-
|
45
|
-
|
46
|
-
|
41
|
+
rainbow (3.1.1)
|
42
|
+
rake (13.2.1)
|
43
|
+
rspec (3.13.0)
|
44
|
+
rspec-core (~> 3.13.0)
|
45
|
+
rspec-expectations (~> 3.13.0)
|
46
|
+
rspec-mocks (~> 3.13.0)
|
47
|
+
rspec-core (3.13.0)
|
48
|
+
rspec-support (~> 3.13.0)
|
49
|
+
rspec-expectations (3.13.2)
|
47
50
|
diff-lcs (>= 1.2.0, < 2.0)
|
48
|
-
rspec-support (~> 3.
|
49
|
-
rspec-mocks (3.
|
51
|
+
rspec-support (~> 3.13.0)
|
52
|
+
rspec-mocks (3.13.1)
|
50
53
|
diff-lcs (>= 1.2.0, < 2.0)
|
51
|
-
rspec-support (~> 3.
|
52
|
-
rspec-support (3.
|
53
|
-
|
54
|
-
thor (1.3.
|
54
|
+
rspec-support (~> 3.13.0)
|
55
|
+
rspec-support (3.13.1)
|
56
|
+
securerandom (0.3.1)
|
57
|
+
thor (1.3.1)
|
55
58
|
tzinfo (2.0.6)
|
56
59
|
concurrent-ruby (~> 1.0)
|
57
|
-
uri (0.13.
|
60
|
+
uri (0.13.1)
|
58
61
|
|
59
62
|
PLATFORMS
|
60
|
-
|
61
|
-
|
63
|
+
arm64-darwin-23
|
64
|
+
ruby
|
62
65
|
|
63
66
|
DEPENDENCIES
|
64
67
|
rake (~> 13.0)
|
@@ -66,4 +69,4 @@ DEPENDENCIES
|
|
66
69
|
yamlfish!
|
67
70
|
|
68
71
|
BUNDLED WITH
|
69
|
-
2.
|
72
|
+
2.5.18
|
data/exe/yamlfish
CHANGED
@@ -9,6 +9,9 @@ class YamlfishExe < Thor
|
|
9
9
|
option :branch, type: :string, default: "main"
|
10
10
|
def push(locale)
|
11
11
|
Yamlfish::Cli::Push.new(locale, branch: options[:branch]).call
|
12
|
+
rescue Errno::ENOENT => e
|
13
|
+
puts Rainbow("Could not push: #{e.message}").red.bright
|
14
|
+
exit 1
|
12
15
|
end
|
13
16
|
|
14
17
|
desc "pull", "Pulls translations from yamlfish"
|
@@ -17,6 +20,14 @@ class YamlfishExe < Thor
|
|
17
20
|
option :branch, type: :string, default: "main"
|
18
21
|
def pull(locale)
|
19
22
|
Yamlfish::Cli::Pull.new(locale, inplace: options[:inplace], force_update: options[:force_update], branch: options[:branch]).call
|
23
|
+
rescue Errno::ENOENT => e
|
24
|
+
puts Rainbow("Could not pull: #{e.message}").red.bright
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "version", "Prints the version"
|
29
|
+
def version
|
30
|
+
puts Yamlfish::Cli::VERSION
|
20
31
|
end
|
21
32
|
end
|
22
33
|
|
data/lib/yamlfish/cli/pull.rb
CHANGED
@@ -25,19 +25,27 @@ module Yamlfish
|
|
25
25
|
"Authorization": "Bearer #{Yamlfish::Cli.configuration.api_key}"
|
26
26
|
}
|
27
27
|
)
|
28
|
+
|
29
|
+
if response.status != 200
|
30
|
+
puts Rainbow("Failed to pull, unexpected HTTP status #{response.status}").red.bright
|
31
|
+
exit 1
|
32
|
+
end
|
33
|
+
|
28
34
|
translations = JSON.parse(response.body)
|
29
35
|
|
30
36
|
if @inplace
|
31
37
|
replace_inplace(translations)
|
38
|
+
puts "Fetched translations in-place for locale #{Rainbow(@locale_identifier).magenta.bright}"
|
32
39
|
else
|
33
40
|
dump_translations(translations)
|
41
|
+
puts "Downloaded new translations for locale #{Rainbow(@locale_identifier).magenta.bright}"
|
34
42
|
end
|
35
43
|
end
|
36
44
|
|
37
45
|
private
|
38
46
|
|
39
47
|
def replace_inplace(translations)
|
40
|
-
Dir.glob("
|
48
|
+
Dir.glob("./#{Yamlfish::Cli.configuration.locales_path}/**/*.yml").each do |filename|
|
41
49
|
file = YAML.load_file(filename).dot_flatten
|
42
50
|
update = false
|
43
51
|
|
@@ -53,7 +61,7 @@ module Yamlfish
|
|
53
61
|
end
|
54
62
|
|
55
63
|
def dump_translations(translations)
|
56
|
-
File.write("
|
64
|
+
File.write("./#{Yamlfish::Cli.configuration.locales_path}/#{@locale_identifier}.yml", Yamlfish::Cli::YamlDumper.dump(translations.dot_unflatten))
|
57
65
|
end
|
58
66
|
end
|
59
67
|
end
|
data/lib/yamlfish/cli/push.rb
CHANGED
@@ -12,7 +12,7 @@ module Yamlfish
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def call
|
15
|
-
translations = Dir.glob("
|
15
|
+
translations = Dir.glob("./#{Yamlfish::Cli.configuration.locales_path}/**/*.yml").each_with_object({}) do |filename, translations|
|
16
16
|
translations.deep_merge!(YAML.load_file(filename))
|
17
17
|
end
|
18
18
|
|
@@ -27,7 +27,12 @@ module Yamlfish
|
|
27
27
|
"Authorization": "Bearer #{Yamlfish::Cli.configuration.api_key}"
|
28
28
|
}
|
29
29
|
)
|
30
|
-
|
30
|
+
if response.status == 201
|
31
|
+
puts "Successfully pushed translations for locale #{Rainbow(@locale_identifier).magenta.bright} on branch #{Rainbow(@branch).magenta.bright}"
|
32
|
+
else
|
33
|
+
puts Rainbow("Failed to push, unexpected HTTP status #{response.status}").red.bright
|
34
|
+
exit 1
|
35
|
+
end
|
31
36
|
end
|
32
37
|
end
|
33
38
|
end
|
data/lib/yamlfish/cli/version.rb
CHANGED
data/lib/yamlfish/cli.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative "cli/version"
|
|
4
4
|
require_relative "cli/push"
|
5
5
|
require_relative "cli/pull"
|
6
6
|
require "yaml"
|
7
|
+
require "rainbow"
|
7
8
|
|
8
9
|
module Yamlfish
|
9
10
|
module Cli
|
@@ -15,9 +16,10 @@ module Yamlfish
|
|
15
16
|
end
|
16
17
|
|
17
18
|
class Configuration
|
18
|
-
attr_accessor :api_key, :project_token, :base_url
|
19
|
+
attr_accessor :api_key, :project_token, :base_url, :locales_path
|
19
20
|
|
20
21
|
DEFAULT_BASE_URL = "https://yamlfish.dev/api/v1"
|
22
|
+
DEFAULT_LOCALES_PATH = "config/locales"
|
21
23
|
|
22
24
|
def initialize
|
23
25
|
configuration = begin
|
@@ -29,6 +31,7 @@ module Yamlfish
|
|
29
31
|
@api_key = configuration["api_key"]
|
30
32
|
@project_token = configuration["project_token"]
|
31
33
|
@base_url = configuration["base_url"] || DEFAULT_BASE_URL
|
34
|
+
@locales_path = configuration["locales_path"] || DEFAULT_LOCALES_PATH
|
32
35
|
end
|
33
36
|
end
|
34
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yamlfish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrien Siami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rainbow
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.1'
|
55
69
|
description:
|
56
70
|
email:
|
57
71
|
- adrien@siami.fr
|
@@ -92,11 +106,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
92
106
|
version: 2.6.0
|
93
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
108
|
requirements:
|
95
|
-
- - "
|
109
|
+
- - ">="
|
96
110
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
111
|
+
version: '0'
|
98
112
|
requirements: []
|
99
|
-
rubygems_version: 3.
|
113
|
+
rubygems_version: 3.5.10
|
100
114
|
signing_key:
|
101
115
|
specification_version: 4
|
102
116
|
summary: Easily manage your translations with yamlfish
|