upcloudify 0.0.3 → 0.1.0

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: ca722e487d4c17a7b5ccc2098583d9d736319b79
4
- data.tar.gz: e030b5f7783420f82bb6d93f5d73758b487c47ae
3
+ metadata.gz: 3b384a4aa972b795a902500e84510f881ef51961
4
+ data.tar.gz: f9d69b5caee4682cd0a86a48ab16fd47ebd3fbba
5
5
  SHA512:
6
- metadata.gz: b3d9d095441995cb79acea9e7f69e51417d401de1bdd5adcca8577adc3cf04b622c774e3aa84e0d49993c31a50771dd37f6f5027994d67d537c01d9b9edb22ac
7
- data.tar.gz: e4edcd2d8e70b521e9a9e3c81fd51d25a9f1b864621ed44a7c0c99d4c34bfc8818b5ada57a11fd2f47c41927df458eecf6a9771176d0ba336cc15b36103731b0
6
+ metadata.gz: a8e47a6899af9b30fa3dfbf9e76ea80a3df22429c23047f6027448a6fb00f29989b1474ab74826aee2948db796f08c96281b562a31371d8aa533583d206a555d
7
+ data.tar.gz: 177e5cd7d57d5cd03c2719a1a0305fc652af08f6bc6f2bf065e6584c7c08dba0cf94e6ad5295ab8659c9091cceb443556c212b5f3fd1cf7fa9d0b1b75f39088f
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .idea
data/README.md CHANGED
@@ -25,7 +25,7 @@ Configure the app:
25
25
  Upcloudify.configure do |config|
26
26
  config.aws_secret_access_key = 'foobarbaz' # can also be ENV['AWS_SECRET_ACCESS_KEY']
27
27
  config.aws_access_key_id = 'hello' # can also be ENV['AWS_ACCESS_KEY_ID']
28
- config.aws_directory = ''aws-directory
28
+ config.aws_directory = 'aws-directory'
29
29
  end
30
30
  ```
31
31
 
@@ -1,3 +1,3 @@
1
1
  module Upcloudify
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/upcloudify.rb CHANGED
@@ -17,15 +17,25 @@ module Upcloudify
17
17
 
18
18
  class S3
19
19
 
20
- # Internal: Connects to Amazon S3 using sored credentials
20
+ def initialize(options = {
21
+ s3_id: Upcloudify.configuration.aws_access_key_id,
22
+ s3_secret: Upcloudify.configuration.aws_secret_access_key,
23
+ s3_directory: Upcloudify.configuration.aws_directory
24
+ })
25
+ @id = options[:s3_id]
26
+ @secret = options[:s3_secret]
27
+ @directory = options[:s3_directory]
28
+ end
29
+
30
+ # Internal: Connects to Amazon S3 using stored credentials
21
31
  # Returns an object handle for the S3 bucket-directory
22
32
  def cloud
23
33
  connection = Fog::Storage.new(
24
34
  :provider => 'AWS',
25
- :aws_secret_access_key => Upcloudify.configuration.aws_secret_access_key,
26
- :aws_access_key_id => Upcloudify.configuration.aws_access_key_id,
35
+ :aws_secret_access_key => @secret,
36
+ :aws_access_key_id => @id,
27
37
  )
28
- directory = connection.directories.get(Upcloudify.configuration.aws_directory)
38
+ directory = connection.directories.get(@directory)
29
39
  directory.files
30
40
  end
31
41
 
@@ -34,7 +44,7 @@ module Upcloudify
34
44
  def upload(filename, data)
35
45
  file = cloud.create(
36
46
  key: "#{filename}.zip",
37
- body: Zippy.new("#{filename}.csv" => data).data,
47
+ body: Zippy.new("#{filename}" => data).data,
38
48
  :public => false
39
49
  )
40
50
  file
@@ -42,23 +52,26 @@ module Upcloudify
42
52
 
43
53
  # Public: Uploads a file to S3 and emails a link to the file.
44
54
  # Returns nothing.
45
- def email(email,
55
+ def email(email_address,
46
56
  filename,
47
57
  attachment,
48
- options={suffix: " generated on #{Time.now.to_s}",
49
- expiration: (Date.today + 30).to_time,
58
+ options = {
59
+ suffix: " generated on #{Time.now.to_s}-#{Rails.env}",
60
+ expiration: Time.now.tomorrow,
50
61
  from: 'upcloudify',
51
62
  subject: 'your file is attached',
52
- body: 'your report is linked '})
53
-
63
+ body: 'your report is linked '
64
+ }
65
+ )
66
+
54
67
  suffix = options[:suffix]
55
68
  expiration = options[:expiration]
56
69
  file = upload((filename.to_s + suffix.to_s).parameterize, attachment)
57
70
 
58
- Pony.mail to: email,
71
+ Pony.mail to: email_address,
59
72
  from: options[:from],
60
73
  subject: options[:subject],
61
- body: (options[:body] || '') + file.url(expiration)
74
+ body: (options[:body] || '') + file.url(expiration) + ' '
62
75
 
63
76
  end
64
77
 
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'sinatra'
4
+ gem 'upcloudify', path: '../'
5
+ gem 'pry'
@@ -0,0 +1,23 @@
1
+ require 'sinatra'
2
+ require 'pry'
3
+ require 'upcloudify'
4
+ require 'active_support/all'
5
+
6
+ enable :sessions
7
+
8
+ get '/' do
9
+ erb :index
10
+ end
11
+
12
+ post '/upload' do
13
+ Upcloudify.configure do |config|
14
+ config.aws_access_key_id = params["s3_id"]
15
+ config.aws_secret_access_key = params["s3_key"]
16
+ config.aws_directory = params["s3_directory"]
17
+ end
18
+
19
+ uploader = Upcloudify::S3.new
20
+
21
+ uploader.email(params["email"], params["file"]["filename"], params["file"]["tempfile"])
22
+ # redirect '/'
23
+ end
@@ -0,0 +1,8 @@
1
+ <form method="post" action="/upload" enctype='multipart/form-data'>
2
+ S3 Secret ID <input name="s3_id" type="text" /><br />
3
+ S3 Secret Key <input name="s3_key" type="text" /><br />
4
+ S3 Directory <input name="s3_directory" type="text" /><br />
5
+ Email <input name="email" type="text" /><br />
6
+ File <input name="file" type="file"><br />
7
+ <input type="submit" />
8
+ </form>
data/upcloudify.gemspec CHANGED
@@ -26,6 +26,8 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency 'gem_config'
27
27
  spec.add_dependency 'pony'
28
28
  spec.add_dependency 'zippy'
29
+ spec.add_dependency 'zip-zip'
29
30
  spec.add_dependency 'fog'
31
+ spec.add_dependency 'activesupport'
30
32
 
31
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upcloudify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - parasquid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-27 00:00:00.000000000 Z
11
+ date: 2014-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: zip-zip
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: fog
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,20 @@ dependencies:
94
108
  - - '>='
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: activesupport
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
97
125
  description: |-
98
126
  Upcloudify simplifies the process for uploading
99
127
  attachments to the cloud and emailing the recipient
@@ -111,6 +139,9 @@ files:
111
139
  - Rakefile
112
140
  - lib/upcloudify.rb
113
141
  - lib/upcloudify/version.rb
142
+ - sample_app/Gemfile
143
+ - sample_app/sample.rb
144
+ - sample_app/views/index.erb
114
145
  - upcloudify.gemspec
115
146
  homepage: ''
116
147
  licenses:
@@ -132,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
163
  version: '0'
133
164
  requirements: []
134
165
  rubyforge_project:
135
- rubygems_version: 2.0.3
166
+ rubygems_version: 2.2.2
136
167
  signing_key:
137
168
  specification_version: 4
138
169
  summary: Upload a file to the cloud and email a link for the attachment