trireme 0.0.1

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.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +1 -0
  7. data/bin/trireme +12 -0
  8. data/lib/trireme/actions.rb +20 -0
  9. data/lib/trireme/app_builder.rb +207 -0
  10. data/lib/trireme/generators/app_generator.rb +177 -0
  11. data/lib/trireme/templates/.rspec +1 -0
  12. data/lib/trireme/templates/Capfile +4 -0
  13. data/lib/trireme/templates/Guardfile +32 -0
  14. data/lib/trireme/templates/README.md.erb +6 -0
  15. data/lib/trireme/templates/additional_gems +37 -0
  16. data/lib/trireme/templates/app/assets/stylesheets/_bootstrap_and_overrides.scss +818 -0
  17. data/lib/trireme/templates/app/assets/stylesheets/application.css.scss +3 -0
  18. data/lib/trireme/templates/app/helpers/utility_helper.rb +32 -0
  19. data/lib/trireme/templates/app/views/layouts/application.html.erb +34 -0
  20. data/lib/trireme/templates/app/views/shared/_admin_actions.html.erb +3 -0
  21. data/lib/trireme/templates/app/views/shared/_flashes.html.erb +12 -0
  22. data/lib/trireme/templates/app/views/shared/_form_errors.html.erb +9 -0
  23. data/lib/trireme/templates/config/deploy/production.rb +17 -0
  24. data/lib/trireme/templates/config/deploy/staging.rb +8 -0
  25. data/lib/trireme/templates/config/deploy.rb.erb +41 -0
  26. data/lib/trireme/templates/config/environments/development.rb +45 -0
  27. data/lib/trireme/templates/config/environments/production.rb +70 -0
  28. data/lib/trireme/templates/config/environments/staging.rb +68 -0
  29. data/lib/trireme/templates/config/environments/test.rb +37 -0
  30. data/lib/trireme/templates/config/initializers/better_errors.rb +1 -0
  31. data/lib/trireme/templates/config/initializers/jazz_hands.rb +4 -0
  32. data/lib/trireme/templates/config/recipes/base.rb +8 -0
  33. data/lib/trireme/templates/config/recipes/check.rb +14 -0
  34. data/lib/trireme/templates/config/recipes/log.rb +6 -0
  35. data/lib/trireme/templates/config/recipes/logrotate.rb +8 -0
  36. data/lib/trireme/templates/config/recipes/nginx.rb +17 -0
  37. data/lib/trireme/templates/config/recipes/postgresql.rb +32 -0
  38. data/lib/trireme/templates/config/recipes/scripts/sql_functions.sql +23 -0
  39. data/lib/trireme/templates/config/recipes/templates/logrotate.erb +9 -0
  40. data/lib/trireme/templates/config/recipes/templates/nginx_unicorn.erb +69 -0
  41. data/lib/trireme/templates/config/recipes/templates/postgresql.yml.erb +8 -0
  42. data/lib/trireme/templates/config/recipes/templates/unicorn.rb.erb +14 -0
  43. data/lib/trireme/templates/config/recipes/templates/unicorn_init.erb +84 -0
  44. data/lib/trireme/templates/config/recipes/unicorn.rb +26 -0
  45. data/lib/trireme/templates/gitignore_additions +2 -0
  46. data/lib/trireme/templates/lib/templates/erb/scaffold/_form.html.erb +16 -0
  47. data/lib/trireme/templates/lib/templates/erb/scaffold/edit.html.erb +6 -0
  48. data/lib/trireme/templates/lib/templates/erb/scaffold/index.html.erb +27 -0
  49. data/lib/trireme/templates/lib/templates/erb/scaffold/new.html.erb +5 -0
  50. data/lib/trireme/templates/lib/templates/erb/scaffold/show.html.erb +10 -0
  51. data/lib/trireme/templates/spec/spec_helper.rb +60 -0
  52. data/lib/trireme/version.rb +3 -0
  53. data/lib/trireme.rb +48 -0
  54. data/trireme.gemspec +23 -0
  55. metadata +127 -0
@@ -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=<%= current_path %>
16
+ PID=<%= unicorn_pid %>
17
+ CMD="cd <%= current_path %>; bundle exec unicorn -D -c <%= unicorn_config %> -E <%= rails_env %>"
18
+ AS_USER=<%= unicorn_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,26 @@
1
+ set_default(:unicorn_user) { user }
2
+ set_default(:unicorn_pid) { "#{current_path}/tmp/pids/unicorn.pid" }
3
+ set_default(:unicorn_config) { "#{shared_path}/config/unicorn.rb" }
4
+ set_default(:unicorn_log) { "#{shared_path}/log/unicorn.log" }
5
+ set_default(:unicorn_workers, 2)
6
+
7
+ namespace :unicorn do
8
+ desc "Setup Unicorn initializer and app configuration"
9
+ task :setup, roles: :app do
10
+ run "mkdir -p #{shared_path}/config"
11
+ template "unicorn.rb.erb", unicorn_config
12
+ template "unicorn_init.erb", "/tmp/unicorn_init"
13
+ run "chmod +x /tmp/unicorn_init"
14
+ run "#{sudo} mv /tmp/unicorn_init /etc/init.d/unicorn_#{application}_#{rails_env}"
15
+ run "#{sudo} update-rc.d -f unicorn_#{application}_#{rails_env} defaults"
16
+ end
17
+ after "deploy:setup", "unicorn:setup"
18
+
19
+ %w[start stop restart].each do |command|
20
+ desc "#{command.capitalize} unicorn"
21
+ task command, roles: :app do
22
+ run "/etc/init.d/unicorn_#{application}_#{stage} #{command}"
23
+ end
24
+ after "deploy:#{command}", "unicorn:#{command}"
25
+ end
26
+ end
@@ -0,0 +1,2 @@
1
+ config/database.yml
2
+ .vagrant
@@ -0,0 +1,16 @@
1
+ <%%= form_for(@<%= singular_table_name %>) do |f| %>
2
+ <%% if @<%= singular_table_name %>.errors.any? %>
3
+ <%%= render 'shared/form_errors', obj: @category %>
4
+ <%% end %>
5
+
6
+ <% attributes.each do |attribute| -%>
7
+ <div class="form-group">
8
+ <%%= f.label :<%= attribute.name %> %>
9
+ <%%= f.<%= attribute.field_type %> :<%= attribute.name %>, class: 'form-control' %>
10
+ </div>
11
+ <% end -%>
12
+
13
+ <div class="form-actions">
14
+ <%%= f.submit 'Save', class: 'btn btn-primary' %>
15
+ </div>
16
+ <%% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing <%= singular_table_name %></h1>
2
+
3
+ <%%= render 'form' %>
4
+
5
+ <%%= link_to "Show", @<%= singular_table_name %>, class: 'btn btn-primary' %> |
6
+ <%%= link_to "Back to <%= plural_table_name %>", <%= index_helper %>_path, class: 'btn btn-default' %>
@@ -0,0 +1,27 @@
1
+ <h1><%= plural_table_name %></h1>
2
+
3
+ <table class="table">
4
+ <thead>
5
+ <tr>
6
+ <% attributes.each do |attribute| -%>
7
+ <th><%= attribute.human_name %></th>
8
+ <% end -%>
9
+ <th class="index-actions"></th>
10
+ </tr>
11
+ </thead>
12
+
13
+ <tbody>
14
+ <%%= content_tag_for(:tr, @<%= plural_table_name %>) do |<%= singular_table_name %>| %>
15
+ <% attributes.each do |attribute| -%>
16
+ <td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
17
+ <% end -%>
18
+ <td>
19
+ <td><%%= render 'shared/admin_actions', obj: category %></td>
20
+ </td>
21
+ <%% end %>
22
+ </tbody>
23
+ </table>
24
+
25
+ <br />
26
+
27
+ <%%= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path, class: 'btn btn-default' %>
@@ -0,0 +1,5 @@
1
+ <h1>New <%= singular_table_name %></h1>
2
+
3
+ <%%= render 'form' %>
4
+
5
+ <%%= link_to 'Back to <%= plural_table_name %>', <%= index_helper %>_path, class: 'btn btn-default' %>
@@ -0,0 +1,10 @@
1
+ <% attributes.each do |attribute| -%>
2
+ <p>
3
+ <strong><%= attribute.human_name %>:</strong>
4
+ <%%= @<%= singular_table_name %>.<%= attribute.name %> %>
5
+ </p>
6
+
7
+ <% end -%>
8
+
9
+ <%%= link_to 'Edit', edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: 'btn btn-default' %>
10
+ <%%= link_to 'Back to <%= plural_table_name %>', <%= index_helper %>_path, class: 'btn btn-default' %>
@@ -0,0 +1,60 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../../config/environment", __FILE__)
4
+ require 'rspec/rails'
5
+ require 'rspec/autorun'
6
+ require 'capybara/rails'
7
+ require 'capybara/rspec'
8
+
9
+ # Requires supporting ruby files with custom matchers and macros, etc, in
10
+ # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
11
+ # run as spec files by default. This means that files in spec/support that end
12
+ # in _spec.rb will both be required and run as specs, causing the specs to be
13
+ # run twice. It is recommended that you do not name files matching this glob to
14
+ # end with _spec.rb. You can configure this pattern with with the --pattern
15
+ # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
16
+ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
17
+
18
+ # Checks for pending migrations before tests are run.
19
+ # If you are not using ActiveRecord, you can remove this line.
20
+ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
21
+
22
+ RSpec.configure do |config|
23
+ # ## Mock Framework
24
+ #
25
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
26
+ #
27
+ # config.mock_with :mocha
28
+ # config.mock_with :flexmock
29
+ # config.mock_with :rr
30
+
31
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
32
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
33
+
34
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
35
+ # examples within a transaction, remove the following line or assign false
36
+ # instead of true.
37
+ config.use_transactional_fixtures = true
38
+
39
+ # If true, the base class of anonymous controllers will be inferred
40
+ # automatically. This will be the default behavior in future versions of
41
+ # rspec-rails.
42
+ config.infer_base_class_for_anonymous_controllers = false
43
+
44
+ # Run specs in random order to surface order dependencies. If you find an
45
+ # order dependency and want to debug it, you can fix the order by providing
46
+ # the seed, which is printed after each run.
47
+ # --seed 1234
48
+ config.order = "random"
49
+
50
+ config.include Rails.application.routes.url_helpers
51
+ config.include FactoryGirl::Syntax::Methods
52
+ config.include Devise::TestHelpers, :type => :controller
53
+
54
+ Rails.application.routes.default_url_options[:host] = 'test.host'
55
+
56
+ config.before(:suite) do
57
+ # Clean all tables to start
58
+ DatabaseCleaner.clean_with :truncation
59
+ end
60
+ end
@@ -0,0 +1,3 @@
1
+ module Trireme
2
+ VERSION = "0.0.1"
3
+ end
data/lib/trireme.rb ADDED
@@ -0,0 +1,48 @@
1
+ require "trireme/version"
2
+ require "yaml"
3
+
4
+ module Trireme
5
+ @config = {
6
+ devise: {
7
+ model: 'user',
8
+ seed: false
9
+ }
10
+ }
11
+
12
+ # @valid_config_keys = @config.keys
13
+
14
+ def self.configure(opts = {})
15
+ symbolize_keys(opts).each { |k, v| @config[k] = v } # if @valid_config_keys.include? k.to_sym}
16
+ end
17
+
18
+ def self.configure_with(path_to_yaml_file)
19
+ begin
20
+ config = YAML::load(IO.read(path_to_yaml_file))
21
+ rescue Errno::ENOENT
22
+ puts "YAML configuration file couldn't be found. Using defaults."; return
23
+ rescue Psych::SyntaxError
24
+ puts "YAML configuration file contains invalid syntax. Using defaults."; return
25
+ end
26
+
27
+ configure(config)
28
+ end
29
+
30
+ def self.config
31
+ @config
32
+ end
33
+
34
+ def self.symbolize_keys(hash)
35
+ hash.inject({}){|result, (key, value)|
36
+ new_key = case key
37
+ when String then key.to_sym
38
+ else key
39
+ end
40
+ new_value = case value
41
+ when Hash then symbolize_keys(value)
42
+ else value
43
+ end
44
+ result[new_key] = new_value
45
+ result
46
+ }
47
+ end
48
+ end
data/trireme.gemspec ADDED
@@ -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 'trireme/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "trireme"
8
+ spec.version = Trireme::VERSION
9
+ spec.authors = ["Nathan Sharpe"]
10
+ spec.email = ["nathan@cliftonlabs.com"]
11
+ spec.description = %q{Rails application generator}
12
+ spec.summary = %q{Generates rails application and configures some extras}
13
+ spec.homepage = "https://github.com/cliftonlabs/trireme"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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.3"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trireme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nathan Sharpe
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-01 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Rails application generator
42
+ email:
43
+ - nathan@cliftonlabs.com
44
+ executables:
45
+ - trireme
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/trireme
55
+ - lib/trireme.rb
56
+ - lib/trireme/actions.rb
57
+ - lib/trireme/app_builder.rb
58
+ - lib/trireme/generators/app_generator.rb
59
+ - lib/trireme/templates/.rspec
60
+ - lib/trireme/templates/Capfile
61
+ - lib/trireme/templates/Guardfile
62
+ - lib/trireme/templates/README.md.erb
63
+ - lib/trireme/templates/additional_gems
64
+ - lib/trireme/templates/app/assets/stylesheets/_bootstrap_and_overrides.scss
65
+ - lib/trireme/templates/app/assets/stylesheets/application.css.scss
66
+ - lib/trireme/templates/app/helpers/utility_helper.rb
67
+ - lib/trireme/templates/app/views/layouts/application.html.erb
68
+ - lib/trireme/templates/app/views/shared/_admin_actions.html.erb
69
+ - lib/trireme/templates/app/views/shared/_flashes.html.erb
70
+ - lib/trireme/templates/app/views/shared/_form_errors.html.erb
71
+ - lib/trireme/templates/config/deploy.rb.erb
72
+ - lib/trireme/templates/config/deploy/production.rb
73
+ - lib/trireme/templates/config/deploy/staging.rb
74
+ - lib/trireme/templates/config/environments/development.rb
75
+ - lib/trireme/templates/config/environments/production.rb
76
+ - lib/trireme/templates/config/environments/staging.rb
77
+ - lib/trireme/templates/config/environments/test.rb
78
+ - lib/trireme/templates/config/initializers/better_errors.rb
79
+ - lib/trireme/templates/config/initializers/jazz_hands.rb
80
+ - lib/trireme/templates/config/recipes/base.rb
81
+ - lib/trireme/templates/config/recipes/check.rb
82
+ - lib/trireme/templates/config/recipes/log.rb
83
+ - lib/trireme/templates/config/recipes/logrotate.rb
84
+ - lib/trireme/templates/config/recipes/nginx.rb
85
+ - lib/trireme/templates/config/recipes/postgresql.rb
86
+ - lib/trireme/templates/config/recipes/scripts/sql_functions.sql
87
+ - lib/trireme/templates/config/recipes/templates/logrotate.erb
88
+ - lib/trireme/templates/config/recipes/templates/nginx_unicorn.erb
89
+ - lib/trireme/templates/config/recipes/templates/postgresql.yml.erb
90
+ - lib/trireme/templates/config/recipes/templates/unicorn.rb.erb
91
+ - lib/trireme/templates/config/recipes/templates/unicorn_init.erb
92
+ - lib/trireme/templates/config/recipes/unicorn.rb
93
+ - lib/trireme/templates/gitignore_additions
94
+ - lib/trireme/templates/lib/templates/erb/scaffold/_form.html.erb
95
+ - lib/trireme/templates/lib/templates/erb/scaffold/edit.html.erb
96
+ - lib/trireme/templates/lib/templates/erb/scaffold/index.html.erb
97
+ - lib/trireme/templates/lib/templates/erb/scaffold/new.html.erb
98
+ - lib/trireme/templates/lib/templates/erb/scaffold/show.html.erb
99
+ - lib/trireme/templates/spec/spec_helper.rb
100
+ - lib/trireme/version.rb
101
+ - trireme.gemspec
102
+ homepage: https://github.com/cliftonlabs/trireme
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - '>='
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 2.2.1
123
+ signing_key:
124
+ specification_version: 4
125
+ summary: Generates rails application and configures some extras
126
+ test_files: []
127
+ has_rdoc: