rails_init_gem 0.0.5

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.
@@ -0,0 +1,12 @@
1
+ <%- content_for :top do -%>
2
+ <h1><%= t "website_title" %></h1>
3
+ <h2><%= t "welcome" %></h2>
4
+ </br>
5
+ <p class="lead">
6
+ <%= t "lead" %>
7
+ </p>
8
+ <% if can? :edit, current_user %>
9
+ <%= link_to "Edit", edit_user_registration_path %>
10
+ <% end %>
11
+
12
+ <%- end -%>
@@ -0,0 +1,4 @@
1
+ if !Redis.nil?
2
+ TRANSLATION_STORE = Redis.new(db: 2)
3
+ I18n.backend = I18n::Backend::Chain.new(I18n::Backend::KeyValue.new(TRANSLATION_STORE), I18n.backend)
4
+ end
@@ -0,0 +1,7 @@
1
+ project_name = Rails.application.class.parent_name
2
+ if ENV["REDISCLOUD_URL"]
3
+ uri = URI.parse(ENV["REDISCLOUD_URL"])
4
+ $redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
5
+ else
6
+ $redis = Redis::Namespace.new(project_name, :redis => Redis.new)
7
+ end
@@ -0,0 +1,8 @@
1
+ development:
2
+ secret_key_base: <%= secret_token %>
3
+
4
+ production:
5
+ secret_key_base: <%= secret_token %>
6
+
7
+ test:
8
+ secret_key_base: <%= secret_token %>
@@ -0,0 +1,27 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure your secret_key_base is kept private
11
+ # if you're sharing your code publicly.
12
+ require 'securerandom'
13
+
14
+ def secret_token
15
+ token_file = Rails.root.join('.secret')
16
+ if File.exist?(token_file)
17
+ # Use the existing token.
18
+ File.read(token_file).chomp
19
+ else
20
+ # Generate a new token and store it in token_file.
21
+ token = SecureRandom.hex(64)
22
+ File.write(token_file, token)
23
+ token
24
+ end
25
+ end
26
+
27
+ Ww::Application.config.secret_key_base = secret_token
@@ -0,0 +1,26 @@
1
+ /*
2
+ * Simple CSS stylesheet for a navigation bar and flash messages.
3
+ */
4
+ .flash_notice, .flash_alert {
5
+ padding: 8px 35px 8px 14px;
6
+ margin-bottom: 20px;
7
+ text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
8
+ border: 1px solid #fbeed5;
9
+ -webkit-border-radius: 4px;
10
+ -moz-border-radius: 4px;
11
+ border-radius: 4px;
12
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
13
+ font-size: 14px;
14
+ line-height: 20px;
15
+ }
16
+ .flash_notice {
17
+ background-color: #dff0d8;
18
+ border-color: #d6e9c6;
19
+ color: #468847;
20
+ }
21
+ .flash_alert {
22
+ background-color: #f2dede;
23
+ border-color: #eed3d7;
24
+ color: #b94a48;
25
+ }
26
+
@@ -0,0 +1,82 @@
1
+
2
+ # config/unicorn.rb
3
+
4
+
5
+
6
+ root = "/home/ziongh/railsProjects/current/ww"
7
+ working_directory root
8
+ pid "#{root}/tmp/pids/unicorn.pid"
9
+ stderr_path "#{root}/log/unicorn.log"
10
+ stdout_path "#{root}/log/unicorn.log"
11
+
12
+ worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
13
+ timeout 15
14
+ preload_app true
15
+
16
+
17
+ listen "/tmp/unicorn.Ww.sock"
18
+
19
+ # Force the bundler gemfile environment variable to
20
+ # reference the capistrano "current" symlink
21
+ before_exec do |_|
22
+ ENV["BUNDLE_GEMFILE"] = File.join(root, 'Gemfile')
23
+ end
24
+
25
+ before_fork do |server, worker|
26
+ Signal.trap 'TERM' do
27
+ puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
28
+ Process.kill 'QUIT', Process.pid
29
+ end
30
+ # the following is highly recomended for Rails + "preload_app true"
31
+ # as there's no need for the master process to hold a connection
32
+ if defined?(Redis)
33
+ # this throws errors
34
+ # Redis.current tries to connect localhost
35
+ Redis.current.quit
36
+ end
37
+
38
+ if defined?(ActiveRecord::Base)
39
+ ActiveRecord::Base.connection.disconnect!
40
+ end
41
+
42
+ defined?(ActiveRecord::Base) and
43
+ ActiveRecord::Base.connection.disconnect!
44
+
45
+ # Before forking, kill the master process that belongs to the .oldbin PID.
46
+ # This enables 0 downtime deploys.
47
+ old_pid = "/tmp/unicorn.Ww.pid.oldbin"
48
+ if File.exists?(old_pid) && server.pid != old_pid
49
+ begin
50
+ Process.kill("QUIT", File.read(old_pid).to_i)
51
+ rescue Errno::ENOENT, Errno::ESRCH
52
+ # someone else did our job for us
53
+ end
54
+ end
55
+ end
56
+
57
+ after_fork do |server, worker|
58
+
59
+ Signal.trap 'TERM' do
60
+ puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
61
+ end
62
+
63
+ # the following is *required* for Rails + "preload_app true",
64
+ defined?(ActiveRecord::Base) and
65
+ ActiveRecord::Base.establish_connection
66
+
67
+ if defined?(Redis)
68
+ if ENV["REDISCLOUD_URL"]
69
+ uri = URI.parse(ENV["REDISCLOUD_URL"])
70
+ $redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
71
+ else
72
+ $redis = Redis::Namespace.new("Ww", :redis => Redis.new)
73
+ end
74
+ # Redis.current = Redis.new(url: ENV['REDIS_URI'])
75
+ end
76
+
77
+ # if preload_app is true, then you may also want to check and
78
+ # restart any other shared sockets/descriptors such as Memcached,
79
+ # and Redis. TokyoCabinet file handles are safe to reuse
80
+ # between any number of forked children (assuming your kernel
81
+ # correctly implements pread()/pwrite() system calls)
82
+ end
@@ -0,0 +1,84 @@
1
+ #!/bin/sh
2
+ ### BEGIN INIT INFO
3
+ # Provides: unicorn
4
+ # Required-Start: $remote_fs $syslog
5
+ # Required-Stop: $remote_fs $syslog
6
+ # Default-Start: 2 3 4 5
7
+ # Default-Stop: 0 1 6
8
+ # Short-Description: Manage unicorn server
9
+ # Description: Start, stop, restart unicorn server for a specific application.
10
+ ### END INIT INFO
11
+ set -e
12
+
13
+ # Feel free to change any of the following variables for your app:
14
+ TIMEOUT=${TIMEOUT-60}
15
+ APP_ROOT="/home/EXAMPLE_USER/railsProjects/current/ww"
16
+ PID=$APP_ROOT/tmp/pids/unicorn.pid
17
+ CMD="cd $APP_ROOT; bundle exec unicorn -p 3000 -D -c $APP_ROOT/config/unicorn.rb -E production"
18
+ AS_USER=EXAMPLE_USER
19
+ set -u
20
+
21
+ OLD_PIN="$PID.oldbin"
22
+
23
+ sig () {
24
+ test -s "$PID" && kill -$1 `cat $PID`
25
+ }
26
+
27
+ oldsig () {
28
+ test -s $OLD_PIN && kill -$1 `cat $OLD_PIN`
29
+ }
30
+
31
+ run () {
32
+ if [ "$(id -un)" = "$AS_USER" ]; then
33
+ eval $1
34
+ else
35
+ su -c "$1" - $AS_USER
36
+ fi
37
+ }
38
+
39
+ case "$1" in
40
+ start)
41
+ sig 0 && echo >&2 "Already running" && exit 0
42
+ run "$CMD"
43
+ ;;
44
+ stop)
45
+ sig QUIT && exit 0
46
+ echo >&2 "Not running"
47
+ ;;
48
+ force-stop)
49
+ sig TERM && exit 0
50
+ echo >&2 "Not running"
51
+ ;;
52
+ restart|reload)
53
+ sig HUP && echo reloaded OK && exit 0
54
+ echo >&2 "Couldn't reload, starting '$CMD' instead"
55
+ run "$CMD"
56
+ ;;
57
+ upgrade)
58
+ if sig USR2 && sleep 2 && sig 0 && oldsig QUIT
59
+ then
60
+ n=$TIMEOUT
61
+ while test -s $OLD_PIN && test $n -ge 0
62
+ do
63
+ printf '.' && sleep 1 && n=$(( $n - 1 ))
64
+ done
65
+ echo
66
+
67
+ if test $n -lt 0 && test -s $OLD_PIN
68
+ then
69
+ echo >&2 "$OLD_PIN still exists after $TIMEOUT seconds"
70
+ exit 1
71
+ fi
72
+ exit 0
73
+ fi
74
+ echo >&2 "Couldn't upgrade, starting '$CMD' instead"
75
+ run "$CMD"
76
+ ;;
77
+ reopen-logs)
78
+ sig USR1
79
+ ;;
80
+ *)
81
+ echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"
82
+ exit 1
83
+ ;;
84
+ esac
@@ -0,0 +1,3 @@
1
+ module RailsInitGem
2
+ VERSION = "0.0.5"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "rails_init_gem/version"
2
+
3
+ module RailsInitGem
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails_init_gem/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rails_init_gem"
8
+ spec.version = RailsInitGem::VERSION
9
+ spec.authors = ["Rodrigo Riskalla Leal"]
10
+ spec.email = ["rodrigo.riskalla.leal@usp.br"]
11
+ spec.summary = %q{Generates a initial application.}
12
+ spec.description = %q{Uses lots of Gems to create a functioning application ready for improvements.}
13
+ spec.homepage = "https://github.com/ziongh/rails_init_gem"
14
+ spec.license = "Apache v2.0"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_init_gem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - Rodrigo Riskalla Leal
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Uses lots of Gems to create a functioning application ready for improvements.
42
+ email:
43
+ - rodrigo.riskalla.leal@usp.br
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - Gemfile_sources
51
+ - LICENSE
52
+ - README.md
53
+ - Rakefile
54
+ - lib/generators/new/new_generator.rb
55
+ - lib/generators/new/templates/Gemfile
56
+ - lib/generators/new/templates/_navigation.html.erb
57
+ - lib/generators/new/templates/_navigation_links.html.erb
58
+ - lib/generators/new/templates/about.html.erb
59
+ - lib/generators/new/templates/application.html.erb
60
+ - lib/generators/new/templates/custom.js
61
+ - lib/generators/new/templates/database.yml
62
+ - lib/generators/new/templates/docs.css
63
+ - lib/generators/new/templates/home.html.erb
64
+ - lib/generators/new/templates/i18n_backend.rb
65
+ - lib/generators/new/templates/redis.rb
66
+ - lib/generators/new/templates/secret.yml
67
+ - lib/generators/new/templates/secret_token.rb
68
+ - lib/generators/new/templates/simple.css
69
+ - lib/generators/new/templates/unicorn.rb
70
+ - lib/generators/new/templates/unicorn_init.sh
71
+ - lib/rails_init_gem.rb
72
+ - lib/rails_init_gem/version.rb
73
+ - rails_init_gem.gemspec
74
+ homepage: https://github.com/ziongh/rails_init_gem
75
+ licenses:
76
+ - Apache v2.0
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.2.2
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Generates a initial application.
98
+ test_files: []