tupper 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +36 -1
- data/lib/tupper/version.rb +1 -1
- data/sample/Gemfile +5 -0
- data/sample/config.ru +8 -0
- data/sample/sample.rb +30 -0
- data/sample/views/form.erb +16 -0
- metadata +8 -4
data/README.md
CHANGED
@@ -18,7 +18,42 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
usage on Sinatra application:
|
22
|
+
|
23
|
+
### upload
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
post '/upload' do
|
27
|
+
tupper = Tupper.new session
|
28
|
+
tupper.upload params[:file_from_form]
|
29
|
+
redirect '/somewher', 302
|
30
|
+
end
|
31
|
+
```
|
32
|
+
### process uploaded file
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
get '/show_file_info' do
|
36
|
+
tupper = Tupper.new session
|
37
|
+
if tupper.has_uploaded_file?
|
38
|
+
filename = tupper.uploaded_file
|
39
|
+
# do something
|
40
|
+
end
|
41
|
+
erb :show_file_info, locals: { tupper: tupper }
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
### cleanup uploaded file and session
|
46
|
+
```ruby
|
47
|
+
post '/cleanup' do
|
48
|
+
tupper = Tupper.new session
|
49
|
+
tupper.cleanup
|
50
|
+
redirect '/', 302
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
### more info
|
55
|
+
|
56
|
+
see /sample
|
22
57
|
|
23
58
|
## Contributing
|
24
59
|
|
data/lib/tupper/version.rb
CHANGED
data/sample/Gemfile
ADDED
data/sample/config.ru
ADDED
data/sample/sample.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'tupper'
|
3
|
+
class Sample < Sinatra::Base
|
4
|
+
enable :sessions
|
5
|
+
|
6
|
+
get '/' do
|
7
|
+
tupper = Tupper.new session
|
8
|
+
erb :form, locals: { tupper: tupper }
|
9
|
+
end
|
10
|
+
|
11
|
+
post '/upload' do
|
12
|
+
tupper = Tupper.new session
|
13
|
+
tupper.upload params[:dummy_file]
|
14
|
+
redirect '/', 302
|
15
|
+
end
|
16
|
+
|
17
|
+
post '/cleanup' do
|
18
|
+
tupper = Tupper.new session
|
19
|
+
tupper.cleanup
|
20
|
+
redirect '/', 302
|
21
|
+
end
|
22
|
+
|
23
|
+
get '/show_size' do
|
24
|
+
tupper = Tupper.new session
|
25
|
+
unless tupper.has_uploaded_file?
|
26
|
+
redirect '/', 302
|
27
|
+
end
|
28
|
+
"uploaded file is [#{tupper.uploaded_file}] (size:#{File.size(tupper.uploaded_file)})"
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<html>
|
2
|
+
<body>
|
3
|
+
<form method="POST" action="/upload" enctype="multipart/form-data">
|
4
|
+
<input type="file" name="dummy_file"><br>
|
5
|
+
<input type="submit" value="upload">
|
6
|
+
</form>
|
7
|
+
<% if tupper.has_uploaded_file? %>
|
8
|
+
<hr>
|
9
|
+
<p>file <%= tupper.uploaded_file %> is uploaded.</p>
|
10
|
+
<p><a href="show_size">show size</a></p>
|
11
|
+
<form method="POST" action="/cleanup">
|
12
|
+
<input type="submit" value="cleanup">
|
13
|
+
</form>
|
14
|
+
<% end %>
|
15
|
+
</body>
|
16
|
+
</html>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tupper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -57,6 +57,10 @@ files:
|
|
57
57
|
- Rakefile
|
58
58
|
- lib/tupper.rb
|
59
59
|
- lib/tupper/version.rb
|
60
|
+
- sample/Gemfile
|
61
|
+
- sample/config.ru
|
62
|
+
- sample/sample.rb
|
63
|
+
- sample/views/form.erb
|
60
64
|
- spec/tupper_spec.rb
|
61
65
|
- tupper.gemspec
|
62
66
|
homepage: https://github.com/kwappa/tupper
|
@@ -73,7 +77,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
77
|
version: '0'
|
74
78
|
segments:
|
75
79
|
- 0
|
76
|
-
hash:
|
80
|
+
hash: 2395613315418707515
|
77
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
82
|
none: false
|
79
83
|
requirements:
|
@@ -82,7 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
86
|
version: '0'
|
83
87
|
segments:
|
84
88
|
- 0
|
85
|
-
hash:
|
89
|
+
hash: 2395613315418707515
|
86
90
|
requirements: []
|
87
91
|
rubyforge_project:
|
88
92
|
rubygems_version: 1.8.24
|