cableguy 0.2.3 → 0.5.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +59 -1
- data/Gemfile +6 -5
- data/Gemfile.lock +38 -0
- data/LICENSE.md +20 -0
- data/README.md +28 -0
- data/Rakefile +23 -1
- data/bin/cable +2 -37
- data/cableguy.gemspec +15 -17
- data/lib/palmade/cableguy/builders/cable_chmod.rb +3 -5
- data/lib/palmade/cableguy/builders/cable_copy.rb +2 -5
- data/lib/palmade/cableguy/builders/cable_custom.rb +6 -3
- data/lib/palmade/cableguy/builders/cable_mkdir.rb +3 -6
- data/lib/palmade/cableguy/builders/cable_move.rb +2 -5
- data/lib/palmade/cableguy/builders/cable_symlink.rb +4 -7
- data/lib/palmade/cableguy/builders/cable_template.rb +25 -9
- data/lib/palmade/cableguy/builders.rb +7 -8
- data/lib/palmade/cableguy/cable.rb +1 -24
- data/lib/palmade/cableguy/cablefile.rb +107 -0
- data/lib/palmade/cableguy/cabler.rb +257 -53
- data/lib/palmade/cableguy/cabling_values.rb +54 -0
- data/lib/palmade/cableguy/cli.rb +232 -0
- data/lib/palmade/cableguy/cli_helper.rb +18 -0
- data/lib/palmade/cableguy/configurator.rb +19 -20
- data/lib/palmade/cableguy/constants.rb +17 -2
- data/lib/palmade/cableguy/db.rb +115 -66
- data/lib/palmade/cableguy/{cable_configurator.rb → legacy_configurator.rb} +1 -2
- data/lib/palmade/cableguy/migration.rb +37 -61
- data/lib/palmade/cableguy/migrator.rb +124 -0
- data/lib/palmade/cableguy/templatebinding.rb +23 -16
- data/lib/palmade/cableguy/utils.rb +6 -7
- data/lib/palmade/cableguy/version.rb +1 -1
- data/lib/palmade/cableguy.rb +19 -34
- data/test/.cabling_values.yml +9 -0
- data/test/app/Cablefile +10 -0
- data/test/app/cabling/base/blog.rb +21 -0
- data/test/app/cabling/init.rb +16 -0
- data/test/app/config/templates/blog.yml +10 -0
- data/test/app_cabling_test.rb +33 -0
- data/test/boboot.rb +53 -0
- data/test/boot_test.rb +25 -0
- data/test/cablefile_test.rb +44 -0
- data/test/cabler_test.rb +45 -0
- data/test/cabling/base/blog.rb +17 -0
- data/test/cabling/init.rb +16 -0
- data/test/cabling_values_test.rb +24 -0
- data/test/cli_lock_test.rb +28 -0
- data/test/cli_test.rb +88 -0
- data/test/configure_test.rb +31 -0
- data/test/db_methods_test.rb +19 -0
- data/test/migrate_legacy_test.rb +34 -0
- data/test/migrate_test.rb +39 -0
- data/test/test_apply/config/blog.yml +10 -0
- data/test/test_helper.rb +81 -0
- metadata +93 -29
- data/Manifest +0 -19
- data/README +0 -1
- data/lib/palmade/cableguy/runner.rb +0 -44
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 545e7bcbee6bcfe47a9fac4fffc57f57a9adffa1
|
4
|
+
data.tar.gz: 31bd947e819681b59cb496ebf8a67c7df4e75d5e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f1da5aa67c675b32d302f398003d2349900e80b013221dd30bc0c6d4fa1fd500aec366195d3b5fd4453c294f55ba5c5268b10a455be199c20026a1b029138813
|
7
|
+
data.tar.gz: d1df4ebf2b0eb784378dc6d1e811190769de97633b5a42622f485bb10deb933d4a4f463e97166228d368997a472bd913065097cd97319d0e0efe4217ee5d6db9
|
data/.gitignore
CHANGED
@@ -1,4 +1,62 @@
|
|
1
|
+
# Source:
|
2
|
+
# https://github.com/github/gitignore/blob/master/Ruby.gitignore
|
3
|
+
|
4
|
+
*.gem
|
5
|
+
*.rbc
|
6
|
+
/.config
|
7
|
+
/coverage/
|
8
|
+
/InstalledFiles
|
9
|
+
/pkg/
|
10
|
+
/spec/reports/
|
11
|
+
/spec/examples.txt
|
12
|
+
/test/tmp/
|
13
|
+
/test/version_tmp/
|
14
|
+
/tmp/
|
15
|
+
|
16
|
+
# Used by dotenv library to load environment variables.
|
17
|
+
# .env
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
.dat*
|
21
|
+
.repl_history
|
22
|
+
build/
|
23
|
+
*.bridgesupport
|
24
|
+
build-iPhoneOS/
|
25
|
+
build-iPhoneSimulator/
|
26
|
+
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
28
|
+
#
|
29
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
30
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
31
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
32
|
+
#
|
33
|
+
# vendor/Pods/
|
34
|
+
|
35
|
+
## Documentation cache and generated files:
|
36
|
+
/.yardoc/
|
37
|
+
/_yardoc/
|
38
|
+
/doc/
|
39
|
+
/rdoc/
|
40
|
+
|
41
|
+
## Environment normalization:
|
42
|
+
/.bundle/
|
43
|
+
/vendor/bundle
|
44
|
+
/lib/bundler/man/
|
45
|
+
|
46
|
+
# for a library or gem, you might want to ignore these files since the code is
|
47
|
+
# intended to run in multiple environments; otherwise, check them in:
|
48
|
+
# Gemfile.lock
|
49
|
+
.ruby-version
|
50
|
+
# .ruby-gemset
|
51
|
+
|
52
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
53
|
+
.rvmrc
|
54
|
+
|
1
55
|
*.gem
|
2
56
|
.bundle
|
3
|
-
Gemfile.lock
|
4
57
|
pkg/*
|
58
|
+
test/*/test.sqlite3
|
59
|
+
test/**/test.sqlite3
|
60
|
+
.cabling.yml
|
61
|
+
.#*
|
62
|
+
test/app/config/blog.yml
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cableguy (0.5.0.pre2)
|
5
|
+
sequel
|
6
|
+
sqlite3
|
7
|
+
thor
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
faraday (0.9.2)
|
13
|
+
multipart-post (>= 1.2, < 3)
|
14
|
+
gemfury (0.6.0)
|
15
|
+
faraday (>= 0.9.0, < 0.10.0.pre)
|
16
|
+
highline (~> 1.6.0)
|
17
|
+
multi_json (~> 1.10)
|
18
|
+
netrc (~> 0.10.0)
|
19
|
+
thor (>= 0.14.0, < 1.0.0.pre)
|
20
|
+
highline (1.6.21)
|
21
|
+
minitest (5.10.1)
|
22
|
+
multi_json (1.12.1)
|
23
|
+
multipart-post (2.0.0)
|
24
|
+
netrc (0.10.3)
|
25
|
+
sequel (4.45.0)
|
26
|
+
sqlite3 (1.3.13)
|
27
|
+
thor (0.19.4)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
cableguy!
|
34
|
+
gemfury
|
35
|
+
minitest
|
36
|
+
|
37
|
+
BUNDLED WITH
|
38
|
+
1.14.6
|
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2017-onwards Cebu Code Camp
|
2
|
+
Copyright (c) pre-2017 Caresharing
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
6
|
+
in the Software without restriction, including without limitation the rights
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
12
|
+
copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
## Overview
|
2
|
+
|
3
|
+
Compile configuration files based on a template and a cabling DB. Cabling DB is a key-value store, defined using a ruby-based DSL.
|
4
|
+
|
5
|
+
## How to use
|
6
|
+
|
7
|
+
...
|
8
|
+
|
9
|
+
## How to contribute
|
10
|
+
|
11
|
+
Please fork, modify, test, and send a PR. If making a change, please add a test code, or update existing ones.
|
12
|
+
|
13
|
+
```
|
14
|
+
bundle
|
15
|
+
rake
|
16
|
+
```
|
17
|
+
|
18
|
+
## Origins
|
19
|
+
|
20
|
+
Cableguy started as an internal dev library at [Caresharing](https://caresharing.com). This is a fork from that, with a clean Git history.
|
21
|
+
|
22
|
+
CCC version, started with v0.5.0. All prior are still the internal versions.
|
23
|
+
|
24
|
+
While at Caresharing, originally authored by @poysama and @markjeee. For current contributors, please see this project's commit history.
|
25
|
+
|
26
|
+
## License
|
27
|
+
|
28
|
+
See [LICENSE.md](/LICENSE.md) file.
|
data/Rakefile
CHANGED
@@ -1 +1,23 @@
|
|
1
|
-
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
require 'palmade/cableguy/version'
|
3
|
+
|
4
|
+
require 'bundler/gem_tasks'
|
5
|
+
require 'rake/testtask'
|
6
|
+
require 'minitest'
|
7
|
+
|
8
|
+
Rake::TestTask.new do |t|
|
9
|
+
t.libs << %w(test lib)
|
10
|
+
t.pattern = 'test/**/*_test.rb'
|
11
|
+
end
|
12
|
+
|
13
|
+
task :default => :test
|
14
|
+
|
15
|
+
FURY_USERNAME = 'cebucodecamp'
|
16
|
+
|
17
|
+
desc 'Build gem and push to gem repo to staging (repo.fury.io/cebucodecamp)'
|
18
|
+
task :build_and_stage => [ :build ] do
|
19
|
+
gem_path = File.expand_path('../pkg/cableguy-%s.gem' % Palmade::Cableguy::VERSION, __FILE__)
|
20
|
+
cmd = 'bundle exec fury push --as=%s %s' % [ FURY_USERNAME, gem_path ]
|
21
|
+
|
22
|
+
puts cmd; system(cmd); puts "\n"
|
23
|
+
end
|
data/bin/cable
CHANGED
@@ -1,40 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
require File.join(CABLE_LIB_PATH, 'cableguy')
|
5
|
-
require 'optparse'
|
6
|
-
|
7
|
-
options = {}
|
8
|
-
options[:verbose] = false
|
9
|
-
|
10
|
-
optparse = OptionParser.new do |opts|
|
11
|
-
opts.banner = "Set cable options.\n"
|
12
|
-
|
13
|
-
opts.on('-p', '--path PATH', 'Specify cabling path') do |path|
|
14
|
-
options[:path] = path
|
15
|
-
end
|
16
|
-
|
17
|
-
opts.on('-l', '--location LOCATION', 'Specify cabling location') do |location|
|
18
|
-
options[:location] = location
|
19
|
-
end
|
20
|
-
|
21
|
-
opts.on('-t', '--target TARGET', 'Specify cabling target') do |target|
|
22
|
-
options[:target] = target
|
23
|
-
end
|
24
|
-
|
25
|
-
opts.on('-v', '--verbose', 'Verbose logging') do
|
26
|
-
options[:verbose] = true
|
27
|
-
end
|
28
|
-
|
29
|
-
opts.on('-h', '--help', 'Help screen') do
|
30
|
-
puts opts
|
31
|
-
exit
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
optparse.parse!
|
37
|
-
|
38
|
-
Palmade::Cableguy::Runner.run(Dir.pwd, ARGV.shift, options)
|
39
|
-
|
3
|
+
require 'palmade/cableguy'
|
40
4
|
|
5
|
+
Palmade::Cableguy::CLI.start(ARGV)
|
data/cableguy.gemspec
CHANGED
@@ -1,26 +1,24 @@
|
|
1
|
-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
1
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
2
|
require 'palmade/cableguy/version'
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
5
|
+
s.name = 'cableguy'
|
7
6
|
s.version = Palmade::Cableguy::VERSION
|
8
|
-
s.authors = ["Jan Mendoza"]
|
9
|
-
s.email = ["poymode@gmail.com"]
|
10
|
-
s.homepage = "https://github.com/poymode/cableguy"
|
11
|
-
s.summary = %q{Generate rails configurations from a sqlite key-value storage}
|
12
|
-
s.description = %q{cableguy}
|
13
7
|
|
14
|
-
s.
|
15
|
-
s.
|
16
|
-
s.
|
8
|
+
s.authors = [ 'Cebu Code Campers' ]
|
9
|
+
s.email = [ 'core@cebucodecamp.org' ]
|
10
|
+
s.homepage = 'https://github.com/cebucodecamp/cableguy'
|
11
|
+
|
12
|
+
s.summary = %q{Generate configurations based on a template and a cabling database}
|
13
|
+
s.description = %q{Generate configurations based on a template and a cabling database}
|
14
|
+
s.rubyforge_project = 'cableguy'
|
15
|
+
|
16
|
+
s.add_dependency 'sqlite3'
|
17
|
+
s.add_dependency 'sequel'
|
18
|
+
s.add_dependency 'thor'
|
17
19
|
|
18
20
|
s.files = `git ls-files`.split("\n")
|
19
21
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
-
s.require_paths = [
|
22
|
-
|
23
|
-
# specify any dependencies here; for example:
|
24
|
-
# s.add_development_dependency "rspec"
|
25
|
-
# s.add_runtime_dependency "rest-client"
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
23
|
+
s.require_paths = [ 'lib' ]
|
26
24
|
end
|
@@ -2,11 +2,9 @@ module Palmade::Cableguy
|
|
2
2
|
class Builders::CableChmod < Cable
|
3
3
|
add_as :chmod
|
4
4
|
|
5
|
-
def configure(cabler
|
6
|
-
|
7
|
-
|
8
|
-
end
|
5
|
+
def configure(cabler)
|
6
|
+
FileUtils.chmod(@args.shift.to_i(8),
|
7
|
+
File.join(cabler.determine_apply_path, @args.shift))
|
9
8
|
end
|
10
9
|
end
|
11
10
|
end
|
12
|
-
|
@@ -2,11 +2,8 @@ module Palmade::Cableguy
|
|
2
2
|
class Builders::CableCopy < Cable
|
3
3
|
add_as :copy
|
4
4
|
|
5
|
-
def configure(cabler
|
6
|
-
|
7
|
-
FileUtils.cp(@args.shift, @args.shift)
|
8
|
-
end
|
5
|
+
def configure(cabler)
|
6
|
+
FileUtils.cp(@args.shift, @args.shift)
|
9
7
|
end
|
10
8
|
end
|
11
9
|
end
|
12
|
-
|
@@ -2,11 +2,14 @@ module Palmade::Cableguy
|
|
2
2
|
class Builders::CableCustom < Cable
|
3
3
|
add_as :custom
|
4
4
|
|
5
|
-
def configure(cabler
|
5
|
+
def configure(cabler)
|
6
6
|
unless @block.nil?
|
7
|
-
@block.
|
7
|
+
if @block.arity == 2
|
8
|
+
@block.call(self, cabler)
|
9
|
+
else
|
10
|
+
@block.call(self)
|
11
|
+
end
|
8
12
|
end
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
12
|
-
|
@@ -2,13 +2,10 @@ module Palmade::Cableguy
|
|
2
2
|
class Builders::CableMkdir < Cable
|
3
3
|
add_as :mkdir
|
4
4
|
|
5
|
-
def configure(cabler
|
6
|
-
|
7
|
-
|
8
|
-
FileUtils.mkdir_p(File.join(cabler.app_root, path))
|
9
|
-
end
|
5
|
+
def configure(cabler)
|
6
|
+
@args.each do |path|
|
7
|
+
FileUtils.mkdir_p(File.join(cabler.determine_apply_path, path))
|
10
8
|
end
|
11
9
|
end
|
12
10
|
end
|
13
11
|
end
|
14
|
-
|
@@ -2,11 +2,8 @@ module Palmade::Cableguy
|
|
2
2
|
class Builders::CableMove < Cable
|
3
3
|
add_as :move
|
4
4
|
|
5
|
-
def configure(cabler
|
6
|
-
|
7
|
-
FileUtils.mv(@args.shift, @args.shift)
|
8
|
-
end
|
5
|
+
def configure(cabler)
|
6
|
+
FileUtils.mv(@args.shift, @args.shift)
|
9
7
|
end
|
10
8
|
end
|
11
9
|
end
|
12
|
-
|
@@ -2,14 +2,11 @@ module Palmade::Cableguy
|
|
2
2
|
class Builders::CableSymlink < Cable
|
3
3
|
add_as :symlink
|
4
4
|
|
5
|
-
def configure(cabler
|
5
|
+
def configure(cabler)
|
6
|
+
source = @args[0]
|
7
|
+
destination = @args[1]
|
6
8
|
|
7
|
-
|
8
|
-
destination = @args.shift
|
9
|
-
cabler.say_with_time "creating symlink #{source} -> #{destination}" do
|
10
|
-
FileUtils.ln_s(source, destination, :force => true)
|
11
|
-
end
|
9
|
+
FileUtils.ln_s(source, destination, :force => true)
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
15
|
-
|
@@ -2,17 +2,33 @@ module Palmade::Cableguy
|
|
2
2
|
class Builders::CableTemplate < Cable
|
3
3
|
add_as :template
|
4
4
|
|
5
|
-
def configure(cabler
|
6
|
-
cabler.
|
7
|
-
|
8
|
-
target_path = File.join(cabler.app_root, @args[1], @args[0])
|
9
|
-
else
|
10
|
-
target_path = nil
|
11
|
-
end
|
5
|
+
def configure(cabler)
|
6
|
+
templates_apply_path = cabler.determine_apply_path(:for_templates => true)
|
7
|
+
template_file = @args[0]
|
12
8
|
|
13
|
-
|
9
|
+
unless @args[1].nil?
|
10
|
+
target_path = File.join(cabler.determine_apply_path, @args[1], template_file)
|
11
|
+
else
|
12
|
+
target_path = File.join(templates_apply_path, template_file)
|
13
|
+
end
|
14
|
+
|
15
|
+
install_template(template_file, cabler, target_path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def install_template(template_file, cabler, target_path = nil)
|
19
|
+
templates_apply_path = cabler.determine_apply_path(:for_templates => true)
|
20
|
+
|
21
|
+
template_path = File.join(cabler.templates_path, template_file)
|
22
|
+
if target_path.nil?
|
23
|
+
target_path = File.join(templates_apply_path, template_file)
|
24
|
+
end
|
25
|
+
|
26
|
+
if File.exists?(template_path)
|
27
|
+
tb = TemplateBinding.new(self, cabler)
|
28
|
+
tb.install(template_path, target_path)
|
29
|
+
else
|
30
|
+
raise ArgumentError, "template file %s not found" % template_path
|
14
31
|
end
|
15
32
|
end
|
16
33
|
end
|
17
34
|
end
|
18
|
-
|
@@ -10,13 +10,12 @@ module Palmade::Cableguy
|
|
10
10
|
CableCopy
|
11
11
|
end
|
12
12
|
|
13
|
-
autoload :CableChmod,
|
14
|
-
autoload :CableCustom,
|
15
|
-
autoload :CableMkdir,
|
16
|
-
autoload :CableSymlink,
|
17
|
-
autoload :CableTemplate,
|
18
|
-
autoload :CableMove,
|
19
|
-
autoload :CableCopy,
|
13
|
+
autoload :CableChmod,'palmade/cableguy/builders/cable_chmod'
|
14
|
+
autoload :CableCustom,'palmade/cableguy/builders/cable_custom'
|
15
|
+
autoload :CableMkdir,'palmade/cableguy/builders/cable_mkdir'
|
16
|
+
autoload :CableSymlink,'palmade/cableguy/builders/cable_symlink'
|
17
|
+
autoload :CableTemplate,'palmade/cableguy/builders/cable_template'
|
18
|
+
autoload :CableMove,'palmade/cableguy/builders/cable_move'
|
19
|
+
autoload :CableCopy,'palmade/cableguy/builders/cable_copy'
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
@@ -32,31 +32,8 @@ module Palmade::Cableguy
|
|
32
32
|
@block = block
|
33
33
|
end
|
34
34
|
|
35
|
-
def configure(cabler,
|
35
|
+
def configure(cabler, &block)
|
36
36
|
puts "Not implemented: #{self.class.build_key}"
|
37
37
|
end
|
38
|
-
|
39
|
-
protected
|
40
|
-
|
41
|
-
def install_template(template_file, cabler, cabling, target, target_path = nil)
|
42
|
-
app_root = cabler.app_root
|
43
|
-
|
44
|
-
template_path = File.join(app_root, DEFAULT_TEMPLATES_PATH, template_file)
|
45
|
-
if target_path.nil?
|
46
|
-
target_path = File.join(app_root, DEFAULT_TARGET_PATH, template_file)
|
47
|
-
end
|
48
|
-
|
49
|
-
if File.exists?(template_path)
|
50
|
-
cabler.say "installing template file: #{template_file}", true
|
51
|
-
|
52
|
-
tb = TemplateBinding.new(self, cabler, cabling, target)
|
53
|
-
tb.install(template_path, target_path)
|
54
|
-
else
|
55
|
-
raise ArgumentError, "template file #{template_file} not found in #{DEFAULT_TEMPLATES_PATH}"
|
56
|
-
end
|
57
|
-
end
|
58
38
|
end
|
59
|
-
|
60
|
-
Builders.load_all_builders
|
61
39
|
end
|
62
|
-
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module Palmade::Cableguy
|
4
|
+
class Cablefile < Configurator
|
5
|
+
include Constants
|
6
|
+
|
7
|
+
attr_reader :setups
|
8
|
+
|
9
|
+
attr_reader :file_path
|
10
|
+
attr_reader :app_root
|
11
|
+
|
12
|
+
def self.parse!(cabler)
|
13
|
+
klass = Class.new(self)
|
14
|
+
klass.new(cabler).parse!
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(*args)
|
18
|
+
super
|
19
|
+
|
20
|
+
@cabler = args[0]
|
21
|
+
@app_root = @cabler.app_root
|
22
|
+
|
23
|
+
@file_path = nil
|
24
|
+
@setups = [ ]
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse!
|
28
|
+
unless @app_root.nil?
|
29
|
+
@file_path = File.join(@app_root, cablefile_name)
|
30
|
+
|
31
|
+
unless File.exists?(file_path)
|
32
|
+
@file_path = nil
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
if @file_path.nil?
|
37
|
+
@file_path = find_cable_file
|
38
|
+
end
|
39
|
+
|
40
|
+
unless File.exists?(@file_path)
|
41
|
+
legacy_file_path = File.join(@app_root, legacy_cablefile_name)
|
42
|
+
if File.exists?(legacy_file_path)
|
43
|
+
@file_path = legacy_file_path
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
if File.exists?(@file_path)
|
48
|
+
configure_from_file(@file_path)
|
49
|
+
end
|
50
|
+
|
51
|
+
self
|
52
|
+
end
|
53
|
+
|
54
|
+
def cabling(*args, &block)
|
55
|
+
if block_given?
|
56
|
+
update_section(:cabling, *args, &block)
|
57
|
+
else
|
58
|
+
call_section(:cabling, *args)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
alias :setup_cabling :cabling
|
62
|
+
|
63
|
+
def setup(what, *args, &block)
|
64
|
+
@setups.push([ what, args, block ])
|
65
|
+
end
|
66
|
+
|
67
|
+
def requirements(*args, &block)
|
68
|
+
if block_given?
|
69
|
+
update_section(:requirements, *args, &block)
|
70
|
+
else
|
71
|
+
call_section(:requirements, *args)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def configured?
|
76
|
+
@sections.include?(:cabling)
|
77
|
+
end
|
78
|
+
|
79
|
+
protected
|
80
|
+
|
81
|
+
def legacy_cablefile_name
|
82
|
+
DEFAULT_LEGACY_CABLEFILE_NAME
|
83
|
+
end
|
84
|
+
|
85
|
+
def cablefile_name
|
86
|
+
DEFAULT_CABLEFILE_NAME
|
87
|
+
end
|
88
|
+
|
89
|
+
def find_cable_file
|
90
|
+
found = nil
|
91
|
+
pname = Pathname.new(@app_root)
|
92
|
+
|
93
|
+
pname.ascend do |path|
|
94
|
+
if File.exists?(File.join(path, cablefile_name))
|
95
|
+
found = path
|
96
|
+
break
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
unless found.nil?
|
101
|
+
@app_root = found.to_path
|
102
|
+
end
|
103
|
+
|
104
|
+
@file_path = File.join(@app_root, cablefile_name)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|