inline_forms 5.0.20 → 5.0.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e81675de0a6f199e9558ffcad307ec20cdb66965
4
- data.tar.gz: a60ab75bf6140e339fccb29c249143e7a586481d
3
+ metadata.gz: 2e59e18d87dd2a20edd0b3196d9929839b7f5b7b
4
+ data.tar.gz: b369c07c0a608fd042ef40b0d55fbd0115ef3d4d
5
5
  SHA512:
6
- metadata.gz: d84fc21d1c4db2302cb415e58c5222b2d5635ec7339b2fef78543bc47e5515333e351d25544b9550ddfd34e2b8293ebad707bf9c16bbec287f8fab58bb7e6f8d
7
- data.tar.gz: 3f070fc2fa9559fb6a078c091dd05e57638541982ee6e4ac162ebf607e84a1d029f9735b04c4823bc223bb76e8a99b12844a49719271f07c3bb779a69efca08c
6
+ metadata.gz: 7703368ccb58471d9f86ba1444d51ed8d6d8a15c72edf6ccf3515ede5b47fcac4eff51efb658f23d448f783c035eba3017511a5406ae54723e1c26fe812e5cb2
7
+ data.tar.gz: 5b9961fecdba9f8b800b7e26649c06a78c1e55b1af077f261ffc7fc5958be5f85c7d28266d1770f086aad1ed63ca7d2e94c56cd8c6af92e9ce44bbca4d9d848f
data/.gitignore CHANGED
@@ -17,3 +17,8 @@ pkg
17
17
  # other (Lemuel I think)
18
18
  .project
19
19
  .vscode
20
+
21
+ # Builds
22
+ *.gem
23
+
24
+ Gemfile.lock
data/bin/inline_forms CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  module InlineForms
3
3
  require File.join(File.dirname(__FILE__), "../lib/inline_forms/version.rb")
4
-
4
+ require 'securerandom'
5
+
5
6
  # what is this?
6
7
  Signal.trap("INT") { puts; exit }
7
8
 
@@ -48,6 +48,7 @@ gem_group :development do
48
48
  gem 'capistrano-rails', '~> 1.3', require: false
49
49
  gem 'capistrano-bundler', '~> 1.3', require: false
50
50
  gem 'capistrano-rvm', require: false
51
+ gem "capistrano3-unicorn"
51
52
  end
52
53
 
53
54
  say "- Running bundle..."
@@ -69,18 +70,17 @@ else
69
70
  create_file "config/database.yml", <<-END_DATABASEYML.strip_heredoc
70
71
  development:
71
72
  adapter: mysql2
72
- database: #{app_name}_dev
73
- username: #{app_name}
74
- password: #{app_name}
75
-
73
+ database: <%= ENV["DATABASE_NAME"] %>
74
+ username: <%= ENV["DATABASE_USER"] %>
75
+ password: <%= ENV["DATABASE_PASSWORD"] %>
76
76
  END_DATABASEYML
77
77
  end
78
78
  append_file "config/database.yml", <<-END_DATABASEYML.strip_heredoc
79
79
  production:
80
80
  adapter: mysql2
81
- database: #{app_name}_prod
82
- username: #{app_name}
83
- password: #{app_name}444
81
+ database: <%= ENV["DATABASE_NAME"] %>
82
+ username: <%= ENV["DATABASE_USER"] %>
83
+ password: <%= ENV["DATABASE_PASSWORD"] %>
84
84
  END_DATABASEYML
85
85
 
86
86
  say "- Devise install..."
@@ -158,7 +158,7 @@ USERS_CONTROLLER
158
158
 
159
159
  say "- Create User Model..."
160
160
  create_file "app/models/user.rb", <<-USER_MODEL.strip_heredoc
161
- class User < ActiveRecord::Base
161
+ class User < ApplicationRecord
162
162
 
163
163
  # devise options
164
164
  devise :database_authenticatable
@@ -535,12 +535,16 @@ DEVISE_MAILER_STUFF
535
535
  # capify
536
536
  say "- Capify..."
537
537
  run 'bundle exec cap install'
538
- #remove_file "config/deploy.rb" # remove the file capify created!
539
- #copy_file File.join(GENERATOR_PATH,'lib/generators/templates/deploy.rb'), "config/deploy.rb"
538
+ remove_file "config/deploy.rb" # remove the file capify created!
539
+ copy_file File.join(GENERATOR_PATH,'lib/generators/templates/capistrano/deploy.rb'), "config/deploy.rb"
540
+ remove_file "config/deploy/production.rb" # remove the production file capify created!
541
+ copy_file File.join(GENERATOR_PATH,'lib/generators/templates/capistrano/production.rb'), "config/deploy/production.rb"
542
+ remove_file "Capfile" # remove the Capfile file capify created!
543
+ copy_file File.join(GENERATOR_PATH,'lib/generators/templates/capistrano/Capfile'), "Capfile"
540
544
 
541
545
  # Unicorn
542
546
  say "- Unicorn Config..."
543
- copy_file File.join(GENERATOR_PATH,'lib/generators/templates/unicorn.rb'), "config/unicorn.rb"
547
+ copy_file File.join(GENERATOR_PATH,'lib/generators/templates/unicorn/production.rb'), "config/unicorn/production.rb"
544
548
 
545
549
 
546
550
  # Git
@@ -556,14 +560,15 @@ GITIGNORE
556
560
 
557
561
  say "- Installing Figaro..."
558
562
  run 'bundle exec figaro install'
563
+ remove_file "config/application.yml"
559
564
  copy_file File.join(GENERATOR_PATH,'lib/generators/templates/application.yml.blank'), "config/application.yml"
560
565
  copy_file File.join(GENERATOR_PATH,'lib/generators/templates/application.yml.blank'), "config/application.yml.blank"
561
566
 
562
567
  say "- Installing config/secrets.yml..."
563
568
  remove_file "config/secrets.yml"
564
- create_file "config/secrets.yml", <<-END_SECRETS_YML.strip_heredoc(2)
569
+ create_file "config/secrets.yml", <<-END_SECRETS_YML.strip_heredoc
565
570
  development:
566
- secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
571
+ secret_key_base: #{SecureRandom.hex(64)}
567
572
 
568
573
  test:
569
574
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -605,6 +610,7 @@ if ENV['install_example'] == 'true'
605
610
  else
606
611
  # run tests
607
612
  run "rspec" if ENV['runtest']
613
+ say "- Don't forget: add your secret key base in config/application.yml \n"
608
614
  end
609
615
  # done!
610
616
  say "\nDone! Now make your tables with 'bundle exec rails g inline_forms ...", :yellow
data/lib/generators/USAGE CHANGED
@@ -12,7 +12,7 @@ This will create:
12
12
  create db/migrate/20110204074707_inline_forms_create_things.rb
13
13
 
14
14
  app/models/thing.rb:
15
- class Thing < ActiveRecord::Base
15
+ class Thing < ApplicationRecord
16
16
  def _presentation
17
17
  #define your presentation here
18
18
  end
@@ -43,7 +43,7 @@ module InlineForms
43
43
  def attribute_type
44
44
  SPECIAL_COLUMN_TYPES.merge(RELATIONS).has_key?(type) ? type : DEFAULT_FORM_ELEMENTS[type] || :unknown
45
45
  end
46
-
46
+
47
47
  def special_relation?
48
48
  SPECIAL_RELATIONS.has_key?(type)
49
49
  end
@@ -73,7 +73,7 @@ module InlineForms
73
73
  argument :attributes, :type => :array, :banner => "[name:form_element]..."
74
74
 
75
75
  source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
76
-
76
+
77
77
  # using flags.
78
78
  def set_some_flags
79
79
  @flag_not_accessible_through_html = true
@@ -107,7 +107,7 @@ module InlineForms
107
107
  @inline_forms_attribute_list = String.new
108
108
 
109
109
  for attribute in attributes
110
- if attribute.column_type == :belongs_to
110
+ if attribute.column_type == :belongs_to
111
111
  ## :drop_down, :references and :belongs_to all end up with the column_type :belongs_to
112
112
  @belongs_to << ' belongs_to :' + attribute.name + "\n"
113
113
  end
@@ -175,7 +175,7 @@ module InlineForms
175
175
  end
176
176
  ROUTE
177
177
  end
178
- end
178
+ end
179
179
 
180
180
  def generate_migration
181
181
  if @flag_create_migration
@@ -199,6 +199,7 @@ module InlineForms
199
199
  end
200
200
  end
201
201
  end
202
+ @primary_key_option = @create_id ? '' : ', id: false'
202
203
  template "migration.erb", "db/migrate/#{time_stamp}_inline_forms_create_#{table_name}.rb"
203
204
  end
204
205
  end
@@ -214,14 +215,14 @@ module InlineForms
214
215
  :after => "ActionView::CompiledTemplates::MODEL_TABS = %w("
215
216
  end
216
217
  end
217
-
218
+
218
219
  def generate_test
219
220
  template "test.erb", "test/unit/#{test_file_name}.rb"
220
221
  end
221
222
 
222
223
  def generate_controller
223
224
  template "controller.erb", "app/controllers/#{controller_file_name}.rb" if @flag_create_controller
224
- end
225
+ end
225
226
 
226
227
 
227
228
  private
@@ -240,11 +241,11 @@ module InlineForms
240
241
  def controller_file_name
241
242
  controller_name.underscore
242
243
  end
243
-
244
+
244
245
  def test_name
245
246
  name + 'Test'
246
247
  end
247
-
248
+
248
249
  def test_file_name
249
250
  test_name.underscore
250
251
  end
@@ -3,6 +3,9 @@ SECRET_TOKEN:
3
3
 
4
4
  DEPLOY_USER:
5
5
  DEPLOY_HOST:
6
+ DEPLOY_APPLICATION:
7
+ DEPLOY_REPO_URL:
8
+ DEPLOY_DIRECTORY:
6
9
 
7
10
  development:
8
11
  ACTION_MAILER_SMTP_SETTINGS_ADDRESS:
@@ -0,0 +1,44 @@
1
+ # Load ENV vars via Figaro
2
+ require 'figaro'
3
+ Figaro.application = Figaro::Application.new(environment: 'production', path: File.expand_path('../config/application.yml', __FILE__))
4
+ Figaro.load
5
+
6
+ # Load DSL and set up stages
7
+ require "capistrano/setup"
8
+
9
+ # Include default deployment tasks
10
+ require "capistrano/deploy"
11
+
12
+ # Load the SCM plugin appropriate to your project:
13
+ #
14
+ # require "capistrano/scm/hg"
15
+ # install_plugin Capistrano::SCM::Hg
16
+ # or
17
+ # require "capistrano/scm/svn"
18
+ # install_plugin Capistrano::SCM::Svn
19
+ # or
20
+ require "capistrano/scm/git"
21
+ install_plugin Capistrano::SCM::Git
22
+
23
+ # Include tasks from other gems included in your Gemfile
24
+ #
25
+ # For documentation on these, see for example:
26
+ #
27
+ # https://github.com/capistrano/rvm
28
+ # https://github.com/capistrano/rbenv
29
+ # https://github.com/capistrano/chruby
30
+ # https://github.com/capistrano/bundler
31
+ # https://github.com/capistrano/rails
32
+ # https://github.com/capistrano/passenger
33
+ #
34
+ require "capistrano/rvm"
35
+ # require "capistrano/rbenv"
36
+ # require "capistrano/chruby"
37
+ require "capistrano/bundler"
38
+ require "capistrano/rails/assets"
39
+ require "capistrano/rails/migrations"
40
+ # require "capistrano/passenger"
41
+ require "capistrano3/unicorn"
42
+
43
+ # Load custom tasks from `lib/capistrano/tasks` if you have any defined
44
+ Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }
@@ -0,0 +1,39 @@
1
+ set :application, ENV['DEPLOY_APPLICATION']
2
+ set :repo_url, ENV['DEPLOY_REPO_URL']
3
+ set :bundle_binstubs, nil
4
+
5
+ # Default deploy_to directory is /var/www/my_app_name
6
+ set :deploy_to, ENV['DEPLOY_DIRECTORY']
7
+
8
+ # Default value for :linked_files is []
9
+ set :linked_files, fetch(:linked_files, [])
10
+ .push("config/database.yml", "config/secrets.yml", "config/application.yml")
11
+ # Default value for linked_dirs is []
12
+ set :linked_dirs, fetch(:linked_dirs, [])
13
+ .push("log", "tmp/pids", "tmp/cache", "tmp/sockets", "public/system", "vendor/bundle")
14
+
15
+ # Default value for keep_releases is 5
16
+ set :keep_releases, 5
17
+
18
+ before 'deploy:check', 'figaro:upload'
19
+ after "deploy:publishing", "deploy:restart"
20
+
21
+ # Restart unicorn
22
+ namespace :deploy do
23
+ task :restart do
24
+ invoke "unicorn:restart"
25
+ end
26
+ end
27
+
28
+ # Uploads secrets.yml, database.yml and application.yml files
29
+ namespace :figaro do
30
+ task :upload do
31
+ on roles(:all) do
32
+ execute "mkdir -p #{shared_path}/config"
33
+
34
+ upload! 'config/secrets.yml', "#{shared_path}/config/secrets.yml"
35
+ upload! 'config/database.yml', "#{shared_path}/config/database.yml"
36
+ upload! 'config/application.yml', "#{shared_path}/config/application.yml"
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,7 @@
1
+ set :user, ENV["DEPLOY_USER"]
2
+ set :deploy_via, :remote_cache
3
+ set :conditionally_migrate, true
4
+ set :rails_env, "production"
5
+
6
+ # Server IP
7
+ server ENV["DEPLOY_HOST"], user: fetch(:user), port: fetch(:port), roles: %w(web app db)
@@ -1,8 +1,7 @@
1
- class InlineFormsCreate<%= table_name.camelize %> < ActiveRecord::Migration
1
+ class InlineFormsCreate<%= table_name.camelize %> < ActiveRecord::Migration[5.0]
2
2
 
3
3
  def self.up
4
- #create_table :<%= table_name + ", :id => " + @create_id.to_s %> do |t|
5
- create_table :<%= table_name %> do |t|
4
+ create_table :<%= table_name + @primary_key_option %> do |t|
6
5
  <%= @columns -%>
7
6
  t.timestamps
8
7
  end
@@ -1,4 +1,4 @@
1
- class <%= name %> < ActiveRecord::Base
1
+ class <%= name %> < ApplicationRecord
2
2
  attr_reader :per_page
3
3
  @per_page = 7
4
4
  attr_writer :inline_forms_attribute_list
@@ -0,0 +1,39 @@
1
+ # Load ENV vars via Figaro
2
+ require 'figaro'
3
+ Figaro.application = Figaro::Application.new(environment: 'production', path: File.expand_path('../../../config/application.yml', __FILE__))
4
+ Figaro.load
5
+
6
+ app_path = "#{ENV['DEPLOY_DIRECTORY']}/current"
7
+ working_directory app_path
8
+
9
+ pid "#{app_path}/tmp/pids/unicorn.pid"
10
+
11
+ stderr_path "#{app_path}/log/unicorn.err.log"
12
+ stdout_path "#{app_path}/log/unicorn.out.log"
13
+
14
+ worker_processes 3
15
+ timeout 30
16
+ preload_app true
17
+
18
+ listen "#{app_path}/tmp/sockets/unicorn.sock", backlog: 64
19
+
20
+ before_exec do |_|
21
+ ENV["BUNDLE_GEMFILE"] = File.join(app_path, "Gemfile")
22
+ end
23
+
24
+ before_fork do |server, worker|
25
+ defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
26
+
27
+ old_pid = "#{app_path}/tmp/pids/unicorn.pid.oldbin"
28
+
29
+ if File.exists?(old_pid) && server.pid != old_pid
30
+ begin
31
+ Process.kill("QUIT", File.read(old_pid).to_i)
32
+ rescue Errno::ENOENT, Errno::ESRCH
33
+ end
34
+ end
35
+ end
36
+
37
+ after_fork do |server, worker|
38
+ defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
39
+ end
data/lib/inline_forms.rb CHANGED
@@ -49,7 +49,7 @@ module InlineForms
49
49
  # rails g inline_forms Example name:string price:integer
50
50
  # will result in the following model:
51
51
  #
52
- # class Example < ActiveRecord::Base
52
+ # class Example < ApplicationRecord
53
53
  # def inline_forms_attribute_list
54
54
  # {
55
55
  # :name => [ "name", :text_field ],
@@ -91,7 +91,7 @@ module InlineForms
91
91
  SPECIAL_COLUMN_TYPES = {
92
92
  :associated => :no_migration
93
93
  }
94
-
94
+
95
95
  # RELATIONS defines a mapping between AR::Migrations columns and the Model.
96
96
  #
97
97
  # When a column has the type of :references or :belongs_to, then
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineForms
3
- VERSION = "5.0.20"
3
+ VERSION = "5.0.21"
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: 5.0.20
4
+ version: 5.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-10-28 00:00:00.000000000 Z
13
+ date: 2017-11-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rvm
@@ -256,12 +256,14 @@ files:
256
256
  - lib/generators/templates/_inline_forms_tabs.html.erb
257
257
  - lib/generators/templates/abstract_mysql2_adapter.rb
258
258
  - lib/generators/templates/application.yml.blank
259
+ - lib/generators/templates/capistrano/Capfile
260
+ - lib/generators/templates/capistrano/deploy.rb
261
+ - lib/generators/templates/capistrano/production.rb
259
262
  - lib/generators/templates/controller.erb
260
- - lib/generators/templates/deploy.rb
261
263
  - lib/generators/templates/migration.erb
262
264
  - lib/generators/templates/model.erb
263
265
  - lib/generators/templates/test.erb
264
- - lib/generators/templates/unicorn.rb
266
+ - lib/generators/templates/unicorn/production.rb
265
267
  - lib/inline_forms.rb
266
268
  - lib/inline_forms/version.rb
267
269
  - lib/locales/inline_forms.en.yml
@@ -1,82 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- require "bundler/capistrano"
4
- require "rvm/capistrano"
5
-
6
- load 'deploy/assets'
7
-
8
- set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"") # Read from local system
9
- set :rvm_install_ruby_params, '--1.9' # for jruby/rbx default to 1.9 mode https://github.com/wayneeseguin/rvm-capistrano/commit/663252851a9d6294439a9b501cebe66f8c3150f7
10
-
11
- set :application, "YOUR_APPLICATION_NAME"
12
- set :domain, "YOUR_HOST_NAME"
13
- set :user, "YOUR_USERNAME_ON_THE_HOST"
14
-
15
- set :bundle_flags, "--deployment"
16
-
17
- set :use_sudo, false
18
-
19
- set :deploy_to, "/var/www/ror/#{application}"
20
-
21
- set :repository, "file:///home/#{user}/git-repos/#{application}.git"
22
- set :local_repository, "ssh://#{user}@#{domain}/home/#{user}/git-repos/#{application}.git"
23
- set :scm, "git"
24
-
25
-
26
- role :app, domain
27
- role :web, domain
28
- role :db, domain, :primary => true
29
-
30
- before :deploy do
31
- system "bundle install"
32
- system "git commit -a"
33
- system "git push"
34
- end
35
-
36
- before 'deploy:setup', 'rvm:install_rvm'
37
- before 'deploy:setup', 'rvm:install_ruby'
38
- before "deploy:assets:precompile", "deploy:fix_stuff"
39
-
40
-
41
- namespace :deploy do
42
- desc "Zero-downtime restart of Unicorn"
43
- task :zero_restart, :except => { :no_release => true } do
44
- run "kill -s USR2 `cat #{shared_path}/pids/unicorn.pid`"
45
- end
46
-
47
- desc "Downtime restart of Unicorn"
48
- task :restart, :except => { :no_release => true } do
49
- run "kill -s KILL `cat #{shared_path}/pids/unicorn.pid`"
50
- sleep 10
51
- run "rvm rvmrc trust #{current_release}"
52
- run "cd #{current_path} ; bundle exec r200_unicorn -c #{current_path}/config/unicorn.rb -D -E production"
53
- end
54
-
55
-
56
- desc "Start unicorn"
57
- task :start, :except => { :no_release => true } do
58
- run "rvm rvmrc trust #{current_release}"
59
- run "cd #{current_path} ; bundle exec r200_unicorn -c #{current_path}/config/unicorn.rb -D -E production"
60
- end
61
-
62
- desc "Stop unicorn"
63
- task :stop, :except => { :no_release => true } do
64
- run "kill -s QUIT `cat #{shared_path}/pids/unicorn.pid`"
65
- end
66
-
67
- desc "Kill unicorn"
68
- task :kill, :except => { :no_release => true } do
69
- run "kill -s KILL `cat #{shared_path}/pids/unicorn.pid`"
70
- end
71
-
72
- desc "Fix Stuff."
73
- task :fix_stuff do
74
- run "cd #{shared_path} && mkdir -p log"
75
- run "cd #{shared_path} && mkdir -p sockets"
76
- run "ln -s #{shared_path}/sockets #{release_path}/tmp/sockets"
77
- run "cd #{shared_path} && mkdir -p uploads"
78
- run "ln -s #{shared_path}/uploads #{release_path}/public/uploads"
79
- end
80
-
81
-
82
- end
@@ -1,47 +0,0 @@
1
- APP_ROOT = File.expand_path(File.dirname(File.dirname(__FILE__)))
2
-
3
- if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
4
- begin
5
- #rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
6
- #rvm_lib_path = File.join(rvm_path, 'lib')
7
- #$LOAD_PATH.unshift rvm_lib_path
8
- require 'rvm'
9
- RVM.use_from_path! APP_ROOT
10
- rescue LoadError
11
- raise "RVM ruby lib is currently unavailable."
12
- end
13
- end
14
-
15
- ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
16
- require 'bundler/setup'
17
-
18
- worker_processes 4
19
- working_directory APP_ROOT
20
-
21
- preload_app true
22
-
23
- timeout 30
24
-
25
- listen APP_ROOT + "/tmp/sockets/unicorn.sock", :backlog => 64
26
-
27
- pid APP_ROOT + "/tmp/pids/unicorn.pid"
28
-
29
- stderr_path APP_ROOT + "/log/unicorn.stderr.log"
30
- stdout_path APP_ROOT + "/log/unicorn.stdout.log"
31
-
32
- before_fork do |server, worker|
33
- defined?(ActiveRecord::Base) && ActiveRecord::Base.connection.disconnect!
34
-
35
- old_pid = Rails.root + '/tmp/pids/unicorn.pid.oldbin'
36
- if File.exists?(old_pid) && server.pid != old_pid
37
- begin
38
- Process.kill("QUIT", File.read(old_pid).to_i)
39
- rescue Errno::ENOENT, Errno::ESRCH
40
- puts "Old master alerady dead"
41
- end
42
- end
43
- end
44
-
45
- after_fork do |server, worker|
46
- defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection
47
- end