hoick 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b2771b8314e1b92ef811e38eab01de8f9bd227c1
4
- data.tar.gz: 561c3d1f37cdc2f8d43dc0581c96e3c6e21096cf
3
+ metadata.gz: 9a45c81b44157ce9e833bda8f0b4a0d8822043f0
4
+ data.tar.gz: 5dd7e6c5da5a8ed72684f9db9481c06e728112ef
5
5
  SHA512:
6
- metadata.gz: f3b958749de72a41427fac673f5997a4d626136a8144d1f5046657d9e7830f547956a233c34c09fc6076e6b433fc348f20cb28db6d12ea2aeb6546e6046697eb
7
- data.tar.gz: 66bb7e6847cf8435f0f1f44d33df706146f09c0c16534745c1eae334f9bccc59e9afffca14488e0d41cef39af527338fd09844fd76d1b71602fcd95244a01b2b
6
+ metadata.gz: 16036cba8cd39cda4dd6e7e43ca3cea2dedd7e6efbccc1627978f71f5b93e80c35e495229a34a1d4b0afb89919c257072af195684673e1564a8b0225171a4f64
7
+ data.tar.gz: 655d76ada1d8c7b125f201a6d06e679d430181cf96489b439b4650570ce0c9740cbd3beb0f75da11663ea669121494da24b1cc58c897dadedbc73f7c450c9909
@@ -6,7 +6,25 @@ module Hoick
6
6
 
7
7
  class Command < Clamp::Command
8
8
 
9
- option ["--base-url"], "URL", "base URL"
9
+ class << self
10
+
11
+ private
12
+
13
+ def parse_url(url)
14
+ URI(url)
15
+ rescue ArgumentError => e
16
+ raise e
17
+ rescue URI::InvalidURIError => e
18
+ raise ArgumentError, e.message
19
+ end
20
+
21
+ def declare_url_parameter
22
+ parameter "URL", "address", &method(:parse_url)
23
+ end
24
+
25
+ end
26
+
27
+ option ["--base-url"], "URL", "base URL", &method(:parse_url)
10
28
 
11
29
  option ["-b", "--[no-]body"], :flag, "display response body", :default => true
12
30
  option ["-h", "--[no-]headers"], :flag, "display response status and headers"
@@ -17,7 +35,7 @@ module Hoick
17
35
 
18
36
  option ["--follow"], :flag, "follow redirects"
19
37
 
20
- parameter "URL", "address"
38
+ declare_url_parameter
21
39
 
22
40
  def execute
23
41
  get_with_redirects do |response|
@@ -77,7 +95,7 @@ module Hoick
77
95
 
78
96
  include PayloadOptions
79
97
 
80
- parameter "URL", "address"
98
+ declare_url_parameter
81
99
 
82
100
  def execute
83
101
  content = payload
@@ -97,7 +115,7 @@ module Hoick
97
115
 
98
116
  include PayloadOptions
99
117
 
100
- parameter "URL", "address"
118
+ declare_url_parameter
101
119
 
102
120
  def execute
103
121
  content = payload
@@ -116,7 +134,11 @@ module Hoick
116
134
  private
117
135
 
118
136
  def uri
119
- URI(base_url) + URI(url)
137
+ if base_url
138
+ base_url + url
139
+ else
140
+ url
141
+ end
120
142
  end
121
143
 
122
144
  def with_http_connection
@@ -1,3 +1,3 @@
1
1
  module Hoick
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-31 00:00:00.000000000 Z
11
+ date: 2013-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types