icapps-translations 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43a4c063cd284480ac0ba00710f15b9ee3dc66a0
4
- data.tar.gz: 18501eeac2975dbe452748dd98d508a7d6fe1d92
3
+ metadata.gz: 7dd2178741324fa58e7936b8807d41bdda6ec28a
4
+ data.tar.gz: a86b14558053d326198c1d2dc913e810124249e2
5
5
  SHA512:
6
- metadata.gz: 452909028b55b33562ddb0e126dd3cf1850a996f475c50f8066c416292c891c9ba0686d6a6e561abe069ed179c87d7fd483e6a2b95d61a09fb03a3325d6c3dd7
7
- data.tar.gz: f4b52bf360483b47acff530231299d5b44be5eb62d109c7115c093df1e2a94705db959f8df80b44d2f3855690ae69eb07aaa39050832890cd293c3d05f8e6fe9
6
+ metadata.gz: d1df6931a9b3cad88373fd51f62108fa4e4f810d58d61ccb19116a9d7448455cb05b77babb41474abf55831b10eac69ff5dd49e82648ee33d553fe2f91ec493d
7
+ data.tar.gz: be7e24477c232b132b4097ff123a2997dd298c50dcee80d30ca24cf83b27bf322d996de73a3e541ddd9370362f4fb053453ea1eb4530bfb53c4fa26e9b342089
data/.rubocop.yml ADDED
@@ -0,0 +1,21 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2015-10-13 11:47:22 +0200 using RuboCop version 0.29.1.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ Metrics/AbcSize:
9
+ Max: 21
10
+
11
+ Metrics/LineLength:
12
+ Max: 143
13
+
14
+ Metrics/MethodLength:
15
+ Max: 12
16
+
17
+ Style/Documentation:
18
+ Enabled: false
19
+
20
+ Style/GuardClause:
21
+ Enabled: false
data/README.md CHANGED
@@ -39,5 +39,6 @@ Then build the gem by running the following commands:
39
39
  1. Fork it ( https://github.com/icapps/translations/fork )
40
40
  2. Create your feature branch (`git checkout -b my-new-feature`)
41
41
  3. Commit your changes (`git commit -am 'Add some feature'`)
42
- 4. Push to the branch (`git push origin my-new-feature`)
43
- 5. Create a new Pull Request
42
+ 4. Run `rubycop` in order to be compliant to our coding style.
43
+ 5. Push to the branch (`git push origin my-new-feature`)
44
+ 6. Create a new Pull Request
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
- require "bundler/gem_tasks"
2
-
1
+ require 'bundler/gem_tasks'
@@ -4,21 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'icapps/translations/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "icapps-translations"
7
+ spec.name = 'icapps-translations'
8
8
  spec.version = Icapps::Translations::VERSION
9
- spec.authors = ["Jelle Vandebeeck"]
10
- spec.email = ["jelle.vandebeeck@icapps.com"]
11
- spec.summary = %q{Import translations from the iCapps translations portal.}
9
+ spec.authors = ['Jelle Vandebeeck']
10
+ spec.email = ['jelle.vandebeeck@icapps.com']
11
+ spec.summary = 'Import translations from the iCapps translations portal.'
12
12
  spec.homepage = 'https://github.com/icapps/translations'
13
- spec.license = "MIT"
13
+ spec.license = 'MIT'
14
14
 
15
15
  spec.files = `git ls-files -z`.split("\x0")
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
16
+ spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(/^(test|spec|features)/)
18
+ spec.require_paths = ['lib']
19
19
 
20
- spec.add_development_dependency "bundler", "~> 1.7"
21
- spec.add_development_dependency "rake", "~> 10.0"
20
+ spec.add_development_dependency 'bundler', '~> 1.7'
21
+ spec.add_development_dependency 'rake', '~> 10.0'
22
22
 
23
23
  spec.add_dependency 'thor', '~> 0.19'
24
24
  spec.add_dependency 'colorize', '~> 0.7'
@@ -1,8 +1,8 @@
1
1
  require 'thor'
2
2
  require 'colorize'
3
3
 
4
- require "icapps/translations/configuration"
5
- require "icapps/translations/import/xcode"
4
+ require 'icapps/translations/configuration'
5
+ require 'icapps/translations/import/xcode'
6
6
 
7
7
  module Icapps
8
8
  module Translations
@@ -4,9 +4,10 @@ require 'yaml'
4
4
  module Icapps
5
5
  module Translations
6
6
  class Configuration
7
- attr :url
8
- attr :filename
9
- attr :project_key
7
+ attr_reader :url
8
+ attr_reader :filename
9
+ attr_reader :project_key
10
+ attr_reader :default_language
10
11
 
11
12
  class << self
12
13
  def create
@@ -15,12 +16,12 @@ module Icapps
15
16
  return
16
17
  end
17
18
 
18
- File.open(path, "w") { |f| f.write(initial_content.to_yaml) }
19
+ File.open(path, 'w') { |f| f.write(initial_content.to_yaml) }
19
20
  puts "[MESSAGE] Configuration created at '#{path}'.".colorize(:green)
20
21
  end
21
22
 
22
23
  def exists?
23
- File.exists?(path)
24
+ File.exist?(path)
24
25
  end
25
26
 
26
27
  def path
@@ -36,6 +37,15 @@ module Icapps
36
37
  end
37
38
 
38
39
  def initial_content
40
+ ::Icapps::Translations.android? ? android_initial_content : common_initial_content
41
+ end
42
+
43
+ def android_initial_content
44
+ common_initial_content.merge!(filename: 'strings.xml',
45
+ default_language: 'en')
46
+ end
47
+
48
+ def common_initial_content
39
49
  {
40
50
  url: 'http://your_url.com',
41
51
  filename: 'Localizable.strings',
@@ -59,11 +69,12 @@ module Icapps
59
69
  def read_config
60
70
  puts "[VERBOSE] Reading the config file at '#{Configuration.path}'.".colorize(:white) if Configuration.options[:verbose]
61
71
 
62
- params = YAML::load File.open(Configuration.path)
72
+ params = YAML.load File.open(Configuration.path)
63
73
  if params
64
- @filename = params[:filename]
65
- @url = params[:url]
66
- @project_key = params[:project_key]
74
+ @filename = params[:filename]
75
+ @url = params[:url]
76
+ @project_key = params[:project_key]
77
+ @default_language = params[:default_language]
67
78
  end
68
79
  end
69
80
  end
@@ -6,13 +6,13 @@ module Icapps
6
6
  module Translations
7
7
  class Http
8
8
  class << self
9
- def authenticated_response(path, is_json=false)
9
+ def authenticated_response(path, is_json = false)
10
10
  uri = URI("#{config.url}/#{path}")
11
11
  puts "[VERBOSE] Connecting to url '#{uri}'.".colorize(:white) if options[:verbose]
12
12
 
13
13
  http = Net::HTTP.new(uri.host, uri.port)
14
14
  request = Net::HTTP::Get.new(uri)
15
- request.add_field "Authorization", "Token token=#{config.project_key}"
15
+ request.add_field 'Authorization', "Token token=#{config.project_key}"
16
16
  response = http.request(request)
17
17
  is_json ? JSON.parse(response.body) : response.body
18
18
  end
@@ -1,6 +1,6 @@
1
1
  require 'colorize'
2
2
 
3
- require "icapps/translations/http"
3
+ require 'icapps/translations/http'
4
4
 
5
5
  module Icapps
6
6
  module Translations
@@ -14,7 +14,7 @@ module Icapps
14
14
  puts "[VERBOSE] There are currently #{languages_json.count} language(s) for this project.".colorize(:white) if options[:verbose]
15
15
 
16
16
  languages_json.each { |language| fetch_language_file language }
17
- puts "[MESSAGE] Finished importing translation.".colorize(:green)
17
+ puts '[MESSAGE] Finished importing translation.'.colorize(:green)
18
18
  end
19
19
 
20
20
  def options
@@ -1,7 +1,7 @@
1
1
  require 'colorize'
2
2
 
3
- require "icapps/translations/http"
4
- require "icapps/translations/import/base"
3
+ require 'icapps/translations/http'
4
+ require 'icapps/translations/import/base'
5
5
 
6
6
  module Icapps
7
7
  module Translations
@@ -27,9 +27,12 @@ module Icapps
27
27
 
28
28
  private
29
29
 
30
+ def default_language
31
+ config.default_language || 'en'
32
+ end
33
+
30
34
  def values_name(short_name)
31
- if short_name == 'en'
32
- # Default language is English.
35
+ if short_name == default_language
33
36
  'values'
34
37
  else
35
38
  # Android requires the country code to be prefixed with an 'r'.
@@ -1,7 +1,7 @@
1
1
  require 'colorize'
2
2
 
3
- require "icapps/translations/http"
4
- require "icapps/translations/import/base"
3
+ require 'icapps/translations/http'
4
+ require 'icapps/translations/import/base'
5
5
 
6
6
  module Icapps
7
7
  module Translations
@@ -1,5 +1,5 @@
1
1
  module Icapps
2
2
  module Translations
3
- VERSION = "0.2.0"
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
- require "icapps/translations/version"
2
- require "icapps/translations/cli"
3
- require "icapps/translations/import/xcode"
4
- require "icapps/translations/import/gradle"
1
+ require 'icapps/translations/version'
2
+ require 'icapps/translations/cli'
3
+ require 'icapps/translations/import/xcode'
4
+ require 'icapps/translations/import/gradle'
5
5
 
6
6
  module Icapps
7
7
  module Translations
@@ -17,23 +17,23 @@ module Icapps
17
17
  config.validate
18
18
 
19
19
  # Import the files.
20
- if is_xcode?
21
- puts "[VERBOSE] Detected an Xcode project.".colorize(:white) if options[:verbose]
20
+ if xcode?
21
+ puts '[VERBOSE] Detected an Xcode project.'.colorize(:white) if options[:verbose]
22
22
  Import::Xcode.import
23
- elsif is_android?
24
- puts "[VERBOSE] Detected an Android project with a .gradle file.".colorize(:white) if options[:verbose]
23
+ elsif android?
24
+ puts '[VERBOSE] Detected an Android project with a .gradle file.'.colorize(:white) if options[:verbose]
25
25
  Import::Gradle.import
26
26
  else
27
27
  abort '[ERROR] No Xcode or Android gradle file detected.'.colorize(:red) unless @project_key
28
28
  end
29
29
  end
30
30
 
31
- def is_android?
32
- Dir.glob("**/*.gradle").count > 0
31
+ def android?
32
+ Dir.glob('**/*.gradle').count > 0
33
33
  end
34
34
 
35
- def is_xcode?
36
- Dir.glob("**/*.xcodeproj").count > 0
35
+ def xcode?
36
+ Dir.glob('**/*.xcodeproj').count > 0
37
37
  end
38
38
  end
39
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: icapps-translations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jelle Vandebeeck
@@ -75,6 +75,7 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - ".gitignore"
78
+ - ".rubocop.yml"
78
79
  - Gemfile
79
80
  - LICENSE.txt
80
81
  - README.md