tbm 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fb1dd4edda87be9428377a06d5041a648d7d5f28
4
+ data.tar.gz: 499437f869395fc830f35727181b5127a2be7d0a
5
+ SHA512:
6
+ metadata.gz: d1f4457502f87d2875089f976d93245069b363281ae88e900bf3367109c50a457f5772beea36720016c10c123b845de3ff56f94bcffdef22da00ffd9431f9fc9
7
+ data.tar.gz: 9e99a047453d865df54e0f41c3a914779204fde2b9af76defa349d42b0da870ba14e386d49353a9848e3e6adf8fd467b21f9aaf2f93a0f765b3f02e2f7a02e07
@@ -16,8 +16,10 @@ module TBM
16
16
 
17
17
  # Parses the command-line arguments by seeking targets, and print errors/usage if necessary.
18
18
  def parse
19
- if ARGV.empty? then
20
- print_targets "SYNTAX: tbm <targets>\n\nWhere <targets> is a comma-separated list of:"
19
+ if ARGV.empty?
20
+ print_targets "SYNTAX: tbm <targets>\n\nWhere <targets> is a comma-separated list of:"
21
+ elsif ARGV == ['--version']
22
+ puts "Tunnel Boring Machine v#{VERSION}"
21
23
  else
22
24
  parse_targets( ARGV )
23
25
  end
@@ -41,8 +43,8 @@ module TBM
41
43
  machine.bore
42
44
  end
43
45
  else
44
- formatted_errors = config.errors.join( "\n\t" )
45
- puts "Cannot parse configuration. Errors:\n\t#{formatted_errors}\n"
46
+ joined_errors = config.errors.join("\n\t")
47
+ puts "Cannot parse configuration:\n\t#{joined_errors}"
46
48
  end
47
49
  end
48
50
 
@@ -53,7 +55,7 @@ module TBM
53
55
  missing_targets = []
54
56
  targets.each do |target_name|
55
57
  target = @config.get_target( target_name )
56
- if target.nil? then
58
+ if target.nil?
57
59
  missing_targets << target_name
58
60
  else
59
61
  found_targets << target
@@ -81,4 +83,4 @@ module TBM
81
83
  end
82
84
 
83
85
  end
84
- end
86
+ end
@@ -4,9 +4,11 @@ require 'tbm'
4
4
 
5
5
  module TBM
6
6
  class ConfigParser
7
+ # The configuration file before expansion
8
+ CONFIG_FILE = '~/.tbm'
7
9
 
8
10
  # The configuration file used for parsing config.
9
- CONFIG_FILE = File.expand_path( '~/.tbm' )
11
+ EXPANDED_CONFIG_FILE = File.expand_path( CONFIG_FILE )
10
12
 
11
13
  # Pattern for Gateway Server with Optional Username
12
14
  GATEWAY_PATTERN = /^([^@]+)(@([^@]+))?$/
@@ -32,14 +34,14 @@ module TBM
32
34
  \))?\s*$/x # end of parenthesized aliases
33
35
 
34
36
 
35
- # Parses the tunnel boring machine configuration to get a list of targets which can
37
+ # Parses the tunnel boring machine configuration to get a list of targets which can
36
38
  # be invoked to bore tunnels.
37
39
  #
38
40
  # @return [Config] the parsed configuration for TBM
39
41
  def self.parse
40
42
  config = Config.new
41
- if File.file? CONFIG_FILE
42
- config_data = YAML.load_file( CONFIG_FILE )
43
+ if File.file? EXPANDED_CONFIG_FILE
44
+ config_data = YAML.load_file( EXPANDED_CONFIG_FILE )
43
45
  case config_data
44
46
  when Hash
45
47
  parse_gateways( config_data, config ) if config_data.is_a? Hash
@@ -47,7 +49,7 @@ module TBM
47
49
  config.errors << "Cannot parse TBM configuration of type: #{config_data.class}"
48
50
  end
49
51
  else
50
- config.errors << "No configuration file found. Specify your tunnels in YAML form in: ~/.tunnels"
52
+ config.errors << "No configuration file found. Specify your tunnels in YAML form in: #{CONFIG_FILE}"
51
53
  end
52
54
  return config
53
55
  rescue Psych::SyntaxError => pse
@@ -121,7 +123,7 @@ module TBM
121
123
 
122
124
  def self.configure_target( target, target_config, config )
123
125
  case target_config
124
- when Fixnum, String
126
+ when Integer, String
125
127
  tunnel( target, target_config, config )
126
128
  when Array
127
129
  target_config.each { |tunnel_config| tunnel(target, tunnel_config, config) }
@@ -138,10 +140,10 @@ module TBM
138
140
 
139
141
  def self.tunnel( target, tunnel_config, config )
140
142
  case tunnel_config
141
- when Fixnum
143
+ when Integer
142
144
  config.errors.concat validate_and_add( tunnel_config, tunnel_config, target )
143
145
  when String
144
- case tunnel_config
146
+ case tunnel_config
145
147
  when PORT_PATTERN
146
148
  config.errors.concat validate_and_add( tunnel_config.to_i, tunnel_config, target )
147
149
  when PORTPORT_PATTERN
@@ -196,10 +198,10 @@ module TBM
196
198
  else
197
199
  target.add_alias( attribute_value.to_s )
198
200
  end
199
- else
201
+ else
200
202
  remote_host = attribute_name.to_s
201
203
  case attribute_value
202
- when Fixnum, String
204
+ when Integer, String
203
205
  remote_tunnel( target, remote_host, attribute_value, config )
204
206
  when Array
205
207
  attribute_value.each { |tunnel_config| remote_tunnel(target, remote_host, tunnel_config, config) }
@@ -214,10 +216,10 @@ module TBM
214
216
 
215
217
  def self.remote_tunnel( target, remote_host, tunnel_config, config )
216
218
  case tunnel_config
217
- when Fixnum
219
+ when Integer
218
220
  config.errors.concat validate_and_add( tunnel_config, tunnel_config, target, :remote_host => remote_host )
219
221
  when String
220
- case tunnel_config
222
+ case tunnel_config
221
223
  when PORT_PATTERN
222
224
  config.errors.concat validate_and_add( tunnel_config.to_i, tunnel_config, target, :remote_host => remote_host )
223
225
  when PORTPORT_PATTERN
@@ -232,4 +234,4 @@ module TBM
232
234
 
233
235
 
234
236
  end
235
- end
237
+ end
@@ -1,6 +1,6 @@
1
1
  # The namespace for this application/gem.
2
2
  module TBM
3
3
  APP_NAME = "Tunnel Boring Machine"
4
- VERSION = "0.3.0"
5
- RELEASE_DATE = '2013-03-07'
4
+ VERSION = "0.4.0"
5
+ RELEASE_DATE = '2017-12-14'
6
6
  end
metadata CHANGED
@@ -1,30 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tbm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 0.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Geoffrey Wiseman
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-07 00:00:00.000000000 Z
11
+ date: 2017-12-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: net-ssh
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 2.6.2
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 2.6.2
30
27
  description: The "Tunnel Boring Machine" is meant to bore ssh tunnels through the
@@ -36,6 +33,10 @@ executables:
36
33
  extensions: []
37
34
  extra_rdoc_files: []
38
35
  files:
36
+ - README.md
37
+ - Rakefile
38
+ - UNLICENSE
39
+ - bin/tbm
39
40
  - lib/TBM/cli.rb
40
41
  - lib/TBM/config.rb
41
42
  - lib/TBM/config_parser.rb
@@ -48,37 +49,29 @@ files:
48
49
  - spec/config_spec.rb
49
50
  - spec/spec_helper.rb
50
51
  - spec/target_spec.rb
51
- - bin/tbm
52
- - Rakefile
53
- - README.md
54
- - UNLICENSE
55
52
  homepage: http://github.com/geoffreywiseman/tunnel-boring-machine
56
53
  licenses:
57
54
  - UNLICENSE
55
+ metadata: {}
58
56
  post_install_message:
59
57
  rdoc_options: []
60
58
  require_paths:
61
59
  - lib
62
60
  required_ruby_version: !ruby/object:Gem::Requirement
63
- none: false
64
61
  requirements:
65
- - - ! '>='
62
+ - - ">="
66
63
  - !ruby/object:Gem::Version
67
64
  version: '0'
68
- segments:
69
- - 0
70
- hash: 450154189210157473
71
65
  required_rubygems_version: !ruby/object:Gem::Requirement
72
- none: false
73
66
  requirements:
74
- - - ! '>='
67
+ - - ">="
75
68
  - !ruby/object:Gem::Version
76
69
  version: '0'
77
70
  requirements: []
78
71
  rubyforge_project:
79
- rubygems_version: 1.8.24
72
+ rubygems_version: 2.2.2
80
73
  signing_key:
81
- specification_version: 3
74
+ specification_version: 4
82
75
  summary: Manages SSH Tunnels by creating an SSH connection and forwarding ports based
83
76
  on named targets defined in configuration.
84
77
  test_files: []