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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 60792719868deebdd7bd4bea8038381292742167
4
- data.tar.gz: c4f2b39466de167960401b1bd294953ec34386a3
3
+ metadata.gz: d57882c06b5a26836d0ae6527ec73d595b838198
4
+ data.tar.gz: be7eababe8e94a55f3b79a385c060c78b10300b9
5
5
  SHA512:
6
- metadata.gz: 161746628854d33df2d377559d77c191884261992cff185cbb92148eaf987193a0c9b02177ead0acd2981001c878f057b78ea2734cfbe164f69f1c852e32be27
7
- data.tar.gz: e208e43f2cd75135a4cca5ec184f90304927df5034f6fae6c519d49e0b765f49644c70deed95f2cd13a81d47de33f6fa15ff74cdd17f02c78fe055515c5397ac
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
@@ -1,3 +1,3 @@
1
1
  module Yatapp
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
@@ -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 = base_file_path
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 base_file_path
79
- "#{Rails.root}/config/locales/" if defined?(Rails)
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
@@ -37,6 +37,10 @@ module Yatapp
37
37
  @current_project.set_languages(languages)
38
38
  end
39
39
 
40
+ def save_to_path(path)
41
+ @current_project.set_save_to_path(path)
42
+ end
43
+
40
44
  def project_id(project_id)
41
45
  @current_project.set_project_id(project_id)
42
46
  end
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.1
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-19 00:00:00.000000000 Z
11
+ date: 2015-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday