rutty 2.0.0 → 2.1.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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.1.0
data/bin/rutty CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+
2
4
  require 'rubygems'
3
5
  require 'commander/import'
4
6
  require 'rutty'
@@ -21,13 +23,26 @@ program :help_formatter, Commander::HelpFormatter::TerminalCompact
21
23
 
22
24
  default_command :dsh
23
25
 
26
+ global_option '-c', '--config DIR', 'Directory to load configs from, defaults to ~/.rutty' do |dir|
27
+ begin
28
+ $r.config File.join(dir, Rutty::Consts::GENERAL_CONF_FILE)
29
+ $r.nodes File.join(dir, Rutty::Consts::NODES_CONF_FILE)
30
+ rescue Errno::ENOENT => e
31
+ if e.to_s =~ /No such file or directory - (.*)/
32
+ raise Rutty::NotInstalledError.new "Unable to find #{$1}. Maybe run `rutty init #{dir}' first?"
33
+ end
34
+ end
35
+ end
36
+
24
37
  # Commander commands
25
38
  command :init do |c|
26
- c.syntax = "rutty init"
27
- c.summary = "Creates the default file structure for rutty."
28
- c.when_called do
29
- r = Rutty::Runner.new
30
- r.init
39
+ c.syntax = "rutty init [DIR]"
40
+ c.summary = "Creates the default file structure for rutty"
41
+ c.description = "#{c.summary} in the specified DIR. If DIR is not given, defaults to ~/.rutty"
42
+ c.when_called do |args, options|
43
+ args.push Rutty::Consts::CONF_DIR if args.empty?
44
+
45
+ $r.init args.pop
31
46
  end
32
47
  end
33
48
 
@@ -43,8 +58,7 @@ command :add_node do |c|
43
58
  add_filter_options.call(c)
44
59
 
45
60
  c.when_called do |args, options|
46
- r = Rutty::Runner.new
47
- r.add_node args, options
61
+ $r.add_node args, options
48
62
  end
49
63
  end
50
64
 
@@ -61,8 +75,7 @@ command :list_nodes do |c|
61
75
  add_filter_options.call(c)
62
76
 
63
77
  c.when_called do |args, options|
64
- r = Rutty::Runner.new
65
- r.list_nodes args, options
78
+ $r.list_nodes args, options
66
79
  end
67
80
  end
68
81
 
@@ -78,8 +91,7 @@ command :dsh do |c|
78
91
  c.option('-d', '--debug', 'Enable debug output')
79
92
 
80
93
  c.when_called do |args, options|
81
- r = Rutty::Runner.new
82
- r.dsh args, options
94
+ $r.dsh args, options
83
95
  end
84
96
  end
85
97
 
@@ -93,8 +105,7 @@ command :scp do |c|
93
105
  c.option('-d', '--debug', 'Enable debug output')
94
106
 
95
107
  c.when_called do |args, options|
96
- r = Rutty::Runner.new
97
- r.dsh args, options
108
+ $r.dsh args, options
98
109
  end
99
110
  end
100
111
 
@@ -16,12 +16,12 @@ module Rutty
16
16
  include Rutty::Helpers
17
17
  include Rutty::Actions
18
18
 
19
- def config
20
- @config ||= Rutty::Config.load_config
19
+ def config file = Rutty::Consts::GENERAL_CONF
20
+ @config ||= Rutty::Config.load_config file
21
21
  end
22
22
 
23
- def nodes
24
- @nodes ||= Rutty::Nodes.load_config
23
+ def nodes file = Rutty::Consts::NODES_CONF
24
+ @nodes ||= Rutty::Nodes.load_config file
25
25
  end
26
26
  end
27
27
  end
@@ -2,18 +2,21 @@ require 'rutty/consts'
2
2
 
3
3
  module Rutty
4
4
  module Actions
5
- def init
6
- if File.exists? Rutty::Consts::CONF_DIR
7
- log "exists", Rutty::Consts::CONF_DIR
5
+ def init dir
6
+ general_file = File.join(dir, Rutty::Consts::GENERAL_CONF_FILE)
7
+ nodes_file = File.join(dir, Rutty::Consts::NODES_CONF_FILE)
8
+
9
+ if File.exists? dir
10
+ log "exists", dir
8
11
  else
9
- log "create", Rutty::Consts::CONF_DIR
10
- Dir.mkdir Rutty::Consts::CONF_DIR
12
+ log "create", dir
13
+ Dir.mkdir dir
11
14
  end
12
15
 
13
- if File.exists? Rutty::Consts::GENERAL_CONF
14
- log "exists", Rutty::Consts::GENERAL_CONF
16
+ if File.exists? general_file
17
+ log "exists", general_file
15
18
  else
16
- log "create", Rutty::Consts::GENERAL_CONF
19
+ log "create", general_file
17
20
 
18
21
  defaults_hash = {
19
22
  :user => 'root',
@@ -21,17 +24,17 @@ module Rutty
21
24
  :port => 22
22
25
  }
23
26
 
24
- File.open(Rutty::Consts::GENERAL_CONF, 'w') do |f|
27
+ File.open(general_file, 'w') do |f|
25
28
  YAML.dump(defaults_hash, f)
26
29
  end
27
30
  end
28
31
 
29
- if File.exists? Rutty::Consts::NODES_CONF
30
- log "exists", Rutty::Consts::NODES_CONF
32
+ if File.exists? nodes_file
33
+ log "exists", nodes_file
31
34
  else
32
- log "create", Rutty::Consts::NODES_CONF
35
+ log "create", nodes_file
33
36
 
34
- File.open(Rutty::Consts::NODES_CONF, 'w') do |f|
37
+ File.open(nodes_file, 'w') do |f|
35
38
  YAML.dump([], f)
36
39
  end
37
40
  end
@@ -2,10 +2,10 @@
2
2
  module Rutty
3
3
  class Config
4
4
  class << self
5
- def load_config
5
+ def load_config file
6
6
  require 'yaml'
7
7
 
8
- data = YAML.load(File.open(Rutty::Consts::GENERAL_CONF).read)
8
+ data = YAML.load(File.open(file).read)
9
9
  Rutty::Config.new data
10
10
  end
11
11
  end
@@ -1,7 +1,10 @@
1
1
  module Rutty
2
2
  module Consts
3
+ GENERAL_CONF_FILE = 'defaults.yaml'
4
+ NODES_CONF_FILE = 'nodes.yaml'
5
+
3
6
  CONF_DIR = File.join(ENV['HOME'], '.rutty')
4
- GENERAL_CONF = File.join(CONF_DIR, 'defaults.yaml')
5
- NODES_CONF = File.join(CONF_DIR, 'nodes.yaml')
7
+ GENERAL_CONF = File.join(CONF_DIR, GENERAL_CONF_FILE)
8
+ NODES_CONF = File.join(CONF_DIR, NODES_CONF_FILE)
6
9
  end
7
10
  end
@@ -4,9 +4,9 @@ require 'rutty/consts'
4
4
  module Rutty
5
5
  class Nodes < Array
6
6
  class << self
7
- def load_config
7
+ def load_config file
8
8
  require 'yaml'
9
- Rutty::Nodes.new YAML.load(File.open(Rutty::Consts::NODES_CONF).read)
9
+ Rutty::Nodes.new YAML.load(File.open(file).read)
10
10
  end
11
11
  end
12
12
 
@@ -1,7 +1,7 @@
1
1
  module Rutty
2
2
  module Version
3
3
  MAJOR = 2
4
- MINOR = 0
4
+ MINOR = 1
5
5
  PATCH = 0
6
6
  BUILD = nil
7
7
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rutty}
8
- s.version = "2.0.0"
8
+ s.version = "2.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Josh Lindsey"]
12
- s.date = %q{2010-11-01}
12
+ s.date = %q{2010-11-03}
13
13
  s.default_executable = %q{rutty}
14
14
  s.description = %q{
15
15
  RuTTY is a DSH (distributed / dancer's shell) written in Ruby. It's used to run commands
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rutty
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 2.0.0
10
+ version: 2.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Josh Lindsey
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-01 00:00:00 -04:00
18
+ date: 2010-11-03 00:00:00 -04:00
19
19
  default_executable: rutty
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency