wright 0.4.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +10 -3
- data/NEWS.md +8 -0
- data/README.md +9 -16
- data/lib/wright/cli.rb +25 -24
- data/lib/wright/config.rb +5 -3
- data/lib/wright/dsl.rb +52 -9
- data/lib/wright/logger.rb +1 -1
- data/lib/wright/provider.rb +8 -5
- data/lib/wright/provider/directory.rb +2 -2
- data/lib/wright/provider/file.rb +4 -4
- data/lib/wright/provider/group.rb +4 -4
- data/lib/wright/provider/package.rb +3 -3
- data/lib/wright/provider/package/apt.rb +1 -1
- data/lib/wright/provider/package/yum.rb +1 -1
- data/lib/wright/provider/symlink.rb +2 -2
- data/lib/wright/provider/user.rb +8 -8
- data/lib/wright/resource.rb +21 -19
- data/lib/wright/resource/directory.rb +21 -10
- data/lib/wright/resource/file.rb +25 -14
- data/lib/wright/resource/group.rb +16 -9
- data/lib/wright/resource/package.rb +14 -9
- data/lib/wright/resource/symlink.rb +10 -8
- data/lib/wright/resource/user.rb +30 -9
- data/lib/wright/util.rb +14 -2
- data/lib/wright/util/erb_renderer.rb +29 -0
- data/lib/wright/util/file.rb +1 -1
- data/lib/wright/util/file_owner.rb +8 -3
- data/lib/wright/util/file_permissions.rb +14 -12
- data/lib/wright/util/file_renderer.rb +50 -0
- data/lib/wright/util/mustache_renderer.rb +41 -0
- data/lib/wright/util/pencil_mustache.rb +58 -0
- data/lib/wright/version.rb +1 -1
- data/man/wright.1 +10 -11
- data/spec/dsl_spec.rb +72 -7
- data/spec/provider/package/apt/{apt-get_--purge_remove_-qy_abcde.return → apt-get_-qy_--purge_remove_abcde.return} +0 -0
- data/spec/provider/package/apt/{apt-get_--purge_remove_-qy_abcde.stderr → apt-get_-qy_--purge_remove_abcde.stderr} +0 -0
- data/spec/provider/package/apt/{apt-get_--purge_remove_-qy_abcde.stdout → apt-get_-qy_--purge_remove_abcde.stdout} +0 -0
- data/spec/provider/package/apt/{apt-get_install_-qy_abcde=2.5.4-1.return → apt-get_-qy_install_abcde=2.5.4-1.return} +0 -0
- data/spec/provider/package/apt/{apt-get_install_-qy_abcde=2.5.4-1.stderr → apt-get_-qy_install_abcde=2.5.4-1.stderr} +0 -0
- data/spec/provider/package/apt/{apt-get_install_-qy_abcde=2.5.4-1.stdout → apt-get_-qy_install_abcde=2.5.4-1.stdout} +0 -0
- data/spec/provider/package/apt/{apt-get_install_-qy_htop.return → apt-get_-qy_install_htop.return} +0 -0
- data/spec/provider/package/apt/{apt-get_install_-qy_htop.stderr → apt-get_-qy_install_htop.stderr} +0 -0
- data/spec/provider/package/apt/{apt-get_install_-qy_htop.stdout → apt-get_-qy_install_htop.stdout} +0 -0
- data/spec/provider/package/apt/{apt-get_install_-qy_not-a-real-package.return → apt-get_-qy_install_not-a-real-package.return} +0 -0
- data/spec/provider/package/apt/{apt-get_install_-qy_not-a-real-package.stderr → apt-get_-qy_install_not-a-real-package.stderr} +0 -0
- data/spec/provider/package/apt/{apt-get_install_-qy_not-a-real-package.stdout → apt-get_-qy_install_not-a-real-package.stdout} +0 -0
- data/spec/provider/package/apt/{apt-get_remove_-qy_abcde.return → apt-get_-qy_remove_abcde.return} +0 -0
- data/spec/provider/package/apt/{apt-get_remove_-qy_abcde.stderr → apt-get_-qy_remove_abcde.stderr} +0 -0
- data/spec/provider/package/apt/{apt-get_remove_-qy_abcde.stdout → apt-get_-qy_remove_abcde.stdout} +0 -0
- data/spec/provider/package/apt_spec.rb +2 -2
- data/spec/provider/package/yum/{yum_install_-y_mc-4.8.7-8.el7.return → yum_-y_install_mc-4.8.7-8.el7.return} +0 -0
- data/spec/provider/package/yum/{yum_install_-y_mc-4.8.7-8.el7.stderr → yum_-y_install_mc-4.8.7-8.el7.stderr} +0 -0
- data/spec/provider/package/yum/{yum_install_-y_mc-4.8.7-8.el7.stdout → yum_-y_install_mc-4.8.7-8.el7.stdout} +0 -0
- data/spec/provider/package/yum/{yum_install_-y_nano.return → yum_-y_install_nano.return} +0 -0
- data/spec/provider/package/yum/{yum_install_-y_nano.stderr → yum_-y_install_nano.stderr} +0 -0
- data/spec/provider/package/yum/{yum_install_-y_nano.stdout → yum_-y_install_nano.stdout} +0 -0
- data/spec/provider/package/yum/{yum_install_-y_not-a-real-package.return → yum_-y_install_not-a-real-package.return} +0 -0
- data/spec/provider/package/yum/{yum_install_-y_not-a-real-package.stderr → yum_-y_install_not-a-real-package.stderr} +0 -0
- data/spec/provider/package/yum/{yum_install_-y_not-a-real-package.stdout → yum_-y_install_not-a-real-package.stdout} +0 -0
- data/spec/provider/package/yum/{yum_remove_-y_screen.return → yum_-y_remove_screen.return} +0 -0
- data/spec/provider/package/yum/{yum_remove_-y_screen.stderr → yum_-y_remove_screen.stderr} +0 -0
- data/spec/provider/package/yum/{yum_remove_-y_screen.stdout → yum_-y_remove_screen.stdout} +0 -0
- data/spec/provider/package/yum_spec.rb +1 -1
- data/spec/resource/directory_spec.rb +15 -0
- data/spec/resource/file_spec.rb +17 -0
- data/spec/resource/group_spec.rb +15 -0
- data/spec/resource/package_spec.rb +13 -0
- data/spec/resource/symlink_spec.rb +11 -0
- data/spec/resource/user_spec.rb +32 -0
- data/spec/resource_spec.rb +18 -10
- data/spec/spec_helper.rb +1 -0
- data/spec/spec_helpers/fake_capture3.rb +1 -1
- data/spec/util/erb_renderer_spec.rb +23 -0
- data/spec/util/file_owner_spec.rb +19 -0
- data/spec/util/file_renderer_spec.rb +28 -0
- data/spec/util/mustache_renderer_spec.rb +57 -0
- data/spec/util/pencil_mustache_spec.rb +15 -0
- data/spec/util_spec.rb +17 -3
- metadata +90 -64
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a9d5eb3fb564f26c7d3c7e2dbc90aa4086e74fbb
|
|
4
|
+
data.tar.gz: f742866f8bfe1e1c8c40a61bf919b052ebe2744c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e84a4542c49ef1d19c1f04bfa645d7d5308dfbdce16cc7804f927e0a4ec24f2a451f9b09b8395b3085c68190234f21c2ca7ec5ee4a2c9db71e334b2a3f4b58b7
|
|
7
|
+
data.tar.gz: e3a4531204757348c7a5d139f8196443d8ac542e6225d4fd2032a7cb2a5760f75b6139b64ed82621fb9de8c69256386ca6381e1e7a0c4c106bae6714d48ed530
|
data/CONTRIBUTING.md
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
Contributing
|
|
2
2
|
============
|
|
3
|
-
|
|
4
3
|
Contributions to wright are greatly appreciated. Here's how you can
|
|
5
4
|
help.
|
|
6
5
|
|
|
7
6
|
Reporting issues
|
|
8
7
|
----------------
|
|
9
|
-
|
|
10
8
|
If you encounter any problems with wright, please take the time to
|
|
11
9
|
report them via the [issue tracker][github-issues].
|
|
12
10
|
|
|
@@ -19,7 +17,6 @@ report them via the [issue tracker][github-issues].
|
|
|
19
17
|
|
|
20
18
|
Submitting pull requests
|
|
21
19
|
------------------------
|
|
22
|
-
|
|
23
20
|
- Fork the project.
|
|
24
21
|
- Open a new feature branch (`git checkout -b hackety-hack`).
|
|
25
22
|
- Write [proper commit messages][commit-messages].
|
|
@@ -32,3 +29,13 @@ Submitting pull requests
|
|
|
32
29
|
|
|
33
30
|
[commit-messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
|
|
34
31
|
[pull-requests]: https://help.github.com/articles/using-pull-requests/
|
|
32
|
+
|
|
33
|
+
Running the tests
|
|
34
|
+
-----------------
|
|
35
|
+
To start hacking on wright, simply install the development
|
|
36
|
+
dependencies via bundler and run the tests:
|
|
37
|
+
|
|
38
|
+
- `bundle install --path .bundle`
|
|
39
|
+
- `bundle exec rake test`
|
|
40
|
+
|
|
41
|
+
All tests should pass.
|
data/NEWS.md
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
# wright NEWS
|
|
2
|
+
## 0.5.0 (2015-09-21)
|
|
3
|
+
- Add attribute hash support to DSL and resources
|
|
4
|
+
- Add template helpers
|
|
5
|
+
- Add util.render_erb to DSL
|
|
6
|
+
- Add util.render_mustache to DSL
|
|
7
|
+
- Add util.render_file to DSL
|
|
8
|
+
- Add support for Fedora
|
|
9
|
+
|
|
2
10
|
## 0.4.4 (2015-08-06)
|
|
3
11
|
- Fix update status for file provider if content attribute is nil and
|
|
4
12
|
file already has content (#16)
|
data/README.md
CHANGED
|
@@ -17,21 +17,20 @@ Performing simple administrative tasks with wright is easy.
|
|
|
17
17
|
|
|
18
18
|
package 'sudo'
|
|
19
19
|
|
|
20
|
-
file '/etc/sudoers.d/env_keep-editor'
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
end
|
|
20
|
+
file '/etc/sudoers.d/env_keep-editor',
|
|
21
|
+
content: "Defaults env_keep += EDITOR\n",
|
|
22
|
+
owner: 'root:root',
|
|
23
|
+
mode: '440'
|
|
25
24
|
```
|
|
26
25
|
|
|
27
26
|
Scripts can also be run directly from the shell.
|
|
28
27
|
|
|
29
|
-
wright -e "package
|
|
28
|
+
wright -e "package 'tmux'"
|
|
30
29
|
|
|
31
30
|
If you would rather see the effects of running a wright script first,
|
|
32
31
|
use the dry-run option:
|
|
33
32
|
|
|
34
|
-
wright --dry-run -e "package
|
|
33
|
+
wright --dry-run -e "package 'tmux'"
|
|
35
34
|
|
|
36
35
|
For a list of command-line parameters, see
|
|
37
36
|
[the manpage][wright-manpage]. For a more in-depth list of tasks you
|
|
@@ -68,10 +67,11 @@ interest to you:
|
|
|
68
67
|
- [wright manpage][wright-manpage]
|
|
69
68
|
- [list of wright resources][wright-resources]
|
|
70
69
|
- [wright is just Ruby][wright-is-ruby]
|
|
70
|
+
- [list of supported platforms][wright-platforms]
|
|
71
71
|
|
|
72
72
|
As a wright developer, you might also be interested in the
|
|
73
73
|
[wright developer docs](http://www.rubydoc.info/gems/wright/) which
|
|
74
|
-
can
|
|
74
|
+
can be generated via `bundle exec yard`.
|
|
75
75
|
|
|
76
76
|
Contributing
|
|
77
77
|
------------
|
|
@@ -79,14 +79,6 @@ Contributions to wright are greatly appreciated. If you would like to
|
|
|
79
79
|
contribute to wright, please have a look at the
|
|
80
80
|
[contribution guidelines](CONTRIBUTING.md).
|
|
81
81
|
|
|
82
|
-
To start hacking on wright, simply install the development
|
|
83
|
-
dependencies via bundler:
|
|
84
|
-
|
|
85
|
-
- `bundle install --path .bundle`
|
|
86
|
-
- `bundle exec rake test`
|
|
87
|
-
|
|
88
|
-
All tests should pass.
|
|
89
|
-
|
|
90
82
|
Copyright
|
|
91
83
|
---------
|
|
92
84
|
Copyright (c) 2012-2015 Sebastian Boehm. See [LICENSE](LICENSE) for
|
|
@@ -100,3 +92,4 @@ details.
|
|
|
100
92
|
[wright-manpage]: http://wright.sometimesfood.org/man/wright.1.html
|
|
101
93
|
[wright-resources]: http://wright.sometimesfood.org/doc/resources.html
|
|
102
94
|
[wright-is-ruby]: http://wright.sometimesfood.org/doc/wright-is-ruby.html
|
|
95
|
+
[wright-platforms]: http://wright.sometimesfood.org/doc/supported-platforms.html
|
data/lib/wright/cli.rb
CHANGED
|
@@ -16,38 +16,39 @@ module Wright
|
|
|
16
16
|
# @param argv [Array<String>] the arguments passed to bin/wright
|
|
17
17
|
def run(argv)
|
|
18
18
|
arguments = parse(argv)
|
|
19
|
-
return if
|
|
19
|
+
return if quit
|
|
20
20
|
|
|
21
|
-
Wright.activate_dry_run if
|
|
22
|
-
Wright.log.level =
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
Wright.activate_dry_run if dry_run
|
|
22
|
+
Wright.log.level = log_level if log_level
|
|
23
|
+
main.extend Wright::DSL
|
|
24
|
+
requires.each { |r| require r }
|
|
25
25
|
|
|
26
26
|
run_script(arguments)
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
private
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
attr_accessor :parser, :quit, :log_level, :dry_run
|
|
32
|
+
attr_reader :commands, :requires, :main
|
|
32
33
|
|
|
33
34
|
def parse(argv)
|
|
34
35
|
# use OptionParser#order! instead of #parse! so CLI#run does not
|
|
35
36
|
# consume --arguments passed to wright scripts
|
|
36
|
-
|
|
37
|
+
parser.order!(argv)
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
def run_script(arguments)
|
|
40
|
-
if
|
|
41
|
+
if commands.empty? && arguments.any?
|
|
41
42
|
script = File.expand_path(arguments.shift)
|
|
42
43
|
load script
|
|
43
44
|
else
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
cmds = commands.empty? ? $stdin.read : commands.join("\n")
|
|
46
|
+
main.instance_eval(cmds, '<main>', 1)
|
|
46
47
|
end
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
def set_up_parser
|
|
50
|
-
|
|
51
|
+
self.parser = OptionParser.new
|
|
51
52
|
set_up_command_option
|
|
52
53
|
set_up_require_option
|
|
53
54
|
set_up_dry_run_option
|
|
@@ -56,38 +57,38 @@ module Wright
|
|
|
56
57
|
end
|
|
57
58
|
|
|
58
59
|
def set_up_command_option
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
parser.on('-e COMMAND', 'Run COMMAND') do |e|
|
|
61
|
+
commands << e
|
|
61
62
|
end
|
|
62
63
|
end
|
|
63
64
|
|
|
64
65
|
def set_up_require_option
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
parser.on('-r LIBRARY',
|
|
67
|
+
'Require LIBRARY before running the script') do |r|
|
|
68
|
+
requires << r
|
|
68
69
|
end
|
|
69
70
|
end
|
|
70
71
|
|
|
71
72
|
def set_up_dry_run_option
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
parser.on('-n', '--dry-run', 'Enable dry-run mode') do
|
|
74
|
+
self.dry_run = true
|
|
74
75
|
end
|
|
75
76
|
end
|
|
76
77
|
|
|
77
78
|
def set_up_verbosity_options
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
parser.on('-v', '--verbose', 'Increase verbosity') do
|
|
80
|
+
self.log_level = Wright::Logger::DEBUG
|
|
80
81
|
end
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
parser.on('-q', '--quiet', 'Decrease verbosity') do
|
|
84
|
+
self.log_level = Wright::Logger::ERROR
|
|
84
85
|
end
|
|
85
86
|
end
|
|
86
87
|
|
|
87
88
|
def set_up_version_option
|
|
88
|
-
|
|
89
|
+
parser.on_tail('--version', 'Show wright version') do
|
|
89
90
|
puts "wright version #{Wright::VERSION}"
|
|
90
|
-
|
|
91
|
+
self.quit = true
|
|
91
92
|
end
|
|
92
93
|
end
|
|
93
94
|
end
|
data/lib/wright/config.rb
CHANGED
|
@@ -14,7 +14,9 @@ module Wright
|
|
|
14
14
|
@config_hash = {}
|
|
15
15
|
class << self
|
|
16
16
|
extend Forwardable
|
|
17
|
-
def_delegators
|
|
17
|
+
def_delegators :config_hash, :[], :[]=, :size
|
|
18
|
+
attr_reader :config_hash
|
|
19
|
+
private :config_hash
|
|
18
20
|
end
|
|
19
21
|
private_class_method :new
|
|
20
22
|
|
|
@@ -34,7 +36,7 @@ module Wright
|
|
|
34
36
|
# otherwise.
|
|
35
37
|
def self.nested_key?(*path)
|
|
36
38
|
last_key = path.pop
|
|
37
|
-
last_hash = path.reduce(
|
|
39
|
+
last_hash = path.reduce(config_hash) do |hash, key|
|
|
38
40
|
return false unless hash.respond_to?(:fetch)
|
|
39
41
|
hash.fetch(key, {})
|
|
40
42
|
end
|
|
@@ -55,7 +57,7 @@ module Wright
|
|
|
55
57
|
#
|
|
56
58
|
# @return the configuration value or nil if the value is not set
|
|
57
59
|
def self.nested_value(*path)
|
|
58
|
-
nested_key?(*path) ? path.reduce(
|
|
60
|
+
nested_key?(*path) ? path.reduce(config_hash) { |a, e| a[e] } : nil
|
|
59
61
|
end
|
|
60
62
|
end
|
|
61
63
|
end
|
data/lib/wright/dsl.rb
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
require 'wright/util'
|
|
2
|
+
require 'wright/util/erb_renderer'
|
|
3
|
+
require 'wright/util/mustache_renderer'
|
|
4
|
+
require 'wright/util/file_renderer'
|
|
2
5
|
|
|
3
6
|
module Wright
|
|
4
7
|
# Includable Wright script DSL.
|
|
@@ -27,22 +30,58 @@ module Wright
|
|
|
27
30
|
# a_sink_to_remember.class
|
|
28
31
|
# # => KitchenSink
|
|
29
32
|
module DSL
|
|
33
|
+
# DSL helper class.
|
|
34
|
+
class Util
|
|
35
|
+
# Renders an ERB template using the supplied hash.
|
|
36
|
+
# @param template [String] the template
|
|
37
|
+
# @param hash [Hash] the hash
|
|
38
|
+
# @return [String] the rendered template
|
|
39
|
+
def render_erb(template, hash)
|
|
40
|
+
Wright::Util::ErbRenderer.new(hash).render(template)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# Renders a mustache template using the supplied hash.
|
|
44
|
+
# @param template [String] the template
|
|
45
|
+
# @param hash [Hash] the hash
|
|
46
|
+
# @return [String] the rendered template
|
|
47
|
+
def render_mustache(template, hash)
|
|
48
|
+
Wright::Util::MustacheRenderer.new(hash).render(template)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Renders a template file according to the file's extension
|
|
52
|
+
# using the supplied hash. Currently supports ERB (+.erb+) and
|
|
53
|
+
# Mustache (+.mustache+).
|
|
54
|
+
#
|
|
55
|
+
# @param filename [String] the filename of the template file
|
|
56
|
+
# @param hash [Hash] the hash
|
|
57
|
+
# @return [String] the rendered template
|
|
58
|
+
def render_file(filename, hash)
|
|
59
|
+
Wright::Util::FileRenderer.new(hash).render(filename)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Supplies access to various useful helper methods.
|
|
64
|
+
# @return [Wright::DSL::Util] a utility helper
|
|
65
|
+
def util
|
|
66
|
+
Wright::DSL::Util.new
|
|
67
|
+
end
|
|
68
|
+
|
|
30
69
|
# Registers a class as a resource.
|
|
31
70
|
#
|
|
32
71
|
# Creates a resource method in the DSL module. Uses the
|
|
33
72
|
# snake-cased class name as method name.
|
|
34
73
|
#
|
|
35
|
-
# Typically resource_class is a subclass of {Resource}. It is
|
|
36
|
-
# initialized with the resource's name
|
|
37
|
-
#
|
|
38
|
-
# @param resource_class the resource class
|
|
74
|
+
# Typically +resource_class+ is a subclass of {Resource}. It is
|
|
75
|
+
# initialized with the resource's name and the attribute hash as
|
|
76
|
+
# arguments.
|
|
39
77
|
#
|
|
78
|
+
# @param resource_class [Class] the resource class
|
|
40
79
|
# @return [void]
|
|
41
80
|
def self.register_resource(resource_class)
|
|
42
|
-
method_name = Util.class_to_resource_name(resource_class)
|
|
81
|
+
method_name = Wright::Util.class_to_resource_name(resource_class)
|
|
43
82
|
this_module = self
|
|
44
|
-
define_method(method_name) do |name, &block|
|
|
45
|
-
this_module.yield_resource(resource_class, name, &block)
|
|
83
|
+
define_method(method_name) do |name, args = {}, &block|
|
|
84
|
+
this_module.yield_resource(resource_class, name, args, &block)
|
|
46
85
|
end
|
|
47
86
|
end
|
|
48
87
|
|
|
@@ -52,10 +91,14 @@ module Wright
|
|
|
52
91
|
# Implicitly invoking a block from within another block does not
|
|
53
92
|
# work: http://blog.sidu.in/2007/11/ruby-blocks-gotchas.html
|
|
54
93
|
#
|
|
94
|
+
# @param resource_class [Class] the resource class
|
|
95
|
+
# @param name [String] the name of the resource object
|
|
96
|
+
# @param args [Hash<Symbol, Object] the attribute hash of the resource
|
|
97
|
+
#
|
|
55
98
|
# @yield [Resource] the resource
|
|
56
99
|
# @return [void]
|
|
57
|
-
def self.yield_resource(resource_class, name)
|
|
58
|
-
r = resource_class.new(name)
|
|
100
|
+
def self.yield_resource(resource_class, name, args)
|
|
101
|
+
r = resource_class.new(name, args)
|
|
59
102
|
yield(r) if block_given?
|
|
60
103
|
r.run_action if r.respond_to?(:run_action)
|
|
61
104
|
r
|
data/lib/wright/logger.rb
CHANGED
|
@@ -58,7 +58,7 @@ module Wright # rubocop:disable Documentation
|
|
|
58
58
|
def initialize(logdev = $stdout)
|
|
59
59
|
super
|
|
60
60
|
Wright::Config[:log] ||= {}
|
|
61
|
-
return if Wright::Config[:log].
|
|
61
|
+
return if Wright::Config[:log].key?(:colorize)
|
|
62
62
|
|
|
63
63
|
Wright::Config[:log][:colorize] = logdev.tty?
|
|
64
64
|
end
|
data/lib/wright/provider.rb
CHANGED
|
@@ -26,13 +26,16 @@ module Wright
|
|
|
26
26
|
# @return [Bool] true if the provider was updated and false
|
|
27
27
|
# otherwise
|
|
28
28
|
def updated?
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
updated_since_last_call = updated
|
|
30
|
+
self.updated = false
|
|
31
|
+
updated_since_last_call
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
private
|
|
35
35
|
|
|
36
|
+
attr_accessor :updated
|
|
37
|
+
attr_reader :resource
|
|
38
|
+
|
|
36
39
|
# @api public
|
|
37
40
|
# Logs an info message and runs a code block unless dry run mode
|
|
38
41
|
# is active.
|
|
@@ -49,7 +52,7 @@ module Wright
|
|
|
49
52
|
|
|
50
53
|
# @api public
|
|
51
54
|
# Checks if the provider is up-to-date, runs a code block and sets
|
|
52
|
-
#
|
|
55
|
+
# `updated` to `true` if it is not.
|
|
53
56
|
#
|
|
54
57
|
# @param action [String] the target action
|
|
55
58
|
# @param message [String] a log message that is displayed if the
|
|
@@ -59,7 +62,7 @@ module Wright
|
|
|
59
62
|
Wright.log.debug message
|
|
60
63
|
else
|
|
61
64
|
yield
|
|
62
|
-
|
|
65
|
+
self.updated = true
|
|
63
66
|
end
|
|
64
67
|
end
|
|
65
68
|
|
|
@@ -42,11 +42,11 @@ module Wright
|
|
|
42
42
|
private
|
|
43
43
|
|
|
44
44
|
def dir_name
|
|
45
|
-
|
|
45
|
+
resource.name
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
def permissions
|
|
49
|
-
Wright::Util::FilePermissions.create_from_resource(
|
|
49
|
+
Wright::Util::FilePermissions.create_from_resource(resource,
|
|
50
50
|
:directory)
|
|
51
51
|
end
|
|
52
52
|
|
data/lib/wright/provider/file.rb
CHANGED
|
@@ -14,7 +14,7 @@ module Wright
|
|
|
14
14
|
# Creates or updates the file.
|
|
15
15
|
#
|
|
16
16
|
# @return [void]
|
|
17
|
-
# @raise [Errno::EISDIR] if there is
|
|
17
|
+
# @raise [Errno::EISDIR] if there already is a directory with
|
|
18
18
|
# the specified name
|
|
19
19
|
def create
|
|
20
20
|
fail_if_directory
|
|
@@ -44,15 +44,15 @@ module Wright
|
|
|
44
44
|
private
|
|
45
45
|
|
|
46
46
|
def file_name
|
|
47
|
-
|
|
47
|
+
resource.name
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def content
|
|
51
|
-
|
|
51
|
+
resource.content
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def permissions
|
|
55
|
-
Wright::Util::FilePermissions.create_from_resource(
|
|
55
|
+
Wright::Util::FilePermissions.create_from_resource(resource, :file)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def write_content_to_file
|
|
@@ -32,19 +32,19 @@ module Wright
|
|
|
32
32
|
private
|
|
33
33
|
|
|
34
34
|
def group_name
|
|
35
|
-
|
|
35
|
+
resource.name
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
def gid
|
|
39
|
-
|
|
39
|
+
resource.gid
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
def members
|
|
43
|
-
|
|
43
|
+
resource.members
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
def system_group?
|
|
47
|
-
|
|
47
|
+
resource.system
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def ensure_group_exists
|