proxylocal 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/bin/proxylocal +47 -22
  2. data/lib/client.rb +1 -1
  3. data/proxylocal.gemspec +2 -2
  4. metadata +4 -4
data/bin/proxylocal CHANGED
@@ -1,35 +1,59 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'optparse'
4
+ require 'yaml'
4
5
  require File.expand_path('client', File.join(File.dirname(__FILE__), '..', 'lib'))
5
6
 
6
- options = {}
7
+ rc_path = File.expand_path(File.join('~', '.proxylocalrc'))
8
+ rc = YAML.load_file(rc_path) rescue {}
7
9
 
8
- cmd_args = OptionParser.new do |opts|
9
- opts.banner = 'Usage: proxylocal [options] [PORT]'
10
+ options = rc.dup
10
11
 
11
- opts.on('-s', '--server SERVER') do |s|
12
- options[:server_host], options[:server_port] = s.split(':')
13
- end
12
+ begin
13
+ cmd_args = OptionParser.new do |opts|
14
+ opts.banner = 'Usage: proxylocal [options] [PORT]'
14
15
 
15
- opts.on('--[no-]tls', 'Use TLS') do |tls|
16
- options[:tls] = tls
17
- end
16
+ opts.on('--token TOKEN', 'Save token to .proxylocalrc') do |token|
17
+ rc[:token] = token
18
+ File.open(rc_path, 'w') { |f| f.write(YAML.dump(rc)) }
19
+ File.chmod(0600, rc_path)
20
+ exit
21
+ end
18
22
 
19
- opts.on('-v', '--[no-]verbose', 'Run verbosely') do |v|
20
- options[:verbose] = v
21
- end
23
+ opts.on('--host HOST', 'Bind to host') do |host|
24
+ options[:hosts] ||= []
25
+ options[:hosts] << host
26
+ end
22
27
 
23
- opts.on_tail('-h', '--help', 'Show this message') do
24
- puts opts
25
- exit
26
- end
28
+ opts.on('--[no-]tls', 'Use TLS') do |tls|
29
+ options[:tls] = tls
30
+ end
27
31
 
28
- opts.on_tail("--version", "Show version") do
29
- puts ProxyLocal::VERSION
30
- exit
31
- end
32
- end.parse!
32
+ opts.on('-s', '--server SERVER', 'Specify proxylocal server') do |s|
33
+ options[:server_host], options[:server_port] = s.split(':')
34
+ end
35
+
36
+ opts.on('-v', '--[no-]verbose', 'Run verbosely') do |v|
37
+ options[:verbose] = v
38
+ end
39
+
40
+ opts.on_tail("--version", "Show version") do
41
+ puts ProxyLocal::VERSION
42
+ exit
43
+ end
44
+
45
+ opts.on_tail('-h', '--help', 'Show this message') do
46
+ puts opts
47
+ exit
48
+ end
49
+ end.parse!
50
+ rescue OptionParser::MissingArgument => e
51
+ puts e
52
+ exit
53
+ rescue OptionParser::InvalidOption => e
54
+ puts e
55
+ exit
56
+ end
33
57
 
34
58
  options[:local_port] = cmd_args[0]
35
59
 
@@ -38,7 +62,8 @@ default_options = {
38
62
  :server_port => '8282',
39
63
  :local_port => '80',
40
64
  :tls => true,
41
- :verbose => false
65
+ :verbose => false,
66
+ :version => ProxyLocal::VERSION
42
67
  }
43
68
 
44
69
  options = default_options.merge(options.reject { |k, v| v.nil? })
data/lib/client.rb CHANGED
@@ -4,7 +4,7 @@ require 'eventmachine'
4
4
  require 'bert'
5
5
 
6
6
  module ProxyLocal
7
- VERSION = '0.0.5'
7
+ VERSION = '0.1.0'
8
8
 
9
9
  module Serializer
10
10
  def self.dump(object)
data/proxylocal.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{proxylocal}
5
- s.version = "0.0.5"
5
+ s.version = "0.1.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Just Lest"]
9
- s.date = %q{2010-11-17}
9
+ s.date = %q{2010-11-23}
10
10
  s.default_executable = %q{proxylocal}
11
11
  s.description = %q{http://proxylocal.com/}
12
12
  s.email = %q{just.lest@gmail.com}
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxylocal
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
+ - 1
8
9
  - 0
9
- - 5
10
- version: 0.0.5
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Just Lest
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-11-17 00:00:00 +02:00
18
+ date: 2010-11-23 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency