puppet_forge 2.2.1 → 2.2.2

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: 274c0fbddb8599de6d21476810d91eb298e88720
4
- data.tar.gz: 147c3aadd5fe7c3fc6cc1d2ebca74916049d2925
3
+ metadata.gz: cf3597a6621d4980a95db5690d60d0448c48295d
4
+ data.tar.gz: 90545df14bb6128d330e2d6c0769b0bbeb84ff10
5
5
  SHA512:
6
- metadata.gz: ca092a41b2952ab4a8564e136a3b9562eeba61830863be6c8871baa2fa6a3c6bbae1d4aee56add286f9ff55c0bbe3bb16c4ed7634dbf4e790429edc57cc655ef
7
- data.tar.gz: 564152499bcfd5b418a3842da2ff8d202194ab3f66997aacb4e0ddef7ab5c787858f7463b60e70ff84363654245e30bfb13924b5edb073e743137cc21da6bdf1
6
+ metadata.gz: fd7247cdacde04841fab5a86fa5b11d82307f64d5ad4081be62f2a60cab63ea995736dee808047e487d7b58172dda0035bab3718039b09a3a3d467192302b617
7
+ data.tar.gz: fa634012325f4b1211e1ea8ca6b25db72a33143607f6af8202c1c554e5624cee1768b16dec28a9ee27e42ae5605120d6b4395023784ba750171652d46e82fad9
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ _yardoc
20
20
  *.o
21
21
  *.a
22
22
  mkmf.log
23
+ locales/forge-ruby.pot
@@ -3,6 +3,12 @@
3
3
  Starting with v2.0.0, all notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## v2.2.2 - 2016-07-06
7
+
8
+ ### Changed
9
+
10
+ * Externalized all user facing strings with gettext to support future localization work.
11
+
6
12
  ## v2.2.1 - 2016-05-24
7
13
 
8
14
  ### Changed
data/README.md CHANGED
@@ -186,6 +186,26 @@ user.username # => "puppetlabs"
186
186
  user.created_at # => "2010-05-19 05:46:26 -0700"
187
187
  ```
188
188
 
189
+ ### i18n
190
+
191
+ When adding new error or log messages please follow the instructions for
192
+ [writing translatable code](https://github.com/puppetlabs/gettext-setup-gem#writing-translatable-code).
193
+
194
+ The PuppetForge gem will default to outputing all error messages in English, but you may set the locale
195
+ using the `FastGettext.set_locale` method. If translations do not exist for the language you request then the gem will
196
+ default to English. The `set_locale` method will return the locale, as a string, that FastGettext will now
197
+ use to report PuppetForge errors.
198
+
199
+ ``` ruby
200
+ # Assuming the German translations exist, this will set the reporting language
201
+ # to German
202
+
203
+ locale = FastGettext.set_locale "de_DE"
204
+
205
+ # If it successfully finds Germany's locale, locale will be "de_DE"
206
+ # If it fails to find any German locale, locale will be "en"
207
+ ```
208
+
189
209
  ##Caveats
190
210
 
191
211
  This library currently does no response caching of its own, instead opting to
@@ -214,3 +234,12 @@ to create a free account to add new tickets.
214
234
  * Austin Blatt, Puppet Labs
215
235
  * Adrien Thebo, Puppet Labs
216
236
  * Anderson Mills, Puppet Labs
237
+
238
+ ## Maintenance
239
+
240
+ Maintainers:
241
+
242
+ * Jesse Scott, jesse@puppet.com
243
+ * Anderson Mills, anderson@puppet.com
244
+
245
+ Tickets: File at https://tickets.puppet.com/browse/FORGE
data/Rakefile CHANGED
@@ -1,2 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ # i18n/gettext Rake tasks
4
+ spec = Gem::Specification.find_by_name 'gettext-setup'
5
+ load "#{spec.gem_dir}/lib/tasks/gettext.rake"
6
+ GettextSetup.initialize(File.absolute_path('locales', File.dirname(__FILE__)))
7
+
@@ -1,4 +1,5 @@
1
1
  require 'puppet_forge/version'
2
+ require 'gettext-setup'
2
3
 
3
4
  module PuppetForge
4
5
  class << self
@@ -6,6 +7,8 @@ module PuppetForge
6
7
  attr_accessor :host
7
8
  end
8
9
 
10
+ GettextSetup.initialize(File.absolute_path('../locales', File.dirname(__FILE__)))
11
+
9
12
  self.host = 'https://forgeapi.puppetlabs.com'
10
13
 
11
14
  require 'puppet_forge/tar'
@@ -10,9 +10,10 @@ module PuppetForge
10
10
  rescue Faraday::ConnectionFailed => e
11
11
  baseurl = env[:url].dup
12
12
  baseurl.path = ''
13
- errmsg = "Unable to connect to #{baseurl.to_s}"
14
13
  if proxy = env[:request][:proxy]
15
- errmsg << " (using proxy #{proxy.uri.to_s})"
14
+ errmsg = _("Unable to connect to %{url} (using proxy %{proxy})") % {url: baseurl.to_s, proxy: proxy.uri.to_s}
15
+ else
16
+ errmsg = _("Unable to connect to %{url}") % {url: baseurl.to_s}
16
17
  end
17
18
  errmsg << ": #{e.message}"
18
19
  m = Faraday::ConnectionFailed.new(errmsg)
@@ -16,15 +16,11 @@ module PuppetForge
16
16
  def initialize(options)
17
17
  @entry_path = options[:entry_path]
18
18
  @directory = options[:directory]
19
- super "Attempt to install file into #{@entry_path.inspect} under #{@directory.inspect}"
19
+ super _("Attempt to install file into %{path} under %{directory}") % {path: @entry_path.inspect, directory: @directory.inspect}
20
20
  end
21
21
 
22
22
  def multiline
23
- <<-MSG.strip
24
- Could not install package
25
- Package attempted to install file into
26
- #{@entry_path.inspect} under #{@directory.inspect}.
27
- MSG
23
+ _("Could not install package\n Package attempted to install file into\n %{path} under %{directory}.") % {path: @entry_path.inspect, directory: @directory.inspect}
28
24
  end
29
25
  end
30
26
 
@@ -24,7 +24,7 @@ module PuppetForge
24
24
  version = class_name.split("::")[-2]
25
25
 
26
26
  if version.nil?
27
- raise RuntimeError, "Unable to determine the parent PuppetForge version module"
27
+ raise RuntimeError, _("Unable to determine the parent PuppetForge version module")
28
28
  end
29
29
 
30
30
  PuppetForge.const_get(version)
@@ -39,7 +39,7 @@ module PuppetForge
39
39
  begin
40
40
  PuppetForge::Tar.instance.unpack(@filename, @tmpdir)
41
41
  rescue PuppetForge::ExecutionFailure => e
42
- raise RuntimeError, "Could not extract contents of module archive: #{e.message}"
42
+ raise RuntimeError, _("Could not extract contents of module archive: %{error_msg}") % {error_msg: e.message}
43
43
  end
44
44
  end
45
45
 
@@ -61,7 +61,7 @@ module PuppetForge
61
61
  if metadata_file
62
62
  @root_dir = Pathname.new(metadata_file).dirname
63
63
  else
64
- raise "No valid metadata.json found!"
64
+ raise _("No valid metadata.json found!")
65
65
  end
66
66
  end
67
67
  end
@@ -63,7 +63,7 @@ module PuppetForge
63
63
  validate_version_range(version_requirement) if version_requirement
64
64
 
65
65
  if dup = @data['dependencies'].find { |d| d.full_module_name == name && d.version_requirement != version_requirement }
66
- raise ArgumentError, "Dependency conflict for #{full_module_name}: Dependency #{name} was given conflicting version requirements #{version_requirement} and #{dup.version_requirement}. Verify that there are no duplicates in the metadata.json or the Modulefile."
66
+ raise ArgumentError, _("Dependency conflict for %{module_name}: Dependency %{conflict_name} was given conflicting version requirements %{version} and %{conflict_version}. Verify that there are no duplicates in the metadata.json or the Modulefile.") % {module_name: full_module_name, conflict_name: name, version: version_requirement, conflict_version: dup.version_requirement}
67
67
  end
68
68
 
69
69
  dep = Dependency.new(name, version_requirement, repository)
@@ -165,31 +165,30 @@ module PuppetForge
165
165
 
166
166
  err = case modname
167
167
  when nil, '', :namespace_missing
168
- "the field must be a namespaced module name"
168
+ _("the field must be a namespaced module name")
169
169
  when /[^a-z0-9_]/i
170
- "the module name contains non-alphanumeric (or underscore) characters"
170
+ _("the module name contains non-alphanumeric (or underscore) characters")
171
171
  when /^[^a-z]/i
172
- "the module name must begin with a letter"
172
+ _("the module name must begin with a letter")
173
173
  else
174
- "the namespace contains non-alphanumeric characters"
174
+ _("the namespace contains non-alphanumeric characters")
175
175
  end
176
176
 
177
- raise ArgumentError, "Invalid 'name' field in metadata.json: #{err}"
177
+ raise ArgumentError, _("Invalid 'name' field in metadata.json: %{error}") % {error: err}
178
178
  end
179
179
 
180
180
  # Validates that the version string can be parsed by SemanticPuppet.
181
181
  def validate_version(version)
182
182
  return if SemanticPuppet::Version.valid?(version)
183
183
 
184
- err = "version string cannot be parsed as a valid Semantic Version"
185
- raise ArgumentError, "Invalid 'version' field in metadata.json: #{err}"
184
+ raise ArgumentError, _("Invalid 'version' field in metadata.json: version string cannot be parsed as a valid Semantic Version")
186
185
  end
187
186
 
188
187
  # Validates that the version range can be parsed by SemanticPuppet.
189
188
  def validate_version_range(version_range)
190
189
  SemanticPuppet::VersionRange.parse(version_range)
191
190
  rescue ArgumentError => e
192
- raise ArgumentError, "Invalid 'version_range' field in metadata.json: #{e}"
191
+ raise ArgumentError, _("Invalid 'version_range' field in metadata.json: %{error}") % {error: e}
193
192
  end
194
193
  end
195
194
  end
@@ -27,7 +27,7 @@ module PuppetForge
27
27
  resp = self.class.conn.get(download_url)
28
28
  path.open('wb') { |fh| fh.write(resp.body) }
29
29
  rescue Faraday::ResourceNotFound => e
30
- raise PuppetForge::ReleaseNotFound, "The module release #{slug} does not exist on #{self.class.conn.url_prefix}.", e.backtrace
30
+ raise PuppetForge::ReleaseNotFound, (_("The module release %{release_slug} does not exist on %{url}.") % {release_slug: slug, url: self.class.conn.url_prefix}), e.backtrace
31
31
  rescue Faraday::ClientError => e
32
32
  if e.response && e.response[:status] == 403
33
33
  raise PuppetForge::ReleaseForbidden.from_response(e.response)
@@ -1,3 +1,3 @@
1
1
  module PuppetForge
2
- VERSION = '2.2.1' # Library version
2
+ VERSION = '2.2.2' # Library version
3
3
  end
@@ -0,0 +1,21 @@
1
+ ---
2
+ # This is the project-specific configuration file for setting up
3
+ # fast_gettext for your project.
4
+ gettext:
5
+ # This is used for the name of the .pot and .po files; they will be
6
+ # called <project_name>.pot?
7
+ project_name: 'forge-ruby'
8
+ # This is used in comments in the .pot and .po files to indicate what
9
+ # project the files belong to and should bea little more desctiptive than
10
+ # <project_name>
11
+ package_name: Puppet Forge Gem
12
+ # The locale that the default messages in the .pot file are in
13
+ default_locale: en
14
+ # The email used for sending bug reports.
15
+ bugs_address: docs@puppetlabs.com
16
+ # The holder of the copyright.
17
+ copyright_holder: Puppet, Inc.
18
+ # Patterns for +Dir.glob+ used to find all files that might contain
19
+ # translatable content, relative to the project root directory
20
+ source_files:
21
+ - 'lib/**/*.rb'
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_runtime_dependency "faraday_middleware", [">= 0.9.0", "< 0.11.0"]
25
25
  spec.add_dependency 'semantic_puppet', '~> 0.1.0'
26
26
  spec.add_dependency 'minitar'
27
+ spec.add_dependency 'gettext-setup', '>= 0.3'
27
28
 
28
29
  spec.add_development_dependency "bundler", "~> 1.6"
29
30
  spec.add_development_dependency "rake"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet_forge
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-24 00:00:00.000000000 Z
11
+ date: 2016-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -72,6 +72,20 @@ dependencies:
72
72
  - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: gettext-setup
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0.3'
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0.3'
75
89
  - !ruby/object:Gem::Dependency
76
90
  name: bundler
77
91
  requirement: !ruby/object:Gem::Requirement
@@ -217,6 +231,7 @@ files:
217
231
  - lib/puppet_forge/v3/release.rb
218
232
  - lib/puppet_forge/v3/user.rb
219
233
  - lib/puppet_forge/version.rb
234
+ - locales/config.yaml
220
235
  - puppet_forge.gemspec
221
236
  - spec/fixtures/v3/files/puppetlabs-apache-0.0.1.tar.gz.headers
222
237
  - spec/fixtures/v3/files/puppetlabs-apache-0.0.1.tar.gz.json