collins_shell 0.2.18 → 0.2.19

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
- 0.2.18
1
+ 0.2.19
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "collins_shell"
8
- s.version = "0.2.18"
8
+ s.version = "0.2.19"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Blake Matheny"]
12
- s.date = "2013-03-19"
12
+ s.date = "2013-04-15"
13
13
  s.description = "Provides basic CLI for interacting with Collins API"
14
14
  s.email = "bmatheny@tumblr.com"
15
15
  s.executables = ["collins-shell"]
@@ -8,7 +8,10 @@ class Pry
8
8
  # We kill the built in completion so we can tell users what things are available
9
9
  module InputCompleter
10
10
  class << self
11
- def build_completion_proc(target, commands=[""])
11
+ def build_completion_proc(target, commands=[""], cmplns = nil)
12
+ if cmplns.is_a?(Array) then # Work around for breakage between pry 0.9.9.6 and 0.9.12
13
+ commands = cmplns
14
+ end
12
15
  proc do |input|
13
16
  commands.map do |cmd|
14
17
  cmd_s = cmd.to_s
@@ -75,7 +75,10 @@ module CollinsShell; module Console; module Commands
75
75
  end
76
76
  # Should we just display commands?
77
77
  if display_commands then
78
- output.puts("Available commands:")
78
+ output.puts("Available formats (see ls --help):")
79
+ r = fs_node.asset_methods(true)
80
+ process_values r.map{|m| "{{#{m}}}"}, 8
81
+ output.puts("\nAvailable commands:")
79
82
  process_values fs_node.available_commands, 8
80
83
  output.puts()
81
84
  # If we have nothing, grab all tags
@@ -45,12 +45,38 @@ module CollinsShell; module Console
45
45
  CollinsShell::Console::Filesystem.new(opts)
46
46
  end
47
47
 
48
+ def exclude_methods
49
+ ['respond_to?','to_s','cput', 'id'].map{|s|s.to_sym}
50
+ end
51
+
52
+ def asset_methods exclude_non_scalar = false
53
+ non_scalar = [:addresses, :backend_address, :backend_addresses, :backend_ip_addresses,
54
+ :backend_netmasks, :cpus, :disks, :extras, :get_attribute, :mac_addresses, :memory, :nics,
55
+ :power, :public_address, :public_addresses, :public_ip_addresses]
56
+ asset_objects = {:ipmi => Collins::Ipmi, :state => Collins::AssetState}
57
+ ex_methods = exclude_methods
58
+ ex_methods += non_scalar if exclude_non_scalar
59
+ Collins::Asset.public_instance_methods(false).map(&:to_sym).reject do |meth|
60
+ ex_methods.include?(meth)
61
+ end.map do |meth|
62
+ if asset_objects.key?(meth) then
63
+ asset_objects[meth].public_instance_methods(false).map(&:to_sym).reject do |meh|
64
+ ex_methods.include?(meh) || meh.to_s =~ /=$/
65
+ end.map do |meh|
66
+ "#{meth}.#{meh}"
67
+ end
68
+ else
69
+ [meth.to_s]
70
+ end
71
+ end.flatten.sort
72
+ end
73
+
48
74
  def available_commands
49
75
  includes = ['clear_cache'] + pry_commands
50
76
  if asset? then
51
- excludes = ['respond_to?','to_s','cput'].map{|s|s.to_sym}
77
+ excludes = exclude_methods
52
78
  cmds1 = CollinsShell::Console::Asset.public_instance_methods(false).reject{|i| excludes.include?(i.to_sym)}
53
- cmds2 = Collins::Asset.public_instance_methods(false).reject{|i| excludes.include?(i.to_sym)}.map{|s| "asset.#{s}"}
79
+ cmds2 = asset_methods.map{|m| "asset.#{m}"}.sort
54
80
  cmds1 + cmds2 + includes
55
81
  else
56
82
  includes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collins_shell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.18
4
+ version: 0.2.19
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-19 00:00:00.000000000 Z
12
+ date: 2013-04-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: collins_client
@@ -184,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  segments:
186
186
  - 0
187
- hash: -4494318623502944839
187
+ hash: -2173725503607646113
188
188
  required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  none: false
190
190
  requirements: