katapult 0.1.0 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b262aea45a6e72401c0cee7d558e0320e3fe4a1
4
- data.tar.gz: c252ae0b85dd9bd0cf682910a22212bff6058e70
3
+ metadata.gz: c0c8a60d4ea75bbc8ab64191575c2a672d80daf6
4
+ data.tar.gz: 8e3b106a9465545b5bccef527bf11358aa0ecd37
5
5
  SHA512:
6
- metadata.gz: 9a96e6f9ab0445e68bbf35bfa69a8dd2c9122ed212bc6c086a4f402ca57a11d717b5885c805702ba237b109e2439a5be06cefdfcba28eea4b7947c66f2cf39d9
7
- data.tar.gz: b1ee95eb5749a091c3e9d4ed3dd95a209e816cd6c92dfd313a27df545ffb2bac83252988ea0b4b50f8cd21578109fa94968d658a6d9946adc39f07c252692674
6
+ metadata.gz: e0fa254887044ccb0d59a3d7921e8a6122797f1950a2ed4cd55ccfb5da9e25e5c62ab1fe496cdc7b6dbf5675ab7410ae005e888ac69e9e95667d3ca5c146ed8d
7
+ data.tar.gz: 5367cb38a7cd8945ad1c6bb912b0004b17051cbac11a38172c8ea0c1435369e12dbc36f2a3a86a582c6a1ace860515da88572e23a1bd535e0cc3c87657b4d723
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.1.5
data/README.md CHANGED
@@ -8,7 +8,7 @@ application basics and generates (makandra-flavored) code from an application
8
8
  model, significantly speeding up the initial phase of a Rails project.
9
9
 
10
10
  `Katapult` will always support current versions of Ruby and Rails, currently
11
- Rails 4.1 and Ruby 2.1.
11
+ Rails 4.2 and Ruby 2.1.
12
12
 
13
13
 
14
14
  ## Installation
@@ -39,7 +39,9 @@ After installation, you find a file `lib/katapult/application_model.rb` where
39
39
  you will define the properties of your application. Inside this file, use
40
40
  `katapult`'s simple DSL (domain specific language) to express yourself.
41
41
 
42
- The DSL consists of elements, e.g. Model or WUI (which stands for *Web User
42
+
43
+ ### DSL syntax example
44
+ The DSL consists of _elements_, e.g. Model or WUI (which stands for *Web User
43
45
  Interface*). Each `katapult` element has the same syntax, taking a name,
44
46
  options, and a block:
45
47
 
@@ -94,13 +96,7 @@ WUIs.
94
96
  navigation :main
95
97
 
96
98
 
97
- ## Contributing
98
-
99
- <!-- 1. Fork it ( http://github.com/<my-github-username>/katapult/fork )
100
- 2. Create your feature branch (`git checkout -b my-new-feature`)
101
- 3. Commit your changes (`git commit -am 'Add some feature'`)
102
- 4. Push to the branch (`git push origin my-new-feature`)
103
- 5. Create new Pull Request -->
99
+ ## Development
104
100
 
105
101
  `Katapult` caches a pristine Rails application inside its `tmp/` directory to
106
102
  speed up test runs. Keep this in mind, as it may lead to caching issues when
@@ -1,7 +1,7 @@
1
1
  Feature: Katapult binary `katapult`
2
2
 
3
3
  Scenario: Start new Rails application
4
- Given The default aruba timeout is 120 seconds
4
+ Given the default aruba timeout is 120 seconds
5
5
 
6
6
  When I successfully run `katapult target binary_test`
7
7
  Then the output should contain "Creating new Rails application"
@@ -26,6 +26,12 @@ Feature: Katapult binary `katapult`
26
26
  And the output should contain "rails generate katapult:basics"
27
27
  And the output should contain "Author: katapult <katapult@makandra.com>"
28
28
 
29
+ And the output should contain:
30
+ """
31
+ Next step: Model your application in lib/katapult/application_model.rb and
32
+ trigger the code generation by running `katapult fire`.
33
+ """
34
+
29
35
 
30
36
  Scenario: Forget to pass application name
31
37
  When I run `katapult target # without app name`
@@ -46,3 +52,9 @@ Feature: Katapult binary `katapult`
46
52
  Then the output should contain "Loading katapult"
47
53
  And the output should contain "parse lib/katapult/application_model"
48
54
  And the output should contain "render into katapult_test_app"
55
+
56
+ And the output should contain:
57
+ """
58
+ You're done! Now boot up your development server (e.g. with `rails server`)
59
+ and try your kickstarted application in the browser.
60
+ """
@@ -33,16 +33,16 @@ Feature: Katapult in general
33
33
  Scenario: Generate basic files and settings
34
34
  Given I install katapult
35
35
  When I generate katapult basics
36
- Then the file "Gemfile" should contain exactly:
36
+ Then the file ".ruby-version" should contain "2.1.5"
37
+ And the file "Gemfile" should contain exactly:
37
38
  """
38
39
  source 'https://rubygems.org'
39
40
 
40
41
  # from original Gemfile
41
- gem 'rails', '4.1.0'
42
+ gem 'rails', '4.2.1'
42
43
  gem 'mysql2'
43
44
  gem 'jquery-rails'
44
45
  gem 'jbuilder', '~> 2.0'
45
- gem 'spring', group: :development
46
46
  gem 'katapult', path: '../../..'
47
47
 
48
48
  # engines
@@ -79,7 +79,7 @@ Feature: Katapult in general
79
79
  gem 'autoprefixer-rails'
80
80
  gem 'coffee-rails'
81
81
  gem 'uglifier'
82
- gem 'compass-rails'
82
+ gem 'compass-rails', '>= 2.0.4' # fixes "uninitialized constant Sprockets::SassCacheStore"
83
83
  gem 'compass-rgbapng'
84
84
 
85
85
  group :development do
@@ -98,6 +98,7 @@ Feature: Katapult in general
98
98
  gem 'byebug'
99
99
  gem 'factory_girl_rails'
100
100
  gem 'rspec-rails'
101
+ gem 'spring'
101
102
  end
102
103
 
103
104
  group :test do
@@ -113,7 +114,7 @@ Feature: Katapult in general
113
114
  gem 'selenium-webdriver'
114
115
  gem 'spreewald'
115
116
 
116
- gem 'rspec_candy'
117
+ gem 'rspec'
117
118
  gem 'shoulda-matchers', require: false
118
119
  end
119
120
 
@@ -161,7 +162,6 @@ Feature: Katapult in general
161
162
 
162
163
  And the file "features/support/env-custom.rb" should contain:
163
164
  """
164
- require 'rspec_candy/all'
165
165
  require 'spreewald/all_steps'
166
166
  """
167
167
  And a file named "features/support/paths.rb" should exist
@@ -28,7 +28,7 @@ Feature: Generate Models
28
28
  def change
29
29
  create_table :cars do |t|
30
30
 
31
- t.timestamps
31
+ t.timestamps null: false
32
32
  end
33
33
  end
34
34
  end
@@ -95,7 +95,7 @@ Feature: Generate Models
95
95
  t.string :homepage
96
96
  t.boolean :locked
97
97
 
98
- t.timestamps
98
+ t.timestamps null: false
99
99
  end
100
100
  end
101
101
  end
@@ -10,5 +10,5 @@ Then /^there should be a migration with:$/ do |migration|
10
10
  migrations_path = File.join(current_dir, 'db', 'migrate', '*.rb')
11
11
 
12
12
  all_migrations = Dir.glob(migrations_path).map(&File.method(:read)).join
13
- all_migrations.should include(migration)
13
+ expect(all_migrations).to include(migration)
14
14
  end
@@ -21,7 +21,7 @@ module KatapultRailsHelper
21
21
  def ensure_bundled(path)
22
22
  Dir.chdir(path) do
23
23
  Bundler.with_clean_env do
24
- system('bundle check &> /dev/null') or system('bundle install')
24
+ system('bundle check > /dev/null 2>&1') or system('bundle install')
25
25
  end
26
26
  end
27
27
  end
data/features/wui.feature CHANGED
@@ -9,7 +9,7 @@ Feature: Web User Interface
9
9
  Scenario: Generate a Web User Interface
10
10
  When I overwrite "lib/katapult/application_model.rb" with:
11
11
  """
12
- model 'Customer' do |customer|
12
+ model 'customer' do |customer|
13
13
  customer.attr :name
14
14
  customer.attr :age, type: :integer
15
15
 
@@ -19,7 +19,7 @@ Feature: Web User Interface
19
19
  customer.attr :locked, type: :flag, default: false
20
20
  end
21
21
 
22
- wui 'Customer', model: 'Customer' do |wui|
22
+ wui 'customer', model: 'customer' do |wui|
23
23
  wui.crud
24
24
  wui.action :get_member, method: :get, scope: :member
25
25
  wui.action :post_member, method: :post, scope: :member
@@ -10,6 +10,10 @@ module Katapult
10
10
  source_root File.expand_path('../templates', __FILE__)
11
11
 
12
12
 
13
+ def write_ruby_version
14
+ template '.ruby-version'
15
+ end
16
+
13
17
  def write_database_ymls
14
18
  template 'config/database.yml', force: true
15
19
  template 'config/database.sample.yml'
@@ -28,6 +32,12 @@ module Katapult
28
32
 
29
33
  def bundle_install
30
34
  bundle 'install'
35
+
36
+ # There is a bug in the current version of Compass, so we use an older
37
+ # one in our Gemfile template. Since its dependencies "sprockets" and
38
+ # "sass-rails" are already in the Gemfile.lock (from installing Rails),
39
+ # we need to explicitly update them.
40
+ bundle 'update sprockets sass-rails'
31
41
  end
32
42
 
33
43
  def remove_turbolinks_js
@@ -78,6 +88,14 @@ config.autoload_paths << "#{Rails.root}/app/controllers/shared"
78
88
  # template 'config/deploy.rb'
79
89
  # end
80
90
 
91
+ def print_instructions
92
+ puts <<-INSTRUCTIONS.strip_heredoc
93
+
94
+ Next step: Model your application in lib/katapult/application_model.rb and
95
+ trigger the code generation by running `katapult fire`.
96
+ INSTRUCTIONS
97
+ end
98
+
81
99
  private
82
100
 
83
101
  def app_name
@@ -37,7 +37,7 @@ gem 'sass-rails'
37
37
  gem 'autoprefixer-rails'
38
38
  gem 'coffee-rails'
39
39
  gem 'uglifier'
40
- gem 'compass-rails'
40
+ gem 'compass-rails', '>= 2.0.4' # fixes "uninitialized constant Sprockets::SassCacheStore"
41
41
  gem 'compass-rgbapng'
42
42
 
43
43
  group :development do
@@ -56,6 +56,7 @@ group :development, :test do
56
56
  gem 'byebug'
57
57
  gem 'factory_girl_rails'
58
58
  gem 'rspec-rails'
59
+ gem 'spring'
59
60
  end
60
61
 
61
62
  group :test do
@@ -71,6 +72,6 @@ group :test do
71
72
  gem 'selenium-webdriver'
72
73
  gem 'spreewald'
73
74
 
74
- gem 'rspec_candy'
75
+ gem 'rspec'
75
76
  gem 'shoulda-matchers', require: false
76
77
  end
@@ -1,3 +1 @@
1
- require 'rspec' # it does not work without explicitly doing this. why??
2
- require 'rspec_candy/all'
3
1
  require 'spreewald/all_steps'
@@ -1,6 +1,6 @@
1
- Feature: <%= model.name(:human_plural).titleize %>
1
+ Feature: <%= model.name(:humans).titleize %>
2
2
 
3
- Scenario: CRUD <%= model.name(:human_plural) %>
3
+ Scenario: CRUD <%= model.name(:humans) %>
4
4
  Given I am on the list of <%= model.name(:variables) %>
5
5
 
6
6
  # create
@@ -2,4 +2,4 @@
2
2
  <%= @action.name.humanize.titleize %>
3
3
 
4
4
  .tools
5
- = link_to 'All <%= model_name(:human_plural) %>', <%= wui.path(:index) %>, class: 'tools__button'
5
+ = link_to 'All <%= model_name(:humans) %>', <%= wui.path(:index) %>, class: 'tools__button'
@@ -1,5 +1,5 @@
1
1
  %h1
2
- <%= model_name(:human_plural).capitalize %>
2
+ <%= model_name(:humans).capitalize %>
3
3
 
4
4
  .tools
5
5
  = link_to 'Add <%= model_name(:human) %>', <%= wui.path(:new) %>, class: 'tools__button is_primary'
@@ -26,4 +26,4 @@
26
26
 
27
27
  - else
28
28
  %p.help-block
29
- There are no <%= model_name(:human_plural) %> yet.
29
+ There are no <%= model_name(:humans) %> yet.
@@ -2,7 +2,7 @@
2
2
  = <%= model_name(:ivar) %>.to_s
3
3
 
4
4
  .tools
5
- = link_to 'All <%= model_name(:human_plural) %>', <%= wui.path(:index) %>, class: 'tools__button'
5
+ = link_to 'All <%= model_name(:humans) %>', <%= wui.path(:index) %>, class: 'tools__button'
6
6
  = link_to 'Edit', <%= wui.path(:edit, model_name(:ivar)) %>, class: 'tools__button is_primary'
7
7
  = link_to 'Destroy', <%= wui.path(:destroy, model_name(:ivar)) %>, method: :delete, class: 'tools__button', confirm: 'Really destroy?'
8
8
  <% wui.custom_actions.select(&:member?).each do |action| -%>
@@ -15,7 +15,7 @@
15
15
  <% wui.model.attrs.each do |attribute| -%>
16
16
  <%- model_attribute = "#{model_name(:ivar)}.#{attribute.name}" -%>
17
17
  %dt
18
- = <%= model_name(:class_name) %>.human_attribute_name(:<%= attribute.name %>)
18
+ = <%= model_name(:class) %>.human_attribute_name(:<%= attribute.name %>)
19
19
  %dd
20
20
  <%- case attribute.type -%>
21
21
  <%- when :string -%>
@@ -4,7 +4,7 @@ class Navigation
4
4
  navigation :<%= name.downcase %> do
5
5
  <% navigation.wuis.each do |wui| -%>
6
6
  <%- if wui.find_action(:index) -%>
7
- section <%= navigation.section_name(wui) %>, <%= wui.model_name(:human_plural).titlecase.inspect %>, <%= wui.path(:index) %>
7
+ section <%= navigation.section_name(wui) %>, <%= wui.model_name(:humans).titlecase.inspect %>, <%= wui.path(:index) %>
8
8
  <%- end -%>
9
9
  <% end -%>
10
10
  end
@@ -37,6 +37,14 @@ module Katapult
37
37
  run 'bin/rake db:create db:migrate RAILS_ENV=test'
38
38
  end
39
39
 
40
+ def print_instructions
41
+ puts <<-INSTRUCTIONS.strip_heredoc
42
+
43
+ You're done! Now boot up your development server (e.g. with `rails server`)
44
+ and try your kickstarted application in the browser.
45
+ INSTRUCTIONS
46
+ end
47
+
40
48
  private
41
49
 
42
50
  def application_name
@@ -95,7 +95,7 @@ class <%= model_name(:classes) %>Controller < ApplicationController
95
95
  end
96
96
 
97
97
  def <%= method_name(:scope) %>
98
- <%= model_name(:class_name) %>.scoped
98
+ <%= model_name(:class) %>.scoped
99
99
  end
100
100
 
101
101
  <%- if navigation -%>
@@ -8,6 +8,7 @@ module Katapult
8
8
  class Element
9
9
 
10
10
  UnknownOptionError = Class.new(StandardError)
11
+ UnknownFormattingError = Class.new(StandardError)
11
12
 
12
13
  attr_accessor :name, :options
13
14
  attr_reader :application_model
@@ -36,18 +37,18 @@ module Katapult
36
37
  machine_name = @name.underscore
37
38
 
38
39
  case kind.to_s
39
- when 'symbol' then ":#{machine_name}"
40
- when 'symbols' then ":#{machine_name.pluralize}"
41
- when 'variable' then machine_name
42
- when 'variables' then machine_name.pluralize
43
- when 'ivar' then "@#{machine_name}"
44
- when 'ivars' then "@#{machine_name.pluralize}"
45
- when 'human_plural' then human_name.pluralize
46
- when 'human' then human_name
47
- when 'class' then machine_name.classify
48
- when 'classes' then machine_name.classify.pluralize
49
- else
50
- @name
40
+ when '' then @name
41
+ when 'symbol' then ":#{machine_name}"
42
+ when 'symbols' then ":#{machine_name.pluralize}"
43
+ when 'variable' then machine_name
44
+ when 'variables' then machine_name.pluralize
45
+ when 'ivar' then "@#{machine_name}"
46
+ when 'ivars' then "@#{machine_name.pluralize}"
47
+ when 'human' then human_name
48
+ when 'humans' then human_name.pluralize
49
+ when 'class' then machine_name.classify
50
+ when 'classes' then machine_name.classify.pluralize
51
+ else raise UnknownFormattingError, "Unknown name formatting: #{ kind.inspect }"
51
52
  end
52
53
  end
53
54
 
@@ -1,3 +1,3 @@
1
1
  module Katapult
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+ require 'katapult/element'
3
+
4
+ describe Katapult::Element do
5
+ subject { described_class.new('element') }
6
+
7
+ describe '#name' do
8
+ it 'raises an error when passed an unknown formatting kind' do
9
+ expect do
10
+ subject.name(:foobar)
11
+ end.to raise_error(Katapult::Element::UnknownFormattingError,
12
+ 'Unknown name formatting: :foobar')
13
+ end
14
+ end
15
+
16
+ end
data/spec/spec_helper.rb CHANGED
@@ -7,7 +7,6 @@ require 'pry'
7
7
  require 'active_support/core_ext/string/inflections'
8
8
 
9
9
  RSpec.configure do |config|
10
- config.treat_symbols_as_metadata_keys_with_true_values = true
11
10
  config.run_all_when_everything_filtered = true
12
11
  config.filter_run :focus
13
12
 
data/spec/util_spec.rb CHANGED
@@ -5,17 +5,17 @@ describe Katapult::Util do
5
5
 
6
6
  describe '#git_commit' do
7
7
  it 'adds all files before committing' do
8
- Katapult::Util.should_receive(:system).with(/git add --all; git commit/)
8
+ allow(Katapult::Util).to receive(:system).with(/git add --all; git commit/)
9
9
  Katapult::Util.git_commit 'test'
10
10
  end
11
11
 
12
12
  it 'sets "katapult" as commit author' do
13
- Katapult::Util.should_receive(:system).with(/git commit.*--author='katapult \<katapult@makandra\.com\>'/)
13
+ allow(Katapult::Util).to receive(:system).with(/git commit.*--author='katapult \<katapult@makandra\.com\>'/)
14
14
  Katapult::Util.git_commit 'test'
15
15
  end
16
16
 
17
17
  it 'sanitizes the commit message' do
18
- Katapult::Util.should_receive(:system).with(/git commit -m '"hack0r"'/)
18
+ allow(Katapult::Util).to receive(:system).with(/git commit -m '"hack0r"'/)
19
19
  Katapult::Util.git_commit "\"hack''''0r\""
20
20
  end
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: katapult
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Schöler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-16 00:00:00.000000000 Z
11
+ date: 2015-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -154,6 +154,7 @@ files:
154
154
  - katapult.gemspec
155
155
  - katapult.png
156
156
  - lib/generators/katapult/basics/basics_generator.rb
157
+ - lib/generators/katapult/basics/templates/.ruby-version
157
158
  - lib/generators/katapult/basics/templates/Gemfile
158
159
  - lib/generators/katapult/basics/templates/app/assets/stylesheets/application.css.sass
159
160
  - lib/generators/katapult/basics/templates/app/assets/stylesheets/application/blocks/_all.css.sass
@@ -204,6 +205,7 @@ files:
204
205
  - script/console
205
206
  - spec/action_spec.rb
206
207
  - spec/attribute_spec.rb
208
+ - spec/element_spec.rb
207
209
  - spec/model_spec.rb
208
210
  - spec/spec_helper.rb
209
211
  - spec/util_spec.rb
@@ -228,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
230
  version: '0'
229
231
  requirements: []
230
232
  rubyforge_project:
231
- rubygems_version: 2.4.2
233
+ rubygems_version: 2.4.3
232
234
  signing_key:
233
235
  specification_version: 4
234
236
  summary: Kickstart Rails development
@@ -247,6 +249,7 @@ test_files:
247
249
  - features/wui.feature
248
250
  - spec/action_spec.rb
249
251
  - spec/attribute_spec.rb
252
+ - spec/element_spec.rb
250
253
  - spec/model_spec.rb
251
254
  - spec/spec_helper.rb
252
255
  - spec/util_spec.rb