yatapp 0.4.1 → 0.4.2
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/README.md +12 -0
- data/lib/yatapp/version.rb +1 -1
- data/lib/yatapp/yata_api_caller.rb +13 -4
- data/lib/yatapp.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d57882c06b5a26836d0ae6527ec73d595b838198
|
4
|
+
data.tar.gz: be7eababe8e94a55f3b79a385c060c78b10300b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9a13183a3142c6faeb904378369f3cc286c94fe91b0c4bac4c0d1768d8311c06dd1222673902b885357820041a22e2b777b0e760521d74237b2f32d0fb1d448
|
7
|
+
data.tar.gz: c51734a8c720f139629d296d6f12671752392d7c6d3ba84e8da74c9f7925a43d20d962db9255963703017355c44d19dd4e06fd83a44bbbcae1824c09a11880b3
|
data/README.md
CHANGED
@@ -38,6 +38,18 @@ yata_project do
|
|
38
38
|
format :json # format you wish to get files in, available for now are (yaml, js and json)
|
39
39
|
end
|
40
40
|
|
41
|
+
# another example of the same project, fetching js translation and saving it at custom path
|
42
|
+
# (in this case to support rails assets pipe line)
|
43
|
+
# please notice that if 'save_to_path' is not specified gem will save translations to the local directory
|
44
|
+
# or in case of rails application into 'config/locales' directory
|
45
|
+
|
46
|
+
yata_project do
|
47
|
+
project_id 'your-project-id' # project id you wish to fetch from (you can find it under settings of your organization)
|
48
|
+
languages ['en', 'de'] # add any languages you wish by language code
|
49
|
+
format :js # format you wish to get files in, available for now are (yaml, js and json)
|
50
|
+
save_to_path "app/assets/javascripts/"
|
51
|
+
end
|
52
|
+
|
41
53
|
```
|
42
54
|
|
43
55
|
## Development
|
data/lib/yatapp/version.rb
CHANGED
@@ -5,7 +5,6 @@ require 'pry'
|
|
5
5
|
|
6
6
|
module Yatapp
|
7
7
|
class YataApiCaller
|
8
|
-
ALLOWED_FORMATS = %w(json yaml)
|
9
8
|
API_VERSION = 'v1'
|
10
9
|
API_END_POINT_URL = "/api/:api_version/project/:project_id/:lang/:format"
|
11
10
|
API_BASE_URL = "http://api.yatapp.net"
|
@@ -13,6 +12,7 @@ module Yatapp
|
|
13
12
|
:connection,
|
14
13
|
:languages,
|
15
14
|
:project_id,
|
15
|
+
:save_to_path,
|
16
16
|
:translation_format
|
17
17
|
].freeze
|
18
18
|
|
@@ -22,6 +22,7 @@ module Yatapp
|
|
22
22
|
def initialize
|
23
23
|
initialize_configuration
|
24
24
|
@translation_format = 'json'
|
25
|
+
@save_to_path = ""
|
25
26
|
@connection = prepare_connection
|
26
27
|
end
|
27
28
|
|
@@ -33,6 +34,10 @@ module Yatapp
|
|
33
34
|
@project_id = project_id
|
34
35
|
end
|
35
36
|
|
37
|
+
def set_save_to_path(path)
|
38
|
+
@save_to_path = path
|
39
|
+
end
|
40
|
+
|
36
41
|
def set_translation_format(translation_format)
|
37
42
|
@translation_format = translation_format
|
38
43
|
end
|
@@ -70,13 +75,17 @@ module Yatapp
|
|
70
75
|
end
|
71
76
|
|
72
77
|
def save_translation(lang, response)
|
73
|
-
bfp =
|
78
|
+
bfp = save_file_path
|
74
79
|
File.open("#{bfp}#{lang}.yata.#{translation_format}", 'wb') { |f| f.write(response.body) }
|
75
80
|
puts "#{lang}.yata.#{translation_format} saved"
|
76
81
|
end
|
77
82
|
|
78
|
-
def
|
79
|
-
|
83
|
+
def save_file_path
|
84
|
+
if defined?(Rails) && @save_to_path == ""
|
85
|
+
"#{Rails.root}/config/locales/"
|
86
|
+
elsif @save_to_path != ""
|
87
|
+
@save_to_path
|
88
|
+
end
|
80
89
|
end
|
81
90
|
|
82
91
|
def download_url(lang)
|
data/lib/yatapp.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yatapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- luki3k5
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|