temper 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/temper.rb +1 -0
- data/lib/temper/base.rb +15 -5
- data/lib/temper/file.rb +5 -1
- data/lib/temper/version.rb +1 -1
- data/temper.gemspec +2 -1
- metadata +77 -74
data/lib/temper.rb
CHANGED
data/lib/temper/base.rb
CHANGED
@@ -7,6 +7,18 @@ module Temper
|
|
7
7
|
raise RuntimeException, "No @storage set" unless @storage
|
8
8
|
self.original_filename = options[:original_filename] || ::File.basename(path)
|
9
9
|
self.content_type = options[:content_type] || infer_content_type || "text/plain"
|
10
|
+
|
11
|
+
if block_given?
|
12
|
+
begin
|
13
|
+
yield self
|
14
|
+
ensure
|
15
|
+
close
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def close
|
21
|
+
#noop
|
10
22
|
end
|
11
23
|
|
12
24
|
def fingerprint
|
@@ -42,13 +54,11 @@ module Temper
|
|
42
54
|
def type_from_file_command
|
43
55
|
# On BSDs, `file` doesn't give a result code of 1 if the file doesn't exist.
|
44
56
|
type = (self.original_filename.match(/\.(\w+)$/)[1] rescue "octet-stream").downcase
|
45
|
-
|
57
|
+
result = Shellter.run("file", "-b --mime-type :file", :file => self.path)
|
58
|
+
result = Shellter.run("file", "-b --mime-type :file", :file => self.path) unless result.success?
|
59
|
+
mime_type = (result.stdout.split(";").first.split(':').last.strip rescue "application/x-#{type}")
|
46
60
|
mime_type = "application/x-#{type}" if mime_type.match(/\(.*?\)/)
|
47
61
|
mime_type
|
48
62
|
end
|
49
|
-
|
50
|
-
def run(command, *arguments)
|
51
|
-
Cocaine::CommandLine.new(command, *arguments).run
|
52
|
-
end
|
53
63
|
end
|
54
64
|
end
|
data/lib/temper/file.rb
CHANGED
data/lib/temper/version.rb
CHANGED
data/temper.gemspec
CHANGED
@@ -16,7 +16,8 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.version = Temper::VERSION
|
17
17
|
|
18
18
|
gem.add_runtime_dependency "mime-types"
|
19
|
-
gem.add_runtime_dependency "
|
19
|
+
gem.add_runtime_dependency "shellter"
|
20
|
+
gem.add_runtime_dependency "popen4"
|
20
21
|
|
21
22
|
gem.add_development_dependency "rspec", "> 2.0"
|
22
23
|
end
|
metadata
CHANGED
@@ -1,75 +1,87 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: temper
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 0
|
9
|
-
- 0
|
10
|
-
version: 1.0.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Andrew Eberbach
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-07-12 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: mime-types
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
22
23
|
prerelease: false
|
23
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: shellter
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
24
33
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
32
38
|
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: cocaine
|
36
39
|
prerelease: false
|
37
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
41
|
none: false
|
39
|
-
requirements:
|
40
|
-
- -
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: popen4
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
46
54
|
type: :runtime
|
47
|
-
version_requirements: *id002
|
48
|
-
- !ruby/object:Gem::Dependency
|
49
|
-
name: rspec
|
50
55
|
prerelease: false
|
51
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
57
|
none: false
|
53
|
-
requirements:
|
54
|
-
- -
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>'
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.0'
|
61
70
|
type: :development
|
62
|
-
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>'
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2.0'
|
63
78
|
description: A gem for a slightly smarter temporary file and temporary directory maintenance
|
64
|
-
email:
|
79
|
+
email:
|
65
80
|
- andrew@ebertech.ca
|
66
81
|
executables: []
|
67
|
-
|
68
82
|
extensions: []
|
69
|
-
|
70
83
|
extra_rdoc_files: []
|
71
|
-
|
72
|
-
files:
|
84
|
+
files:
|
73
85
|
- .gitignore
|
74
86
|
- .rspec
|
75
87
|
- Gemfile
|
@@ -88,40 +100,31 @@ files:
|
|
88
100
|
- temper.gemspec
|
89
101
|
homepage: https://github.com/ebertech/temper
|
90
102
|
licenses: []
|
91
|
-
|
92
103
|
post_install_message:
|
93
104
|
rdoc_options: []
|
94
|
-
|
95
|
-
require_paths:
|
105
|
+
require_paths:
|
96
106
|
- lib
|
97
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
108
|
none: false
|
99
|
-
requirements:
|
100
|
-
- -
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
|
103
|
-
|
104
|
-
- 0
|
105
|
-
version: "0"
|
106
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ! '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
114
|
none: false
|
108
|
-
requirements:
|
109
|
-
- -
|
110
|
-
- !ruby/object:Gem::Version
|
111
|
-
|
112
|
-
segments:
|
113
|
-
- 0
|
114
|
-
version: "0"
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
115
119
|
requirements: []
|
116
|
-
|
117
120
|
rubyforge_project:
|
118
|
-
rubygems_version: 1.8.
|
121
|
+
rubygems_version: 1.8.24
|
119
122
|
signing_key:
|
120
123
|
specification_version: 3
|
121
|
-
summary: Combines the best parts of Upfile from paperclip and Rack::Multipart::UploadedFile
|
122
|
-
|
124
|
+
summary: Combines the best parts of Upfile from paperclip and Rack::Multipart::UploadedFile
|
125
|
+
from rack.
|
126
|
+
test_files:
|
123
127
|
- spec/examples/sample.txt
|
124
128
|
- spec/file/basic_spec.rb
|
125
129
|
- spec/spec_helper.rb
|
126
130
|
- spec/stringio/basic_spec.rb
|
127
|
-
has_rdoc:
|