wright 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a6ea11aed95157e957a5d973bbf12e34cb868ace
4
- data.tar.gz: 4bcb75ed67ab7f90027fe7a621b0f240c6a8c7fb
3
+ metadata.gz: 0005b749e54ff7904188cbd497f1757c460c0b4d
4
+ data.tar.gz: b1fc596dc236a11f9a18c9de89823c91f0d20fee
5
5
  SHA512:
6
- metadata.gz: 0c5b952723832faf165f63ccdccd3e46cd9bce20b37a7092bc88bdb478f766bc3ab2684bba85f0633f61f152f4908a9726590b160263ab7c01f1cd97046fe653
7
- data.tar.gz: 02971bb7a151b4a15712177fd70306a87cb4adad83faa69e1b3900a5b1462513099c152b9d542cf983bc4c297c62c896d2eba60017884b9f2d222687baf28d45
6
+ metadata.gz: d9eaae5610049c8407782fd8089f789a9dbbe7208d08a46f5de4e8618b258824830c653f18c59bb0175d83b5d5661d90c276996fed278ebaa223ffce7748a706
7
+ data.tar.gz: 0975e81800682d9e93ec0d365f20ef9a4effdab230c217b2b6661eb2ffc8e1ed7d2e1ec39933f30f46795c5a42ce01343eab154bb104e3009558ceb52552abc5
data/NEWS CHANGED
@@ -1,4 +1,9 @@
1
1
  * wright NEWS
2
+ ** 0.1.2 (2015-01-31)
3
+
4
+ - Convert docs to YARD
5
+ - Fix color code for warnings
6
+
2
7
  ** 0.1.1 (2015-01-20)
3
8
 
4
9
  - Remove hardcoded package provider config
data/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ wright
2
+ ======
3
+
1
4
  [![Gem Version](http://img.shields.io/gem/v/wright.svg?style=flat-square)][gem]
2
5
  [![Build Status](http://img.shields.io/travis/sometimesfood/wright.svg?style=flat-square)][travis]
3
6
  [![Code Climate](http://img.shields.io/codeclimate/github/sometimesfood/wright.svg?style=flat-square)][codeclimate]
@@ -6,9 +9,6 @@
6
9
  [travis]: https://travis-ci.org/sometimesfood/wright
7
10
  [codeclimate]: https://codeclimate.com/github/sometimesfood/wright
8
11
 
9
- wright
10
- ======
11
-
12
12
  Lightweight configuration management.
13
13
 
14
14
  Requirements
data/Rakefile CHANGED
@@ -1,21 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
  require 'bundler/gem_tasks'
3
3
  require 'rake/testtask'
4
- require 'rdoc/task'
5
4
 
6
5
  Rake::TestTask.new do |t|
7
6
  t.pattern = 'spec/**/*_spec.rb'
8
7
  end
9
-
10
- RDoc::Task.new(clobber_rdoc: 'rdoc:clobber',
11
- rerdoc: 'rdoc:force') do |t|
12
- t.rdoc_files.include('lib/**/*.rb')
13
- t.options << '--markup=tomdoc'
14
- end
15
-
16
- namespace :rdoc do
17
- desc 'Show RDoc coverage report'
18
- task :coverage do
19
- exec 'rdoc --markup=tomdoc --coverage-report lib/'
20
- end
21
- end
data/lib/wright.rb CHANGED
@@ -8,6 +8,7 @@ require 'wright/resource/file'
8
8
  require 'wright/resource/package'
9
9
  require 'wright/resource/symlink'
10
10
 
11
- # Public: TODO: Add some documentation
11
+ # @todo add proper documentation
12
+ # Lightweight configuration management.
12
13
  module Wright
13
14
  end
data/lib/wright/config.rb CHANGED
@@ -1,13 +1,12 @@
1
1
  require 'forwardable'
2
2
 
3
3
  module Wright
4
- # Public: Configuration container, wraps a regular Ruby hash.
4
+ # Configuration container, wraps a regular Ruby hash.
5
5
  #
6
6
  # Useful for getting and setting configuration values, such as
7
- # logging verbosity, colour output and provider configuration.
8
- #
9
- # Examples
7
+ # logging verbosity, color output and provider configuration.
10
8
  #
9
+ # @example
11
10
  # Wright::Config[:foo] = { bar: :baz }
12
11
  # Wright::Config[:foo][:bar]
13
12
  # # => :baz
@@ -19,12 +18,11 @@ module Wright
19
18
  end
20
19
  private_class_method :new
21
20
 
22
- # Public: Check if a (nested) configuration value is set.
23
- #
24
- # path - The configuration item as an argument list.
21
+ # Checks if a (nested) configuration value is set.
25
22
  #
26
- # Examples
23
+ # @param path [Array<Symbol>] the configuration key
27
24
  #
25
+ # @example
28
26
  # Wright::Config[:foo] = { bar: :baz }
29
27
  # Wright::Config.nested_key?(:foo, :bar)
30
28
  # # => true
@@ -32,7 +30,7 @@ module Wright
32
30
  # Wright::Config.nested_key?(:this, :doesnt, :exist)
33
31
  # # => false
34
32
  #
35
- # Returns true if the configuration value is set and false
33
+ # @return [Bool] true if the configuration value is set and false
36
34
  # otherwise.
37
35
  def self.nested_key?(*path)
38
36
  last_key = path.pop
@@ -43,12 +41,11 @@ module Wright
43
41
  last_hash.respond_to?(:key?) && last_hash.key?(last_key)
44
42
  end
45
43
 
46
- # Public: Retrieve a (nested) configuration value.
47
- #
48
- # path - The configuration item as an argument list.
44
+ # Retrieves a (nested) configuration value.
49
45
  #
50
- # Examples
46
+ # @param path [Array<Symbol>] the configuration key
51
47
  #
48
+ # @example
52
49
  # Wright::Config[:foo] = { bar: :baz }
53
50
  # Wright::Config.nested_value(:foo, :bar)
54
51
  # # => :baz
@@ -56,7 +53,7 @@ module Wright
56
53
  # Wright::Config.nested_value(:this, :doesnt, :exist)
57
54
  # # => nil
58
55
  #
59
- # Returns the configuration value or nil if the value is not set.
56
+ # @return the configuration value or nil if the value is not set
60
57
  def self.nested_value(*path)
61
58
  nested_key?(*path) ? path.reduce(@config_hash) { |a, e| a[e] } : nil
62
59
  end
@@ -1,28 +1,27 @@
1
1
  module Wright # rubocop:disable Documentation
2
2
  @dry_run = false
3
3
 
4
- # Public: Checks if dry-run mode is currently active.
5
- #
6
- # Examples
4
+ # Checks if dry-run mode is currently active.
7
5
  #
6
+ # @example
8
7
  # puts 'Just a dry-run...' if Wright.dry_run?
9
8
  #
10
- # Returns true if dry-run mode is currently active and false otherwise.
9
+ # @return [Bool] true if dry-run mode is currently active and false
10
+ # otherwise
11
11
  def self.dry_run?
12
12
  @dry_run
13
13
  end
14
14
 
15
- # Public: Runs a block in dry-run mode.
16
- #
17
- # Examples
15
+ # Runs a block in dry-run mode.
18
16
  #
17
+ # @example
19
18
  # Wright.dry_run do
20
19
  # symlink '/tmp/fstab' do |s|
21
20
  # s.to = '/etc/fstab'
22
21
  # end
23
22
  # end
24
23
  #
25
- # Returns the block's return value.
24
+ # @return the block's return value
26
25
  def self.dry_run
27
26
  saved_dry_run = @dry_run
28
27
  @dry_run = true
data/lib/wright/dsl.rb CHANGED
@@ -1,12 +1,11 @@
1
1
  require 'wright/util'
2
2
 
3
3
  module Wright
4
- # Public: Includable Wright script DSL.
4
+ # Includable Wright script DSL.
5
5
  #
6
6
  # Contains resource methods for all registered resources.
7
7
  #
8
- # Examples
9
- #
8
+ # @example
10
9
  # # define a new resource at runtime
11
10
  # class KitchenSink < Wright::Resource; end
12
11
  #
@@ -28,16 +27,17 @@ module Wright
28
27
  # a_sink_to_remember.class
29
28
  # # => KitchenSink
30
29
  module DSL
31
- # Public: Register a class as a resource.
30
+ # Registers a class as a resource.
32
31
  #
33
32
  # Creates a resource method in the DSL module. Uses the
34
33
  # snake-cased class name as method name.
35
34
  #
36
- # resource_class - The resource class. Usually a subclass of
37
- # Wright::Resource. Will be initialized with the
38
- # resource's name as an argument.
35
+ # Typically resource_class is a subclass of {Resource}. It is
36
+ # initialized with the resource's name as an argument.
37
+ #
38
+ # @param resource_class the resource class
39
39
  #
40
- # Returns nothing.
40
+ # @return [void]
41
41
  def self.register_resource(resource_class)
42
42
  method_name = Util.class_to_resource_name(resource_class)
43
43
  this_module = self
@@ -46,13 +46,15 @@ module Wright
46
46
  end
47
47
  end
48
48
 
49
- # Internal: Instantiate a resource_class object and perform its
50
- # default action.
49
+ # @api private
50
+ # Instantiates a resource and performs its default action.
51
51
  #
52
52
  # Implicitly invoking a block from within another block does not
53
53
  # work: http://blog.sidu.in/2007/11/ruby-blocks-gotchas.html
54
54
  #
55
- # Returns nothing.
55
+ # @yield [resource] the resource
56
+ #
57
+ # @return [void]
56
58
  def self.yield_resource(resource_class, name)
57
59
  r = resource_class.new(name)
58
60
  yield(r) if block_given?
data/lib/wright/logger.rb CHANGED
@@ -4,18 +4,20 @@ require 'wright/config'
4
4
  require 'wright/util/color'
5
5
 
6
6
  module Wright # rubocop:disable Documentation
7
- # Public: Default logger for Wright.
7
+ # Default logger for Wright.
8
8
  class Logger < ::Logger
9
- # Public: Default formatter for Wright log messages.
9
+ # @api private
10
+ # Default formatter for Wright log messages.
10
11
  class Formatter < ::Logger::Formatter
11
- # Internal: Called by Wright::Logger to format log messages.
12
+ # This method is called by {Wright::Logger} to format log
13
+ # messages.
12
14
  #
13
- # severity - The String log severity.
14
- # time - The time for the log entry. Ignored.
15
- # progname - The program name for the log entry. Ignored.
16
- # message - The actual log message.
15
+ # @param severity [String] the log entry's severity
16
+ # @param _time [Time] the log entry's time stamp (ignored)
17
+ # @param _progname [String] the log entry's program name (ignored)
18
+ # @param message [String] the log message
17
19
  #
18
- # Returns the formatted String log entry.
20
+ # @return [String] the formatted log entry
19
21
  def call(severity, _time, _progname, message)
20
22
  log_entry = "#{severity}: #{message}\n"
21
23
  if Wright::Config[:log][:colorize]
@@ -27,13 +29,12 @@ module Wright # rubocop:disable Documentation
27
29
 
28
30
  private
29
31
 
30
- # Internal: ANSI-Colorize a log message according to its
31
- # severity.
32
+ # ANSI-Colorizes a log message according to its severity.
32
33
  #
33
- # string - The String log message to be colorized.
34
- # severity - The String severity of the log message.
34
+ # @param string [String] the log message to be colorized
35
+ # @param severity [String] the severity of the log message
35
36
  #
36
- # Returns the colorized String.
37
+ # @return [String] the colorized log message
37
38
  def colorize(string, severity)
38
39
  case severity
39
40
  when 'ERROR', 'FATAL'
@@ -48,12 +49,12 @@ module Wright # rubocop:disable Documentation
48
49
  end
49
50
  end
50
51
 
51
- # Public: Initialize a Logger.
52
+ # Initializes a Logger.
52
53
  #
53
54
  # Enables log colorization if the log device is a TTY and
54
55
  # colorization was not disabled before initialization.
55
56
  #
56
- # logdev - The log device used by the Logger.
57
+ # @param logdev [IO] the log device used by the Logger.
57
58
  def initialize(logdev = $stdout)
58
59
  super
59
60
  Wright::Config[:log] ||= {}
@@ -64,7 +65,7 @@ module Wright # rubocop:disable Documentation
64
65
  end
65
66
 
66
67
  class << self
67
- # Public: Get/Set Wright's Logger.
68
+ # @return [Logger] the logger used by Wright
68
69
  attr_accessor :log
69
70
  end
70
71
  @log = Wright::Logger.new
@@ -2,26 +2,26 @@ require 'wright/config'
2
2
  require 'wright/util/recursive_autoloader'
3
3
 
4
4
  module Wright
5
- # Public: Provider class.
5
+ # Provider class.
6
6
  class Provider
7
- # Public: Wright standard provider directory.
7
+ # Wright standard provider directory
8
8
  PROVIDER_DIR = File.expand_path('provider', File.dirname(__FILE__))
9
9
 
10
10
  Wright::Util::RecursiveAutoloader.add_autoloads(PROVIDER_DIR, name)
11
11
 
12
- # Public: Initialize a Provider.
12
+ # Initializes a Provider.
13
13
  #
14
- # resource - The resource used by the provider, typically a
15
- # Wright::Resource.
14
+ # @param resource [Resource] the resource used by the provider
16
15
  def initialize(resource)
17
16
  @resource = resource
18
17
  @updated = false
19
18
  end
20
19
 
21
- # Public: Checks if the provider was updated since the last call
22
- # to updated?.
20
+ # Checks if the provider was updated since the last call to
21
+ # {#updated?}
23
22
  #
24
- # Returns true if the provider was updated and false otherwise.
23
+ # @return [Bool] true if the provider was updated and false
24
+ # otherwise
25
25
  def updated?
26
26
  updated = @updated
27
27
  @updated = false
@@ -6,11 +6,11 @@ require 'wright/util/file_permissions'
6
6
 
7
7
  module Wright
8
8
  class Provider
9
- # Public: Directory provider. Used as a Provider for Resource::Directory.
9
+ # Directory provider. Used as a provider for {Resource::Directory}.
10
10
  class Directory < Wright::Provider
11
- # Public: Create or update the directory.
11
+ # Creates or updates the directory.
12
12
  #
13
- # Returns nothing.
13
+ # @return [void]
14
14
  def create
15
15
  if ::File.directory?(dirname) && permissions.uptodate?
16
16
  Wright.log.debug "directory already created: '#{@resource.name}'"
@@ -22,9 +22,9 @@ module Wright
22
22
  @updated = true
23
23
  end
24
24
 
25
- # Public: Remove the directory.
25
+ # Removes the directory.
26
26
  #
27
- # Returns nothing.
27
+ # @return [void]
28
28
  def remove
29
29
  if ::File.exist?(dirname) && !::File.directory?(dirname)
30
30
  fail "'#{dirname}' exists but is not a directory"
@@ -8,11 +8,11 @@ require 'tmpdir'
8
8
 
9
9
  module Wright
10
10
  class Provider
11
- # Public: File provider. Used as a Provider for Resource::File.
11
+ # File provider. Used as a provider for {Resource::File}.
12
12
  class File < Wright::Provider
13
- # Public: Create or update the File.
13
+ # Creates or updates the file.
14
14
  #
15
- # Returns nothing.
15
+ # @return [void]
16
16
  def create
17
17
  fail Errno::EISDIR, filename if ::File.directory?(filename)
18
18
 
@@ -25,9 +25,9 @@ module Wright
25
25
  @updated = true
26
26
  end
27
27
 
28
- # Public: Remove the File.
28
+ # Removes the file.
29
29
  #
30
- # Returns nothing.
30
+ # @return [void]
31
31
  def remove
32
32
  fail Errno::EISDIR, filename if ::File.directory?(filename)
33
33
 
@@ -2,19 +2,20 @@ require 'wright/provider'
2
2
 
3
3
  module Wright
4
4
  class Provider
5
- # Public: Package provider. Used as a Provider base class for
6
- # Resource::Package.
5
+ # Package provider. Used as a base class for Resource::Package
6
+ # providers.
7
7
  class Package < Wright::Provider
8
8
  private
9
9
 
10
- # Public: Check if the package is up-to-date for a given
11
- # action.
10
+ # @api public
11
+ # Checks if the package is up-to-date for a given action.
12
12
  #
13
- # action - The action symbol. Currently supports :install and
14
- # :remove.
13
+ # @param action [Symbol] the action. Currently supports
14
+ # +:install+ and +:remove+.
15
15
  #
16
- # Returns true if the package is up-to-date and false otherwise.
17
- # Raises ArgumentError if the action is invalid.
16
+ # @return [Bool] +true+ if the package is up-to-date and +false+
17
+ # otherwise
18
+ # @raise [ArgumentError] if the action is invalid
18
19
  def uptodate?(action)
19
20
  case action
20
21
  when :install
@@ -7,12 +7,10 @@ require 'wright/provider/package'
7
7
  module Wright
8
8
  class Provider
9
9
  class Package
10
- # Public: AptPackage provider. Used as a Provider for
11
- # Resource::Package on Debian-based systems.
10
+ # Apt package provider. Used as a Provider for
11
+ # {Resource::Package} on Debian-based systems.
12
12
  class Apt < Wright::Provider::Package
13
- # Public: Get the installed package version.
14
- #
15
- # Returns an array of installed package version Strings.
13
+ # @return [Array<String>] the installed package versions
16
14
  def installed_versions
17
15
  cmd = "dpkg-query -s #{@resource.name}"
18
16
  cmd_stdout, _cmd_stderr, cmd_status = Open3.capture3(env, cmd)
@@ -26,9 +24,9 @@ module Wright
26
24
  end
27
25
  end
28
26
 
29
- # Public: Install the package.
27
+ # Installs the package.
30
28
  #
31
- # Returns nothing.
29
+ # @return [void]
32
30
  def install
33
31
  if uptodate?(:install)
34
32
  Wright.log.debug "package already installed: '#{@resource.name}'"
@@ -39,9 +37,9 @@ module Wright
39
37
  @updated = true
40
38
  end
41
39
 
42
- # Public: Remove the package.
40
+ # Removes the package.
43
41
  #
44
- # Returns nothing.
42
+ # @return [void]
45
43
  def remove
46
44
  if uptodate?(:remove)
47
45
  Wright.log.debug "package already removed: '#{@resource.name}'"