upyun-paperclip 0.1 → 0.1.2

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.
Files changed (85) hide show
  1. data/.gitignore +10 -0
  2. data/Gemfile +4 -0
  3. data/README.md +30 -0
  4. data/Rakefile +1 -0
  5. data/lib/paperclip/storage/upyun.rb +67 -0
  6. data/lib/upyun-paperclip.rb +3 -0
  7. data/lib/upyun-paperclip/version.rb +5 -0
  8. data/spec/dummy/.gitignore +15 -0
  9. data/spec/dummy/Gemfile +42 -0
  10. data/spec/dummy/README +261 -0
  11. data/spec/dummy/Rakefile +7 -0
  12. data/spec/dummy/app/assets/images/rails.png +0 -0
  13. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  14. data/spec/dummy/app/assets/javascripts/home.js.coffee +3 -0
  15. data/spec/dummy/app/assets/javascripts/users.js.coffee +3 -0
  16. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  17. data/spec/dummy/app/assets/stylesheets/home.css.scss +3 -0
  18. data/spec/dummy/app/assets/stylesheets/users.css.scss +3 -0
  19. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  20. data/spec/dummy/app/controllers/home_controller.rb +5 -0
  21. data/spec/dummy/app/controllers/users_controller.rb +43 -0
  22. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  23. data/spec/dummy/app/helpers/error_messages_helper.rb +23 -0
  24. data/spec/dummy/app/helpers/home_helper.rb +2 -0
  25. data/spec/dummy/app/helpers/layout_helper.rb +22 -0
  26. data/spec/dummy/app/helpers/users_helper.rb +2 -0
  27. data/spec/dummy/app/mailers/.gitkeep +0 -0
  28. data/spec/dummy/app/models/.gitkeep +0 -0
  29. data/spec/dummy/app/models/user.rb +21 -0
  30. data/spec/dummy/app/views/home/index.html.erb +2 -0
  31. data/spec/dummy/app/views/layouts/application.html.erb +19 -0
  32. data/spec/dummy/app/views/users/_form.html.erb +10 -0
  33. data/spec/dummy/app/views/users/edit.html.erb +8 -0
  34. data/spec/dummy/app/views/users/index.html.erb +17 -0
  35. data/spec/dummy/app/views/users/new.html.erb +5 -0
  36. data/spec/dummy/app/views/users/show.html.erb +12 -0
  37. data/spec/dummy/config.ru +4 -0
  38. data/spec/dummy/config/application.rb +48 -0
  39. data/spec/dummy/config/boot.rb +6 -0
  40. data/spec/dummy/config/database.yml +25 -0
  41. data/spec/dummy/config/environment.rb +5 -0
  42. data/spec/dummy/config/environments/development.rb +30 -0
  43. data/spec/dummy/config/environments/production.rb +60 -0
  44. data/spec/dummy/config/environments/test.rb +39 -0
  45. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  46. data/spec/dummy/config/initializers/inflections.rb +10 -0
  47. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  48. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  49. data/spec/dummy/config/initializers/session_store.rb +8 -0
  50. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  51. data/spec/dummy/config/locales/en.yml +5 -0
  52. data/spec/dummy/config/routes.rb +62 -0
  53. data/spec/dummy/db/migrate/20120102013503_create_users.rb +9 -0
  54. data/spec/dummy/db/migrate/20120102013543_add_avatar_to_user.rb +12 -0
  55. data/spec/dummy/db/schema.rb +26 -0
  56. data/spec/dummy/db/seeds.rb +7 -0
  57. data/spec/dummy/doc/README_FOR_APP +2 -0
  58. data/spec/dummy/lib/assets/.gitkeep +0 -0
  59. data/spec/dummy/lib/tasks/.gitkeep +0 -0
  60. data/spec/dummy/log/.gitkeep +0 -0
  61. data/spec/dummy/public/404.html +26 -0
  62. data/spec/dummy/public/422.html +26 -0
  63. data/spec/dummy/public/500.html +26 -0
  64. data/spec/dummy/public/favicon.ico +0 -0
  65. data/spec/dummy/public/robots.txt +5 -0
  66. data/spec/dummy/public/stylesheets/application.css +75 -0
  67. data/spec/dummy/script/rails +6 -0
  68. data/spec/dummy/test/fixtures/.gitkeep +0 -0
  69. data/spec/dummy/test/fixtures/users.yml +5 -0
  70. data/spec/dummy/test/functional/.gitkeep +0 -0
  71. data/spec/dummy/test/functional/home_controller_test.rb +9 -0
  72. data/spec/dummy/test/functional/users_controller_test.rb +54 -0
  73. data/spec/dummy/test/integration/.gitkeep +0 -0
  74. data/spec/dummy/test/performance/browsing_test.rb +12 -0
  75. data/spec/dummy/test/test_helper.rb +13 -0
  76. data/spec/dummy/test/unit/.gitkeep +0 -0
  77. data/spec/dummy/test/unit/helpers/home_helper_test.rb +4 -0
  78. data/spec/dummy/test/unit/helpers/users_helper_test.rb +4 -0
  79. data/spec/dummy/test/unit/user_test.rb +7 -0
  80. data/spec/dummy/vendor/assets/stylesheets/.gitkeep +0 -0
  81. data/spec/dummy/vendor/plugins/.gitkeep +0 -0
  82. data/spec/upyun_paperclip_spec.rb +6 -0
  83. data/upyun-paperclip.gemspec +27 -0
  84. metadata +208 -11
  85. data/lib/upyun.rb +0 -5
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,9 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require_tree .
@@ -0,0 +1,3 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
@@ -0,0 +1,3 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require_tree .
7
+ */
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the home controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the users controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,5 @@
1
+ class HomeController < ApplicationController
2
+ def index
3
+ end
4
+
5
+ end
@@ -0,0 +1,43 @@
1
+ class UsersController < ApplicationController
2
+ def index
3
+ @users = User.all
4
+ end
5
+
6
+ def show
7
+ @user = User.find(params[:id])
8
+ end
9
+
10
+ def new
11
+ @user = User.new
12
+ end
13
+
14
+ def create
15
+ @user = User.new(params[:user])
16
+ @user.avatar = params[:user][:avatar]
17
+ if @user.save
18
+ redirect_to @user, :notice => "Successfully created user."
19
+ else
20
+ render :action => 'new'
21
+ end
22
+ end
23
+
24
+ def edit
25
+ @user = User.find(params[:id])
26
+ end
27
+
28
+ def update
29
+ @user = User.find(params[:id])
30
+ @user.avatar = params[:user][:avatar]
31
+ if @user.update_attributes(params[:user])
32
+ redirect_to @user, :notice => "Successfully updated user."
33
+ else
34
+ render :action => 'edit'
35
+ end
36
+ end
37
+
38
+ def destroy
39
+ @user = User.find(params[:id])
40
+ @user.destroy
41
+ redirect_to users_url, :notice => "Successfully destroyed user."
42
+ end
43
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,23 @@
1
+ module ErrorMessagesHelper
2
+ # Render error messages for the given objects. The :message and :header_message options are allowed.
3
+ def error_messages_for(*objects)
4
+ options = objects.extract_options!
5
+ options[:header_message] ||= I18n.t(:"activerecord.errors.header", :default => "Invalid Fields")
6
+ options[:message] ||= I18n.t(:"activerecord.errors.message", :default => "Correct the following errors and try again.")
7
+ messages = objects.compact.map { |o| o.errors.full_messages }.flatten
8
+ unless messages.empty?
9
+ content_tag(:div, :class => "error_messages") do
10
+ list_items = messages.map { |msg| content_tag(:li, msg) }
11
+ content_tag(:h2, options[:header_message]) + content_tag(:p, options[:message]) + content_tag(:ul, list_items.join.html_safe)
12
+ end
13
+ end
14
+ end
15
+
16
+ module FormBuilderAdditions
17
+ def error_messages(options = {})
18
+ @template.error_messages_for(@object, options)
19
+ end
20
+ end
21
+ end
22
+
23
+ ActionView::Helpers::FormBuilder.send(:include, ErrorMessagesHelper::FormBuilderAdditions)
@@ -0,0 +1,2 @@
1
+ module HomeHelper
2
+ end
@@ -0,0 +1,22 @@
1
+ # These helper methods can be called in your template to set variables to be used in the layout
2
+ # This module should be included in all views globally,
3
+ # to do so you may need to add this line to your ApplicationController
4
+ # helper :layout
5
+ module LayoutHelper
6
+ def title(page_title, show_title = true)
7
+ content_for(:title) { h(page_title.to_s) }
8
+ @show_title = show_title
9
+ end
10
+
11
+ def show_title?
12
+ @show_title
13
+ end
14
+
15
+ def stylesheet(*args)
16
+ content_for(:head) { stylesheet_link_tag(*args) }
17
+ end
18
+
19
+ def javascript(*args)
20
+ content_for(:head) { javascript_include_tag(*args) }
21
+ end
22
+ end
@@ -0,0 +1,2 @@
1
+ module UsersHelper
2
+ end
File without changes
File without changes
@@ -0,0 +1,21 @@
1
+ class User < ActiveRecord::Base
2
+ attr_accessible :name
3
+
4
+ has_attached_file :avatar,
5
+ {
6
+ :storage => :upyun,
7
+
8
+ # To run this test, please set the correct options.
9
+ :upyun_bucketname => 'bucketname',
10
+ :upyun_username => 'username',
11
+ :upyun_password => 'password',
12
+ :upyun_domain => 'domain',
13
+
14
+
15
+ # :url => "/system/images/:hash.:extension",
16
+ # :hash_secret => "SKDLJKLJKIIoiuoijksdfjjiJIOJLKJKJjlkj",
17
+ # :use_timestamp => false,
18
+
19
+ :styles => { :medium => "300x300>", :thumb => "100x100>" }
20
+ }
21
+ end
@@ -0,0 +1,2 @@
1
+ <h1>Home#index</h1>
2
+ <p>Find me in app/views/home/index.html.erb</p>
@@ -0,0 +1,19 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= content_for?(:title) ? yield(:title) : "Untitled" %></title>
5
+ <%= stylesheet_link_tag "application" %>
6
+ <%= javascript_include_tag :defaults %>
7
+ <%= csrf_meta_tag %>
8
+ <%= yield(:head) %>
9
+ </head>
10
+ <body>
11
+ <div id="container">
12
+ <% flash.each do |name, msg| %>
13
+ <%= content_tag :div, msg, :id => "flash_#{name}" %>
14
+ <% end %>
15
+ <%= content_tag :h1, yield(:title) if show_title? %>
16
+ <%= yield %>
17
+ </div>
18
+ </body>
19
+ </html>
@@ -0,0 +1,10 @@
1
+ <%= form_for @user, :html => { :multipart => true } do |f| %>
2
+
3
+ <%= f.error_messages %>
4
+ <p>
5
+ <%= f.label :name %><br />
6
+ <%= f.text_field :name %>
7
+ </p>
8
+ <%= f.file_field :avatar %>
9
+ <p><%= f.submit %></p>
10
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <% title "Edit User" %>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <p>
6
+ <%= link_to "Show", @user %> |
7
+ <%= link_to "View All", users_path %>
8
+ </p>
@@ -0,0 +1,17 @@
1
+ <% title "Users" %>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ </tr>
7
+ <% for user in @users %>
8
+ <tr>
9
+ <td><%= user.name %></td>
10
+ <td><%= link_to "Show", user %></td>
11
+ <td><%= link_to "Edit", edit_user_path(user) %></td>
12
+ <td><%= link_to "Destroy", user, :confirm => 'Are you sure?', :method => :delete %></td>
13
+ </tr>
14
+ <% end %>
15
+ </table>
16
+
17
+ <p><%= link_to "New User", new_user_path %></p>
@@ -0,0 +1,5 @@
1
+ <% title "New User" %>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <p><%= link_to "Back to List", users_path %></p>
@@ -0,0 +1,12 @@
1
+ <% title "User" %>
2
+
3
+ <p>
4
+ <strong>Name:</strong>
5
+ <%= @user.name %>
6
+ </p>
7
+ <%= image_tag @user.avatar.path(:medium) %>
8
+ <p>
9
+ <%= link_to "Edit", edit_user_path(@user) %> |
10
+ <%= link_to "Destroy", @user, :confirm => 'Are you sure?', :method => :delete %> |
11
+ <%= link_to "View All", users_path %>
12
+ </p>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,48 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ if defined?(Bundler)
6
+ # If you precompile assets before deploying to production, use this line
7
+ Bundler.require(*Rails.groups(:assets => %w(development test)))
8
+ # If you want your assets lazily compiled in production, use this line
9
+ # Bundler.require(:default, :assets, Rails.env)
10
+ end
11
+
12
+ module Dummy
13
+ class Application < Rails::Application
14
+ # Settings in config/environments/* take precedence over those specified here.
15
+ # Application configuration should go into files in config/initializers
16
+ # -- all .rb files in that directory are automatically loaded.
17
+
18
+ # Custom directories with classes and modules you want to be autoloadable.
19
+ # config.autoload_paths += %W(#{config.root}/extras)
20
+
21
+ # Only load the plugins named here, in the order given (default is alphabetical).
22
+ # :all can be used as a placeholder for all plugins not explicitly named.
23
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
24
+
25
+ # Activate observers that should always be running.
26
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
27
+
28
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
29
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
30
+ # config.time_zone = 'Central Time (US & Canada)'
31
+
32
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
33
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
34
+ # config.i18n.default_locale = :de
35
+
36
+ # Configure the default encoding used in templates for Ruby 1.9.
37
+ config.encoding = "utf-8"
38
+
39
+ # Configure sensitive parameters which will be filtered from the log file.
40
+ config.filter_parameters += [:password]
41
+
42
+ # Enable the asset pipeline
43
+ config.assets.enabled = true
44
+
45
+ # Version of your assets, change this if you want to expire all your assets
46
+ config.assets.version = '1.0'
47
+ end
48
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+
3
+ # Set up gems listed in the Gemfile.
4
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
5
+
6
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/upyun_paperclip_development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/upyun_paperclip_test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/upyun_paperclip_porduction.sqlite3
24
+ pool: 5
25
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the rails application
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the rails application
5
+ Dummy::Application.initialize!
@@ -0,0 +1,30 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger
20
+ config.active_support.deprecation = :log
21
+
22
+ # Only use best-standards-support built into browsers
23
+ config.action_dispatch.best_standards_support = :builtin
24
+
25
+ # Do not compress assets
26
+ config.assets.compress = false
27
+
28
+ # Expands the lines which load the assets
29
+ config.assets.debug = true
30
+ end
@@ -0,0 +1,60 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb
3
+
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Full error reports are disabled and caching is turned on
8
+ config.consider_all_requests_local = false
9
+ config.action_controller.perform_caching = true
10
+
11
+ # Disable Rails's static asset server (Apache or nginx will already do this)
12
+ config.serve_static_assets = false
13
+
14
+ # Compress JavaScripts and CSS
15
+ config.assets.compress = true
16
+
17
+ # Don't fallback to assets pipeline if a precompiled asset is missed
18
+ config.assets.compile = false
19
+
20
+ # Generate digests for assets URLs
21
+ config.assets.digest = true
22
+
23
+ # Defaults to Rails.root.join("public/assets")
24
+ # config.assets.manifest = YOUR_PATH
25
+
26
+ # Specifies the header that your server uses for sending files
27
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
29
+
30
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
+ # config.force_ssl = true
32
+
33
+ # See everything in the log (default is :info)
34
+ # config.log_level = :debug
35
+
36
+ # Use a different logger for distributed setups
37
+ # config.logger = SyslogLogger.new
38
+
39
+ # Use a different cache store in production
40
+ # config.cache_store = :mem_cache_store
41
+
42
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server
43
+ # config.action_controller.asset_host = "http://assets.example.com"
44
+
45
+ # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
46
+ # config.assets.precompile += %w( search.js )
47
+
48
+ # Disable delivery errors, bad email addresses will be ignored
49
+ # config.action_mailer.raise_delivery_errors = false
50
+
51
+ # Enable threaded mode
52
+ # config.threadsafe!
53
+
54
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
55
+ # the I18n.default_locale when a translation can not be found)
56
+ config.i18n.fallbacks = true
57
+
58
+ # Send deprecation notices to registered listeners
59
+ config.active_support.deprecation = :notify
60
+ end