Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add padding for single character #48

Merged
merged 4 commits into from
May 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'

#desc 'Run RSpec'
#RSpec::Core::RakeTask.new(:test) do |t|
#t.pattern = 'spec/{unit}/**/*.rb'
# t.rspec_opts = ['--color']
#end
task :default => [:test]

desc 'Run RSpec'
RSpec::Core::RakeTask.new(:test) do |t|
t.pattern = 'spec/{unit}/**/*.rb'
#t.rspec_opts = ['--color']
end

desc 'Generate code coverage'
RSpec::Core::RakeTask.new(:coverage) do |t|
t.rcov = true
t.rcov_opts = ['--exclude', 'spec']
end

desc "Run rake tasks"
task "beaker:test:pe" do |t, args|

cmd_str = "beaker --options-file .beaker-pe.cfg "
args.extras.each do |v|
cmd_str += "#{v} "
end

Dir.chdir("./acceptance")
system(cmd_str)
Dir.chdir("../")
end

PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp","tests/**/*.pp"]
2 changes: 1 addition & 1 deletion acceptance/tests/resource/registry/should_manage_values.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class phase1 {
# Binary Values
registry_value { '#{keypath}\\SubKey1\\ValueBinary1':
type => binary,
data => "0${::fact_phase}",
data => "${::fact_phase}",
}
registry_value { '#{keypath}\\SubKey1\\ValueBinary2':
type => binary,
Expand Down
7 changes: 5 additions & 2 deletions lib/puppet/type/registry_value.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

**Autorequires:** Any parent registry key managed by Puppet will be
autorequired.
EOT
EOT

def self.title_patterns
[ [ /^(.*?)\Z/m, [ [ :path, lambda{|x| x} ] ] ] ]
[[/^(.*?)\Z/m, [[:path, lambda { |x| x }]]]]
end

ensurable
Expand Down Expand Up @@ -84,6 +84,9 @@ def self.title_patterns
fail("The data must be a valid QWORD: #{value}") unless val and (val.abs >> 64) <= 0
val
when :binary
if (value.respond_to?(:length) && value.length == 1) || (value.kind_of?(Integer) && value <= 9)
value = "0#{value}"
end
unless value.match(/^([a-f\d]{2} ?)*$/i)
fail("The data must be a hex encoded string of the form: '00 01 02 ...'")
end
Expand Down
6 changes: 6 additions & 0 deletions spec/unit/puppet/type/registry_value_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@
value[:data] = data
end
end
[9,'1','A'].each do |data|
it "should accept '#{data}' and have a leading zero" do
value[:type] = :binary
value[:data] = data
end
end

["\040\040", 'foobar', :true].each do |data|
it "should reject '#{data}'" do
Expand Down