Skip to content

Commit 4e73e10

Browse files
author
Jeff McCune
committed
Merge branch 'domcleal-tickets/master/18494-ruby-2.0'
* domcleal-tickets/master/18494-ruby-2.0: (#18494) Rearrange loop to remove Ruby 2.0 warning (#18494) Enable Travis building on Ruby 2.0.0 (#18494) Make ActiveRecord-based inventory service unsupported under Ruby 2 (#18494) Force literal strings in test to ASCII-8BIT encoding (#18494) Remove TypeError handling code used for tests (#18494) Fix error message test for Ruby 2.0 (#18494) Fix Ruby version number format for Ruby 2.0.0-p-1 (#18494) Change version comparisons to support Ruby 2.0 closes #1470
2 parents 077de03 + c2295b7 commit 4e73e10

File tree

12 files changed

+196
-165
lines changed

12 files changed

+196
-165
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ script: "bundle exec rake spec SPEC_OPTS='--color --format documentation'"
44
notifications:
55
email: false
66
rvm:
7+
- 2.0.0
78
- 1.9.3
89
- 1.8.7
910
- ruby-head

lib/puppet/file_serving/fileset.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def perform_recursion
136136
result = []
137137
return result unless recurse?(depth)
138138

139-
while dir_path = current_dirs.shift or ((depth += 1) and recurse?(depth) and current_dirs = next_dirs and next_dirs = [] and dir_path = current_dirs.shift)
139+
while dir_path = current_dirs.shift
140140
next unless stat = stat(dir_path)
141141
next unless stat.directory?
142142

@@ -153,6 +153,14 @@ def perform_recursion
153153
# And to our list of files/directories to iterate over.
154154
next_dirs << File.join(dir_path, file_path)
155155
end
156+
157+
# Move to the next recusion level
158+
if current_dirs.empty?
159+
depth += 1
160+
break unless recurse?(depth)
161+
current_dirs = next_dirs
162+
next_dirs = []
163+
end
156164
end
157165

158166
result

lib/puppet/indirector/facts/inventory_active_record.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Puppet::Node::Facts::InventoryActiveRecord < Puppet::Indirector::ActiveRec
1111
and inventory are deprecated. See http://links.puppetlabs.com/activerecord-deprecation"
1212

1313
def initialize
14+
raise Puppet::Error, "ActiveRecords-based inventory is unsupported with Ruby 2 and Rails 3.0" if RUBY_VERSION[0] == '2'
1415
Puppet.deprecation_warning "ActiveRecord-based storeconfigs and inventory are deprecated. See http://links.puppetlabs.com/activerecord-deprecation"
1516
super
1617
end

lib/puppet/transaction/event.rb

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,8 @@ def property=(prop)
2929
end
3030

3131
def resource=(res)
32-
begin
33-
# In Ruby 1.8 looking up a symbol on a string gives nil; in 1.9 it will
34-
# raise a TypeError, which we then catch. This should work on both
35-
# versions, for all that it is a bit naff. --daniel 2012-03-11
36-
if res.respond_to?(:[]) and level = res[:loglevel]
37-
@default_log_level = level
38-
end
39-
rescue TypeError => e
40-
raise unless e.to_s == "can't convert Symbol into Integer"
32+
if res.respond_to?(:[]) and level = res[:loglevel]
33+
@default_log_level = level
4134
end
4235
@resource = res.to_s
4336
end

lib/puppet/util/classgen.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ class << self
148148
# @api private
149149
#
150150
def is_constant_defined?(const)
151-
if ::RUBY_VERSION =~ /1.9/
152-
const_defined?(const, false)
153-
else
151+
if ::RUBY_VERSION =~ /^1.8/
154152
const_defined?(const)
153+
else
154+
const_defined?(const, false)
155155
end
156156
end
157157

lib/puppet/util/rdoc/parser.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
require "puppet/util/rdoc/code_objects"
99
require "rdoc/tokenstream"
1010

11-
if ::RUBY_VERSION =~ /1.9/
12-
require "rdoc/markup/preprocess"
13-
require "rdoc/parser"
14-
else
11+
if ::RUBY_VERSION =~ /^1.8/
1512
require "rdoc/markup/simple_markup/preprocess"
1613
require "rdoc/parsers/parserfactory"
14+
else
15+
require "rdoc/markup/preprocess"
16+
require "rdoc/parser"
1717
end
1818

1919
module RDoc
2020

2121
class Parser
22-
extend ParserFactory unless ::RUBY_VERSION =~ /1.9/
22+
extend ParserFactory if ::RUBY_VERSION =~ /^1.8/
2323

2424
SITE = "__site__"
2525

spec/unit/forge/repository_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
http.expects(:request).with() do |request|
9393
puppet_version = /Puppet\/\d+\..*/
9494
os_info = /\(.*\)/
95-
ruby_version = /Ruby\/\d+\.\d+\.\d+(-p\d+)? \(\d{4}-\d{2}-\d{2}; .*\)/
95+
ruby_version = /Ruby\/\d+\.\d+\.\d+(-p-?\d+)? \(\d{4}-\d{2}-\d{2}; .*\)/
9696

9797
request["User-Agent"] =~ /^#{consumer_version} #{puppet_version} #{os_info} #{ruby_version}/
9898
end

0 commit comments

Comments
 (0)