spree_carrierwave 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.
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ \#*
2
+ *~
3
+ .#*
4
+ .DS_Store
5
+ .idea
6
+ .project
7
+ tmp
8
+ nbproject
9
+ *.swp
10
+ spec/dummy
11
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2012 [name of plugin creator]
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Spree Carrierwave
2
+
3
+ This is a Spree extension that uploads images to Amazon S3 via [CarrierWave](https://github.com/jnicklas/carrierwave) instead of
4
+ the default [Paperclip](https://github.com/thoughtbot/paperclip).
5
+
6
+ ## Why?
7
+
8
+ The Paperclip gem uses the [aws-s3](https://github.com/marcel/aws-s3) gem, which causes problems
9
+ when used with Spree:
10
+
11
+ superclass mismatch for class PriceBucket (TypeError)
12
+
13
+ Some have claimed to have gotten around this, but the solutions given haven't
14
+ worked for me.
15
+
16
+ # Installation
17
+
18
+ Add `spree_carrierwave` to your Gemfile and `bundle`.
19
+
20
+ # Configuration
21
+
22
+ Create an initializer for CarrierWave
23
+ (`config/initializers/spree_carrierwave.rb`):
24
+
25
+ # See the section titled 'Using Amazon S3' at https://github.com/jnicklas/carrierwave
26
+ # for full options.
27
+ #
28
+ CarrierWave.configure do |config|
29
+ config.fog_credentials = {
30
+ :provider => 'AWS',
31
+ :aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'],
32
+ :aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
33
+ }
34
+ config.fog_directory = 'my-bucket'
35
+ config.fog_attributes = { 'Cache-Control'=>'max-age=315576000' }
36
+ end
37
+
38
+ Enjoy!
39
+
40
+ Copyright (c) 2012 Genuity Technology Services, released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/packagetask'
4
+ require 'rubygems/package_task'
5
+ require 'rspec/core/rake_task'
6
+ require 'spree/core/testing_support/common_rake'
7
+
8
+ RSpec::Core::RakeTask.new
9
+
10
+ task :default => [:spec]
11
+
12
+ spec = eval(File.read('spree_carrierwave.gemspec'))
13
+
14
+ Gem::PackageTask.new(spec) do |p|
15
+ p.gem_spec = spec
16
+ end
17
+
18
+ desc "Release to gemcutter"
19
+ task :release => :package do
20
+ require 'rake/gemcutter'
21
+ Rake::Gemcutter::Tasks.new(spec).define
22
+ Rake::Task['gem:push'].invoke
23
+ end
24
+
25
+ desc "Generates a dummy app for testing"
26
+ task :test_app do
27
+ ENV['LIB_NAME'] = 'spree_carrierwave'
28
+ Rake::Task['common:test_app'].invoke
29
+ end
data/Versionfile ADDED
@@ -0,0 +1 @@
1
+ "1.0.x" => { :tag => "v0.1.0", :version => '0.1.0' }
@@ -0,0 +1,41 @@
1
+ Spree::Image.class_eval do
2
+ class Uploader < CarrierWave::Uploader::Base
3
+ include CarrierWave::Compatibility::Paperclip
4
+ include CarrierWave::MiniMagick
5
+
6
+ storage :fog
7
+
8
+ # Spree looks in attachment#errors, so just delegate to model#errors
9
+ delegate :errors, :to => :model
10
+
11
+ # Match the path defined in Spree::Image
12
+ def paperclip_path
13
+ "assets/products/:id/:style/:basename.:extension"
14
+ end
15
+
16
+ # These are the versions defined in Spree::Image
17
+ version :mini do
18
+ process :resize_to_fill => [48, 48]
19
+ end
20
+
21
+ version :small do
22
+ process :resize_to_fill => [100, 100]
23
+ end
24
+
25
+ version :product do
26
+ process :resize_to_fill => [240, 240]
27
+ end
28
+
29
+ version :large do
30
+ process :resize_to_fill => [600, 600]
31
+ end
32
+ end
33
+
34
+ mount_uploader :attachment, Uploader, :mount_on => :attachment_file_name
35
+
36
+ # Get rid of the paperclip callbacks
37
+
38
+ def save_attached_files; end
39
+ def prepare_for_destroy; end
40
+ def destroy_attached_files; end
41
+ end
@@ -0,0 +1,29 @@
1
+ module SpreeCarrierwave
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ def add_javascripts
6
+ append_file "app/assets/javascripts/store/all.js", "//= require store/spree_carrierwave\n"
7
+ append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_carrierwave\n"
8
+ end
9
+
10
+ def add_stylesheets
11
+ inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_carrierwave\n", :before => /\*\//, :verbose => true
12
+ inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_carrierwave\n", :before => /\*\//, :verbose => true
13
+ end
14
+
15
+ def add_migrations
16
+ run 'bundle exec rake railties:install:migrations FROM=spree_carrierwave'
17
+ end
18
+
19
+ def run_migrations
20
+ res = ask "Would you like to run the migrations now? [Y/n]"
21
+ if res == "" || res.downcase == "y"
22
+ run 'bundle exec rake db:migrate'
23
+ else
24
+ puts "Skiping rake db:migrate, don't forget to run it!"
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ module SpreeCarrierwave
2
+ class Engine < Rails::Engine
3
+ engine_name 'spree_carrierwave'
4
+
5
+ config.autoload_paths += %W(#{config.root}/lib)
6
+
7
+ # use rspec for tests
8
+ config.generators do |g|
9
+ g.test_framework :rspec
10
+ end
11
+
12
+ def self.activate
13
+ Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
14
+ Rails.configuration.cache_classes ? require(c) : load(c)
15
+ end
16
+ end
17
+
18
+ config.to_prepare &method(:activate).to_proc
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module SpreeCarrierwave
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,4 @@
1
+ require 'spree_core'
2
+ require 'carrierwave'
3
+ require 'spree_carrierwave/engine'
4
+ require 'spree_carrierwave/version'
data/script/rails ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ ENGINE_PATH = File.expand_path('../..', __FILE__)
5
+ load File.expand_path('../../spec/dummy/script/rails', __FILE__)
@@ -0,0 +1,25 @@
1
+ # encoding: UTF-8
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "spree_carrierwave/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.platform = Gem::Platform::RUBY
7
+ s.name = 'spree_carrierwave'
8
+ s.version = SpreeCarrierwave::VERSION
9
+ s.summary = 'Spree extension to use carrierwave/fog instead of paperclip.'
10
+ s.description = s.summary
11
+ s.required_ruby_version = '>= 1.8.7'
12
+
13
+ s.author = 'Chad Boyd'
14
+ s.email = 'chad@genuitytech.com'
15
+ s.homepage = 'http://genuitytech.com'
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.require_paths = ['lib/spree_carrierwave']
20
+
21
+ s.add_dependency 'spree_core', '~> 1.0.0.rc1'
22
+ s.add_dependency 'carrierwave', '~> 0.5.8'
23
+ s.add_dependency 'fog', '>= 1.1.2'
24
+ s.add_dependency 'mini_magick', '>= 1.2.5'
25
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_carrierwave
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Chad Boyd
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: spree_core
16
+ requirement: &70195343683300 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0.rc1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70195343683300
25
+ - !ruby/object:Gem::Dependency
26
+ name: carrierwave
27
+ requirement: &70195343682800 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 0.5.8
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70195343682800
36
+ - !ruby/object:Gem::Dependency
37
+ name: fog
38
+ requirement: &70195343682080 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 1.1.2
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70195343682080
47
+ - !ruby/object:Gem::Dependency
48
+ name: mini_magick
49
+ requirement: &70195343681340 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.2.5
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70195343681340
58
+ description: Spree extension to use carrierwave/fog instead of paperclip.
59
+ email: chad@genuitytech.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - .gitignore
65
+ - .rspec
66
+ - Gemfile
67
+ - LICENSE
68
+ - README.md
69
+ - Rakefile
70
+ - Versionfile
71
+ - app/models/spree/image_decorator.rb
72
+ - lib/generators/spree_carrierwave/install/install_generator.rb
73
+ - lib/spree_carrierwave.rb
74
+ - lib/spree_carrierwave/engine.rb
75
+ - lib/spree_carrierwave/version.rb
76
+ - script/rails
77
+ - spree_carrierwave.gemspec
78
+ homepage: http://genuitytech.com
79
+ licenses: []
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib/spree_carrierwave
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: 1.8.7
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 1.8.11
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Spree extension to use carrierwave/fog instead of paperclip.
102
+ test_files: []