Skip to content

Commit ef4ef11

Browse files
committed
Merge pull request #10 from jeffmccune/ticket/master/8792_rename_whole_line_to_file_line
(#8792) Rename whole_line type to file_line.
2 parents 07d0eca + f3c53e6 commit ef4ef11

File tree

6 files changed

+32
-30
lines changed

6 files changed

+32
-30
lines changed

lib/puppet/provider/whole_line/ruby.rb renamed to lib/puppet/provider/file_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(:whole_line).provide(:ruby) do
1+
Puppet::Type.type(:file_line).provide(:ruby) do
22

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

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

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

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

spec/unit/puppet/provider/whole_line/ruby_spec.rb renamed to spec/unit/puppet/provider/file_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(:whole_line).provider(:ruby)
3+
provider_class = Puppet::Type.type(:file_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::Whole_line.new(
9+
@resource = Puppet::Type::File_line.new(
1010
{:name => 'foo', :path => @tmpfile, :line => 'foo'}
1111
)
1212
@provider = provider_class.new(@resource)
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(:file_line) do
4+
before :each do
5+
@file_line = Puppet::Type.type(:file_line).new(:name => 'foo', :line => 'line', :path => '/tmp/path')
6+
end
7+
it 'should accept a line and path' do
8+
@file_line[:line] = 'my_line'
9+
@file_line[:line].should == 'my_line'
10+
end
11+
it 'should accept posix filenames' do
12+
@file_line[:path] = '/tmp/path'
13+
@file_line[:path].should == '/tmp/path'
14+
end
15+
it 'should not accept unqualified path' do
16+
expect { @file_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(:file_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(:file_line).new(:name => 'foo', :line => 'path') }.should raise_error(Puppet::Error, /Both line and path are required attributes/)
23+
end
24+
end

spec/unit/puppet/type/whole_line_spec.rb

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
# This is a simple smoke test
2+
# of the file_line resource type.
13
file { '/tmp/dansfile':
24
ensure => present
35
}->
4-
whole_line { 'dans_line':
6+
file_line { 'dans_line':
57
line => 'dan is awesome',
68
path => '/tmp/dansfile',
79
}

0 commit comments

Comments
 (0)