meskyanichi-generators 0.3.3 → 0.4.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/CHANGELOG +6 -1
- data/README.rdoc +26 -0
- data/VERSION.yml +2 -2
- data/generators/paperclip_template/paperclip_template_generator.rb +24 -0
- data/generators/paperclip_template/templates/model.rb +16 -0
- data/generators.gemspec +3 -1
- metadata +3 -1
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
Meskyanichi - Generators |0.4.0|
|
2
|
+
-----------------------------------------------------------
|
3
|
+
|
4
|
+
- Added a simple Paperclip "get up and running" template.
|
5
|
+
- Updated Readme
|
6
|
+
|
1
7
|
|
2
8
|
Meskyanichi - Generators |0.3.3|
|
3
9
|
-----------------------------------------------------------
|
@@ -5,7 +11,6 @@
|
|
5
11
|
- Extracted 3 symlink tasks and merged them into a single task.
|
6
12
|
|
7
13
|
|
8
|
-
|
9
14
|
Meskyanichi - Generators |0.3.2|
|
10
15
|
-----------------------------------------------------------
|
11
16
|
|
data/README.rdoc
CHANGED
@@ -143,6 +143,32 @@ The default ignoration rules that are added to the main .gitignore file located
|
|
143
143
|
public/assets
|
144
144
|
|
145
145
|
|
146
|
+
|
147
|
+
== The Paperclip Template
|
148
|
+
|
149
|
+
This generator simply generates a model file with a few options to get you up and running.
|
150
|
+
|
151
|
+
script/generate paperclip_template ModelName AttachmentName
|
152
|
+
|
153
|
+
Example:
|
154
|
+
|
155
|
+
script/generate paperclip_template Product image
|
156
|
+
|
157
|
+
The example above will generate a model named Product, stored in the file "product.rb". This file contains a few simple Paperclip options
|
158
|
+
like validation, the upload location, a few image resize examples incase you are working with images, etc.
|
159
|
+
|
160
|
+
If you are using Paperclip and need the database migration attributes, Paperclip provides it's own generator to do just that!
|
161
|
+
|
162
|
+
script/generate paperclip Model Attachment
|
163
|
+
|
164
|
+
If you have multiple attachments, you can append these as additional arguments like so:
|
165
|
+
|
166
|
+
script/generate paperclip Model Attachment1 Attachment2 Attachment3 etc..
|
167
|
+
|
168
|
+
This will generate a migration file containing the necessary table attributes.
|
169
|
+
|
170
|
+
|
171
|
+
|
146
172
|
== Rake Tasks
|
147
173
|
|
148
174
|
This generator gem includes a few rake tasks that might also help you get up and running faster.
|
data/VERSION.yml
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
class PaperclipTemplateGenerator < Rails::Generator::Base
|
2
|
+
|
3
|
+
def initialize(runtime_args, runtime_options = {})
|
4
|
+
super
|
5
|
+
|
6
|
+
@model_name = @args[0] || "MyModel"
|
7
|
+
@attachment_name = @args[1] || "MyAttachment"
|
8
|
+
end
|
9
|
+
|
10
|
+
def manifest
|
11
|
+
record do |m|
|
12
|
+
m.template "model.rb", "app/models/#{model_name.underscore}.rb"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def model_name
|
17
|
+
@model_name.singularize
|
18
|
+
end
|
19
|
+
|
20
|
+
def attachment_name
|
21
|
+
@attachment_name.singularize
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class <%= model_name.camelize %> < ActiveRecord::Base
|
2
|
+
|
3
|
+
has_attached_file :<%= attachment_name.underscore %>,
|
4
|
+
:styles => {
|
5
|
+
:small => '100x100#',
|
6
|
+
:medium => '200x200>',
|
7
|
+
:large => '300x300>'
|
8
|
+
},
|
9
|
+
:url => "/assets/images/:style/:id.:basename.:extension",
|
10
|
+
:path => ":rails_root/public/assets/images/:style/:id.:basename.:extension"
|
11
|
+
|
12
|
+
validates_attachment_presence :<%= attachment_name.underscore %>
|
13
|
+
validates_attachment_size :<%= attachment_name.underscore %>, :less_than => 5.megabytes
|
14
|
+
validates_attachment_content_type :<%= attachment_name.underscore %>, :content_type => ['image/jpeg', 'image/png']
|
15
|
+
|
16
|
+
end
|
data/generators.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{generators}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.4.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Michael"]
|
@@ -30,6 +30,8 @@ Gem::Specification.new do |s|
|
|
30
30
|
"generators/rake_tasks/.gitignore",
|
31
31
|
"generators/rake_tasks/repository/repository_rake_tasks_generator.rb",
|
32
32
|
"generators/rake_tasks/repository/templates/repository.rake",
|
33
|
+
"generators/paperclip_template/paperclip_template_generator.rb",
|
34
|
+
"generators/paperclip_template/templates/model.rb",
|
33
35
|
"lib/generators.rb",
|
34
36
|
"test/generators_test.rb",
|
35
37
|
"test/test_helper.rb"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meskyanichi-generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael
|
@@ -79,6 +79,8 @@ files:
|
|
79
79
|
- generators/rake_tasks/.gitignore
|
80
80
|
- generators/rake_tasks/repository/repository_rake_tasks_generator.rb
|
81
81
|
- generators/rake_tasks/repository/templates/repository.rake
|
82
|
+
- generators/paperclip_template/paperclip_template_generator.rb
|
83
|
+
- generators/paperclip_template/templates/model.rb
|
82
84
|
- lib/generators.rb
|
83
85
|
- test/generators_test.rb
|
84
86
|
- test/test_helper.rb
|