haraway 0.1.0.dev.42 → 0.1.0.dev.45
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/haraway.rb +2 -0
- data/lib/haraway/active_record/macro.rb +0 -1
- data/lib/haraway/deployer.rb +2 -3
- data/lib/haraway/ingress.rb +50 -0
- data/lib/haraway/json_stream_reader.rb +23 -0
- data/lib/haraway/lib_version.rb +1 -1
- data/lib/haraway/tags_helper.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c42a03882347769823295c1322c0c0638dd68919
|
4
|
+
data.tar.gz: bae0d2c6b482c4e0ce7ed6afc917ec8c579a309a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 428009490c6595b716f286eecce7d5f6caf1090af9a0b7c5f62d51981dec5a12cace72efbfdcaad0ca9cae148a5d4b7011f89e6dd1f9f84f5e402e4d2c177967
|
7
|
+
data.tar.gz: 7d91576d51de903a766579e24881f82fdfe2ded20765a7a1de3a9272382afc4909ae91cd0311f36ba0a99b75ba532a69960999f2a546768c7fd288d01943d51b
|
data/lib/haraway.rb
CHANGED
data/lib/haraway/deployer.rb
CHANGED
@@ -29,9 +29,8 @@ private
|
|
29
29
|
raise "Deploy failed: #{resp.code} #{resp.message}\n#{resp.body}"
|
30
30
|
end
|
31
31
|
|
32
|
-
resp
|
33
|
-
|
34
|
-
$stdout.print segment
|
32
|
+
Haraway::JsonStreamReader.read(resp) do |msg|
|
33
|
+
$stdout.puts msg.inspect
|
35
34
|
$stdout.flush
|
36
35
|
end
|
37
36
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class Haraway::Ingress
|
2
|
+
|
3
|
+
def initialize(config)
|
4
|
+
@config = config
|
5
|
+
end
|
6
|
+
|
7
|
+
def ingest_url(url, profile)
|
8
|
+
metadata = nil
|
9
|
+
|
10
|
+
creds = @config.credentials
|
11
|
+
token = creds.make_authentication_message("uploader")
|
12
|
+
|
13
|
+
call do |http|
|
14
|
+
req = Net::HTTP::Post.new("/upload")
|
15
|
+
req.set_form_data({
|
16
|
+
"token" => token,
|
17
|
+
"profile" => profile.to_s,
|
18
|
+
"src_url" => url.to_s
|
19
|
+
})
|
20
|
+
|
21
|
+
http.request(req) do |resp|
|
22
|
+
if resp.code != "200"
|
23
|
+
raise "Upload failed: #{resp.code} #{resp.message}\n#{resp.body}"
|
24
|
+
end
|
25
|
+
|
26
|
+
Haraway::JsonStreamReader.read(resp) do |msg|
|
27
|
+
if msg["success"] == true
|
28
|
+
metadata = msg["metadata"] || {}
|
29
|
+
metadata["id"] = msg["id"]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
if metadata == nil
|
36
|
+
raise "Upload failed"
|
37
|
+
end
|
38
|
+
|
39
|
+
return metadata
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def call
|
45
|
+
Net::HTTP.start("api."+@config.endpoint, :use_ssl => @config.use_ssl) do |http|
|
46
|
+
yield(http)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Haraway::JsonStreamReader
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
def self.read(resp, &block)
|
6
|
+
buffer = ""
|
7
|
+
|
8
|
+
resp.read_body do |segment|
|
9
|
+
buffer.concat segment
|
10
|
+
|
11
|
+
while idx = buffer.index("\n")
|
12
|
+
chunk = buffer[0...idx]
|
13
|
+
buffer = buffer[(idx+1)..-1]
|
14
|
+
|
15
|
+
if chunk.size > 0
|
16
|
+
msg = JSON.load(chunk)
|
17
|
+
yield(msg)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/haraway/lib_version.rb
CHANGED
data/lib/haraway/tags_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haraway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.dev.
|
4
|
+
version: 0.1.0.dev.45
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Menke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,8 @@ files:
|
|
80
80
|
- lib/haraway/deployer.rb
|
81
81
|
- lib/haraway/formtastic.rb
|
82
82
|
- lib/haraway/formtastic/inputs_helper.rb
|
83
|
+
- lib/haraway/ingress.rb
|
84
|
+
- lib/haraway/json_stream_reader.rb
|
83
85
|
- lib/haraway/lib_version.rb
|
84
86
|
- lib/haraway/profile.rb
|
85
87
|
- lib/haraway/rails.rb
|