meskyanichi-simple_generators 0.2.1 → 0.3.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/README.rdoc CHANGED
@@ -39,7 +39,7 @@ This is a very small generator that just generates a .gitignore file in the RAIL
39
39
  Now, I always tend to forget all the settings I usually need for my Paperclip model, hence why I created the gem and added this generators as well.
40
40
 
41
41
  ==== To generate a Paperclip Model you are required to supply 2 of the 3 arguments:
42
- script/generate simple_paperclip_model model:user attachment:avatar [optional: type:image]
42
+ script/generate simple_paperclip_model model:user attachment:avatar [optional: type:image] bucket:my_bucket
43
43
 
44
44
  The optional type:image argument will generate example "styles" for Paperclip.
45
45
 
@@ -79,6 +79,18 @@ These rake tasks allow your to quickly, without manually SSH'ing to your server,
79
79
 
80
80
 
81
81
 
82
+
83
+ == Simple Admin Data Setup
84
+
85
+ This generator will generate a single file, containing some ruby code that will ensure security over the Admin Data Interface. The file will be generated inside the RAILS_ROOT/config/initializers directory. You will want to open this
86
+ file to see if the methods that are added are the ones you desire and use to check whether the logged in user has privileges to view the interface.
87
+
88
+ ==== To generate the Admin Data file, run the following command:
89
+ script/generate simple_admin_data_setup
90
+
91
+ * There are no available arguments.
92
+
93
+
82
94
  == Copyright
83
95
 
84
96
  Copyright (c) 2009 Michael van Rooijen. See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.3.0
@@ -0,0 +1,7 @@
1
+ This generator will generate a single file, containing some ruby code that will ensure security over the Admin Data Interface. The file will be generated inside the RAILS_ROOT/config/initializers directory. You will want to open this
2
+ file to see if the methods that are added are the ones you desire and use to check whether the logged in user has privileges to view the interface.
3
+
4
+ ==== To generate the Admin Data file, run the following command:
5
+ script/generate simple_admin_data_setup
6
+
7
+ * There are no available arguments.
@@ -0,0 +1,53 @@
1
+ class SimpleAdminDataSetupGenerator < Rails::Generator::Base
2
+
3
+ # This method gets initialized when the generator gets run.
4
+ # It will receive an array of arguments inside @args
5
+ def initialize(runtime_args, runtime_options = {})
6
+ super
7
+ extract_args
8
+ set_defaults
9
+ confirm_input
10
+ end
11
+
12
+ # Processes the file generation/templating
13
+ # This will automatically be run after the initialize method
14
+ def manifest
15
+ record do |m|
16
+ m.directory "config/initializers"
17
+ m.file "admin_data_setting.rb", "config/initializers/admin_data_setting.rb"
18
+ end
19
+ end
20
+
21
+ # Creates a new Hash Object containing the user input
22
+ # The user input will be available through @input and input
23
+ def extract_args
24
+ @input = Hash.new
25
+ @args.each do |arg|
26
+ if arg.include?(":") then
27
+ @input[:"#{arg.slice(0, arg.index(":"))}"] = arg.slice((arg.index(":") + 1)..-1)
28
+ end
29
+ end
30
+ end
31
+
32
+ # Input Method that's available inside the generated templates
33
+ # because instance variable are not available, so we access them through methods
34
+ def input
35
+ @input
36
+ end
37
+
38
+ # Sets defaults for user input when left blank by the user
39
+ # for each parameter
40
+ def set_defaults
41
+ end
42
+
43
+ # Confirms whether the model and attachment arguments were passed in
44
+ # Raises an error if not
45
+ def confirm_input
46
+ end
47
+
48
+ private
49
+
50
+ def input_error
51
+ end
52
+
53
+ end
@@ -0,0 +1,20 @@
1
+ # AdminDate Plugin/Gem Download On Github:
2
+ # http://github.com/neerajdotname/admin_data
3
+ #
4
+ # Public Git Clone: git://github.com/neerajdotname/admin_data.git
5
+ # script/plugin install git://github.com/neerajdotname/admin_data.git
6
+ #
7
+ # Be sure to install this plugin/gem for the interface.
8
+
9
+ # Define the two methods that should be invoked when checking whether the logged in user has privelleges to either:
10
+ # * View Data From the Database
11
+ # * Update Data from the Database
12
+ #
13
+ # You may change the two methods "logged_in?" and "admin_logged_in?" to methods you've defined.
14
+ # Usually you don't want any non-admin viewing any data from the admin-data interface. If this is what you
15
+ # desire, then create a method, for example, "admin_logged_in?" and let both the
16
+ # :view_security_check and :update_security_check invoke it.
17
+ AdminDataConfig.set = {
18
+ :view_security_check => lambda {|controller| controller.send('logged_in?') },
19
+ :update_security_check => lambda {|controller| controller.send('admin_logged_in?') }
20
+ }
@@ -1,6 +1,6 @@
1
1
  Now, I always tend to forget all the settings I usually need for my Paperclip model, hence why I created the gem and added this generators as well.
2
2
 
3
3
  ==== To generate a Paperclip Model you are required to supply 2 of the 3 arguments:
4
- script/generate simple_paperclip_model model:user attachment:avatar [optional: type:image]
4
+ script/generate simple_paperclip_model model:user attachment:avatar [optional: type:image] bucket:my_bucket
5
5
 
6
6
  The optional type:image argument will generate example "styles" for Paperclip.
@@ -14,7 +14,9 @@ class SimplePaperclipModelGenerator < Rails::Generator::Base
14
14
  def manifest
15
15
  record do |m|
16
16
  m.directory "app/models"
17
- m.template "paperclip.rb", "app/models/#{@input[:model]}.rb"
17
+ m.directory "config"
18
+ m.template "paperclip.rb", "app/models/#{input[:model]}.rb"
19
+ m.template "s3.yml", "config/s3.yml"
18
20
  end
19
21
  end
20
22
 
@@ -38,7 +40,8 @@ class SimplePaperclipModelGenerator < Rails::Generator::Base
38
40
  # Sets defaults for user input when left blank by the user
39
41
  # for each parameter
40
42
  def set_defaults
41
- @input[:type] ||= "image"
43
+ @input[:type] ||= "image"
44
+ @input[:bucket] ||= "my_bucket"
42
45
  end
43
46
 
44
47
  # Confirms whether the model and attachment arguments were passed in
@@ -1,6 +1,10 @@
1
1
  class <%= input[:model].camelcase.singularize %> < ActiveRecord::Base
2
-
2
+
3
+ # Generated with Simple Generators: Simple Paperclip Model
4
+ # Choose one of the two storage methods below..
5
+
3
6
  # Add <%= input[:attachment].singularize.underscore %> attribute
7
+ # Configuration For Filesystem Storage
4
8
  has_attached_file :<%= input[:attachment].singularize.underscore %>,
5
9
  :url => "/assets/<%= input[:attachment].pluralize %>/:style/:id.:basename.:extension",
6
10
  :path => ":rails_root/public/assets/<%= input[:attachment].pluralize %>/:style/:id.:basename.:extension",
@@ -11,6 +15,20 @@ class <%= input[:model].camelcase.singularize %> < ActiveRecord::Base
11
15
  :large => '300x300'
12
16
  <% end -%>
13
17
  }
18
+
19
+ # Add <%= input[:attachment].singularize.underscore %> attribute
20
+ # Configuration For Amazon S3 Storage
21
+ has_attached_file :<%= input[:attachment].singularize.underscore %>,
22
+ :storage => :s3,
23
+ :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
24
+ :path => "<%= input[:attachment].pluralize %>/:style/:id.:basename.:extension",
25
+ :styles => {
26
+ <% if input[:type].eql?("image") -%>
27
+ :small => '50x45#',
28
+ :medium => '150x150',
29
+ :large => '300x300'
30
+ <% end -%>
31
+ }
14
32
 
15
33
  # Validation
16
34
  validates_attachment_presence :<%= input[:attachment].singularize.underscore %>, :message => "You are required to select an <%= input[:attachment].singularize %>."
@@ -0,0 +1,14 @@
1
+ development:
2
+ access_key_id: ACCESS_KEY_ID
3
+ secret_access_key: SECRET_ACCESS_KEY
4
+ bucket: <%= input[:bucket] %>
5
+
6
+ production:
7
+ access_key_id: ACCESS_KEY_ID
8
+ secret_access_key: SECRET_ACCESS_KEY
9
+ bucket: <%= input[:bucket] %>
10
+
11
+ test:
12
+ access_key_id: ACCESS_KEY_ID
13
+ secret_access_key: SECRET_ACCESS_KEY
14
+ bucket: <%= input[:bucket] %>
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{simple_generators}
8
- s.version = "0.2.1"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael van Rooijen"]
12
- s.date = %q{2009-09-24}
12
+ s.date = %q{2009-09-27}
13
13
  s.description = %q{A couple of generators that supply you with some common templates to speed up the development process.}
14
14
  s.email = %q{meskyan@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -23,6 +23,12 @@ Gem::Specification.new do |s|
23
23
  "README.rdoc",
24
24
  "Rakefile",
25
25
  "VERSION",
26
+ "generators/simple_admin_data_setup/USAGE",
27
+ "generators/simple_admin_data_setup/USAGE",
28
+ "generators/simple_admin_data_setup/simple_admin_data_setup_generator.rb",
29
+ "generators/simple_admin_data_setup/simple_admin_data_setup_generator.rb",
30
+ "generators/simple_admin_data_setup/templates/admin_data_setting.rb",
31
+ "generators/simple_admin_data_setup/templates/admin_data_setting.rb",
26
32
  "generators/simple_capistrano_recipe/USAGE",
27
33
  "generators/simple_capistrano_recipe/USAGE",
28
34
  "generators/simple_capistrano_recipe/simple_capistrano_recipe_generator.rb",
@@ -41,6 +47,8 @@ Gem::Specification.new do |s|
41
47
  "generators/simple_paperclip_model/simple_paperclip_model_generator.rb",
42
48
  "generators/simple_paperclip_model/templates/paperclip.rb",
43
49
  "generators/simple_paperclip_model/templates/paperclip.rb",
50
+ "generators/simple_paperclip_model/templates/s3.yml",
51
+ "generators/simple_paperclip_model/templates/s3.yml",
44
52
  "generators/simple_tasks/simple_repository_tasks/USAGE",
45
53
  "generators/simple_tasks/simple_repository_tasks/USAGE",
46
54
  "generators/simple_tasks/simple_repository_tasks/simple_repository_tasks_generator.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meskyanichi-simple_generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael van Rooijen
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-24 00:00:00 -07:00
12
+ date: 2009-09-27 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -29,6 +29,9 @@ files:
29
29
  - README.rdoc
30
30
  - Rakefile
31
31
  - VERSION
32
+ - generators/simple_admin_data_setup/USAGE
33
+ - generators/simple_admin_data_setup/simple_admin_data_setup_generator.rb
34
+ - generators/simple_admin_data_setup/templates/admin_data_setting.rb
32
35
  - generators/simple_capistrano_recipe/USAGE
33
36
  - generators/simple_capistrano_recipe/simple_capistrano_recipe_generator.rb
34
37
  - generators/simple_capistrano_recipe/templates/capistrano_recipe.rb
@@ -38,6 +41,7 @@ files:
38
41
  - generators/simple_paperclip_model/USAGE
39
42
  - generators/simple_paperclip_model/simple_paperclip_model_generator.rb
40
43
  - generators/simple_paperclip_model/templates/paperclip.rb
44
+ - generators/simple_paperclip_model/templates/s3.yml
41
45
  - generators/simple_tasks/simple_repository_tasks/USAGE
42
46
  - generators/simple_tasks/simple_repository_tasks/simple_repository_tasks_generator.rb
43
47
  - generators/simple_tasks/simple_repository_tasks/templates/repository.rake