Please review pull request #771: Fix User-Agent for ruby 1.8.5 opened by (zaphod42)
Description:
The RUBY_PATCHLEVEL constant is not available on ruby 1.8.5. To fix this
the pathlevel will default to "unknown" if the RUBY_PATCHLEVEL is not
available.
- Opened: Mon May 14 18:38:12 UTC 2012
- Based on: puppetlabs:master (639f995c91289b3be9ca5347865247907c7dcb5c)
- Requested merge: zaphod42:bug/master/14387-user-agent-for-module-tool (0fed7a6589316cbc9dc22cee177c635ef403526b)
Diff follows:
diff --git a/lib/puppet/forge/repository.rb b/lib/puppet/forge/repository.rb
index 2528bd3..ac4dba5 100644
--- a/lib/puppet/forge/repository.rb
+++ b/lib/puppet/forge/repository.rb
@@ -102,8 +102,15 @@ def cache_key
end
def user_agent
- "#{@consumer_version} Puppet/#{Puppet.version} (#{Facter.value(:operatingsystem)} #{Facter.value(:operatingsystemrelease)}) Ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE}; #{RUBY_PLATFORM})"
+ "#{@consumer_version} Puppet/#{Puppet.version} (#{Facter.value(:operatingsystem)} #{Facter.value(:operatingsystemrelease)}) #{ruby_version}"
end
private :user_agent
+
+ def ruby_version
+ # the patchlevel is not available in ruby 1.8.5
+ patch = defined?(RUBY_PATCHLEVEL) ? RUBY_PATCHLEVEL : "unknown"
+ "Ruby/#{RUBY_VERSION}-p#{patch} (#{RUBY_RELEASE_DATE}; #{RUBY_PLATFORM})"
+ end
+ private :ruby_version
end
end
diff --git a/spec/unit/forge/repository_spec.rb b/spec/unit/forge/repository_spec.rb
index 7841688..c3f2ca2 100644
--- a/spec/unit/forge/repository_spec.rb
+++ b/spec/unit/forge/repository_spec.rb
@@ -62,7 +62,7 @@
http.expects(:request).with() do |request|
puppet_version = /Puppet\/\d+\..*/
os_info = /\(.*\)/
- ruby_version = /Ruby\/\d+\.\d+\.\d+-p\d+ \(\d{4}-\d{2}-\d{2}; .*\)/
+ ruby_version = /Ruby\/\d+\.\d+\.\d+-p(\d+|unknown) \(\d{4}-\d{2}-\d{2}; .*\)/
request["User-Agent"] =~ /^#{consumer_version} #{puppet_version} #{os_info} #{ruby_version}/
end
-- You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
