file_column_with_s3 0.1.9 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/file_column.rb +1 -1
- data/lib/file_column_helper.rb +7 -1
- data/lib/test_case.rb +5 -5
- data/test/abstract_unit.rb +31 -0
- data/test/file_column_helper_test.rb +1 -3
- metadata +90 -119
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0482bce566504b5f4172787d578a64cf71f37294
|
4
|
+
data.tar.gz: e77a7c13b7bb686225cd8a0786c62abd9ffdd07e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 853f2abd43b2a722fe7ea52423dbe68f234a849a12ea876c263a0bb1eb02dd5992ff64bb023e1d51683f8e115b07aa20360747591f6abed421b89878a101dc5a
|
7
|
+
data.tar.gz: 134232b045d69995b655e043156ca5c95c6ba2ca6ecb9ee14647c6a596d9fb33d046e9ea279d330126775a77fc0da155d7b4d20dba9a00896a9a287ac1516b44
|
data/lib/file_column.rb
CHANGED
@@ -609,7 +609,7 @@ module FileColumn # :nodoc:
|
|
609
609
|
|
610
610
|
# default options. You can override these with +file_column+'s +options+ parameter
|
611
611
|
DEFAULT_OPTIONS = {
|
612
|
-
:root_path => File.join(
|
612
|
+
:root_path => File.join(Rails.root.to_s, "public"),
|
613
613
|
:web_root => "",
|
614
614
|
:mime_extensions => MIME_EXTENSIONS,
|
615
615
|
:extensions => EXTENSIONS,
|
data/lib/file_column_helper.rb
CHANGED
@@ -72,7 +72,7 @@ module FileColumnHelper
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
context_path = absolute ?
|
75
|
+
context_path = absolute ? get_relative_url_for_rails(Rails::VERSION::MAJOR) : nil
|
76
76
|
object.send("#{method}_download_url", context_path, subdir, store_url_for_options)
|
77
77
|
|
78
78
|
end
|
@@ -142,4 +142,10 @@ module FileColumnHelper
|
|
142
142
|
url_for_file_column(object, method, subdir, store_url_for_options)
|
143
143
|
end
|
144
144
|
end
|
145
|
+
|
146
|
+
private
|
147
|
+
def get_relative_url_for_rails(rails_version)
|
148
|
+
(rails_version == 2 ? ActionController::Base.relative_url_root : Rails.application.config.action_controller.relative_url_root).to_s
|
149
|
+
end
|
150
|
+
|
145
151
|
end
|
data/lib/test_case.rb
CHANGED
@@ -70,14 +70,14 @@ class Test::Unit::TestCase
|
|
70
70
|
# # ...
|
71
71
|
# end
|
72
72
|
def setup_fixture_files
|
73
|
-
tmp_path = File.join(
|
74
|
-
file_fixtures = Dir.glob File.join(
|
73
|
+
tmp_path = File.join(Rails.root.to_s, "test", "tmp", "file_column")
|
74
|
+
file_fixtures = Dir.glob File.join(Rails.root.to_s, "test", "fixtures", "file_column", "*")
|
75
75
|
|
76
76
|
FileUtils.mkdir_p tmp_path unless File.exists?(tmp_path)
|
77
77
|
FileUtils.cp_r file_fixtures, tmp_path
|
78
78
|
end
|
79
79
|
|
80
|
-
# Removes the directory "
|
80
|
+
# Removes the directory "/test/tmp/file_column/" so the files
|
81
81
|
# copied on test startup are removed. Call this in your unit test's +teardown+
|
82
82
|
# method.
|
83
83
|
#
|
@@ -89,7 +89,7 @@ class Test::Unit::TestCase
|
|
89
89
|
# # ...
|
90
90
|
# end
|
91
91
|
def teardown_fixture_files
|
92
|
-
FileUtils.rm_rf File.join(
|
92
|
+
FileUtils.rm_rf File.join(Rails.root.to_s, "test", "tmp", "file_column")
|
93
93
|
end
|
94
94
|
|
95
95
|
private
|
@@ -120,5 +120,5 @@ end
|
|
120
120
|
# in tests but rather into the directory "/test/tmp/file_column".
|
121
121
|
if RAILS_ENV == "test"
|
122
122
|
FileColumn::ClassMethods::DEFAULT_OPTIONS[:root_path] =
|
123
|
-
File.join(
|
123
|
+
File.join(Rails.root.to_s, "test", "tmp", "file_column")
|
124
124
|
end
|
data/test/abstract_unit.rb
CHANGED
@@ -13,6 +13,37 @@ RAILS_ENV = ""
|
|
13
13
|
|
14
14
|
$: << "../lib"
|
15
15
|
|
16
|
+
module Rails
|
17
|
+
@root = File.dirname(__FILE__)
|
18
|
+
|
19
|
+
class << self
|
20
|
+
attr_accessor :root
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.application
|
24
|
+
Application.new
|
25
|
+
end
|
26
|
+
|
27
|
+
class Application
|
28
|
+
def config
|
29
|
+
Configuration.new
|
30
|
+
end
|
31
|
+
|
32
|
+
class Configuration
|
33
|
+
def action_controller
|
34
|
+
action_controller = ActiveSupport::OrderedOptions.new
|
35
|
+
action_controller.relative_url_root = '/foo/bar'
|
36
|
+
return action_controller
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class VERSION
|
42
|
+
MAJOR = (ENV['RAILS_VERSION'] || '3').to_i
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
16
47
|
require 'file_column'
|
17
48
|
require 'file_column_helper'
|
18
49
|
require 'file_compat'
|
@@ -6,7 +6,6 @@ class UrlForFileColumnTest < Test::Unit::TestCase
|
|
6
6
|
|
7
7
|
def setup
|
8
8
|
Entry.file_column :image
|
9
|
-
ActionController::Base.relative_url_root = nil
|
10
9
|
@request = RequestMock.new
|
11
10
|
end
|
12
11
|
|
@@ -112,7 +111,6 @@ class UrlForFileColumnWithContextPathTest < Test::Unit::TestCase
|
|
112
111
|
def test_relative_url_root_not_modified
|
113
112
|
e = Entry.new(:image => upload(f("skanthak.png")))
|
114
113
|
url_for_file_column(e, "image", :absolute => true)
|
115
|
-
|
116
|
-
assert_equal "/foo/bar", ActionController::Base.relative_url_root
|
114
|
+
assert_equal "/foo/bar", get_relative_url_for_rails(Rails::VERSION::MAJOR)
|
117
115
|
end
|
118
116
|
end
|
metadata
CHANGED
@@ -1,130 +1,116 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: file_column_with_s3
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 9
|
10
|
-
version: 0.1.9
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Mingle SaaS team
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
22
14
|
name: mingle-storage
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 9
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 0
|
33
|
-
- 11
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
34
19
|
version: 0.0.11
|
35
20
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rails
|
39
21
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.0.11
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "<="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.0.0
|
51
34
|
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: sqlite3
|
55
35
|
prerelease: false
|
56
|
-
|
57
|
-
|
58
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "<="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
59
45
|
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
segments:
|
63
|
-
- 0
|
64
|
-
version: "0"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
65
48
|
type: :development
|
66
|
-
version_requirements: *id003
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: rmagick
|
69
49
|
prerelease: false
|
70
|
-
|
71
|
-
|
72
|
-
requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
73
52
|
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rmagick
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
79
62
|
type: :development
|
80
|
-
version_requirements: *id004
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
|
-
name: aws-sdk
|
83
63
|
prerelease: false
|
84
|
-
|
85
|
-
|
86
|
-
requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
87
66
|
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: aws-sdk
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
93
76
|
type: :development
|
94
|
-
version_requirements: *id005
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: nokogiri
|
97
77
|
prerelease: false
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: nokogiri
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
108
89
|
version: 1.5.11
|
109
90
|
type: :development
|
110
|
-
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.5.11
|
111
97
|
description:
|
112
98
|
email: mingle.saas@thoughtworks.com
|
113
99
|
executables: []
|
114
|
-
|
115
100
|
extensions: []
|
116
|
-
|
117
101
|
extra_rdoc_files: []
|
118
|
-
|
119
|
-
|
102
|
+
files:
|
103
|
+
- CHANGELOG
|
104
|
+
- README
|
120
105
|
- Rakefile
|
121
|
-
- lib/file_column/validations.rb
|
122
106
|
- lib/file_column.rb
|
107
|
+
- lib/file_column/validations.rb
|
123
108
|
- lib/file_column_helper.rb
|
124
109
|
- lib/file_compat.rb
|
125
110
|
- lib/magick_file_column.rb
|
126
111
|
- lib/rails_file_column.rb
|
127
112
|
- lib/test_case.rb
|
113
|
+
- s3_env.example
|
128
114
|
- test/abstract_unit.rb
|
129
115
|
- test/connection.rb
|
130
116
|
- test/file_column_helper_test.rb
|
@@ -137,42 +123,27 @@ files:
|
|
137
123
|
- test/fixtures/skanthak.png
|
138
124
|
- test/magick_test.rb
|
139
125
|
- test/magick_view_only_test.rb
|
140
|
-
- README
|
141
|
-
- CHANGELOG
|
142
|
-
- s3_env.example
|
143
|
-
has_rdoc: true
|
144
126
|
homepage: https://github.com/ThoughtWorksStudios/file_column
|
145
127
|
licenses: []
|
146
|
-
|
128
|
+
metadata: {}
|
147
129
|
post_install_message:
|
148
130
|
rdoc_options: []
|
149
|
-
|
150
|
-
require_paths:
|
131
|
+
require_paths:
|
151
132
|
- lib
|
152
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
-
|
154
|
-
requirements:
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
155
135
|
- - ">="
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
version: "0"
|
161
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
-
none: false
|
163
|
-
requirements:
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
164
140
|
- - ">="
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
|
167
|
-
segments:
|
168
|
-
- 0
|
169
|
-
version: "0"
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
170
143
|
requirements: []
|
171
|
-
|
172
144
|
rubyforge_project:
|
173
|
-
rubygems_version:
|
145
|
+
rubygems_version: 2.4.5.1
|
174
146
|
signing_key:
|
175
|
-
specification_version:
|
147
|
+
specification_version: 4
|
176
148
|
summary: File attachment library for ruby
|
177
149
|
test_files: []
|
178
|
-
|