inline_forms 1.3.28 → 1.3.29

Sign up to get free protection for your applications and to get access to all the features.
data/bin/inline_forms CHANGED
@@ -4,11 +4,10 @@
4
4
  require 'fileutils'
5
5
  require 'pathname'
6
6
  require 'rbconfig'
7
+ require 'rvm'
7
8
 
8
- RUBY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
9
-
10
- if RUBY.empty?
11
- puts "ruby not found"
9
+ if not RVM.current
10
+ puts "ruby or rvm not found"
12
11
  exit 2
13
12
  end
14
13
 
@@ -31,8 +30,6 @@ VERSION: #{InlineForms::VERSION}
31
30
 
32
31
  while true
33
32
  case arg_name = ARGV.shift
34
- # when "--skip-db-setup"
35
- # skip_db_setup = true
36
33
  when "--help"
37
34
  puts USAGE
38
35
  exit
@@ -48,18 +45,18 @@ if !ARGV.empty? || app_name.nil? || !/^[a-zA-Z][0-9a-zA-Z_-]+/.match(app_name) |
48
45
  end
49
46
 
50
47
  puts "\nGenerating Rails app '#{app_name}'...\n"
51
- system("#{RUBY} -S rails new #{app_name}")
48
+ RVM.run "rails new #{app_name}"
52
49
 
53
- Dir.chdir(app_name)
54
- puts "\nWorking directory is now #{`pwd`}"
50
+ RVM.chdir(app_name) do
51
+ puts "\nWorking directory is now #{`pwd`}"
55
52
 
56
- puts "\nInstalling Gemfile...\n"
53
+ puts "\nInstalling Gemfile...\n"
57
54
 
58
- gemfile_sources = "
55
+ gemfile_sources = "
59
56
  source 'http://rubygems.org'
60
57
 
61
- "
62
- gemfile_gems = "
58
+ "
59
+ gemfile_gems = "
63
60
 
64
61
  gem 'test-unit'
65
62
  gem 'rails'
@@ -82,8 +79,8 @@ gem 'rails-i18n'
82
79
  gem 'unicorn'
83
80
  gem 'rvm-capistrano'
84
81
 
85
- "
86
- gemfile_development_group ="
82
+ "
83
+ gemfile_development_group ="
87
84
 
88
85
  # Include everything needed to run rake, tests, features, etc.
89
86
  group :development do
@@ -95,8 +92,8 @@ group :development do
95
92
  # gem 'rcov', '>= 0'
96
93
  end
97
94
 
98
- "
99
- gemfile_production_group ="
95
+ "
96
+ gemfile_production_group ="
100
97
  # these are just for production
101
98
  group :production do
102
99
  gem 'mysql2'
@@ -104,58 +101,60 @@ group :production do
104
101
  gem 'uglifier'
105
102
  end
106
103
 
107
- "
104
+ "
108
105
 
109
- File.open( 'Gemfile', 'w') {|f| f.write(gemfile_sources + gemfile_gems + gemfile_development_group + gemfile_production_group ) }
106
+ File.open( 'Gemfile', 'w') {|f| f.write(gemfile_sources + gemfile_gems + gemfile_development_group + gemfile_production_group ) }
110
107
 
111
- puts "\nCreating and trusting rvmrc...\n"
112
- system("echo rvm use `rvm current`@#{app_name} --create > .rvmrc")
113
- system("rvm rvmrc trust .rvmrc")
114
- system("rvm use `rvm current`@#{app_name} --create")
108
+ puts "\nCreating and trusting rvmrc...\n"
109
+ RVM.run "echo rvm use `rvm current`@#{app_name} --create > .rvmrc"
110
+ RVM.run "rvm rvmrc trust .rvmrc"
115
111
 
116
- puts "\nRunning bundle...\n"
117
- system('bundle install')
112
+ end
113
+ RVM.chdir "#{app_name}" do
118
114
 
119
- puts "\nDatabase setup: creating config/database.yml\n"
120
- development_stanza = "
115
+ puts "\nRunning bundle...\n"
116
+ RVM.run "bundle install"
117
+
118
+ puts "\nDatabase setup: creating config/database.yml\n"
119
+ development_stanza = "
121
120
  development:
122
121
  adapter: sqlite3
123
122
  database: db/development.sqlite3
124
123
  pool: 5
125
124
  timeout: 5000
126
- "
127
- production_stanza = "
125
+ "
126
+ production_stanza = "
128
127
  production:
129
128
  adapter: mysql2
130
129
  database: #{app_name}_p
131
130
  username: #{app_name}
132
131
  password: #{app_name}444
133
132
 
134
- "
135
- File.open( 'config/database.yml', 'w') {|f| f.write(development_stanza + production_stanza) }
136
-
137
- puts "\nDevise install..."
138
- system('bundle exec rails g devise:install')
139
- puts "\nDevise User model install with added name field..."
140
- system('bundle exec rails g devise User name:string')
141
- puts "\nInstall ckeditor..."
142
- system('bundle exec rails g ckeditor:install')
143
- puts "Create config file in app/assets/javascripts/ckeditor/config.js"
144
- FileUtils.mkdir_p 'app/assets/javascripts/ckeditor'
145
- system("cp #{src}/lib/app/assets/javascripts/ckeditor/config.js app/assets/javascripts/ckeditor")
146
- puts "Add remotipart to app/assets/javascripts/application.js..."
147
- system('echo >> app/assets/javascripts/application.js')
148
- system('echo "//= require jquery.remotipart" >> app/assets/javascripts/application.js')
149
- system('echo >> app/assets/javascripts/application.js')
150
- puts "Paper_trail install..."
151
- system('bundle exec rails g paper_trail:install')
152
-
153
-
154
- puts "Migrating Devise and Versions"
155
- system('bundle exec rake db:migrate')
156
-
157
- puts "Creating header in app/views/inline_forms/_header.html.erb...\n"
158
- header_src = "
133
+ "
134
+ File.open( 'config/database.yml', 'w') {|f| f.write(development_stanza + production_stanza) }
135
+
136
+ puts "\nDevise install..."
137
+ system('bundle exec rails g devise:install')
138
+ puts "\nDevise User model install with added name field..."
139
+ system('bundle exec rails g devise User name:string')
140
+ puts "\nInstall ckeditor..."
141
+ system('bundle exec rails g ckeditor:install')
142
+ puts "Create config file in app/assets/javascripts/ckeditor/config.js"
143
+ FileUtils.mkdir_p 'app/assets/javascripts/ckeditor'
144
+ system("cp #{src}/lib/app/assets/javascripts/ckeditor/config.js app/assets/javascripts/ckeditor")
145
+ puts "Add remotipart to app/assets/javascripts/application.js..."
146
+ system('echo >> app/assets/javascripts/application.js')
147
+ system('echo "//= require jquery.remotipart" >> app/assets/javascripts/application.js')
148
+ system('echo >> app/assets/javascripts/application.js')
149
+ puts "Paper_trail install..."
150
+ system('bundle exec rails g paper_trail:install')
151
+
152
+
153
+ puts "Migrating Devise and Versions"
154
+ system('bundle exec rake db:migrate')
155
+
156
+ puts "Creating header in app/views/inline_forms/_header.html.erb...\n"
157
+ header_src = "
159
158
  <div id='Header'>
160
159
  <div id='title'>
161
160
  #{app_name} v<%= inline_forms_version -%>
@@ -167,12 +166,12 @@ header_src = "
167
166
  <% end -%>
168
167
  <div style='clear: both;'></div>
169
168
  </div>
170
- "
171
- FileUtils.mkdir_p 'app/views/inline_forms'
172
- File.open( 'app/views/inline_forms/_header.html.erb', 'w') {|f| f.write(header_src) }
169
+ "
170
+ FileUtils.mkdir_p 'app/views/inline_forms'
171
+ File.open( 'app/views/inline_forms/_header.html.erb', 'w') {|f| f.write(header_src) }
173
172
 
174
- puts "Set application_name and _title in ApplicationHelper...\n"
175
- app_helper = "
173
+ puts "Set application_name and _title in ApplicationHelper...\n"
174
+ app_helper = "
176
175
  module ApplicationHelper
177
176
  def application_name
178
177
  #{app_name}
@@ -181,12 +180,12 @@ module ApplicationHelper
181
180
  #{app_name}
182
181
  end
183
182
  end
184
- "
185
- File.open( 'app/helpers/application_helper.rb', 'w') {|f| f.write(app_helper) }
183
+ "
184
+ File.open( 'app/helpers/application_helper.rb', 'w') {|f| f.write(app_helper) }
186
185
 
187
186
 
188
- puts "Injecting precompile assets stuff in production.rb...\n"
189
- precomp = "
187
+ puts "Injecting precompile assets stuff in production.rb...\n"
188
+ precomp = "
190
189
  \n
191
190
  \n
192
191
  # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
@@ -194,26 +193,27 @@ precomp = "
194
193
  config.assets.precompile += %w( inline_forms_application.js inline_forms_application.css devise.css )
195
194
  end
196
195
  \n"
197
- File.open( 'config/environments/production.rb', 'a') {|f| f.write(precomp) }
196
+ File.open( 'config/environments/production.rb', 'a') {|f| f.write(precomp) }
198
197
 
199
- puts "Capify...\n"
200
- system('capify .')
201
- system("cp #{src}/lib/generators/templates/deploy.rb config/deploy.rb")
198
+ puts "Capify...\n"
199
+ system('capify .')
200
+ system("cp #{src}/lib/generators/templates/deploy.rb config/deploy.rb")
202
201
 
203
- puts "Unicorn Config...\n"
204
- system("cp #{src}/lib/generators/templates/unicorn.rb config/unicorn.rb")
202
+ puts "Unicorn Config...\n"
203
+ system("cp #{src}/lib/generators/templates/unicorn.rb config/unicorn.rb")
205
204
 
206
- puts "Initializing git...\n"
207
- system('git init')
208
- system('echo >> .gitignore')
209
- system('echo "nbproject" >> .gitignore')
210
- system('echo "public/uploads" >> .gitignore')
211
- system('echo >> .gitignore')
212
- system('git add .')
213
- system('git commit -a -m " * Initial"')
205
+ puts "Initializing git...\n"
206
+ system('git init')
207
+ system('echo >> .gitignore')
208
+ system('echo "nbproject" >> .gitignore')
209
+ system('echo "public/uploads" >> .gitignore')
210
+ system('echo >> .gitignore')
211
+ system('git add .')
212
+ system('git commit -a -m " * Initial"')
214
213
 
215
- puts "\n\nDone! Now make your tables with 'rails g inline_forms ...\n"
216
- puts "\nDon't forget: edit .rvmrc, config/{routes.rb, deploy.rb}, .git/config, delete public/index.html\n\n"
214
+ puts "\n\nDone! Now make your tables with 'rails g inline_forms ...\n"
215
+ puts "\nDon't forget: edit .rvmrc, config/{routes.rb, deploy.rb}, .git/config, delete public/index.html\n\n"
217
216
 
218
217
 
219
218
 
219
+ end
@@ -2,11 +2,11 @@
2
2
  InlineForms::SPECIAL_COLUMN_TYPES[:devise_password_field]=:string
3
3
 
4
4
  def devise_password_field_show(object, attribute)
5
- link_to_inline_edit object, attribute, (object.send attribute.to_sym)
5
+ link_to_inline_edit object, attribute, ''
6
6
  end
7
7
 
8
8
  def devise_password_field_edit(object, attribute)
9
- password_field_tag attribute, (object.send attribute.to_sym), :class => 'input_devise_password_field'
9
+ password_field_tag attribute, '', :class => 'input_devise_password_field'
10
10
  end
11
11
 
12
12
  def devise_password_field_update(object, attribute)
@@ -15,18 +15,18 @@ module InlineFormsHelper
15
15
 
16
16
  # used as class name
17
17
  def has_validations(object, attribute)
18
- "has_validations " unless object.class.validators_on(attribute).empty?
18
+ not object.class.validators_on(attribute).empty?
19
19
  end
20
20
 
21
21
  def validation_help_as_list_for(object, attribute)
22
- "" and return if object.class.validators_on(attribute).empty?
22
+ "" and return unless has_validations(object, attribute)
23
23
  content_tag(:ul, validation_help_for(object, attribute).map { |help_message| content_tag(:li, help_message ) }.to_s.html_safe )
24
24
  end
25
25
 
26
26
  # validation_help_for(object, attribute) extracts the help messages for
27
27
  # attribute of object.class (in an Array)
28
28
  def validation_help_for(object, attribute)
29
- "" and return if object.class.validators_on(attribute).empty?
29
+ "" and return unless has_validations(object, attribute)
30
30
  object.class.validators_on(attribute).map do |v|
31
31
  t("inline_forms.validators.help.#{ActiveModel::Name.new(v.class).i18n_key.to_s.gsub(/active_model\/validations\//, '')}")
32
32
  end.compact
@@ -30,7 +30,7 @@
30
30
  <% css_class_id = "attribute_#{attribute}_#{@object.id}" -%>
31
31
  <tr>
32
32
  <td valign="top">
33
- <div class='<%= has_validations(@object, attribute) -%><%= "attribute_name attribute_#{attribute} form_element_#{form_element}" -%>' >
33
+ <div class='<%= "has_validations " if has_validations(@object, attribute) -%><%= "attribute_name attribute_#{attribute} form_element_#{form_element}" -%>' >
34
34
  <%= translated_attribute(@object, attribute) -%>
35
35
  </div>
36
36
  <% if has_validations(@object, attribute) %>
@@ -16,7 +16,7 @@
16
16
  <% css_class_id = "#{@object.class.name.underscore}_#{@object.id}_#{attribute}" -%>
17
17
  <tr>
18
18
  <td valign="top">
19
- <div class='<%= has_validations(@object, attribute) -%><%= "attribute_name attribute_#{attribute} form_element_#{form_element}" -%>' >
19
+ <div class='<%= "has_validations " if _has_validations(@object, attribute) -%><%= "attribute_name attribute_#{attribute} form_element_#{form_element}" -%>' >
20
20
  <%= translated_attribute(@object, attribute) -%>
21
21
  </div>
22
22
  <% if has_validations(@object, attribute) %>
@@ -99,6 +99,10 @@ module InlineForms
99
99
  @has_attached_files = "\n"
100
100
  @presentation = "\n"
101
101
  @order = "\n"
102
+ @order_by_clause = " def self.order_by_clause\n" +
103
+ " \"#{attribute.type}\"\n" +
104
+ " end\n" +
105
+ "\n"
102
106
  @carrierwave_mounters = "\n"
103
107
  @inline_forms_attribute_list = String.new
104
108
 
@@ -130,10 +134,14 @@ module InlineForms
130
134
  "\n"
131
135
  end
132
136
  if attribute.name == '_order'
133
- @order << " def <=>(other)\n" +
137
+ @order << " def <=>(other)\n" +
134
138
  " self.#{attribute.type} <=> other.#{attribute.type}\n" +
135
139
  " end\n" +
136
140
  "\n"
141
+ @order_by_clause = " def self.order_by_clause\n" +
142
+ " \"#{attribute.type}\"\n" +
143
+ " end\n" +
144
+ "\n"
137
145
  end
138
146
  if attribute.attribute?
139
147
  attribute.attribute_type == :unknown ? commenter = '#' : commenter = ' '
@@ -17,8 +17,6 @@ class <%= name %> < ActiveRecord::Base
17
17
  <%= @flag_not_accessible_through_html %>
18
18
  end
19
19
 
20
- def self.order_by_clause
21
- "name"
22
- end
20
+ <%= @order_by_clause -%>
23
21
 
24
22
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineForms
3
- VERSION = "1.3.28"
3
+ VERSION = "1.3.29"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.28
4
+ version: 1.3.29
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-13 00:00:00.000000000 Z
12
+ date: 2012-05-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec-rails