rails_com 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +11 -3
  3. data/app/assets/javascripts/rails_com/application.js +1 -1
  4. data/app/assets/javascripts/rails_com/common.js +32 -0
  5. data/app/assets/javascripts/rails_com/fetch_xhr_script.js +53 -0
  6. data/app/assets/javascripts/rails_com/footer.js +3 -0
  7. data/app/assets/stylesheets/rails_com/application.css +0 -1
  8. data/app/controllers/common_controller.rb +18 -0
  9. data/app/controllers/concerns/the_common_api.rb +15 -3
  10. data/app/helpers/rails_com/active_helper.rb +17 -6
  11. data/app/helpers/rails_com_helper.rb +6 -3
  12. data/app/models/state_machine.rb +5 -4
  13. data/app/views/shared/_alert.html.erb +1 -5
  14. data/app/views/shared/_error_messages.html.erb +1 -7
  15. data/app/views/shared/_locales.html.erb +8 -0
  16. data/config/initializers/time_format.rb +1 -0
  17. data/config/locales/en.yml +8 -6
  18. data/config/routes.rb +7 -0
  19. data/lib/assets/javascripts/semantic.js +11 -0
  20. data/lib/mina/puma.rb +63 -0
  21. data/lib/mina/sidekiq.rb +65 -0
  22. data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.eot +0 -0
  23. data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.otf +0 -0
  24. data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.svg +946 -2670
  25. data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.ttf +0 -0
  26. data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.woff +0 -0
  27. data/lib/nondigest_assets/fonts/themes/default/assets/fonts/icons.woff2 +0 -0
  28. data/lib/nondigest_assets/{images → fonts}/themes/default/assets/images/flags.png +0 -0
  29. data/lib/rails_com/controller_helper.rb +26 -1
  30. data/lib/rails_com/controllers.rb +8 -0
  31. data/lib/rails_com/core_ext/nil.rb +1 -1
  32. data/lib/rails_com/helpers/uid_helper.rb +24 -4
  33. data/lib/rails_com/rails_ext/scaffold_generator.rb +14 -0
  34. data/lib/rails_com/rails_ext/template_renderer.rb +22 -0
  35. data/lib/rails_com/routes.rb +12 -8
  36. data/lib/rails_com/sprockets/non_digest_assets.rb +0 -18
  37. data/lib/rails_com/version.rb +1 -1
  38. data/lib/rails_com.rb +11 -2
  39. data/lib/templates/erb/scaffold/_form.html.erb.tt +12 -0
  40. data/lib/templates/erb/scaffold/_search_form.html.erb.tt +7 -0
  41. data/lib/templates/erb/scaffold/edit.html.erb.tt +14 -0
  42. data/lib/templates/erb/scaffold/index.html.erb.tt +43 -0
  43. data/lib/templates/erb/scaffold/new.html.erb.tt +13 -0
  44. data/lib/templates/erb/scaffold/show.html.erb.tt +7 -0
  45. data/lib/templates/rails/scaffold_controller/controller.rb.tt +53 -0
  46. metadata +25 -16
  47. data/lib/assets/stylesheets/semantic.css +0 -19466
  48. data/lib/rails_com/helpers/qiniu_helper.rb +0 -84
  49. data/lib/rails_com/sprockets/qiniu_exporter.rb +0 -21
  50. data/lib/rails_com/sprockets.rb +0 -15
  51. data/lib/templates/erb/scaffold/_form.html.erb +0 -19
  52. data/lib/templates/erb/scaffold/edit.html.erb +0 -2
  53. data/lib/templates/erb/scaffold/index.html.erb +0 -36
  54. data/lib/templates/erb/scaffold/new.html.erb +0 -1
  55. data/lib/templates/erb/scaffold/show.html.erb +0 -13
  56. data/lib/templates/rails/scaffold_controller/controller.rb +0 -47
data/lib/mina/puma.rb ADDED
@@ -0,0 +1,63 @@
1
+ set :puma_cmd, -> { "#{fetch :bundle_prefix} puma -e #{fetch :rails_env}" }
2
+ set :pumactl_cmd, -> { "#{fetch :bundle_prefix} pumactl" }
3
+ set :puma_socket, -> { "#{fetch :current_path}/tmp/pids/puma.pid" }
4
+
5
+ namespace :puma do
6
+
7
+ desc 'Start puma'
8
+ task start: :remote_environment do
9
+ in_path(fetch(:current_path)) do
10
+ command %{
11
+ if [[ -e #{fetch :puma_socket} ]]
12
+ then
13
+ echo 'Puma is already running!'
14
+ else
15
+ #{fetch :puma_cmd}
16
+ fi
17
+ }
18
+ end
19
+ end
20
+
21
+ desc 'Stop puma'
22
+ task stop: :remote_environment do
23
+ in_path(fetch(:current_path)) do
24
+ command %{
25
+ if [[ -e #{fetch :puma_socket} ]]
26
+ then
27
+ #{fetch :pumactl_cmd} stop
28
+ else
29
+ echo 'Puma is not running!'
30
+ fi
31
+ }
32
+ end
33
+ end
34
+
35
+ desc 'Restart puma'
36
+ task restart: :remote_environment do
37
+ in_path(fetch(:current_path)) do
38
+ command %{
39
+ if [[ -e #{fetch :puma_socket} ]]
40
+ then
41
+ #{fetch :pumactl_cmd} restart
42
+ else
43
+ echo 'Puma is not running! Start Now!' && #{fetch :puma_cmd}
44
+ fi
45
+ }
46
+ end
47
+ end
48
+
49
+ desc 'Restart puma (phased restart)'
50
+ task phased_restart: :remote_environment do
51
+ in_path(fetch(:current_path)) do
52
+ command %{
53
+ if [[ -e #{fetch :puma_socket} ]]
54
+ then
55
+ #{fetch :pumactl_cmd} phased-restart
56
+ else
57
+ echo 'Puma is not running! Start Now!' && #{fetch :puma_cmd}
58
+ fi
59
+ }
60
+ end
61
+ end
62
+
63
+ end
@@ -0,0 +1,65 @@
1
+ set :sidekiq, -> { "#{fetch :bundle_prefix} sidekiq -d" }
2
+ set :sidekiqctl, -> { "#{fetch :bundle_prefix} sidekiqctl" }
3
+ set :sidekiq_config, -> { "#{fetch :current_path}/config/sidekiq.yml" }
4
+ set :sidekiq_pid, -> { "#{fetch :current_path}/tmp/pids/sidekiq.pid" }
5
+ set :sidekiq_processes, 2
6
+ set :sidekiq_timeout, 10
7
+
8
+ namespace :sidekiq do
9
+
10
+ def for_each_process(&block)
11
+ fetch(:sidekiq_processes).times do |idx|
12
+ if idx == 0
13
+ pid_file = fetch :sidekiq_pid
14
+ else
15
+ pid_file = "#{fetch :sidekiq_pid}-#{idx}"
16
+ end
17
+
18
+ yield(pid_file, idx)
19
+ end
20
+ end
21
+
22
+ desc 'Quiet sidekiq (stop accepting new work)'
23
+ task quiet: :remote_environment do
24
+ comment 'Quiet sidekiq (stop accepting new work)'
25
+ for_each_process do |pid_file, idx|
26
+ command %{
27
+ if [ -f #{pid_file} ] && kill -0 `cat #{pid_file}`> /dev/null 2>&1; then
28
+ cd "#{deploy_to}/#{current_path}"
29
+ #{echo_cmd %{#{sidekiqctl} quiet #{pid_file}} }
30
+ else
31
+ echo 'Skip quiet command (no pid file found)'
32
+ fi
33
+ }
34
+ end
35
+ end
36
+
37
+ desc 'Stop sidekiq'
38
+ task stop: :remote_environment do
39
+ comment 'Stop sidekiq!'
40
+
41
+ for_each_process do |pid_file, _|
42
+ in_path fetch(:current_path) do
43
+ command %{ #{fetch :sidekiqctl} stop #{pid_file} #{fetch :sidekiq_timeout}}
44
+ end
45
+ end
46
+ end
47
+
48
+ desc 'Start sidekiq'
49
+ task start: :remote_environment do
50
+ comment 'Start sidekiq!'
51
+
52
+ for_each_process do |pid_file, idx|
53
+ in_path fetch(:current_path) do
54
+ command %{ #{fetch :sidekiq} -d -i #{idx} -P #{pid_file} }
55
+ end
56
+ end
57
+ end
58
+
59
+ desc 'Restart sidekiq'
60
+ task :restart do
61
+ invoke :'sidekiq:stop'
62
+ invoke :'sidekiq:start'
63
+ end
64
+
65
+ end