paperclip-globalize3 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.travis.yml +11 -0
- data/Appraisals +11 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +62 -0
- data/Rakefile +18 -0
- data/gemfiles/rails_3.0.gemfile +7 -0
- data/gemfiles/rails_3.1.gemfile +7 -0
- data/gemfiles/rails_3.2.gemfile +7 -0
- data/lib/paperclip-globalize3.rb +9 -0
- data/lib/paperclip/globalize3/attachment.rb +102 -0
- data/lib/paperclip/globalize3/version.rb +5 -0
- data/paperclip-globalize3.gemspec +29 -0
- data/spec/attachment_helper_spec.rb +103 -0
- data/spec/data/models.rb +12 -0
- data/spec/data/schema.rb +26 -0
- data/spec/data/test.png +0 -0
- data/spec/data/test2.png +0 -0
- data/spec/spec_helper.rb +36 -0
- metadata +169 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
Y2FmNjZlMGNjMGNkNzg4MDZkNGEwMDI4MmI4M2UzN2ZmZjA5NGYzZg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NmI0ZTc1OGZmMjBiZDhjYjJlY2JlMDBmMDgzZGQ0ZmMzNjc5YTI4Zg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MjE1ODcxNzc0MjA4MDNkOGRiNjQyMmM1Yzc0OGExOTNiNTYxOWIyNmI1ZDZi
|
10
|
+
NjY1ZmY1YTQ4NjYwNmFhNmEyOWM2MGE4OTU0ZDQ4NTAyYzJhMDk1YjhhN2Zi
|
11
|
+
ZDU5NDY4ZTc3YjJiMzZiMjdkYWI3MzQzOGY1MDUzYWRjNDI1MWI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YTBmZTU2ZGNlM2JjOTAzZWY0ZDg0Y2NmMWYxZTAxZjc0MDA3OGQ2NzAxOWRl
|
14
|
+
NTE3ZWQxOTlhYmI4NzZmNDY5NWNjNzA4ZDA1ODIwY2MzN2U1MTQzNDYwNDQx
|
15
|
+
ODFiZDE1MmJhZDg4YzZlNTM5OTc0YThiYmJhYTFlOGU2YzkyOTU=
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Appraisals
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 emjot GmbH & Co. KG
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Paperclip::Globalize3
|
2
|
+
|
3
|
+
[](https://travis-ci.org/emjot/paperclip-globalize3)
|
4
|
+
|
5
|
+
Use locale-specific attachments in your Rails app with paperclip and globalize3.
|
6
|
+
|
7
|
+
You can transparently read and write your attachments in context of the current locale. E.g. `my_model.my_attachment` returns a different attachment when your current locale is 'en' compared to when your current locale is 'de'.
|
8
|
+
|
9
|
+
Note that this implementation patches some methods in the `Paperclip::Attachment` class, so make sure you are okay with that.
|
10
|
+
|
11
|
+
## Compatibility
|
12
|
+
|
13
|
+
Currently, paperclip 2.x (>= 2.5) and globalize3 0.3 are supported. Support for paperclip 3.x is planned.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
gem 'paperclip-globalize3'
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install paperclip-globalize3
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
For each of your attachments which should have support for different locales, set up the following:
|
32
|
+
|
33
|
+
1. Migrate the paperclip columns ('xxx_file_name' etc.) of the attachment to the translation table
|
34
|
+
2. Declare in the model that it 'translates' the paperclip fields ('xxx_file_name' etc.)
|
35
|
+
3. Use the :locale interpolation for the paperclip url
|
36
|
+
|
37
|
+
NOTE: Make sure your `translates` are always defined after the `has_attached_file`! (Otherwise the files will not be deleted from the filesystem when the model is destroyed.)
|
38
|
+
|
39
|
+
Example:
|
40
|
+
|
41
|
+
class User < ActiveRecord::Base
|
42
|
+
has_attached_file :avatar,
|
43
|
+
:url => "/system/:attachment/:id/:locale/:style-:fingerprint.:extension"
|
44
|
+
translates :avatar_file_name, :avatar_file_size, :avatar_created_at, :avatar_updated_at, :avatar_fingerprint
|
45
|
+
end
|
46
|
+
|
47
|
+
## Todo / Future Plans
|
48
|
+
|
49
|
+
* Support paperclip 3.x
|
50
|
+
* Make it easier to specify translated attachments, e.g. using one of these options:
|
51
|
+
* support `translates :attachment_name`
|
52
|
+
* support `:translated` option for `has_attached_file`
|
53
|
+
* eliminate the need to specify; automatically set `translates` as soon as the :locale interpolation is used
|
54
|
+
* Don't depend on order of definition for it to work (`translates` after `has_attached_file`)
|
55
|
+
|
56
|
+
## Contributing
|
57
|
+
|
58
|
+
1. Fork it
|
59
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
60
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
61
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
62
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'appraisal'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
require 'bundler/gem_tasks'
|
6
|
+
|
7
|
+
desc 'Default: run all tests with all supported versions'
|
8
|
+
task :default => :all
|
9
|
+
|
10
|
+
desc 'Run tests with all supported Rails versions.'
|
11
|
+
task :all => ["appraisal:install"] do
|
12
|
+
exec('rake appraisal spec')
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Run all tests'
|
16
|
+
RSpec::Core::RakeTask.new('spec') do |t|
|
17
|
+
t.pattern = FileList['spec/**/*_spec.rb']
|
18
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require "paperclip/globalize3/version"
|
2
|
+
require "paperclip/globalize3/attachment"
|
3
|
+
|
4
|
+
require "globalize"
|
5
|
+
require "paperclip"
|
6
|
+
|
7
|
+
Paperclip.interpolates(:locale) { |_, _| Globalize.locale.to_s }
|
8
|
+
|
9
|
+
Paperclip::Attachment.send(:include, Paperclip::Globalize3::Attachment)
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module Paperclip
|
2
|
+
module Globalize3
|
3
|
+
module Attachment
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.send :include, InstanceMethods
|
7
|
+
base.send :alias_method_chain, :instance_write, :globalize3
|
8
|
+
base.send :alias_method_chain, :instance_read, :globalize3
|
9
|
+
base.send :alias_method_chain, :assign, :globalize3
|
10
|
+
base.send :alias_method_chain, :clear, :globalize3
|
11
|
+
base.send :alias_method_chain, :queue_existing_for_delete, :globalize3
|
12
|
+
end
|
13
|
+
|
14
|
+
module InstanceMethods
|
15
|
+
|
16
|
+
# use a localized cache if required
|
17
|
+
def cached_instance_variable_name(getter)
|
18
|
+
if instance.respond_to?(:translated?) && instance.translated?(getter.to_sym)
|
19
|
+
:"@_#{getter}_#{Globalize.locale}"
|
20
|
+
else
|
21
|
+
:"@_#{getter}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def instance_write_with_globalize3(attr, value)
|
26
|
+
setter = :"#{name}_#{attr}="
|
27
|
+
responds = instance.respond_to?(setter)
|
28
|
+
self.instance_variable_set(cached_instance_variable_name(setter.to_s.chop), value)
|
29
|
+
instance.send(setter, value) if responds || attr.to_s == "file_name"
|
30
|
+
end
|
31
|
+
|
32
|
+
def instance_read_with_globalize3(attr)
|
33
|
+
getter = :"#{name}_#{attr}"
|
34
|
+
responds = instance.respond_to?(getter)
|
35
|
+
cached = self.instance_variable_get(cached_instance_variable_name(getter))
|
36
|
+
return cached if cached
|
37
|
+
instance.send(getter) if responds || attr.to_s == "file_name"
|
38
|
+
end
|
39
|
+
|
40
|
+
def assign_with_globalize3(uploaded_file)
|
41
|
+
ensure_required_accessors!
|
42
|
+
|
43
|
+
if uploaded_file.is_a?(Paperclip::Attachment)
|
44
|
+
uploaded_filename = uploaded_file.original_filename
|
45
|
+
uploaded_file = uploaded_file.to_file(:original)
|
46
|
+
close_uploaded_file = uploaded_file.respond_to?(:close)
|
47
|
+
else
|
48
|
+
instance_write(:uploaded_file, uploaded_file) if uploaded_file
|
49
|
+
end
|
50
|
+
|
51
|
+
return nil unless valid_assignment?(uploaded_file)
|
52
|
+
|
53
|
+
uploaded_file.binmode if uploaded_file.respond_to? :binmode
|
54
|
+
self.clear(Globalize.locale) # [paperclip-globalize3] only clear current locale
|
55
|
+
|
56
|
+
return nil if uploaded_file.nil?
|
57
|
+
|
58
|
+
uploaded_filename ||= uploaded_file.original_filename
|
59
|
+
stores_fingerprint = @instance.respond_to?("#{name}_fingerprint".to_sym)
|
60
|
+
@queued_for_write[:original] = to_tempfile(uploaded_file)
|
61
|
+
instance_write(:file_name, cleanup_filename(uploaded_filename.strip))
|
62
|
+
instance_write(:content_type, uploaded_file.content_type.to_s.strip)
|
63
|
+
instance_write(:file_size, uploaded_file.size.to_i)
|
64
|
+
instance_write(:fingerprint, generate_fingerprint(uploaded_file)) if stores_fingerprint
|
65
|
+
instance_write(:updated_at, Time.now)
|
66
|
+
|
67
|
+
@dirty = true
|
68
|
+
|
69
|
+
post_process(*@options[:only_process]) if post_processing
|
70
|
+
|
71
|
+
# Reset the file size if the original file was reprocessed.
|
72
|
+
instance_write(:file_size, @queued_for_write[:original].size.to_i)
|
73
|
+
instance_write(:fingerprint, generate_fingerprint(@queued_for_write[:original])) if stores_fingerprint
|
74
|
+
ensure
|
75
|
+
uploaded_file.close if close_uploaded_file
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
def clear_with_globalize3(with_locales = nil)
|
80
|
+
queue_existing_for_delete(with_locales)
|
81
|
+
@queued_for_write = {}
|
82
|
+
@errors = {}
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def queue_existing_for_delete_with_globalize3(with_locales = nil) #:nodoc:
|
88
|
+
if instance.respond_to?(:translated_locales) && instance.translated?(:"#{name}_file_name")
|
89
|
+
# do it for the given locales only (or for all translated locales if none are given)
|
90
|
+
# TODO translated_locales are not present any more when this is called via destroy callback (unless 'translates' is defined AFTER 'has_attached_file' in the model class)
|
91
|
+
with_locales = instance.translated_locales if with_locales.nil?
|
92
|
+
Globalize.with_locales([*with_locales]) { queue_existing_for_delete_without_globalize3 }
|
93
|
+
else
|
94
|
+
queue_existing_for_delete_without_globalize3
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'paperclip/globalize3/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "paperclip-globalize3"
|
8
|
+
spec.version = Paperclip::Globalize3::VERSION
|
9
|
+
spec.authors = ["Maximilian Herold"]
|
10
|
+
spec.email = ["herold@emjot.de"]
|
11
|
+
spec.description = %q{locale-specific attachments with paperclip and globalize3}
|
12
|
+
spec.summary = %q{locale-specific attachments with paperclip and globalize3}
|
13
|
+
spec.homepage = "https://github.com/emjot/paperclip-globalize3"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "paperclip", "~> 2.5"
|
22
|
+
spec.add_runtime_dependency "globalize3", "~> 0.3"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
25
|
+
spec.add_development_dependency "appraisal", "~> 0.5.1"
|
26
|
+
spec.add_development_dependency "rspec-rails", "~> 2.8.0"
|
27
|
+
spec.add_development_dependency "sqlite3"
|
28
|
+
spec.add_development_dependency "rake"
|
29
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe 'Paperclip::Globalize3::Attachment' do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
Object.const_set(:Rails, double('Rails'))
|
8
|
+
Rails.stub(:root).and_return(ROOT.join('tmp'))
|
9
|
+
Rails.stub(:env).and_return('test')
|
10
|
+
Rails.stub(:const_defined?).with(:Railtie).and_return(false)
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:test_image_file) do
|
14
|
+
File.new(File.expand_path(File.join(File.dirname(__FILE__), 'data/test.png')))
|
15
|
+
end
|
16
|
+
|
17
|
+
let(:test_image_file2) do
|
18
|
+
File.new(File.expand_path(File.join(File.dirname(__FILE__), 'data/test2.png')))
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'with translations' do
|
22
|
+
|
23
|
+
it 'should save different images for different locales' do
|
24
|
+
p = Post.create
|
25
|
+
Globalize.with_locale(:en) do
|
26
|
+
p.image_file_name.should be_nil
|
27
|
+
p.update_attributes!(:image => test_image_file)
|
28
|
+
p.image_file_name.should == "test.png"
|
29
|
+
end
|
30
|
+
Post.count.should == 1
|
31
|
+
Post.translation_class.count.should == 1
|
32
|
+
|
33
|
+
Globalize.with_locale(:de) do
|
34
|
+
p.image_file_name.should be_nil
|
35
|
+
p.update_attributes!(:image => test_image_file2)
|
36
|
+
p.image_file_name.should == "test2.png"
|
37
|
+
end
|
38
|
+
Globalize.with_locale(:en) do
|
39
|
+
p.image_file_name.should == "test.png"
|
40
|
+
end
|
41
|
+
Post.count.should == 1
|
42
|
+
Post.translation_class.count.should == 2
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should only overwrite the image file for the current locale on re-assign' do
|
46
|
+
p = Post.create
|
47
|
+
path_en = Globalize.with_locale(:en) do
|
48
|
+
p.update_attributes!(:image => test_image_file)
|
49
|
+
p.image.path
|
50
|
+
end
|
51
|
+
path_de = Globalize.with_locale(:de) do
|
52
|
+
p.update_attributes!(:image => test_image_file2)
|
53
|
+
p.image.path
|
54
|
+
end
|
55
|
+
File.exist?(path_en).should be_true
|
56
|
+
File.exist?(path_de).should be_true
|
57
|
+
|
58
|
+
# re-assign 'en' image (use different image)
|
59
|
+
path_en2 = Globalize.with_locale(:en) do
|
60
|
+
p.update_attributes!(:image => test_image_file2)
|
61
|
+
p.image.path
|
62
|
+
end
|
63
|
+
[path_en, path_en2, path_de].uniq.size.should == 3 # paths should all be different
|
64
|
+
File.exist?(path_en).should be_false
|
65
|
+
File.exist?(path_en2).should be_true
|
66
|
+
File.exist?(path_de).should be_true
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should delete image files in all locales on destroy' do
|
70
|
+
p = Post.create
|
71
|
+
path_en = Globalize.with_locale(:en) do
|
72
|
+
p.update_attributes!(:image => test_image_file)
|
73
|
+
p.image.path
|
74
|
+
end
|
75
|
+
path_de = Globalize.with_locale(:de) do
|
76
|
+
p.update_attributes!(:image => test_image_file)
|
77
|
+
p.image.path
|
78
|
+
end
|
79
|
+
File.exist?(path_en).should be_true
|
80
|
+
File.exist?(path_de).should be_true
|
81
|
+
|
82
|
+
p.destroy
|
83
|
+
File.exist?(path_en).should be_false
|
84
|
+
File.exist?(path_de).should be_false
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'without translations' do
|
90
|
+
|
91
|
+
it 'should delete image files on destroy' do
|
92
|
+
p = Untranslated.create
|
93
|
+
p.update_attributes!(:image => test_image_file)
|
94
|
+
path = p.image.path
|
95
|
+
File.exist?(path).should be_true
|
96
|
+
|
97
|
+
p.destroy
|
98
|
+
File.exist?(path).should be_false
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
data/spec/data/models.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
class Post < ActiveRecord::Base
|
2
|
+
has_attached_file :image,
|
3
|
+
:url => "/system/:class/:attachment/:id/:locale/:style-:fingerprint.:extension"
|
4
|
+
|
5
|
+
translates :image_file_name, :image_content_type, :image_file_size, :image_updated_at, :image_fingerprint
|
6
|
+
end
|
7
|
+
|
8
|
+
class Untranslated < ActiveRecord::Base
|
9
|
+
has_attached_file :image,
|
10
|
+
:url => "/system/:class/:attachment/:id/:style-:fingerprint.:extension"
|
11
|
+
end
|
12
|
+
|
data/spec/data/schema.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
ActiveRecord::Migration.verbose = false
|
2
|
+
|
3
|
+
ActiveRecord::Schema.define do
|
4
|
+
create_table :posts, :force => true do |t|
|
5
|
+
t.integer :rating
|
6
|
+
end
|
7
|
+
|
8
|
+
create_table :post_translations, :force => true do |t|
|
9
|
+
t.string :locale
|
10
|
+
t.references :post
|
11
|
+
t.string :image_file_name
|
12
|
+
t.integer :image_file_size
|
13
|
+
t.string :image_content_type
|
14
|
+
t.string :image_fingerprint
|
15
|
+
t.timestamp :image_updated_at
|
16
|
+
end
|
17
|
+
|
18
|
+
create_table :untranslateds, :force => true do |t|
|
19
|
+
t.string :image_file_name
|
20
|
+
t.integer :image_file_size
|
21
|
+
t.string :image_content_type
|
22
|
+
t.string :image_fingerprint
|
23
|
+
t.timestamp :image_updated_at
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/spec/data/test.png
ADDED
Binary file
|
data/spec/data/test2.png
ADDED
Binary file
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
ROOT = Pathname(File.expand_path(File.join(File.dirname(__FILE__), '..')))
|
5
|
+
TEST_ASSETS_PATH = Pathname.new(ROOT).join('tmp', 'public')
|
6
|
+
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.mock_with :rspec
|
9
|
+
config.after(:suite) do
|
10
|
+
FileUtils.rm_rf TEST_ASSETS_PATH if File.exist?(TEST_ASSETS_PATH)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'active_support'
|
15
|
+
require 'action_pack'
|
16
|
+
require 'action_view'
|
17
|
+
require 'action_controller'
|
18
|
+
require 'action_dispatch'
|
19
|
+
require File.expand_path(File.join(File.dirname(__FILE__), '../lib/paperclip-globalize3'))
|
20
|
+
|
21
|
+
ActiveRecord::Base.send(:include, Paperclip::Glue)
|
22
|
+
|
23
|
+
# set up globalize3 and models (borrowed from globalize3)
|
24
|
+
require 'fileutils'
|
25
|
+
require 'logger'
|
26
|
+
tmpdir = File.join(File.dirname(__FILE__), "../tmp")
|
27
|
+
FileUtils.mkdir(tmpdir) unless File.exist?(tmpdir)
|
28
|
+
log = File.expand_path(File.join(tmpdir, "globalize3_test.log"))
|
29
|
+
FileUtils.touch(log) unless File.exists?(log)
|
30
|
+
ActiveRecord::Base.logger = Logger.new(log)
|
31
|
+
ActiveRecord::LogSubscriber.attach_to(:active_record)
|
32
|
+
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
|
33
|
+
require File.expand_path('../data/schema', __FILE__)
|
34
|
+
require File.expand_path('../data/models', __FILE__)
|
35
|
+
I18n.locale = I18n.default_locale = :en
|
36
|
+
Globalize.locale = nil
|
metadata
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: paperclip-globalize3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Maximilian Herold
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: paperclip
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.5'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: globalize3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: appraisal
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.5.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.5.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-rails
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.8.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.8.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sqlite3
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: locale-specific attachments with paperclip and globalize3
|
112
|
+
email:
|
113
|
+
- herold@emjot.de
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- .rspec
|
120
|
+
- .travis.yml
|
121
|
+
- Appraisals
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- gemfiles/rails_3.0.gemfile
|
127
|
+
- gemfiles/rails_3.1.gemfile
|
128
|
+
- gemfiles/rails_3.2.gemfile
|
129
|
+
- lib/paperclip-globalize3.rb
|
130
|
+
- lib/paperclip/globalize3/attachment.rb
|
131
|
+
- lib/paperclip/globalize3/version.rb
|
132
|
+
- paperclip-globalize3.gemspec
|
133
|
+
- spec/attachment_helper_spec.rb
|
134
|
+
- spec/data/models.rb
|
135
|
+
- spec/data/schema.rb
|
136
|
+
- spec/data/test.png
|
137
|
+
- spec/data/test2.png
|
138
|
+
- spec/spec_helper.rb
|
139
|
+
homepage: https://github.com/emjot/paperclip-globalize3
|
140
|
+
licenses:
|
141
|
+
- MIT
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ! '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.0.3
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: locale-specific attachments with paperclip and globalize3
|
163
|
+
test_files:
|
164
|
+
- spec/attachment_helper_spec.rb
|
165
|
+
- spec/data/models.rb
|
166
|
+
- spec/data/schema.rb
|
167
|
+
- spec/data/test.png
|
168
|
+
- spec/data/test2.png
|
169
|
+
- spec/spec_helper.rb
|