inline_forms 0.3.1 → 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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.4.0
data/inline_forms.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{inline_forms}
8
- s.version = "0.3.1"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ace Suares"]
12
- s.date = %q{2011-01-30}
12
+ s.date = %q{2011-01-31}
13
13
  s.description = %q{Inline Forms aims to ease the setup of forms that provide inline editing. The field list can be specified in the model.}
14
14
  s.email = %q{ace@suares.an}
15
15
  s.extra_rdoc_files = [
@@ -35,6 +35,11 @@ Gem::Specification.new do |s|
35
35
  "app/views/inline_forms/index.html.erb",
36
36
  "app/views/layouts/inline_forms.rhtml",
37
37
  "inline_forms.gemspec",
38
+ "lib/generators/inline_forms/USAGE",
39
+ "lib/generators/inline_forms/inline_forms_generator.rb",
40
+ "lib/generators/inline_forms/templates/controller.rb",
41
+ "lib/generators/inline_forms/templates/migration.rb",
42
+ "lib/generators/inline_forms/templates/model.rb",
38
43
  "lib/inline_forms.rb",
39
44
  "test/helper.rb",
40
45
  "test/test_inline_forms.rb"
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate inline_forms Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,49 @@
1
+ class InlineFormsGenerator < Rails::Generators::NamedBase
2
+ argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
3
+
4
+ source_root File.expand_path('../templates', __FILE__)
5
+
6
+ def generate_model
7
+ #copy_file "stylesheet.css", "public/stylesheets/#{file_name}.css"
8
+ template "model.rb", "app/models/#{model_file_name}.rb"
9
+ end
10
+
11
+ def generate_controller
12
+ template "controller.rb", "app/controllers/#{controller_file_name}.rb"
13
+ end
14
+
15
+ def generate_route
16
+ route "resources :#{resource_name}"
17
+ end
18
+
19
+ def generate_migration
20
+ template "migration.rb", "db/migrate/#{time_stamp}_inline_forms_create_#{table_name}.rb"
21
+ end
22
+
23
+ private
24
+ def model_file_name
25
+ name.underscore
26
+ end
27
+
28
+ def resource_name
29
+ name.pluralize.underscore
30
+ end
31
+
32
+ def controller_name
33
+ name.pluralize + 'Controller'
34
+ end
35
+
36
+ def controller_file_name
37
+ controller_name.underscore
38
+ end
39
+
40
+ def table_name
41
+ name.pluralize.underscore
42
+ end
43
+
44
+ def time_stamp
45
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
46
+ # found it here http://whynotwiki.com/Ruby_/_Dates_and_times
47
+ end
48
+
49
+ end
@@ -0,0 +1,2 @@
1
+ class <%= controller_name %> < InlineFormsController
2
+ end
@@ -0,0 +1,15 @@
1
+ class InlineFormsCreate<%= table_name.camelize %> < ActiveRecord::Migration
2
+ def self.up
3
+ create_table(:<%= table_name %>) do |t|
4
+ <% for attribute in attributes -%>
5
+ t.<%= attribute.type %> :<%= attribute.name %>
6
+ <% end -%>
7
+ t.timestamps
8
+ end
9
+
10
+ end
11
+
12
+ def self.down
13
+ drop_table :<%= table_name %>
14
+ end
15
+ #The types supported by Active Record are :primary_key, :string, :text, :integer, :float, :decimal, :datetime, :timestamp, :time, :date, :binary, :boolean
@@ -0,0 +1,14 @@
1
+ class <%= name %> < ActiveRecord::Base
2
+
3
+ def presentation
4
+ #define your presentation here
5
+ end
6
+
7
+ def inline_forms_field_list
8
+ [
9
+ <% for attribute in attributes -%>
10
+ [ '<%= attribute.name %>', :<%= attribute.name %>, '<%= attribute.type %>' ]
11
+ <% end -%>
12
+ ]
13
+ end
14
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 1
10
- version: 0.3.1
8
+ - 4
9
+ - 0
10
+ version: 0.4.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ace Suares
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-30 00:00:00 -04:00
18
+ date: 2011-01-31 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -106,6 +106,11 @@ files:
106
106
  - app/views/inline_forms/index.html.erb
107
107
  - app/views/layouts/inline_forms.rhtml
108
108
  - inline_forms.gemspec
109
+ - lib/generators/inline_forms/USAGE
110
+ - lib/generators/inline_forms/inline_forms_generator.rb
111
+ - lib/generators/inline_forms/templates/controller.rb
112
+ - lib/generators/inline_forms/templates/migration.rb
113
+ - lib/generators/inline_forms/templates/model.rb
109
114
  - lib/inline_forms.rb
110
115
  - test/helper.rb
111
116
  - test/test_inline_forms.rb