releaseable 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/releaseable/extensions.rb +0 -1
- data/lib/releaseable/github.rb +61 -87
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
@@ -71,7 +71,6 @@ class Logger
|
|
71
71
|
@config[:time_format] ||= @config[:time] || '%M:%S.%N'
|
72
72
|
|
73
73
|
unless @config[:ignore] # fatal errors
|
74
|
-
@config[:progname] = config[:progname] || ''
|
75
74
|
@config[:tag] = config[:tag] || config[:name] || config[:connection] && config[:env] ?
|
76
75
|
"#{config[:env]}#{config[:connection][:client_id]}" : "Tag#{rand(10000)}"
|
77
76
|
input = case @config[:input]
|
data/lib/releaseable/github.rb
CHANGED
@@ -1,33 +1,15 @@
|
|
1
1
|
#require 'httpclient'
|
2
|
-
|
2
|
+
require 'net/http'
|
3
|
+
require 'net/https'
|
3
4
|
require 'xmlsimple'
|
4
|
-
require 'faraday'
|
5
|
-
require 'faraday_middleware'
|
6
5
|
require 'json'
|
7
6
|
|
8
7
|
module Releaseable
|
9
8
|
module GitHub
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
def self.connection
|
14
|
-
Faraday.new(:ssl => {:verify => false}) do |connection|
|
15
|
-
connection.use Faraday::Request::UrlEncoded
|
16
|
-
connection.use Faraday::Response::Logger
|
17
|
-
connection.adapter(Faraday.default_adapter)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
#def self.get address #, data
|
22
|
-
# connection.get address
|
23
|
-
#end
|
24
|
-
#
|
25
|
-
#def self.post address, data
|
26
|
-
# connection.post address, data
|
27
|
-
#end
|
10
|
+
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
|
28
11
|
|
29
12
|
def self.post address, data
|
30
|
-
require 'net/http'
|
31
13
|
p uri = URI(address) #'https://secure.example.com/some_path?query=string')
|
32
14
|
|
33
15
|
#Net::HTTP.start(uri.host, uri.port,
|
@@ -43,6 +25,7 @@ module Releaseable
|
|
43
25
|
server = Net::HTTP.new(uri.host, uri.port)
|
44
26
|
server.use_ssl = (uri.scheme == 'https')
|
45
27
|
server.verify_mode = OpenSSL::SSL::VERIFY_NONE if server.use_ssl?
|
28
|
+
|
46
29
|
server.start do |http|
|
47
30
|
req = Net::HTTP::Post.new(uri.path)
|
48
31
|
case data
|
@@ -54,8 +37,6 @@ module Releaseable
|
|
54
37
|
end
|
55
38
|
http.request(req)
|
56
39
|
end
|
57
|
-
#rescue => err
|
58
|
-
# p err
|
59
40
|
end
|
60
41
|
|
61
42
|
def self.upload info = {}
|
@@ -71,7 +52,7 @@ module Releaseable
|
|
71
52
|
if info[:file]
|
72
53
|
file = info[:file]
|
73
54
|
raise "bad file #{info[:file]}" unless File.exist?(file) && File.readable?(file)
|
74
|
-
info[:name] ||= File.basename(file)
|
55
|
+
info[:name] ||= File.basename(file) + rand(1000).to_s
|
75
56
|
end
|
76
57
|
|
77
58
|
raise "required name for filename with data parameter" unless info[:name]
|
@@ -85,83 +66,76 @@ module Releaseable
|
|
85
66
|
'description' => info[:description] || '',
|
86
67
|
'login' => info[:login],
|
87
68
|
'token' => info[:token]
|
88
|
-
|
69
|
+
#p response.body
|
89
70
|
raise "Failed to post file info" unless response.code.to_i == 200 #status == 200
|
90
71
|
|
91
|
-
|
92
|
-
upload.each { |k, v| print "#{k}:"; p v }
|
93
|
-
p upload['expirationdate']
|
94
|
-
p Time.utc *upload['expirationdate'].split(/[-T:]/)
|
95
|
-
sec = Time.utc(*upload['expirationdate'].split(/[-T:]/)).to_i
|
72
|
+
upload = JSON.parse(response.body)
|
96
73
|
|
97
|
-
|
74
|
+
#upload.each { |k, v| print "#{k}:"; p v }
|
75
|
+
#sec = Time.utc(*upload['expirationdate'].split(/[-T:]/)).to_i
|
98
76
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
'Content-Type' => upload['mime_type'] || 'application/octet-stream',
|
112
|
-
'file' => f
|
77
|
+
curl = "curl -F \"key=#{upload['path']}\" -F \"acl=#{upload['acl']}\" " +
|
78
|
+
"-F \"success_action_status=201\" -F \"Filename=#{info[:name]}\" " +
|
79
|
+
"-F \"AWSAccessKeyId=#{upload['accesskeyid']}\" -F \"Policy=#{upload['policy']}\" "+
|
80
|
+
"-F \"Signature=#{upload['signature']}\" -F \"Content-Type=application/octet-stream\" "+
|
81
|
+
"-F \"file=@#{info[:file]}\" https://github.s3.amazonaws.com/"
|
82
|
+
|
83
|
+
response = `#{curl}`
|
84
|
+
|
85
|
+
analyze_curl_response response
|
86
|
+
|
87
|
+
#f = File.open(info[:file], 'rb')
|
88
|
+
###stat = HTTPClient.post("http://github.s3.amazonaws.com/", [
|
113
89
|
#response = post "http://github.s3.amazonaws.com/",
|
114
|
-
# '
|
115
|
-
# '
|
90
|
+
# 'key' => upload['path'], #.gsub(/\//, '%2F'),
|
91
|
+
# 'acl' => upload['acl'], #"public-read", #
|
116
92
|
# 'success_action_status' => 201,
|
117
|
-
# '
|
93
|
+
# 'Filename' => info[:name],
|
118
94
|
# 'AWSAccessKeyId' => upload['accesskeyid'],
|
95
|
+
# 'Policy' => upload['policy'],
|
96
|
+
# #'policy' => upload['policy'],
|
97
|
+
# #'signature' => upload['signature'],
|
98
|
+
# 'Signature' => upload['signature'],
|
99
|
+
# 'Expires' => 1483421360, #sec, #upload['expirationdate'],
|
119
100
|
# 'Content-Type' => upload['mime_type'] || 'application/octet-stream',
|
120
|
-
# 'signature' => upload['signature'],
|
121
|
-
# 'acl' => upload['acl'], #"public-read", #
|
122
101
|
# 'file' => f
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
# ['file', f]
|
134
|
-
#])
|
135
|
-
|
136
|
-
#url = 'https://github.s3.amazonaws.com/'
|
137
|
-
#form = {
|
138
|
-
# 'key': 'downloads/octocat/Hello-World/new_file.jpg',
|
139
|
-
# 'acl': 'public-read',
|
140
|
-
# 'file': '@new_file.jpg'
|
141
|
-
#}
|
102
|
+
##response = post "http://github.s3.amazonaws.com/",
|
103
|
+
## 'Filename' => info[:name],
|
104
|
+
## 'policy' => upload['policy'],
|
105
|
+
## 'success_action_status' => 201,
|
106
|
+
## 'key' => upload['path'].gsub(/\//, '%2F'),
|
107
|
+
## 'AWSAccessKeyId' => upload['accesskeyid'],
|
108
|
+
## 'Content-Type' => upload['mime_type'] || 'application/octet-stream',
|
109
|
+
## 'signature' => upload['signature'],
|
110
|
+
## 'acl' => upload['acl'], #"public-read", #
|
111
|
+
## 'file' => f
|
142
112
|
#
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
#
|
155
|
-
#
|
156
|
-
|
157
|
-
|
158
|
-
f.close
|
159
|
-
|
160
|
-
analyze_aws_response response
|
113
|
+
##stat = HTTPClient.post("http://github.s3.amazonaws.com/", [
|
114
|
+
## ['Filename', info[:name]],
|
115
|
+
## ['policy', upload_info['policy']],
|
116
|
+
## ['success_action_status', 201],
|
117
|
+
## ['key', upload_info['path']],
|
118
|
+
## ['AWSAccessKeyId', upload_info['accesskeyid']],
|
119
|
+
## ['Content-Type', upload_info['content_type'] || 'application/octet-stream'],
|
120
|
+
## ['signature', upload_info['signature']],
|
121
|
+
## ['acl', upload_info['acl']],
|
122
|
+
## ['file', f]
|
123
|
+
##])
|
124
|
+
#f.close
|
125
|
+
#analyze_aws_response response
|
161
126
|
end
|
162
127
|
|
163
128
|
private
|
164
129
|
|
130
|
+
def self.analyze_curl_response response
|
131
|
+
message = XmlSimple.xml_in(response)
|
132
|
+
if message['Location']
|
133
|
+
message['Location'].first
|
134
|
+
else
|
135
|
+
raise "Failed to upload to AWS" + (" due to #{message}" rescue '')
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
165
139
|
def self.analyze_aws_response response
|
166
140
|
p message = XmlSimple.xml_in(response.body)
|
167
141
|
if response.code.to_i == 201
|