watarase 0.0.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 (122) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +156 -0
  4. data/Rakefile +32 -0
  5. data/lib/tasks/watarase_tasks.rake +4 -0
  6. data/lib/watarase.rb +28 -0
  7. data/lib/watarase/controller.rb +49 -0
  8. data/lib/watarase/generators/uploader/uploader_generator.rb +45 -0
  9. data/lib/watarase/model.rb +20 -0
  10. data/lib/watarase/version.rb +3 -0
  11. data/test/dummy/Gemfile +40 -0
  12. data/test/dummy/Gemfile.lock +120 -0
  13. data/test/dummy/README.rdoc +28 -0
  14. data/test/dummy/Rakefile +6 -0
  15. data/test/dummy/app/assets/images/rails.png +0 -0
  16. data/test/dummy/app/assets/javascripts/application.js +16 -0
  17. data/test/dummy/app/assets/javascripts/users.js.coffee +3 -0
  18. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  19. data/test/dummy/app/assets/stylesheets/scaffolds.css.scss +69 -0
  20. data/test/dummy/app/assets/stylesheets/users.css.scss +3 -0
  21. data/test/dummy/app/controllers/application_controller.rb +5 -0
  22. data/test/dummy/app/controllers/users_controller.rb +80 -0
  23. data/test/dummy/app/helpers/application_helper.rb +2 -0
  24. data/test/dummy/app/helpers/users_helper.rb +5 -0
  25. data/test/dummy/app/models/user.rb +4 -0
  26. data/test/dummy/app/models/user_image_holder.rb +18 -0
  27. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  28. data/test/dummy/app/views/users/_form.html.erb +31 -0
  29. data/test/dummy/app/views/users/edit.html.erb +6 -0
  30. data/test/dummy/app/views/users/index.html.erb +31 -0
  31. data/test/dummy/app/views/users/index.json.jbuilder +4 -0
  32. data/test/dummy/app/views/users/new.html.erb +5 -0
  33. data/test/dummy/app/views/users/show.html.erb +10 -0
  34. data/test/dummy/app/views/users/show.json.jbuilder +1 -0
  35. data/test/dummy/bin/bundle +3 -0
  36. data/test/dummy/bin/rails +4 -0
  37. data/test/dummy/bin/rake +4 -0
  38. data/test/dummy/config.ru +4 -0
  39. data/test/dummy/config/application.rb +25 -0
  40. data/test/dummy/config/boot.rb +6 -0
  41. data/test/dummy/config/database.yml +60 -0
  42. data/test/dummy/config/environment.rb +5 -0
  43. data/test/dummy/config/environments/development.rb +27 -0
  44. data/test/dummy/config/environments/production.rb +80 -0
  45. data/test/dummy/config/environments/test.rb +36 -0
  46. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  47. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  48. data/test/dummy/config/initializers/inflections.rb +16 -0
  49. data/test/dummy/config/initializers/mime_types.rb +5 -0
  50. data/test/dummy/config/initializers/secret_token.rb +12 -0
  51. data/test/dummy/config/initializers/session_store.rb +3 -0
  52. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  53. data/test/dummy/config/locales/en.yml +23 -0
  54. data/test/dummy/config/routes.rb +55 -0
  55. data/test/dummy/db/migrate/20130316163018_create_users.rb +11 -0
  56. data/test/dummy/db/migrate/20130318134905_create_user_image_holders.rb +13 -0
  57. data/test/dummy/db/schema.rb +42 -0
  58. data/test/dummy/db/seeds.rb +7 -0
  59. data/test/dummy/log/development.log +6173 -0
  60. data/test/dummy/log/test.log +4039 -0
  61. data/test/dummy/public/404.html +27 -0
  62. data/test/dummy/public/422.html +26 -0
  63. data/test/dummy/public/500.html +26 -0
  64. data/test/dummy/public/favicon.ico +0 -0
  65. data/test/dummy/public/robots.txt +5 -0
  66. data/test/dummy/test/controllers/users_controller_test.rb +59 -0
  67. data/test/dummy/test/fixtures/images/default.png +0 -0
  68. data/test/dummy/test/fixtures/user_image_holders.yml +22 -0
  69. data/test/dummy/test/fixtures/users.yml +7 -0
  70. data/test/dummy/test/helpers/users_helper_test.rb +4 -0
  71. data/test/dummy/test/models/user_image_holder_test.rb +7 -0
  72. data/test/dummy/test/models/user_test.rb +7 -0
  73. data/test/dummy/test/test_helper.rb +15 -0
  74. data/test/dummy/tmp/cache/assets/development/sass/d65fc20612cada6cf950acc42e8249eabf15168c/scaffolds.css.scssc +0 -0
  75. data/test/dummy/tmp/cache/assets/development/sass/d65fc20612cada6cf950acc42e8249eabf15168c/users.css.scssc +0 -0
  76. data/test/dummy/tmp/cache/assets/development/sprockets/10fcfbe6ebae11a40c8eac41939a1b9a +0 -0
  77. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  78. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  79. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  80. data/test/dummy/tmp/cache/assets/development/sprockets/4ad413f3e3326481d2f5f9327bbd0e12 +0 -0
  81. data/test/dummy/tmp/cache/assets/development/sprockets/639464835e9b3e69e17ff82198bb49d4 +0 -0
  82. data/test/dummy/tmp/cache/assets/development/sprockets/6c0f2a2c7346b84a92e2cb81473e251b +0 -0
  83. data/test/dummy/tmp/cache/assets/development/sprockets/85ae64edf528ce6e981889f3f3c285d9 +0 -0
  84. data/test/dummy/tmp/cache/assets/development/sprockets/977ead1d20bc9f7e1c191bd4348f9e3a +0 -0
  85. data/test/dummy/tmp/cache/assets/development/sprockets/981fdf59c6c819da5a85424ee749e704 +0 -0
  86. data/test/dummy/tmp/cache/assets/development/sprockets/af0b8e0d6ae482cd467cf7ca6cf461ba +0 -0
  87. data/test/dummy/tmp/cache/assets/development/sprockets/bd3936370d0f952ada5774e2230046ed +0 -0
  88. data/test/dummy/tmp/cache/assets/development/sprockets/be10cf0a459c2397da8192966ed4ae50 +0 -0
  89. data/test/dummy/tmp/cache/assets/development/sprockets/cf0fb9efef3ee1bf2ea2c3e108dee600 +0 -0
  90. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  91. data/test/dummy/tmp/cache/assets/development/sprockets/d46c90159d299e62b189c080134dba53 +0 -0
  92. data/test/dummy/tmp/cache/assets/development/sprockets/d5c7928882375575ed61c458a61defcf +0 -0
  93. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  94. data/test/dummy/tmp/cache/assets/development/sprockets/df8b2265598a7cf1f0db49c6169b3031 +0 -0
  95. data/test/dummy/tmp/cache/assets/development/sprockets/e2e8f7f4c2e46b20bbaa95d67e83c41e +0 -0
  96. data/test/dummy/tmp/cache/assets/development/sprockets/e459168835a5f27b832ace20874f7c10 +0 -0
  97. data/test/dummy/tmp/cache/assets/development/sprockets/e7726188d3504b41f9ac5e31d1eedea7 +0 -0
  98. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  99. data/test/dummy/tmp/cache/assets/development/sprockets/fb009e9fefe26f5f83de37860988c77d +0 -0
  100. data/test/dummy/tmp/cache/assets/test/sass/d65fc20612cada6cf950acc42e8249eabf15168c/scaffolds.css.scssc +0 -0
  101. data/test/dummy/tmp/cache/assets/test/sass/d65fc20612cada6cf950acc42e8249eabf15168c/users.css.scssc +0 -0
  102. data/test/dummy/tmp/cache/assets/test/sprockets/10fcfbe6ebae11a40c8eac41939a1b9a +0 -0
  103. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  104. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  105. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  106. data/test/dummy/tmp/cache/assets/test/sprockets/4ad413f3e3326481d2f5f9327bbd0e12 +0 -0
  107. data/test/dummy/tmp/cache/assets/test/sprockets/6c0f2a2c7346b84a92e2cb81473e251b +0 -0
  108. data/test/dummy/tmp/cache/assets/test/sprockets/85ae64edf528ce6e981889f3f3c285d9 +0 -0
  109. data/test/dummy/tmp/cache/assets/test/sprockets/977ead1d20bc9f7e1c191bd4348f9e3a +0 -0
  110. data/test/dummy/tmp/cache/assets/test/sprockets/af0b8e0d6ae482cd467cf7ca6cf461ba +0 -0
  111. data/test/dummy/tmp/cache/assets/test/sprockets/bd3936370d0f952ada5774e2230046ed +0 -0
  112. data/test/dummy/tmp/cache/assets/test/sprockets/be10cf0a459c2397da8192966ed4ae50 +0 -0
  113. data/test/dummy/tmp/cache/assets/test/sprockets/cf0fb9efef3ee1bf2ea2c3e108dee600 +0 -0
  114. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  115. data/test/dummy/tmp/cache/assets/test/sprockets/d46c90159d299e62b189c080134dba53 +0 -0
  116. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  117. data/test/dummy/tmp/cache/assets/test/sprockets/e7726188d3504b41f9ac5e31d1eedea7 +0 -0
  118. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  119. data/test/dummy/tmp/cache/assets/test/sprockets/fb009e9fefe26f5f83de37860988c77d +0 -0
  120. data/test/test_helper.rb +27 -0
  121. data/test/watarase_test.rb +27 -0
  122. metadata +316 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b6816958a8af5231d8b1b44cbace43f565a71a0f
4
+ data.tar.gz: a6924e9932f269f1fb02a732e49c72304eed0437
5
+ SHA512:
6
+ metadata.gz: dd29a838bc048ebb4d2203c101a4b6949298d6755e76ad938ce801940e0daebbfa28deca48d5198381bc86c0f5b091ae2e926386647e19a271fc483557657dd2
7
+ data.tar.gz: 747086dbb5ce17339ce21ee3599e947a256a1d5abcd860a72359176be7dd30ca6c0c1971a748a7e49aacb84ad9a1f3254e6be3c9ec4722bf65b306715a66ee37
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 Toshinobu KOBAYASHI
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,156 @@
1
+ = Watarase
2
+
3
+ Watarase is a rails plugin for Image Upload.
4
+
5
+ Images are stored into the database as binary data.
6
+ This plugin is inteded to be handled as a small image of the icon.
7
+
8
+
9
+ == Installation
10
+
11
+ Add to Gemfile following
12
+
13
+ gem 'watarase'
14
+ gem 'rmagick'
15
+
16
+ Now, watarase plugin setting following
17
+
18
+ gem 'watarase', :git => 'git://github.com/kobayashi-tbn/watarase.git'
19
+
20
+
21
+ == Getting Started
22
+
23
+ Any model of the target is present is expected.
24
+
25
+ example
26
+
27
+ rails generate scaffold user username:string email:string
28
+
29
+ That model is the image handler.
30
+
31
+ Generate image holder. This is a model that is made separately.
32
+
33
+ rails generate watarase:uploader user
34
+
35
+ The generator made UserImageHolder the model class and the migration file.
36
+
37
+ Example of migration file is following.
38
+
39
+ class CreateUserImageHolders < ActiveRecord::Migration
40
+ def change
41
+ create_table :user_image_holders do |t|
42
+ t.string :user_username
43
+ t.string :filename
44
+ t.string :content_type
45
+ t.binary :image_data
46
+ t.binary :image_thumb
47
+
48
+ t.timestamps
49
+ end
50
+ end
51
+ end
52
+
53
+ In this case, the foreign key 'user_username' is type :string.
54
+ It was named {model name}_{pk} automatically.
55
+
56
+ == Active Record
57
+
58
+ Define 'acts_as_image_hander' into Image handler model (ex. User).
59
+
60
+ class User
61
+ self.primary_key :username # if this model's PK was 'username'.
62
+ acts_as_image_handler # define image hander
63
+ end
64
+
65
+ == Routing
66
+
67
+ Add 'load_image' action in 'config/routes.rb'
68
+
69
+ resources :users do
70
+ member do
71
+ get 'load_image'
72
+ end
73
+ end
74
+
75
+ == Controller
76
+
77
+ Define 'image_loadable <image_handler>' definition in controllers.
78
+
79
+ class UsersController < ApplicationController
80
+ image_loadable :user
81
+ :
82
+
83
+ Set image holder to image handler by method 'set_iamge_holder'.
84
+
85
+ def create
86
+ @user = User.new(user_params)
87
+ set_image_holder @user
88
+ :
89
+
90
+ def update
91
+ set_image_holder @user
92
+ :
93
+
94
+ == View
95
+
96
+ Examples _form.html.erb for User
97
+
98
+ <%= form_for(@user) do |f| %>
99
+ <% if @user.errors.any? %>
100
+ <div id="error_explanation">
101
+ <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
102
+
103
+ <ul>
104
+ <% @user.errors.full_messages.each do |msg| %>
105
+ <li><%= msg %></li>
106
+ <% end %>
107
+ </ul>
108
+ </div>
109
+ <% end %>
110
+
111
+ <div class="field">
112
+ <%= f.label :username %><br />
113
+ <%= f.text_field :username %>
114
+ </div>
115
+ <div class="field">
116
+ <%= f.label :email %><br />
117
+ <%= f.text_field :email %>
118
+ </div>
119
+ <div class="field">
120
+ <%= f.label :image_file %><br />
121
+ <%= f.file_field :image_file %>
122
+ </div>
123
+ <% unless @user.new_record? %>
124
+ <div class="field">
125
+ <%= f.check_box :remove_image %>
126
+ <%= f.label :remove_image %><br />
127
+ </div>
128
+ <% end %>
129
+ <div class="actions">
130
+ <%= f.submit %>
131
+ </div>
132
+ <% end %>
133
+
134
+ Add file_field form, and check box for remove the image.
135
+ Parameter name is fixed, :image_file and :remove_image.
136
+
137
+ Examples image load in index.html.erb
138
+
139
+ <% @users.each do |user| %>
140
+ <tr>
141
+ <td><%= image_tag image_thumb_path user if user.user_image_holder %></td>
142
+ <td><%= user.username %></td>
143
+ <td><%= link_to 'Show', user %></td>
144
+ <td><%= link_to 'Edit', edit_user_path(user) %></td>
145
+ <td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
146
+ </tr>
147
+ <% end %>
148
+
149
+
150
+ == TODO
151
+
152
+ * Configuring parameters for plugin settings.
153
+ * Secure upload by file extentions.
154
+
155
+
156
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Watarase'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+
32
+ task default: :test
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :watarase do
3
+ # # Task goes here
4
+ # end
data/lib/watarase.rb ADDED
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require 'RMagick'
3
+ #require 'rmagick'
4
+ require 'rails/generators'
5
+
6
+ module Watarase
7
+
8
+ @@suffix = "image_holder"
9
+
10
+ def self.suffix
11
+ @@suffix
12
+ end
13
+
14
+ def self.suffix=(_suffix)
15
+ @@suffix = _suffix
16
+ end
17
+ end
18
+
19
+ module Watarase
20
+ module Generators
21
+ class Base < Rails::Generators::NamedBase
22
+ #source_root File.expand_path(File.join(File.dirname(__FILE__), "watarase", "generator", "uploader", "template"))
23
+ end
24
+ end
25
+ end
26
+ require 'watarase/model'
27
+ require 'watarase/controller'
28
+ require 'watarase/generators/uploader/uploader_generator'
@@ -0,0 +1,49 @@
1
+ module Watarase
2
+ module Controller
3
+ def self.included(controller)
4
+ controller.extend Watarase::ImageLoader
5
+ end
6
+ end
7
+
8
+ module ImageLoader
9
+ def image_loadable(_image_handler, options = {})
10
+ ih = _image_handler.to_s.camelize.constantize
11
+ self.class_variable_set(:@@image_handler, ih)
12
+ self.send(:include, Watarase::InstanceMethods)
13
+ self.send(:helper_method, :image_thumb_path)
14
+ end
15
+ end
16
+
17
+ module InstanceMethods
18
+ def load_image
19
+ #image = "#{image_handler}_image".camelize.constantize.find(params[:id])
20
+ image = image_holder.find(params[:id])
21
+ column_name = :"#{(params[:image_column] || :image_data)}"
22
+ send_data image.send(column_name), type: image.content_type, disposition: 'inline'
23
+ end
24
+
25
+ def image_params
26
+ params.require(image_handler.name.underscore.to_sym).permit(:image_file, :remove_image)
27
+ end
28
+
29
+ def image_handler
30
+ self.class.class_variable_get(:@@image_handler)
31
+ end
32
+
33
+ def image_holder
34
+ "#{image_handler.name.underscore}_#{Watarase.suffix}".camelize.constantize
35
+ end
36
+
37
+ def image_thumb_path(model)
38
+ url_for(controller: image_handler.name.downcase!.pluralize, action: 'load_image', id: model.send(:"#{image_holder.name.underscore}").id, image_column: :image_thumb)
39
+ end
40
+
41
+ # Call before create, update
42
+ def set_image_holder(_image_handler)
43
+ _image_handler.send(:"#{image_holder.name.underscore}=", image_holder.new) unless _image_handler.send(:"#{image_holder.name.underscore}")
44
+ _image_handler.send(:"#{image_holder.name.underscore}").uploaded_image = image_params
45
+ end
46
+ end
47
+ end
48
+
49
+ ActionController::Base.send :include, Watarase::Controller unless ActionController::Base.include? Watarase::Controller
@@ -0,0 +1,45 @@
1
+ module Watarase
2
+ module Generators
3
+ class UploaderGenerator < Base
4
+ def create_image_holder
5
+ image_handler = file_name.camelcase.constantize
6
+ fk = image_handler.primary_key
7
+ fk_type = ((image_handler.respond_to? :columns) ? image_handler.columns.select{|column| column.name == fk}.first.type : :integer)
8
+ model_name = "#{file_name}_#{Watarase.suffix}"
9
+
10
+ # RMagick
11
+ str_include = " include Magick unless self.include? Magick\n"
12
+
13
+ # Associations
14
+ str_belongs_to = " belongs_to :#{file_name}, primary_key: :#{fk}, foreign_key: :#{file_name}_#{fk}\n"
15
+
16
+ # Instance Methods
17
+ str_methods = <<-CODE
18
+
19
+ def uploaded_image= (image_params)
20
+ if image_params[:remove_image] && image_params[:remove_image] == "1"
21
+ self.destroy
22
+ elsif image_params[:image_file] && !image_params[:image_file].blank?
23
+ self.filename = image_params[:image_file].original_filename
24
+ self.content_type = image_params[:image_file].content_type
25
+ data = image_params[:image_file].tempfile.read
26
+ self.image_data = Image.from_blob(data).first.resize_to_fit(100, 100).to_blob
27
+ self.image_thumb = Image.from_blob(data).first.thumbnail(35, 35).to_blob
28
+ elsif self.new_record?
29
+ self.destroy
30
+ end
31
+ end
32
+
33
+ def extension_white_list
34
+ %w(jpg jpeg gif png)
35
+ end
36
+ CODE
37
+
38
+ generate "model", "#{model_name} #{file_name}_#{fk}:#{fk_type} filename:string content_type:string image_data:binary image_thumb:binary"
39
+ inject_into_class "app/models/#{model_name}.rb", model_name.camelcase.constantize do
40
+ str_include << str_belongs_to << str_methods
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,20 @@
1
+ require 'active_record/base'
2
+
3
+ module Watarase
4
+ module Model
5
+ def self.included(model)
6
+ model.extend Watarase::ActsAsImageHandler
7
+ end
8
+ end
9
+
10
+ module ActsAsImageHandler
11
+ def acts_as_image_handler
12
+ _image_holder = (self.name.underscore << '_' << Watarase.suffix).to_sym
13
+ self.send(:has_one, _image_holder, primary_key: self.primary_key, foreign_key: "#{self.name.underscore}_#{self.primary_key}", autosave: true)
14
+ self.send(:attr_accessor, :remove_image)
15
+ end
16
+ end
17
+ end
18
+
19
+ ActiveRecord::Base.send :include, Watarase::Model unless ActiveRecord::Base.include? Watarase::Model
20
+
@@ -0,0 +1,3 @@
1
+ module Watarase
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,40 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
4
+ gem 'rails', '4.0.0.beta1'
5
+
6
+ gem 'pg'
7
+
8
+ # Gems used only for assets and not required
9
+ # in production environments by default.
10
+ group :assets do
11
+ gem 'sass-rails', '~> 4.0.0.beta1'
12
+ gem 'coffee-rails', '~> 4.0.0.beta1'
13
+
14
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
15
+ # gem 'therubyracer', platforms: :ruby
16
+
17
+ gem 'uglifier', '>= 1.0.3'
18
+ end
19
+
20
+ gem 'jquery-rails'
21
+
22
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
23
+ gem 'turbolinks'
24
+
25
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
26
+ gem 'jbuilder', '~> 1.0.1'
27
+
28
+ # To use ActiveModel has_secure_password
29
+ # gem 'bcrypt-ruby', '~> 3.0.0'
30
+
31
+ # Use unicorn as the app server
32
+ # gem 'unicorn'
33
+
34
+ # Deploy with Capistrano
35
+ # gem 'capistrano', group: :development
36
+
37
+ # To use debugger
38
+ # gem 'debugger'
39
+
40
+ gem 'rmagick'
@@ -0,0 +1,120 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ actionmailer (4.0.0.beta1)
5
+ actionpack (= 4.0.0.beta1)
6
+ mail (~> 2.5.3)
7
+ actionpack (4.0.0.beta1)
8
+ activesupport (= 4.0.0.beta1)
9
+ builder (~> 3.1.0)
10
+ erubis (~> 2.7.0)
11
+ rack (~> 1.5.2)
12
+ rack-test (~> 0.6.2)
13
+ activemodel (4.0.0.beta1)
14
+ activesupport (= 4.0.0.beta1)
15
+ builder (~> 3.1.0)
16
+ activerecord (4.0.0.beta1)
17
+ activemodel (= 4.0.0.beta1)
18
+ activerecord-deprecated_finders (~> 0.0.3)
19
+ activesupport (= 4.0.0.beta1)
20
+ arel (~> 4.0.0.beta1)
21
+ activerecord-deprecated_finders (0.0.3)
22
+ activesupport (4.0.0.beta1)
23
+ i18n (~> 0.6.2)
24
+ minitest (~> 4.2)
25
+ multi_json (~> 1.3)
26
+ thread_safe (~> 0.1)
27
+ tzinfo (~> 0.3.33)
28
+ arel (4.0.0.beta1)
29
+ atomic (1.0.1)
30
+ builder (3.1.4)
31
+ coffee-rails (4.0.0.beta1)
32
+ coffee-script (>= 2.2.0)
33
+ railties (>= 4.0.0.beta, < 5.0)
34
+ coffee-script (2.2.0)
35
+ coffee-script-source
36
+ execjs
37
+ coffee-script-source (1.5.0)
38
+ erubis (2.7.0)
39
+ execjs (1.4.0)
40
+ multi_json (~> 1.0)
41
+ hike (1.2.1)
42
+ i18n (0.6.4)
43
+ jbuilder (1.0.2)
44
+ activesupport (>= 3.0.0)
45
+ jquery-rails (2.2.1)
46
+ railties (>= 3.0, < 5.0)
47
+ thor (>= 0.14, < 2.0)
48
+ json (1.7.7)
49
+ mail (2.5.3)
50
+ i18n (>= 0.4.0)
51
+ mime-types (~> 1.16)
52
+ treetop (~> 1.4.8)
53
+ mime-types (1.21)
54
+ minitest (4.6.2)
55
+ multi_json (1.6.1)
56
+ pg (0.14.1)
57
+ polyglot (0.3.3)
58
+ rack (1.5.2)
59
+ rack-test (0.6.2)
60
+ rack (>= 1.0)
61
+ rails (4.0.0.beta1)
62
+ actionmailer (= 4.0.0.beta1)
63
+ actionpack (= 4.0.0.beta1)
64
+ activerecord (= 4.0.0.beta1)
65
+ activesupport (= 4.0.0.beta1)
66
+ bundler (>= 1.3.0, < 2.0)
67
+ railties (= 4.0.0.beta1)
68
+ sprockets-rails (~> 2.0.0.rc3)
69
+ railties (4.0.0.beta1)
70
+ actionpack (= 4.0.0.beta1)
71
+ activesupport (= 4.0.0.beta1)
72
+ rake (>= 0.8.7)
73
+ rdoc (~> 3.4)
74
+ thor (>= 0.17.0, < 2.0)
75
+ rake (10.0.3)
76
+ rdoc (3.12.2)
77
+ json (~> 1.4)
78
+ rmagick (2.13.2)
79
+ sass (3.2.6)
80
+ sass-rails (4.0.0.beta1)
81
+ railties (>= 4.0.0.beta, < 5.0)
82
+ sass (>= 3.1.10)
83
+ sprockets-rails (~> 2.0.0.rc0)
84
+ tilt (~> 1.3)
85
+ sprockets (2.9.0)
86
+ hike (~> 1.2)
87
+ multi_json (~> 1.0)
88
+ rack (~> 1.0)
89
+ tilt (~> 1.1, != 1.3.0)
90
+ sprockets-rails (2.0.0.rc3)
91
+ actionpack (>= 3.0)
92
+ activesupport (>= 3.0)
93
+ sprockets (~> 2.8)
94
+ thor (0.17.0)
95
+ thread_safe (0.1.0)
96
+ atomic
97
+ tilt (1.3.4)
98
+ treetop (1.4.12)
99
+ polyglot
100
+ polyglot (>= 0.3.1)
101
+ turbolinks (1.0.0)
102
+ coffee-rails
103
+ tzinfo (0.3.36)
104
+ uglifier (1.3.0)
105
+ execjs (>= 0.3.0)
106
+ multi_json (~> 1.0, >= 1.0.2)
107
+
108
+ PLATFORMS
109
+ ruby
110
+
111
+ DEPENDENCIES
112
+ coffee-rails (~> 4.0.0.beta1)
113
+ jbuilder (~> 1.0.1)
114
+ jquery-rails
115
+ pg
116
+ rails (= 4.0.0.beta1)
117
+ rmagick
118
+ sass-rails (~> 4.0.0.beta1)
119
+ turbolinks
120
+ uglifier (>= 1.0.3)