config_curator 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 739cd145342395af3f9bd1629d26006d80d92095
4
- data.tar.gz: f34cd95e0a71591d16f01dfef21c3dc7a191bd0d
3
+ metadata.gz: e025bf5875775d284843dd093df45960f282e908
4
+ data.tar.gz: 942b7ecffe91f214959dcccbbfaf88fd56c46249
5
5
  SHA512:
6
- metadata.gz: b3fb7a5b09056a397cda636f7975384b023a3012f65f0ca86f3408078faf0634512d0a2b30b37899d41ad23d96384d443c9e10fb904cb8946baac044e0ced7fb
7
- data.tar.gz: e2e1ee6b3cf5e4e185fc2ba4e2a9259eeae9f176470539fdf040bf2511d0bd80293d660a9fc2705decc4947350b40707d2daa14ce81a97555447c4da70dae680
6
+ metadata.gz: 6456369212a86c78383e814acf404770dcb96719b935bd8f1b88f87a9d65f00c517343846e03c552e36944ca226bcf7444e3f29280866ef66e64d76d88745780
7
+ data.tar.gz: 1c49c2541f670186678b071d3c307bcfa7a73344d3224a655ff5be6302317ed0c3dd4d4d132309bc8d329ee13fb5bc75e465c4d9103a744ed3e701a875ce828b
data/README.md CHANGED
@@ -30,6 +30,7 @@ Or install it yourself as:
30
30
  ````bash
31
31
  $ gem install config_curator
32
32
  ````
33
+
33
34
  ## Documentation
34
35
 
35
36
  The primary documentation for Config Curator is this README and the YARD source documentation.
@@ -41,6 +42,12 @@ Documentation for the latest commits is hosted on
41
42
 
42
43
  ## Usage
43
44
 
45
+ ### Scripting
46
+
47
+ Config Curator is fully scriptable for easy inclusion into other Ruby programs.
48
+ The API is well documented for this purpose
49
+ (see [Documentation](#documentation) above).
50
+
44
51
  ## Source Repository
45
52
 
46
53
  The [Config Curator source](https://github.com/razor-x/config_curator)
@@ -53,6 +60,10 @@ $ git clone https://github.com/razor-x/config_curator.git
53
60
 
54
61
  ## Contributing
55
62
 
63
+ Please submit and comment on bug reports and feature requests.
64
+
65
+ To submit a patch:
66
+
56
67
  1. Fork it (https://github.com/razor-x/config_curator/fork).
57
68
  2. Create your feature branch (`git checkout -b my-new-feature`).
58
69
  3. Commit your changes (`git commit -am 'Add some feature'`).
@@ -3,8 +3,11 @@ require 'thor'
3
3
 
4
4
  module ConfigCurator
5
5
 
6
+ # Thor class for the `curate` command.
6
7
  class CLI < Thor
7
8
 
9
+ default_task :install
10
+
8
11
  class_option :verbose, type: :boolean, aliases: %i(v)
9
12
  class_option :quiet, type: :boolean, aliases: %i(q)
10
13
  class_option :debug, type: :boolean
@@ -4,6 +4,9 @@ require 'yaml'
4
4
 
5
5
  module ConfigCurator
6
6
 
7
+ # Manages collections of units.
8
+ # @example Load a list of units and install them
9
+ # Collection.new(manifest_path: 'manifest.yml').install
7
10
  class Collection
8
11
 
9
12
  # Supported unit types.
@@ -108,7 +111,7 @@ module ConfigCurator
108
111
  # @return [Unit] the unit object of the appropriate subclass
109
112
  def create_unit type, attributes: {}
110
113
  options = {}
111
- %i(root).each do |k|
114
+ %i(root package_tool).each do |k|
112
115
  options[k] = manifest[k] unless manifest[k].nil?
113
116
  end if manifest
114
117
 
@@ -3,6 +3,13 @@ require 'open3'
3
3
 
4
4
  module ConfigCurator
5
5
 
6
+ # Lookup if a package is installed on the system.
7
+ # See {TOOLS} for supported package tools.
8
+ # If {#tool} is not explicitly set, it will try and choose one automatically.
9
+ # @example Lookup a package
10
+ # PackageLookup.new.installed? 'ruby' #=> true
11
+ # @example Lookup a package using `pacman`
12
+ # PackageLookup.new(tool: :pacman).installed? 'ruby' #=> true
6
13
  class PackageLookup
7
14
 
8
15
  # Error when a package lookup cannot be completed.
@@ -3,6 +3,9 @@ require 'socket'
3
3
 
4
4
  module ConfigCurator
5
5
 
6
+ # A unit is the base class for a type of configuration
7
+ # that should be installed.
8
+ # All units must specify a {#source} and a {#destination}.
6
9
  class Unit
7
10
 
8
11
  # Error if the unit will fail to install.
@@ -2,11 +2,15 @@ require 'mkmf'
2
2
 
3
3
  module ConfigCurator
4
4
 
5
+ # A component is a folder that should be copied.
6
+ # The {#destination} will become a mirror of the {#source}.
7
+ # The contents of the {#destination_path} is
8
+ # completely replaced by the contents of the {#source_path}.
5
9
  class Component < Unit
6
10
 
7
11
  attr_accessor :fmode, :dmode, :owner, :group
8
12
 
9
- # @see Unit#install
13
+ # (see Unit#install)
10
14
  def install
11
15
  s = super
12
16
  return s unless s
@@ -16,7 +20,7 @@ module ConfigCurator
16
20
  true
17
21
  end
18
22
 
19
- # @see Unit#install?
23
+ # (see Unit#install?)
20
24
  def install?
21
25
  s = super
22
26
  return s unless s
@@ -1,25 +1,26 @@
1
1
  module ConfigCurator
2
2
 
3
+ # A config file is a file that should be copied.
3
4
  class ConfigFile < Unit
4
5
 
5
6
  attr_accessor :fmode, :owner, :group
6
7
 
7
8
  # Will use files of the form `filename.hostname.ext` if found.
8
- # @see Unit#source
9
+ # (see Unit#source)
9
10
  def source
10
11
  path = super
11
12
  host_specific_file = search_for_host_specific_file path if path
12
13
  if host_specific_file then return host_specific_file else return path end
13
14
  end
14
15
 
15
- # Use {#source} by default.
16
- # @see Unit#destination
16
+ # (see Unit#destination)
17
+ # @note Use {#source} by default.
17
18
  def destination
18
19
  super
19
20
  @destination ||= source
20
21
  end
21
22
 
22
- # @see Unit#install
23
+ # (see Unit#install)
23
24
  def install
24
25
  s = super
25
26
  return s unless s
@@ -29,7 +30,7 @@ module ConfigCurator
29
30
  true
30
31
  end
31
32
 
32
- # @see Unit#install?
33
+ # (see Unit#install?)
33
34
  def install?
34
35
  s = super
35
36
  return s unless s
@@ -1,8 +1,11 @@
1
1
  module ConfigCurator
2
2
 
3
+ # A symlink is a symbolic link that should be created.
4
+ # The {#destination_path} will be a link
5
+ # that points to the {#source_path}.
3
6
  class Symlink < Unit
4
7
 
5
- # @see Unit#install
8
+ # (see Unit#install)
6
9
  def install
7
10
  s = super
8
11
  return s unless s
@@ -10,7 +13,7 @@ module ConfigCurator
10
13
  true
11
14
  end
12
15
 
13
- # @see Unit#install?
16
+ # (see Unit#install?)
14
17
  def install?
15
18
  s = super
16
19
  return s unless s
@@ -1,4 +1,4 @@
1
1
  module ConfigCurator
2
2
  # Config Curator version.
3
- VERSION = '0.0.1'
3
+ VERSION = '0.0.2'
4
4
  end
@@ -84,6 +84,7 @@ describe ConfigCurator::Collection do
84
84
  let(:manifest) do
85
85
  YAML.load <<-EOF
86
86
  :root: /tmp
87
+ :package_tool: :pacman
87
88
  :defaults:
88
89
  :fmode: '0640'
89
90
  :dmode: '0750'
@@ -100,6 +101,10 @@ describe ConfigCurator::Collection do
100
101
  expect(unit.options[:root]).to eq manifest[:root]
101
102
  end
102
103
 
104
+ it "sets the unit's package tool" do
105
+ expect(unit.options[:package_tool]).to eq manifest[:package_tool]
106
+ end
107
+
103
108
  it "sets the unit specific attributes" do
104
109
  expect(unit.dmode).to eq '0700'
105
110
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config_curator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Boyd Sosenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-09 00:00:00.000000000 Z
11
+ date: 2014-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport