everbox_client 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -33,3 +33,7 @@
33
33
 
34
34
  everbox login
35
35
  登录 everbox, 登录完成后的 token 保存在 $HOME/.everbox_client/config
36
+
37
+ === 环境变量
38
+
39
+ http_proxy: 用于设置代理,比如 export http_proxy="http://192.168.2.1:3128"
@@ -45,14 +45,14 @@ module EverboxClient
45
45
  :consumer_secret => '9tego848novn68kboENkhW3gTy9rE2woHWpRwAwQ',
46
46
  :oauth_site => 'http://account.everbox.com',
47
47
  :fs_site => 'http://fs.everbox.com',
48
- :chunk_size => 1024*1024*4
49
-
48
+ :chunk_size => 1024*1024*4,
49
+ :proxy => nil
50
50
  }
51
51
 
52
52
  def initialize(opts={})
53
53
  opts ||= {}
54
54
  config_file = opts[:config_file] || DEFAULT_OPTIONS[:config_file]
55
- @options = DEFAULT_OPTIONS.merge(load_config(config_file)).merge(opts)
55
+ @options = DEFAULT_OPTIONS.merge(options_from_env).merge(load_config(config_file)).merge(opts)
56
56
  end
57
57
 
58
58
  def help(arg = nil)
@@ -516,6 +516,12 @@ DOC
516
516
  end
517
517
  protected
518
518
 
519
+ def options_from_env
520
+ res = {}
521
+ res[:proxy] ||= ENV['http_proxy']
522
+ res
523
+ end
524
+
519
525
  def fs(path)
520
526
  path = path.to_s
521
527
  path = '/' + path unless path.start_with? '/'
@@ -544,7 +550,8 @@ DOC
544
550
 
545
551
  def consumer
546
552
  OAuth::Consumer.new @options[:consumer_key], @options[:consumer_secret], {
547
- :site => @options[:oauth_site]
553
+ :site => @options[:oauth_site],
554
+ :proxy => @options[:proxy]
548
555
  }
549
556
  end
550
557
 
@@ -1,3 +1,3 @@
1
1
  module EverboxClient
2
- VERSION = "0.0.10"
2
+ VERSION = "0.0.11"
3
3
  end
@@ -7,5 +7,21 @@ module EverboxClient
7
7
  it "should works" do
8
8
  Runner.new.ls
9
9
  end
10
+
11
+ describe :initialize do
12
+ it "should honor :proxy" do
13
+ OAuth::Consumer.should_receive(:new).with(anything(), anything(), {:site=>"http://account.everbox.com", :proxy=>"http://127.0.0.1:80"})
14
+ runner = Runner.new :proxy => 'http://127.0.0.1:80'
15
+ runner.send :consumer
16
+ end
17
+
18
+ it "should honor :proxy from ENV" do
19
+ OAuth::Consumer.should_receive(:new).with(anything(), anything(), {:site=>"http://account.everbox.com", :proxy=>"http://127.0.0.1:81"})
20
+ @old_env = ENV['http_proxy']
21
+ ENV['http_proxy'] = 'http://127.0.0.1:81'
22
+ Runner.new.send :consumer
23
+ ENV['http_proxy'] = @old_env
24
+ end
25
+ end
10
26
  end
11
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everbox_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-14 00:00:00.000000000Z
12
+ date: 2012-02-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oauth
16
- requirement: &19275280 !ruby/object:Gem::Requirement
16
+ requirement: &7721640 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *19275280
24
+ version_requirements: *7721640
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: highline
27
- requirement: &19274860 !ruby/object:Gem::Requirement
27
+ requirement: &7720400 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *19274860
35
+ version_requirements: *7720400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: json_pure
38
- requirement: &19274420 !ruby/object:Gem::Requirement
38
+ requirement: &7719960 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *19274420
46
+ version_requirements: *7719960
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rest-client
49
- requirement: &19274000 !ruby/object:Gem::Requirement
49
+ requirement: &7719540 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *19274000
57
+ version_requirements: *7719540
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: launchy
60
- requirement: &19273540 !ruby/object:Gem::Requirement
60
+ requirement: &7719120 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *19273540
68
+ version_requirements: *7719120
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
- requirement: &19273020 !ruby/object:Gem::Requirement
71
+ requirement: &7718620 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - =
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.8.7
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *19273020
79
+ version_requirements: *7718620
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rspec
82
- requirement: &19272600 !ruby/object:Gem::Requirement
82
+ requirement: &7718200 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *19272600
90
+ version_requirements: *7718200
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rdoc
93
- requirement: &19272060 !ruby/object:Gem::Requirement
93
+ requirement: &7717680 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *19272060
101
+ version_requirements: *7717680
102
102
  description: EverBox Command Tool
103
103
  email:
104
104
  - lidaobing@gmail.com