arkenstone 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +19 -0
  3. data/.gitignore +10 -0
  4. data/.rspec +2 -0
  5. data/.rubocop.yml +1148 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +5 -0
  8. data/CODE_OF_CONDUCT.md +13 -0
  9. data/Gemfile +3 -0
  10. data/LICENSE +674 -0
  11. data/README.md +41 -0
  12. data/Rakefile +6 -0
  13. data/arkenstone.gemspec +34 -0
  14. data/bin/arkenstone +21 -0
  15. data/bin/console +7 -0
  16. data/bin/setup +7 -0
  17. data/lib/arkenstone.rb +12 -0
  18. data/lib/arkenstone/app_builder.rb +118 -0
  19. data/lib/arkenstone/generators/app_generator.rb +56 -0
  20. data/lib/arkenstone/templates/.travis.yml.erb +3 -0
  21. data/lib/arkenstone/templates/Gemfile.erb +52 -0
  22. data/lib/arkenstone/templates/README.md.erb +1 -0
  23. data/lib/arkenstone/templates/_flashes.html.erb +3 -0
  24. data/lib/arkenstone/templates/_form.html.erb +13 -0
  25. data/lib/arkenstone/templates/application.html.erb +16 -0
  26. data/lib/arkenstone/templates/application.scss +7 -0
  27. data/lib/arkenstone/templates/database.yml.erb +12 -0
  28. data/lib/arkenstone/templates/database_cleaner.rb +21 -0
  29. data/lib/arkenstone/templates/en.yml.erb +3 -0
  30. data/lib/arkenstone/templates/factories.rb +2 -0
  31. data/lib/arkenstone/templates/high_voltage.rb +4 -0
  32. data/lib/arkenstone/templates/home.html.erb +2 -0
  33. data/lib/arkenstone/templates/rails +9 -0
  34. data/lib/arkenstone/templates/rails_helper.rb +16 -0
  35. data/lib/arkenstone/templates/rake +9 -0
  36. data/lib/arkenstone/templates/simple_form.en.yml +31 -0
  37. data/lib/arkenstone/templates/simple_form.rb +165 -0
  38. data/lib/arkenstone/templates/spring +15 -0
  39. data/lib/arkenstone/templates/user.rb +3 -0
  40. data/lib/arkenstone/version.rb +5 -0
  41. data/spec/arkenstone_spec.rb +7 -0
  42. data/spec/features/new_project_spec.rb +136 -0
  43. data/spec/features/new_project_with_authentication_spec.rb +24 -0
  44. data/spec/spec_helper.rb +13 -0
  45. data/spec/support/features/new_project.rb +57 -0
  46. metadata +183 -0
@@ -0,0 +1,3 @@
1
+ en:
2
+ titles:
3
+ application: <%= app_name.humanize.titleize %>
@@ -0,0 +1,2 @@
1
+ FactoryGirl.define do
2
+ end
@@ -0,0 +1,4 @@
1
+ HighVoltage.configure do |config|
2
+ config.home_page = "home"
3
+ end
4
+ 2
@@ -0,0 +1,2 @@
1
+ <h1><%= app_name %></h1>
2
+ <p>You can find me at app/views/pages/home.html.erb.</p>
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
8
+ require_relative '../config/boot'
9
+ require 'rails/commands'
@@ -0,0 +1,16 @@
1
+ ENV["RAILS_ENV"] ||= "test"
2
+ require File.expand_path("../../config/environment", __FILE__)
3
+ abort("The Rails environment is running in production mode!") if Rails.env.production?
4
+ require "spec_helper"
5
+ require "rspec/rails"
6
+
7
+ Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
8
+
9
+ ActiveRecord::Migration.maintain_test_schema!
10
+
11
+ RSpec.configure do |config|
12
+ config.use_transactional_fixtures = false
13
+ config.infer_spec_type_from_file_location!
14
+ config.filter_rails_from_backtrace!
15
+ config.include Features, type: :feature
16
+ end
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ require_relative '../config/boot'
8
+ require 'rake'
9
+ Rake.application.run
@@ -0,0 +1,31 @@
1
+ en:
2
+ simple_form:
3
+ "yes": 'Yes'
4
+ "no": 'No'
5
+ required:
6
+ text: 'required'
7
+ mark: '*'
8
+ # You can uncomment the line below if you need to overwrite the whole required html.
9
+ # When using html, text and mark won't be used.
10
+ # html: '<abbr title="required">*</abbr>'
11
+ error_notification:
12
+ default_message: "Please review the problems below:"
13
+ # Examples
14
+ # labels:
15
+ # defaults:
16
+ # password: 'Password'
17
+ # user:
18
+ # new:
19
+ # email: 'E-mail to sign in.'
20
+ # edit:
21
+ # email: 'E-mail.'
22
+ # hints:
23
+ # defaults:
24
+ # username: 'User name to sign in.'
25
+ # password: 'No special characters, please.'
26
+ # include_blanks:
27
+ # defaults:
28
+ # age: 'Rather not say'
29
+ # prompts:
30
+ # defaults:
31
+ # age: 'Select your age'
@@ -0,0 +1,165 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ # Wrappers are used by the form builder to generate a
4
+ # complete input. You can remove any component from the
5
+ # wrapper, change the order or even add your own to the
6
+ # stack. The options given below are used to wrap the
7
+ # whole input.
8
+ config.wrappers :default, class: :input,
9
+ hint_class: :field_with_hint, error_class: :field_with_errors do |b|
10
+ ## Extensions enabled by default
11
+ # Any of these extensions can be disabled for a
12
+ # given input by passing: `f.input EXTENSION_NAME => false`.
13
+ # You can make any of these extensions optional by
14
+ # renaming `b.use` to `b.optional`.
15
+
16
+ # Determines whether to use HTML5 (:email, :url, ...)
17
+ # and required attributes
18
+ b.use :html5
19
+
20
+ # Calculates placeholders automatically from I18n
21
+ # You can also pass a string as f.input placeholder: "Placeholder"
22
+ b.use :placeholder
23
+
24
+ ## Optional extensions
25
+ # They are disabled unless you pass `f.input EXTENSION_NAME => true`
26
+ # to the input. If so, they will retrieve the values from the model
27
+ # if any exists. If you want to enable any of those
28
+ # extensions by default, you can change `b.optional` to `b.use`.
29
+
30
+ # Calculates maxlength from length validations for string inputs
31
+ b.optional :maxlength
32
+
33
+ # Calculates pattern from format validations for string inputs
34
+ b.optional :pattern
35
+
36
+ # Calculates min and max from length validations for numeric inputs
37
+ b.optional :min_max
38
+
39
+ # Calculates readonly automatically from readonly attributes
40
+ b.optional :readonly
41
+
42
+ ## Inputs
43
+ b.use :label_input
44
+ b.use :hint, wrap_with: { tag: :span, class: :hint }
45
+ b.use :error, wrap_with: { tag: :span, class: :error }
46
+
47
+ ## full_messages_for
48
+ # If you want to display the full error message for the attribute, you can
49
+ # use the component :full_error, like:
50
+ #
51
+ # b.use :full_error, wrap_with: { tag: :span, class: :error }
52
+ end
53
+
54
+ # The default wrapper to be used by the FormBuilder.
55
+ config.default_wrapper = :default
56
+
57
+ # Define the way to render check boxes / radio buttons with labels.
58
+ # Defaults to :nested for bootstrap config.
59
+ # inline: input + label
60
+ # nested: label > input
61
+ config.boolean_style = :nested
62
+
63
+ # Default class for buttons
64
+ config.button_class = 'btn'
65
+
66
+ # Method used to tidy up errors. Specify any Rails Array method.
67
+ # :first lists the first message for each field.
68
+ # Use :to_sentence to list all errors for each field.
69
+ # config.error_method = :first
70
+
71
+ # Default tag used for error notification helper.
72
+ config.error_notification_tag = :div
73
+
74
+ # CSS class to add for error notification helper.
75
+ config.error_notification_class = 'error_notification'
76
+
77
+ # ID to add for error notification helper.
78
+ # config.error_notification_id = nil
79
+
80
+ # Series of attempts to detect a default label method for collection.
81
+ # config.collection_label_methods = [ :to_label, :name, :title, :to_s ]
82
+
83
+ # Series of attempts to detect a default value method for collection.
84
+ # config.collection_value_methods = [ :id, :to_s ]
85
+
86
+ # You can wrap a collection of radio/check boxes in a pre-defined tag, defaulting to none.
87
+ # config.collection_wrapper_tag = nil
88
+
89
+ # You can define the class to use on all collection wrappers. Defaulting to none.
90
+ # config.collection_wrapper_class = nil
91
+
92
+ # You can wrap each item in a collection of radio/check boxes with a tag,
93
+ # defaulting to :span.
94
+ # config.item_wrapper_tag = :span
95
+
96
+ # You can define a class to use in all item wrappers. Defaulting to none.
97
+ # config.item_wrapper_class = nil
98
+
99
+ # How the label text should be generated altogether with the required text.
100
+ # config.label_text = lambda { |label, required, explicit_label| "#{required} #{label}" }
101
+
102
+ # You can define the class to use on all labels. Default is nil.
103
+ # config.label_class = nil
104
+
105
+ # You can define the default class to be used on forms. Can be overriden
106
+ # with `html: { :class }`. Defaulting to none.
107
+ # config.default_form_class = nil
108
+
109
+ # You can define which elements should obtain additional classes
110
+ # config.generate_additional_classes_for = [:wrapper, :label, :input]
111
+
112
+ # Whether attributes are required by default (or not). Default is true.
113
+ # config.required_by_default = true
114
+
115
+ # Tell browsers whether to use the native HTML5 validations (novalidate form option).
116
+ # These validations are enabled in SimpleForm's internal config but disabled by default
117
+ # in this configuration, which is recommended due to some quirks from different browsers.
118
+ # To stop SimpleForm from generating the novalidate option, enabling the HTML5 validations,
119
+ # change this configuration to true.
120
+ config.browser_validations = false
121
+
122
+ # Collection of methods to detect if a file type was given.
123
+ # config.file_methods = [ :mounted_as, :file?, :public_filename ]
124
+
125
+ # Custom mappings for input types. This should be a hash containing a regexp
126
+ # to match as key, and the input type that will be used when the field name
127
+ # matches the regexp as value.
128
+ # config.input_mappings = { /count/ => :integer }
129
+
130
+ # Custom wrappers for input types. This should be a hash containing an input
131
+ # type as key and the wrapper that will be used for all inputs with specified type.
132
+ # config.wrapper_mappings = { string: :prepend }
133
+
134
+ # Namespaces where SimpleForm should look for custom input classes that
135
+ # override default inputs.
136
+ # config.custom_inputs_namespaces << "CustomInputs"
137
+
138
+ # Default priority for time_zone inputs.
139
+ # config.time_zone_priority = nil
140
+
141
+ # Default priority for country inputs.
142
+ # config.country_priority = nil
143
+
144
+ # When false, do not use translations for labels.
145
+ # config.translate_labels = true
146
+
147
+ # Automatically discover new inputs in Rails' autoload path.
148
+ # config.inputs_discovery = true
149
+
150
+ # Cache SimpleForm inputs discovery
151
+ # config.cache_discovery = !Rails.env.development?
152
+
153
+ # Default class for inputs
154
+ # config.input_class = nil
155
+
156
+ # Define the default class of the input wrapper of the boolean input.
157
+ config.boolean_label_class = 'checkbox'
158
+
159
+ # Defines if the default input wrapper class should be included in radio
160
+ # collection wrappers.
161
+ # config.include_default_input_wrapper_class = true
162
+
163
+ # Defines which i18n scope will be used in Simple Form.
164
+ # config.i18n_scope = 'simple_form'
165
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file loads spring without using Bundler, in order to be fast.
4
+ # It gets overwritten when you run the `spring binstub` command.
5
+
6
+ unless defined?(Spring)
7
+ require 'rubygems'
8
+ require 'bundler'
9
+
10
+ if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m))
11
+ Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq }
12
+ gem 'spring', match[1]
13
+ require 'spring/binstub'
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ class User < ActiveRecord::Base
2
+ include Clearance::User
3
+ end
@@ -0,0 +1,5 @@
1
+ module Arkenstone
2
+ VERSION = "0.1.0"
3
+ RUBY_VERSION = IO.read("#{File.dirname(__FILE__)}/../../.ruby-version").strip
4
+ RAILS_VERSION = "~> 4.2.0"
5
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Arkenstone do
4
+ it "has a version number" do
5
+ expect(Arkenstone::VERSION).not_to be_nil
6
+ end
7
+ end
@@ -0,0 +1,136 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Generating a new project" do
4
+ before(:example) do
5
+ remove_dummy_app
6
+ run_arkenstone("--skip-bundle")
7
+ end
8
+
9
+ it "sets Ruby version" do
10
+ ruby_version_file = File.read("#{project_path}/.ruby-version")
11
+ ruby_version_regexp = /^#{Arkenstone::RUBY_VERSION}\n/
12
+
13
+ expect(ruby_version_file).to match(ruby_version_regexp)
14
+ end
15
+
16
+ it "creates Simple Form files" do
17
+ simple_form_initializer = "#{project_path}/config/initializers/simple_form.rb"
18
+ simple_form_locale = "#{project_path}/config/locales/simple_form.en.yml"
19
+ simple_form_partial = "#{project_path}/lib/templates/html/scaffold/_form.html.erb"
20
+
21
+ expect(File).to exist(simple_form_initializer)
22
+ expect(File).to exist(simple_form_locale)
23
+ expect(File).to exist(simple_form_partial)
24
+ end
25
+
26
+ it "sets up the database" do
27
+ db_config = File.read("#{project_path}/config/database.yml")
28
+
29
+ expect(db_config).to include("adapter: postgresql")
30
+ expect(db_config).to include("database: #{app_name}_development")
31
+ end
32
+
33
+ it "customizes application layout" do
34
+ layout = File.read("#{project_path}/app/views/layouts/application.html.erb")
35
+ layout_regexps = [
36
+ /^ +<title><%= page_title %><\/title>$/,
37
+ /^ +<body class="<%= body_class %>">$/
38
+ ]
39
+
40
+ layout_regexps.each do |regexp|
41
+ expect(layout).to match(regexp)
42
+ end
43
+ end
44
+
45
+ it "configures Travis CI" do
46
+ travis_config = File.read("#{project_path}/.travis.yml")
47
+ travis_config_regexp = /^ +- #{Arkenstone::RUBY_VERSION}/
48
+
49
+ expect(travis_config).to match(travis_config_regexp)
50
+ end
51
+
52
+ it "creates factories file" do
53
+ factories_file = "#{project_path}/spec/factories.rb"
54
+
55
+ expect(File).to exist(factories_file)
56
+ end
57
+
58
+ it "creates partials directory" do
59
+ partials_dir = "#{project_path}/app/views/application"
60
+
61
+ expect(File).to exist(partials_dir)
62
+ end
63
+
64
+ it "creates flashes partial" do
65
+ flashes = "#{project_path}/app/views/application/_flashes.html.erb"
66
+
67
+ expect(File).to exist(flashes)
68
+ end
69
+
70
+ it "sets up RSpec" do
71
+ spec_dir = "#{project_path}/spec"
72
+
73
+ expect(File).to exist(spec_dir)
74
+ end
75
+
76
+ it "customizes rails_helper.rb" do
77
+ rails_helper = File.read("#{project_path}/spec/rails_helper.rb")
78
+
79
+ expect(rails_helper).to include('Rails.root.join("spec/support/**/*.rb")')
80
+ expect(rails_helper).to include("config.use_transactional_fixtures = false")
81
+ expect(rails_helper).to include("config.include Features, type: :feature")
82
+ end
83
+
84
+ it "sets up Database Cleaner" do
85
+ database_cleaner_file = "#{project_path}/spec/support/database_cleaner.rb"
86
+
87
+ expect(File).to exist(database_cleaner_file)
88
+ end
89
+
90
+ it "strips comments from Ruby files" do
91
+ result = `grep '^ *#[^!]' -l -r --include=*.rb #{project_path}`
92
+
93
+ expect(result).to eq("")
94
+ end
95
+
96
+ it "sets up style sheets" do
97
+ application_css = "#{project_path}/app/assets/stylesheets/application.css"
98
+ application_scss = "#{project_path}/app/assets/stylesheets/application.scss"
99
+
100
+ expect(File).to_not exist(application_css)
101
+ expect(File).to exist(application_scss)
102
+ end
103
+
104
+ it "sets up Bitters" do
105
+ bitters_dir = "#{project_path}/app/assets/stylesheets/base/_base.scss"
106
+ expect(File).to exist(bitters_dir)
107
+ end
108
+
109
+ it "configures locale" do
110
+ en_locale = File.read("#{project_path}/config/locales/en.yml")
111
+
112
+ expect(en_locale).to include("application: Arkenstone Test")
113
+ end
114
+
115
+ it "sets home page as root path" do
116
+ home_page = "#{project_path}/app/views/pages/home.html.erb"
117
+ high_voltage_initializer = File.read("#{project_path}/config/initializers/high_voltage.rb")
118
+
119
+ expect(File).to exist(home_page)
120
+ expect(high_voltage_initializer).to include('config.home_page = "home"')
121
+ end
122
+
123
+ it "initializes a Git repository" do
124
+ git_dir = "#{project_path}/.git"
125
+
126
+ expect(File).to exist(git_dir)
127
+ end
128
+
129
+ it "creates an initial Git commit" do
130
+ git_opts = "--git-dir=#{project_path}/.git"
131
+ git_opts << " --work-tree=#{project_path}"
132
+ git_log = `git #{git_opts} log -1`
133
+
134
+ expect(git_log).to include("Initial commit")
135
+ end
136
+ end
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Generating a new project with authentication" do
4
+ before(:example) do
5
+ remove_dummy_app
6
+ run_arkenstone("--skip-bundle --authentication")
7
+ end
8
+
9
+ it "creates a User model" do
10
+ user_model = File.join(models_path, "user.rb")
11
+
12
+ expect(File.exist?(user_model)).to be true
13
+ end
14
+
15
+ it "adds Clearance::Controller to ApplicationController" do
16
+ application_controller = File.join(controllers_path, "application_controller.rb")
17
+ pattern = /include Clearance::Controller/
18
+ match = nil
19
+
20
+ File.open(application_controller) { |f| match = pattern.match(f.read) }
21
+
22
+ expect(match).to_not be nil
23
+ end
24
+ end