shoestrap 0.4.1 → 1.0.0.pre1

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 (90) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -18
  3. data/.rspec +1 -1
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +4 -11
  6. data/CHANGELOG.md +15 -1
  7. data/CONTRIBUTING +1 -0
  8. data/Gemfile +1 -1
  9. data/Guardfile +7 -0
  10. data/LICENSE +17 -4
  11. data/README.md +32 -14
  12. data/Rakefile +11 -10
  13. data/bin/shoestrap +2 -10
  14. data/features/features_helper.rb +91 -0
  15. data/features/shoestrap/commands/new_command_feature.rb +191 -0
  16. data/features/shoestrap/generators/bdd_generator_feature.rb +43 -0
  17. data/features/shoestrap/generators/bootstrap_generator_feature.rb +11 -0
  18. data/features/shoestrap/generators/coffee_files_generator_feature.rb +32 -0
  19. data/features/shoestrap/generators/foundation_generator_feature.rb +34 -0
  20. data/features/shoestrap/generators/kuhsaft_generator_feature.rb +38 -0
  21. data/features/shoestrap/generators/smacss_files_generator_feature.rb +45 -0
  22. data/lib/generators/shoestrap/bdd_generator.rb +34 -0
  23. data/lib/generators/shoestrap/bootstrap_generator.rb +6 -0
  24. data/lib/generators/shoestrap/coffee_files_generator.rb +19 -0
  25. data/lib/generators/shoestrap/database_generator.rb +9 -0
  26. data/lib/generators/shoestrap/foundation_generator.rb +24 -0
  27. data/lib/generators/shoestrap/gem_install_generator.rb +12 -0
  28. data/lib/generators/shoestrap/kuhsaft_generator.rb +34 -0
  29. data/lib/generators/shoestrap/mailcatcher_generator.rb +14 -0
  30. data/lib/generators/shoestrap/smacss_file_generator.rb +33 -0
  31. data/lib/shoestrap.rb +2 -6
  32. data/lib/shoestrap/application_generator.rb +96 -0
  33. data/lib/shoestrap/cli.rb +35 -0
  34. data/lib/shoestrap/railtie.rb +7 -0
  35. data/lib/shoestrap/shell.rb +9 -0
  36. data/lib/shoestrap/version.rb +3 -0
  37. data/shoestrap.gemspec +28 -21
  38. data/spec/shoestrap/application_generator_spec.rb +170 -0
  39. data/spec/shoestrap/cli_spec.rb +28 -0
  40. data/spec/spec_helper.rb +34 -0
  41. data/templates/application_generator/application.html.haml +51 -0
  42. data/templates/application_generator/application_helper.rb +6 -0
  43. data/templates/application_generator/application_template.rb +72 -0
  44. data/templates/application_generator/favicons/favicon-sc-129x129.png +0 -0
  45. data/templates/application_generator/favicons/favicon-sc-16x16.ico +0 -0
  46. data/templates/application_generator/favicons/favicon-sc-32x32.png +0 -0
  47. data/templates/bdd_generator/active_record_spec_helper.rb +19 -0
  48. data/templates/bdd_generator/dotrspec +2 -0
  49. data/templates/bdd_generator/fast_spec_helper.rb +6 -0
  50. data/templates/bdd_generator/spec_helper.rb +12 -0
  51. data/templates/coffee_generator/application.js.coffee +3 -0
  52. data/templates/foundation_generator/_ie8_grid.css +85 -0
  53. data/templates/foundation_generator/_settings.css.sass +171 -0
  54. data/templates/kuhsaft_generator/kuhsaft.rb +5 -0
  55. data/templates/smacss_generator/application.css.sass +18 -0
  56. metadata +165 -74
  57. data/.rvmrc +0 -34
  58. data/lib/generators/shoestrap/app_generator.rb +0 -35
  59. data/lib/generators/shoestrap/cms_generator.rb +0 -57
  60. data/lib/generators/shoestrap/deployment_generator.rb +0 -62
  61. data/lib/generators/shoestrap/templates/cms/migration.rb +0 -15
  62. data/lib/generators/shoestrap/templates/cms/model.rb +0 -10
  63. data/lib/generators/shoestrap/templates/cms/model.yml.erb +0 -9
  64. data/lib/generators/shoestrap/templates/cms/view.yml.erb +0 -10
  65. data/lib/generators/shoestrap/templates/deployment/airbrake.rb +0 -10
  66. data/lib/generators/shoestrap/templates/deployment/database.yml.erb +0 -30
  67. data/lib/generators/shoestrap/templates/deployment/deployment.rake.erb +0 -23
  68. data/lib/generators/shoestrap/templates/deployment/unicorn.rb +0 -38
  69. data/lib/shoestrap/app_builder.rb +0 -132
  70. data/lib/shoestrap/tasks/middleman.rb +0 -21
  71. data/lib/shoestrap/tasks/radiant.rb +0 -41
  72. data/lib/shoestrap/tasks/rails.rb +0 -81
  73. data/templates/Gemfile.erb +0 -43
  74. data/templates/Guardfile +0 -33
  75. data/templates/README.md.erb +0 -30
  76. data/templates/_main_navigation.html.haml.erb +0 -5
  77. data/templates/application.html.haml +0 -24
  78. data/templates/bootstrap_and_overrides.css.sass +0 -7
  79. data/templates/cms_navigation.rb +0 -9
  80. data/templates/development_mail_interceptor.rb +0 -7
  81. data/templates/haml/scaffold/_form.html.haml +0 -10
  82. data/templates/haml/scaffold/edit.html.haml +0 -8
  83. data/templates/haml/scaffold/index.html.haml +0 -29
  84. data/templates/haml/scaffold/new.html.haml +0 -5
  85. data/templates/haml/scaffold/show.html.haml +0 -11
  86. data/templates/index.html.haml +0 -27
  87. data/templates/kuhsaft.css.sass +0 -2
  88. data/templates/rails/scaffold_controller/controller.rb +0 -89
  89. data/templates/setup_mail.rb +0 -1
  90. data/templates/shoestrap.yml +0 -41
data/.rvmrc DELETED
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
- # development environment upon cd'ing into the directory
5
-
6
- # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
- # Only full ruby name is supported here, for short names use:
8
- # echo "rvm use 1.9.3" > .rvmrc
9
- environment_id="ruby-1.9.3-p194@shoestrap"
10
-
11
- # Uncomment the following lines if you want to verify rvm version per project
12
- # rvmrc_rvm_version="1.14.10 (stable)" # 1.10.1 seams as a safe start
13
- # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
- # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
- # return 1
16
- # }
17
-
18
- # First we attempt to load the desired environment directly from the environment
19
- # file. This is very fast and efficient compared to running through the entire
20
- # CLI and selector. If you want feedback on which environment was used then
21
- # insert the word 'use' after --create as this triggers verbose mode.
22
- if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
- && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
- then
25
- \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
- [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
- \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
- else
29
- # If the environment file has not yet been created, use the RVM CLI to select.
30
- rvm --create "$environment_id" || {
31
- echo "Failed to create RVM environment '${environment_id}'."
32
- return 1
33
- }
34
- fi
@@ -1,35 +0,0 @@
1
- require 'rails/generators'
2
- require 'rails/generators/rails/app/app_generator'
3
-
4
- module Shoestrap
5
- class AppGenerator < Rails::Generators::AppGenerator
6
- def finish_template
7
- invoke :custom_generators
8
- super
9
- end
10
-
11
- def custom_generators
12
- # TODO: rvm! (generate rvmrc from currently used ruby/gemset)
13
- build :remove_files_we_dont_need
14
- build :bundle
15
- build :configure_application
16
- build :setup_bdd_env
17
- build :configure_generators
18
- build :install_kuhsaft
19
- build :setup_deployment
20
- build :setup_database
21
- build :outro
22
- end
23
-
24
- def run_bundle
25
- # Don't run bundle now. First add gems etc.
26
- end
27
-
28
- protected
29
-
30
- def get_builder_class
31
- Shoestrap::AppBuilder
32
- end
33
- end
34
- end
35
-
@@ -1,57 +0,0 @@
1
- require "rails/generators/active_record/model/model_generator"
2
-
3
- # TODO: add shoestrap to gemfile
4
-
5
- module Shoestrap
6
- class CmsGenerator < ActiveRecord::Generators::ModelGenerator
7
- source_root File.expand_path('../templates/cms', __FILE__)
8
- # ... and those files are from: activerecord-3.2.11/lib/rails/generators/active_record/model/templates
9
-
10
- remove_hook_for :test_framework
11
-
12
- def create_migration_file
13
- return unless options[:migration] && options[:parent].nil?
14
- migration_template "migration.rb", "db/migrate/create_#{table_name.gsub('cms_','')}.rb"
15
- end
16
-
17
- def create_model_file
18
- template 'model.rb', File.join('app/models', "#{file_name}.rb")
19
- end
20
-
21
- def create_module_file
22
- end
23
-
24
- def generate_scaffolds
25
- generate 'scaffold_controller', "#{name} #{attributes_string} --routing-specs=false --request-specs=false --controller-specs=false --view-specs=false"
26
- end
27
-
28
- def generate_route
29
- generate 'resource_route', name
30
- end
31
-
32
- def generate_nav_link
33
- inject_into_file 'config/cms_navigation.rb', :before => 'primary.dom_class = \'nav\'' do
34
- "primary.item :#{real_table_name}, t('cms.navigation.items.#{real_table_name}'), #{plural_table_name}_path\n "
35
- end
36
- inject_into_file 'config/locales/de/views/cms/shoestrap.yml', :after => 'items:' do
37
- "\n #{real_table_name}:TRANSLATEME\n"
38
- end
39
- end
40
-
41
- def generate_translations
42
- template 'model.yml.erb', "config/locales/de/models/#{real_table_name}.yml"
43
- template 'view.yml.erb', "config/locales/de/views/cms/#{real_table_name}.yml"
44
- end
45
-
46
- protected
47
-
48
- def attributes_string
49
- attributes.map{ |a| "#{a.name}:#{a.type}" }.join(' ')
50
- end
51
-
52
- def real_table_name
53
- table_name.gsub('cms_', '')
54
- end
55
- end
56
- end
57
-
@@ -1,62 +0,0 @@
1
- require 'rails/generators'
2
- require 'pathname'
3
-
4
- module Shoestrap
5
- class DeploymentGenerator < Rails::Generators::Base
6
- source_root File.expand_path('../templates/deployment', __FILE__)
7
-
8
- # TODO: enable js runtime in Gemfile
9
- def add_required_gems
10
- inject_into_file 'Gemfile', "\ngem 'yaml_db'", :after => "gem 'blazing'"
11
- end
12
-
13
- def add_unicorn_config
14
- copy_file 'unicorn.rb', 'config/unicorn.rb'
15
- end
16
-
17
- def add_database_config
18
- template 'database.yml.erb', 'config/database.yml', :force => true
19
- end
20
-
21
- def add_deployment_task
22
- inject_into_file 'Rakefile', "\nrequire 'shoestrap/tasks/rails'\n", :after => 'Application.load_tasks'
23
- remove_file 'lib/tasks/deployment.rake'
24
- end
25
-
26
- def add_airbrake_config
27
- copy_file 'airbrake.rb', 'config/initializers/airbrake.rb'
28
- end
29
-
30
- def add_app_name
31
- inject_into_file 'config/application.rb', "\n config.app_name = '#{app_name}'\n", :after => 'class Application < Rails::Application'
32
- end
33
-
34
- private
35
-
36
- def app_name
37
- @app_name ||= ask("What is this app's name?")
38
-
39
- # prevent screwing up deployment scripts by mistaking
40
- # app identifier with app name ;-)
41
- @app_name.gsub!('_production', '')
42
- @app_name.gsub!('_staging', '')
43
- @app_name
44
- end
45
-
46
- def db_credentials_production
47
- '<%= begin IO.read("#{ENV[\'HOME\']}/.config/' + app_name + '_production/db") rescue "" end %>'
48
- end
49
-
50
- def db_credentials_staging
51
- '<%= begin IO.read("#{ENV[\'HOME\']}/.config/' + app_name + '_staging/db") rescue "" end %>'
52
- end
53
-
54
- def restart_unicorn_command
55
- '#{ENV[\'HOME\']}/unicorn.sh upgrade ' + app_name + '_#{ENV[\'RAILS_ENV\']}'
56
- end
57
-
58
- def restart_monit_command
59
- 'monit -g ' + app_name + '_#{ENV[\'RAILS_ENV\']} monitor'
60
- end
61
- end
62
- end
@@ -1,15 +0,0 @@
1
- class <%= migration_class_name %> < ActiveRecord::Migration
2
- def change
3
- create_table :<%= table_name.gsub('cms_','') %> do |t|
4
- <% attributes.each do |attribute| -%>
5
- t.<%= attribute.type %> :<%= attribute.name %><%= attribute.inject_options %>
6
- <% end -%>
7
- <% if options[:timestamps] %>
8
- t.timestamps
9
- <% end -%>
10
- end
11
- <% attributes_with_index.each do |attribute| -%>
12
- add_index :<%= table_name.gsub('cms_','') %>, :<%= attribute.index_name %><%= attribute.inject_index_options %>
13
- <% end -%>
14
- end
15
- end
@@ -1,10 +0,0 @@
1
- class <%= class_name.split('::').last %> < <%= parent_class_name.classify %>
2
- <% attributes.select {|attr| attr.reference? }.each do |attribute| -%>
3
- belongs_to :<%= attribute.name %>
4
- <% end -%>
5
- <% if !accessible_attributes.empty? -%>
6
- attr_accessible <%= accessible_attributes.map {|a| ":#{a.name}" }.sort.join(', ') %>
7
- <% else -%>
8
- # attr_accessible :title, :body
9
- <% end -%>
10
- end
@@ -1,9 +0,0 @@
1
- de:
2
- activerecord:
3
- attributes:
4
- <%= singular_table_name.gsub('cms_', '') %>:
5
- <%- attributes.each do |attr| -%>
6
- <%= attr.name %>: TRANSLATEME
7
- <%- end %>
8
- models:
9
- <%= singular_table_name.gsub('cms_', '') %>: TRANSLATEME
@@ -1,10 +0,0 @@
1
- de:
2
- cms:
3
- <%= real_table_name %>:
4
- index:
5
- title: TRANSLATEME
6
- new: TRANSLATEME
7
- edit:
8
- title: TRANSLATEME
9
- new:
10
- title: TRANSLATEME
@@ -1,10 +0,0 @@
1
- Airbrake.configure do |config|
2
- if Rails.env.production?
3
- config.api_key = "PLEASE ENTER YOUR PRODUCTION API KEY"
4
- else
5
- config.api_key = "PLEASE ENTER YOUR STAGING API KEY"
6
- end
7
- config.host = 'PLEASE ENTER A VALID HOST'
8
- config.port = 80
9
- config.secure = config.port == 8080
10
- end
@@ -1,30 +0,0 @@
1
- production:
2
- adapter: postgresql
3
- database: <%= app_name %>_production
4
- username: <%= app_name %>
5
- password: <%= db_credentials_production %>
6
- encoding: unicode
7
- pool: 5
8
-
9
- staging:
10
- adapter: postgresql
11
- database: <%= app_name %>_staging
12
- username: <%= app_name %>
13
- password: <%= db_credentials_staging %>
14
- encoding: unicode
15
- pool: 5
16
-
17
- development:
18
- adapter: postgresql
19
- database: <%= app_name %>_development
20
- username: screenconcept
21
- password:
22
- host: localhost
23
- encoding: unicode
24
- pool: 5
25
-
26
- test:
27
- adapter: sqlite3
28
- database: db/test.sqlite3
29
- pool: 5
30
- timeout: 5000
@@ -1,23 +0,0 @@
1
- desc 'run post-deployment stuff'
2
- task :post_deploy do
3
-
4
- # Precompile assets
5
- puts 'Precompiling assets'
6
- Rake::Task["assets:precompile"].invoke
7
-
8
- # Run migrations
9
- puts 'Running migrations if necessary'
10
- Rake::Task["db:migrate"].invoke
11
-
12
- # Trigger Unicorn reexec with 0 downtime
13
- puts 'restarting unicorns'
14
- system "<%= restart_unicorn_command %>"
15
-
16
- # Enable monit monitoring
17
- puts 'enable monit'
18
- system "<%= restart_monit_command %>"
19
-
20
- # Notify Airbrake of deployment
21
- puts 'notifying airbrake'
22
- system "rake airbrake:deploy TO=#{ENV['RAILS_ENV']} REVISION=$(git rev-parse HEAD)"
23
- end
@@ -1,38 +0,0 @@
1
- APP_ROOT = File.expand_path(File.dirname(File.dirname(__FILE__)))
2
-
3
- worker_processes 3
4
- working_directory APP_ROOT
5
- preload_app true
6
- timeout 30
7
-
8
- listen APP_ROOT + "/tmp/unicorn.sock", :backlog => 64
9
- pid APP_ROOT + "/tmp/unicorn.pid"
10
-
11
- stderr_path APP_ROOT + "/log/unicorn.stderr.log"
12
- stdout_path APP_ROOT + "/log/unicorn.stdout.log"
13
-
14
- before_fork do |server, worker|
15
- if defined?(ActiveRecord::Base)
16
- ActiveRecord::Base.connection.disconnect!
17
- end
18
-
19
- old_pid = APP_ROOT + '/tmp/unicorn.pid.oldbin'
20
- if File.exists?(old_pid) && server.pid != old_pid
21
- begin
22
- puts "Killing old master"
23
- Process.kill("QUIT", File.read(old_pid).to_i)
24
- rescue Errno::ENOENT, Errno::ESRCH
25
- puts "Old master alerady dead"
26
- end
27
- end
28
- end
29
-
30
- after_fork do |server, worker|
31
- if defined?(ActiveRecord::Base)
32
- ActiveRecord::Base.establish_connection
33
- end
34
-
35
- child_pid = server.config[:pid].sub('.pid', ".#{worker.nr}.pid")
36
- system("echo #{Process.pid} > #{child_pid}")
37
- end
38
-
@@ -1,132 +0,0 @@
1
- module Shoestrap
2
- class AppBuilder < Rails::AppBuilder
3
- def readme
4
- template 'README.md.erb', 'README.md'
5
- end
6
-
7
- def gemfile
8
- template 'Gemfile.erb', 'Gemfile'
9
- end
10
-
11
- def bundle
12
- bundle_command 'install'
13
- bundle_command 'show rspec'
14
- end
15
-
16
- def setup_bdd_env
17
- setup_rspec
18
- setup_cucumber
19
- setup_guard
20
- setup_mail_interceptor
21
- end
22
-
23
- def setup_database
24
- rake 'db:create'
25
- rake 'db:migrate'
26
- rake 'db:seed'
27
- end
28
-
29
- def configure_generators
30
- # depends on haml-rails and bootstrap-sass
31
- copy_file 'bootstrap_and_overrides.css.sass', 'app/assets/stylesheets/bootstrap_and_overrides.css.sass'
32
- generate 'simple_form:install --bootstrap'
33
- remove_file 'lib/templates/haml/scaffold/_form.html.haml'
34
- remove_file 'config/locales/simple_form.en.yml'
35
-
36
- inject_into_file 'config/application.rb', :after => "config.assets.version = '1.0'" do
37
- <<-eos.gsub(/^ {6}/, '').chomp
38
-
39
- # Configure Generators
40
- config.generators do |g|
41
- g.template_engine :haml
42
- g.test_framework :rspec
43
- g.stylesheets false
44
- g.javascripts false
45
- g.assets false
46
- g.helper false
47
- end
48
- eos
49
- end
50
-
51
- inject_into_file 'app/assets/javascripts/application.js', "\n//= require bootstrap\n", :before => '//= require_tree .'
52
- end
53
-
54
- def configure_application
55
- gsub_file 'config/application.rb', '# config.autoload_paths += %W(#{config.root}/extras)' do
56
- <<-'eos'.gsub(/^ {10}/, '').chomp
57
- config.autoload_paths += %W(#{config.root}/lib)
58
- eos
59
- end
60
-
61
- gsub_file 'config/application.rb', ' # config.i18n.default_locale = :de' do
62
- <<-'eos'.gsub(/^ {6}/, '').chomp
63
- config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
64
- config.i18n.available_locales = [:de]
65
- config.i18n.default_locale = :de
66
- config.time_zone = 'Bern'
67
- eos
68
- end
69
-
70
- empty_directory 'config/locales/de/views/cms'
71
- copy_file 'shoestrap.yml', 'config/locales/de/views/cms/shoestrap.yml'
72
- template 'application.html.haml', 'app/views/layouts/application.html.haml'
73
- remove_file 'app/views/layouts/application.html.erb'
74
- end
75
-
76
- def remove_files_we_dont_need
77
- remove_rails_logo_image
78
- remove_public_index
79
- end
80
-
81
- def install_kuhsaft
82
- # depends on kuhsaft
83
- rake 'kuhsaft:install:migrations'
84
- route 'mount Kuhsaft::Engine => "/"'
85
- copy_file 'kuhsaft.css.sass', 'app/assets/stylesheets/kuhsaft.css.sass'
86
- copy_file 'cms_navigation.rb', 'config/cms_navigation.rb'
87
- inject_into_file 'app/assets/javascripts/application.js', "\n//= require 'kuhsaft/application'\n", :before => '//= require_tree .'
88
- empty_directory 'app/views/kuhsaft/cms/admin/'
89
- template '_main_navigation.html.haml.erb', 'app/views/kuhsaft/cms/admin/_main_navigation.html.haml'
90
- end
91
-
92
- def setup_deployment
93
- generate 'shoestrap:deployment'
94
- end
95
-
96
- def outro
97
- say 'Application is ready!'
98
- end
99
-
100
- private
101
-
102
- def setup_mail_interceptor
103
- # depends on mail gem
104
- copy_file 'development_mail_interceptor.rb', 'lib/development_mail_interceptor.rb'
105
- copy_file 'setup_mail.rb', 'config/initializers/setup_mail.rb'
106
- end
107
-
108
- def setup_rspec
109
- # depends on rspec-rails gem
110
- generate 'rspec:install'
111
- end
112
-
113
- def setup_cucumber
114
- # depends on cucumber gem
115
- generate 'cucumber:install'
116
- end
117
-
118
- def setup_guard
119
- # depends on guard, guard-rspec, guard-cucumber
120
- template 'Guardfile'
121
- end
122
-
123
- def remove_public_index
124
- remove_file 'public/index.html'
125
- end
126
-
127
- def remove_rails_logo_image
128
- remove_file 'app/assets/images/rails.png'
129
- end
130
- end
131
- end
132
-