semantic_puppet 0.1.3 → 0.1.4

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: 38ebb59dfcd6e82ac6ea128d8515b2662acbd3e1
4
- data.tar.gz: f09b3b0f9d3df0e086fcc577621352e0e876d8cf
3
+ metadata.gz: e204300a1f6f9188796a9dd602c30f62762d765d
4
+ data.tar.gz: cca5d579a7002ae8207652352497b1ebe5bc3b2c
5
5
  SHA512:
6
- metadata.gz: 270364d1106aaf1e1a23921f7e0a65e94f21d66e8f05ff1f96f10ebd68da177d3d0127f5f09a6c7adfba16969878cbdf9b72429d298ac9fa6a5ccda9d6c29605
7
- data.tar.gz: 1b7e6f4b605d5f9ffefd312933048a9c9e0b17efea59eb09a6b215c2a117ec1ca275e18efbe640e991267d35d19b27b3c66dc4135b323dc9a8eb3c1be9b7f77b
6
+ metadata.gz: 591144201a679d5ed1ddb237b51c78f36a930b426156c1f0ae48bfaec4f66b4285812fe769db326e64875ba7ffec6216e30bf61b2308ed6ef1a4fe56a595a490
7
+ data.tar.gz: d449dcf10e49683e326c117489557ee9c9d1f73cd087a9621c72fb969b89bd69ba6b10a3da97c912c0374a2860bb35eb0d9d84d99814296ae5c1302b7ec93676
data/.gitignore CHANGED
@@ -6,3 +6,4 @@ doc
6
6
  .idea/
7
7
  /.project
8
8
  Gemfile.lock
9
+ locales/semantic_puppet.pot
@@ -2,6 +2,10 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
4
 
5
+ ## 0.1.4 - 2016-07-06
6
+ ### Changed
7
+ - Externalized all user-facing strings using gettext libraries to support future localization.
8
+
5
9
  ## 0.1.3 - 2016-05-24
6
10
  ### Added
7
11
  - Typesafe implementation of ModuleRelease#eql? (and ModuleRelease#==). (PUP-6341)
data/README.md CHANGED
@@ -57,8 +57,37 @@ publishing modules to [Puppet Forge](https://forge.puppetlabs.com) which is
57
57
  documented at
58
58
  [Publishing Modules on the Puppet Forge](https://docs.puppetlabs.com/puppet/latest/reference/modules_publishing.html#dependencies-in-metadatajson).
59
59
 
60
+ ### i18n
61
+
62
+ When adding new error or log messages please follow the instructions for
63
+ [writing translatable code](https://github.com/puppetlabs/gettext-setup-gem#writing-translatable-code).
64
+
65
+ The SemanticPuppet gem will default to outputing all error messages in English, but you may set the locale
66
+ using the `FastGettext.set_locale` method. If translations do not exist for the language you request then the gem will
67
+ default to English. The `set_locale` method will return the locale, as a string, that FastGettext will now
68
+ use to report PuppetForge errors.
69
+
70
+ ``` ruby
71
+ # Assuming the German translations exist, this will set the reporting language
72
+ # to German
73
+
74
+ locale = FastGettext.set_locale "de_DE"
75
+
76
+ # If it successfully finds Germany's locale, locale will be "de_DE"
77
+ # If it fails to find any German locale, locale will be "en"
78
+ ```
79
+
60
80
  Contributors
61
81
  ------------
62
82
 
63
83
  Pieter van de Bruggen wrote the library originally, with additions by Alex
64
84
  Dreyer, Jesse Scott and Anderson Mills.
85
+
86
+ ## Maintenance
87
+
88
+ Maintainers:
89
+
90
+ * Jesse Scott, jesse@puppet.com
91
+ * Anderson Mills, anderson@puppet.com
92
+
93
+ Tickets: File at https://tickets.puppet.com/browse/FORGE
data/Rakefile CHANGED
@@ -56,3 +56,12 @@ begin
56
56
  rescue LoadError
57
57
  warn "[Warning]: Could not load `bundler/gem_tasks`."
58
58
  end
59
+
60
+ # Gettext tasks
61
+ begin
62
+ spec = Gem::Specification.find_by_name 'gettext-setup'
63
+ load "#{spec.gem_dir}/lib/tasks/gettext.rake"
64
+ GettextSetup.initialize(File.absolute_path('locales', File.dirname(__FILE__)))
65
+ rescue LoadError
66
+ warn "[Warning]: Could not load gettext tasks."
67
+ end
@@ -1,7 +1,9 @@
1
+ require 'gettext-setup'
2
+
1
3
  module SemanticPuppet
4
+ GettextSetup.initialize(File.absolute_path('../locales', File.dirname(__FILE__)))
5
+
2
6
  autoload :Version, 'semantic_puppet/version'
3
7
  autoload :VersionRange, 'semantic_puppet/version_range'
4
8
  autoload :Dependency, 'semantic_puppet/dependency'
5
-
6
- VERSION = '0.1.3'
7
9
  end
@@ -0,0 +1,3 @@
1
+ module SemanticPuppet
2
+ VERSION = '0.1.4'
3
+ end
@@ -18,7 +18,7 @@ module SemanticPuppet
18
18
  match, major, minor, patch, prerelease, build = *ver.match(/\A#{REGEX_FULL}\Z/)
19
19
 
20
20
  if match.nil?
21
- raise "Unable to parse '#{ver}' as a semantic version identifier"
21
+ raise _("Unable to parse '%{version}' as a semantic version identifier") % {version: ver}
22
22
  end
23
23
 
24
24
  prerelease = parse_prerelease(prerelease) if prerelease
@@ -26,7 +26,7 @@ module SemanticPuppet
26
26
  # The following code prevents build metadata for now.
27
27
  #build = parse_build_metadata(build) if build
28
28
  if !build.nil?
29
- raise "'#{ver}' MUST NOT include build identifiers"
29
+ raise _("'%{version}' MUST NOT include build identifiers") % {version: ver}
30
30
  end
31
31
 
32
32
  self.new(major.to_i, minor.to_i, patch.to_i, prerelease, build)
@@ -46,11 +46,11 @@ module SemanticPuppet
46
46
  prerelease = prerelease.split('.', -1)
47
47
 
48
48
  if prerelease.empty? or prerelease.any? { |x| x.empty? }
49
- raise "#{subject} MUST NOT be empty"
49
+ raise _("%{subject} MUST NOT be empty") % {subject: subject}
50
50
  elsif prerelease.any? { |x| x =~ /[^0-9a-zA-Z-]/ }
51
- raise "#{subject} MUST use only ASCII alphanumerics and hyphens"
51
+ raise _("%{subject} MUST use only ASCII alphanumerics and hyphens") % {subject: subject}
52
52
  elsif prerelease.any? { |x| x =~ /^0\d+$/ }
53
- raise "#{subject} MUST NOT contain leading zeroes"
53
+ raise _("%{subject} MUST NOT contain leading zeroes") % {subject: subject}
54
54
  end
55
55
 
56
56
  return prerelease.map { |x| x =~ /^\d+$/ ? x.to_i : x }
@@ -61,9 +61,9 @@ module SemanticPuppet
61
61
  build = build.split('.', -1)
62
62
 
63
63
  if build.empty? or build.any? { |x| x.empty? }
64
- raise "#{subject} MUST NOT be empty"
64
+ raise _("%{subject} MUST NOT be empty") % {subject: subject}
65
65
  elsif build.any? { |x| x =~ /[^0-9a-zA-Z-]/ }
66
- raise "#{subject} MUST use only ASCII alphanumerics and hyphens"
66
+ raise _("%{subject} MUST use only ASCII alphanumerics and hyphens") % {subject: subject}
67
67
  end
68
68
 
69
69
  return build
@@ -46,7 +46,7 @@ module SemanticPuppet
46
46
  end
47
47
 
48
48
  rescue ArgumentError
49
- raise ArgumentError, "Unparsable version range: #{range_str.inspect}"
49
+ raise ArgumentError, _("Unparsable version range: %{range}") % {range: range_str.inspect}
50
50
  end
51
51
 
52
52
  private
@@ -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: 'semantic_puppet'
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: Semantic Puppet 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'
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "semantic_puppet"
3
+ require "semantic_puppet/gem_version"
4
4
 
5
5
  spec = Gem::Specification.new do |s|
6
6
  # Metadata
@@ -22,6 +22,8 @@ spec = Gem::Specification.new do |s|
22
22
  # Dependencies
23
23
  s.required_ruby_version = '>= 1.8.7'
24
24
 
25
+ s.add_dependency "gettext-setup", ">= 0.3"
26
+
25
27
  s.add_development_dependency "rake"
26
28
  s.add_development_dependency "rspec"
27
29
  s.add_development_dependency "simplecov"
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semantic_puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
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
+ - !ruby/object:Gem::Dependency
14
+ name: gettext-setup
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0.3'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rake
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -116,8 +130,10 @@ files:
116
130
  - lib/semantic_puppet/dependency/module_release.rb
117
131
  - lib/semantic_puppet/dependency/source.rb
118
132
  - lib/semantic_puppet/dependency/unsatisfiable_graph.rb
133
+ - lib/semantic_puppet/gem_version.rb
119
134
  - lib/semantic_puppet/version.rb
120
135
  - lib/semantic_puppet/version_range.rb
136
+ - locales/config.yaml
121
137
  - semantic_puppet.gemspec
122
138
  - spec/spec_helper.rb
123
139
  - spec/unit/semantic_puppet/dependency/graph_node_spec.rb