s3stream 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,12 +1,6 @@
1
1
  Installation
2
2
  ============
3
3
 
4
- gem install s3stream --development
5
-
6
- Or if that doesn't work for some reason:
7
-
8
- gem install aws-s3 --version 0.6.2
9
- gem install aws-sdk --version 1.3.5
10
4
  gem install s3stream
11
5
 
12
6
  Configuration
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
- # desc "Open development console"
4
- # task :console do
5
- # puts "Loading development console..."
6
- # system "pry -I #{File.join('.', 'lib')} -r #{File.join('.', 'lib', 's3stream')}"
7
- # end
3
+ desc "Open development console"
4
+ task :console do
5
+ puts "Loading development console..."
6
+ system "pry -I #{File.join('.', 'lib')} -r #{File.join('.', 'lib', 's3stream')}"
7
+ end
data/lib/s3stream/main.rb CHANGED
@@ -2,20 +2,22 @@ module S3Stream
2
2
  class Main < Thor
3
3
  desc "fetch bucket filename", "download/stream the file from S3 to stdout"
4
4
  def fetch(bucket_name, filename)
5
- require "aws/s3"
6
- AWS::S3::Base.establish_connection!(S3Stream::CREDENTIALS)
7
- AWS::S3::S3Object.stream(filename, bucket_name) do |chunk|
8
- $stdout.write chunk
5
+ require 'open-uri'
6
+ object = s3object(bucket_name, filename)
7
+ uri = object.url_for(:read, :secure => true, :expires => 60 * 60) # 1 hour
8
+ uri.open do |stream|
9
+ buffer = ""
10
+ until stream.eof?
11
+ stream.readpartial(4096, buffer)
12
+ $stdout.write(buffer)
13
+ end
9
14
  end
10
15
  end
11
16
 
12
17
  desc "store bucket filename", "upload/stream the file from stdin to S3"
13
18
  def store(bucket_name, filename)
14
- require "aws-sdk"
15
19
  $stdout.sync = true
16
- s3 = AWS::S3.new(S3Stream::CREDENTIALS)
17
- bucket = s3.buckets[bucket_name]
18
- object = bucket.objects[filename]
20
+ object = s3object(bucket_name, filename)
19
21
  buffer = ""
20
22
  total = 0
21
23
  buffer_size = INITIAL_BUFFER_SIZE
@@ -47,5 +49,16 @@ module S3Stream
47
49
  end
48
50
  puts "Done uploading to s3://#{bucket_name}/#{filename} (#{total} bytes)"
49
51
  end
52
+
53
+ private
54
+
55
+ def s3
56
+ @s3 ||= AWS::S3.new(S3Stream::CREDENTIALS)
57
+ end
58
+
59
+ def s3object(bucket_name, key)
60
+ bucket = s3.buckets[bucket_name]
61
+ bucket.objects[key]
62
+ end
50
63
  end
51
64
  end
@@ -1,3 +1,3 @@
1
1
  module S3Stream
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/s3stream.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "thor"
2
+ require "aws-sdk"
2
3
  require "s3stream/version"
3
4
  require "s3stream/constants"
4
5
  require "s3stream/main"
data/s3stream.gemspec CHANGED
@@ -19,9 +19,8 @@ Gem::Specification.new do |s|
19
19
  s.require_paths = ["lib"]
20
20
 
21
21
  s.add_runtime_dependency "thor", "~> 0.14.6"
22
- s.add_development_dependency "aws-sdk", "~> 1.3.5" #actually a runtime dependency
23
- s.add_development_dependency "aws-s3", "~> 0.6.2" #actually a runtime dependency
24
- # s.add_development_dependency "pry"
25
- # s.add_development_dependency "pry-doc"
26
- # s.add_development_dependency "pry-nav"
22
+ s.add_runtime_dependency "aws-sdk", "~> 1.3.5"
23
+ s.add_development_dependency "pry"
24
+ s.add_development_dependency "pry-doc"
25
+ s.add_development_dependency "pry-nav"
27
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3stream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
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-27 00:00:00.000000000 Z
12
+ date: 2012-03-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &70189332955800 !ruby/object:Gem::Requirement
16
+ requirement: &70192394775500 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,29 +21,51 @@ dependencies:
21
21
  version: 0.14.6
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70189332955800
24
+ version_requirements: *70192394775500
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: aws-sdk
27
- requirement: &70189332954980 !ruby/object:Gem::Requirement
27
+ requirement: &70192394790820 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
32
  version: 1.3.5
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70192394790820
36
+ - !ruby/object:Gem::Dependency
37
+ name: pry
38
+ requirement: &70192394788600 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
33
44
  type: :development
34
45
  prerelease: false
35
- version_requirements: *70189332954980
46
+ version_requirements: *70192394788600
36
47
  - !ruby/object:Gem::Dependency
37
- name: aws-s3
38
- requirement: &70189332949680 !ruby/object:Gem::Requirement
48
+ name: pry-doc
49
+ requirement: &70192394787200 !ruby/object:Gem::Requirement
39
50
  none: false
40
51
  requirements:
41
- - - ~>
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70192394787200
58
+ - !ruby/object:Gem::Dependency
59
+ name: pry-nav
60
+ requirement: &70192394786080 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
42
64
  - !ruby/object:Gem::Version
43
- version: 0.6.2
65
+ version: '0'
44
66
  type: :development
45
67
  prerelease: false
46
- version_requirements: *70189332949680
68
+ version_requirements: *70192394786080
47
69
  description: Stream files on S3 to stdout or from stdin
48
70
  email:
49
71
  - chris@kindkid.com