Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.

Commit ee10815

Browse files
author
Jeff McCune
committed
Merge branch 'refactor/master/8665_whole_line'
* refactor/master/8665_whole_line: (#8665) Change type from append_line to whole_line
2 parents 0466e1b + 4540949 commit ee10815

File tree

6 files changed

+32
-32
lines changed

6 files changed

+32
-32
lines changed

lib/puppet/provider/append_line/ruby.rb renamed to lib/puppet/provider/whole_line/ruby.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Puppet::Type.type(:append_line).provide(:ruby) do
1+
Puppet::Type.type(:whole_line).provide(:ruby) do
22

33
def exists?
44
File.readlines(resource[:path]).find do |line|

lib/puppet/type/append_line.rb renamed to lib/puppet/type/whole_line.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
Puppet::Type.newtype(:append_line) do
1+
Puppet::Type.newtype(:whole_line) do
22

33
desc <<-EOT
4-
Type that can append a line to a file if it does not already contain it.
4+
Type that can append whole a line to a file if it does not already contain it.
55
66
Example:
77
8-
append_line { 'sudo_rule':
8+
whole_line { 'sudo_rule':
99
path => '/etc/sudoers',
1010
line => '%admin ALL=(ALL) ALL',
1111
}

spec/unit/puppet/provider/append_line/ruby_spec.rb renamed to spec/unit/puppet/provider/whole_line/ruby_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
require 'puppet'
22
require 'tempfile'
3-
provider_class = Puppet::Type.type(:append_line).provider(:ruby)
3+
provider_class = Puppet::Type.type(:whole_line).provider(:ruby)
44
describe provider_class do
55
before :each do
66
tmp = Tempfile.new('tmp')
77
@tmpfile = tmp.path
88
tmp.close!
9-
@resource = Puppet::Type::Append_line.new(
9+
@resource = Puppet::Type::Whole_line.new(
1010
{:name => 'foo', :path => @tmpfile, :line => 'foo'}
1111
)
1212
@provider = provider_class.new(@resource)

spec/unit/puppet/type/append_line_spec.rb

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
require 'puppet'
2+
require 'tempfile'
3+
describe Puppet::Type.type(:whole_line) do
4+
before :each do
5+
@whole_line = Puppet::Type.type(:whole_line).new(:name => 'foo', :line => 'line', :path => '/tmp/path')
6+
end
7+
it 'should accept a line and path' do
8+
@whole_line[:line] = 'my_line'
9+
@whole_line[:line].should == 'my_line'
10+
end
11+
it 'should accept posix filenames' do
12+
@whole_line[:path] = '/tmp/path'
13+
@whole_line[:path].should == '/tmp/path'
14+
end
15+
it 'should not accept unqualified path' do
16+
expect { @whole_line[:path] = 'file' }.should raise_error(Puppet::Error, /File paths must be fully qualified/)
17+
end
18+
it 'should require that a line is specified' do
19+
expect { Puppet::Type.type(:whole_line).new(:name => 'foo', :path => '/tmp/file') }.should raise_error(Puppet::Error, /Both line and path are required attributes/)
20+
end
21+
it 'should require that a file is specified' do
22+
expect { Puppet::Type.type(:whole_line).new(:name => 'foo', :line => 'path') }.should raise_error(Puppet::Error, /Both line and path are required attributes/)
23+
end
24+
end
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
file { '/tmp/dansfile':
22
ensure => present
33
}->
4-
append_line { 'dans_line':
4+
whole_line { 'dans_line':
55
line => 'dan is awesome',
6-
#path => '/tmp/dansfile',
6+
path => '/tmp/dansfile',
77
}

0 commit comments

Comments
 (0)