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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1afabdbd3be764cd7e82ebc8b19c3810b9381ad2
4
- data.tar.gz: 154d53b45fe5413401667a5ce6ab3e5bfe23c728
3
+ metadata.gz: c42a03882347769823295c1322c0c0638dd68919
4
+ data.tar.gz: bae0d2c6b482c4e0ce7ed6afc917ec8c579a309a
5
5
  SHA512:
6
- metadata.gz: 6356ca1f05064fc11b7819b30c0677406115cca1688fc56cf9206e68e07c835b52831fed040dc2f39cf79a946ba1fc7e40737777fa89724071211f416e232162
7
- data.tar.gz: 7a65f08c212a0442663fbc1d7a47d66485266dbb192f903fc81f5de2ffde40226d08ab912a5dc92b26fe204b20249b6e11d8fa3920df7e28178ced2a42e77c17
6
+ metadata.gz: 428009490c6595b716f286eecce7d5f6caf1090af9a0b7c5f62d51981dec5a12cace72efbfdcaad0ca9cae148a5d4b7011f89e6dd1f9f84f5e402e4d2c177967
7
+ data.tar.gz: 7d91576d51de903a766579e24881f82fdfe2ded20765a7a1de3a9272382afc4909ae91cd0311f36ba0a99b75ba532a69960999f2a546768c7fd288d01943d51b
@@ -9,6 +9,8 @@ module Haraway
9
9
  require "haraway/deployer"
10
10
  require "haraway/committer"
11
11
  require "haraway/deleter"
12
+ require "haraway/ingress"
13
+ require "haraway/json_stream_reader"
12
14
 
13
15
  begin # Load the Rails adapter
14
16
  require "rails/engine"
@@ -154,7 +154,6 @@ private
154
154
  end
155
155
 
156
156
  if asset_ids.size > 0
157
- puts "asset_ids=#{asset_ids.inspect}"
158
157
  Haraway::Committer.new(Haraway.configuration, asset_ids).commit!
159
158
  @_haraway_uploaded_assets = nil
160
159
  end
@@ -29,9 +29,8 @@ private
29
29
  raise "Deploy failed: #{resp.code} #{resp.message}\n#{resp.body}"
30
30
  end
31
31
 
32
- resp.read_body do |segment|
33
- segment.gsub!("\x00", "")
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
@@ -1,6 +1,6 @@
1
1
  module Haraway
2
2
  VERSION = "0.1.0"
3
- BUILD = "42"
3
+ BUILD = "45"
4
4
 
5
5
  if BUILD != ("{{BUILD_NUMBER" + "}}") # prevent sed replacement (see script/ci)
6
6
  BUILD_VERSION = "#{VERSION}.dev.#{BUILD}"
@@ -3,7 +3,7 @@ module Haraway::TagsHelper
3
3
  def self.render(config, ttl=nil)
4
4
  creds = config.credentials
5
5
  scheme = config.use_ssl ? "https" : "http"
6
- ttl = ttl || 900
6
+ ttl = ttl || 14400
7
7
 
8
8
  mac = creds.make_authentication_message("uploader", (Time.now + ttl).to_i)
9
9
 
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.42
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-03 00:00:00.000000000 Z
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