cukemin 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -25,7 +25,7 @@ begin
25
25
  require 'jeweler'
26
26
  Jeweler::Tasks.new do |s|
27
27
  s.name = "cukemin"
28
- s.version = "0.1.0"
28
+ s.version = "0.1.2"
29
29
  s.author = "Paul Campbell"
30
30
  s.email = "paul@rslw.com"
31
31
  s.homepage = "http://www.github.com/paulca/cukemin"
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cukemin}
8
- s.version = "0.1.0"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Paul Campbell"]
12
- s.date = %q{2010-05-24}
12
+ s.date = %q{2010-05-25}
13
13
  s.email = %q{paul@rslw.com}
14
14
  s.extra_rdoc_files = [
15
15
  "README.md"
@@ -1,4 +1,45 @@
1
1
  class CukeminGenerator < Rails::Generator::NamedBase
2
+
3
+ attr_accessor :name, :attributes, :controller_actions
4
+
5
+ def initialize(runtime_args, runtime_options = {})
6
+ super
7
+ usage if @args.empty?
8
+
9
+ @name = @args.first
10
+ @controller_actions = []
11
+ @attributes = []
12
+ @args[0..-1].each do |arg|
13
+ if arg == '!'
14
+ options[:invert] = true
15
+ elsif arg.include? ':'
16
+ @attributes << Rails::Generator::GeneratedAttribute.new(*arg.split(":"))
17
+ else
18
+ @controller_actions << arg
19
+ @controller_actions << 'create' if arg == 'new'
20
+ @controller_actions << 'update' if arg == 'edit'
21
+ end
22
+ end
23
+
24
+ @controller_actions.uniq!
25
+ @attributes.uniq!
26
+
27
+ if options[:invert] || @controller_actions.empty?
28
+ @controller_actions = all_actions - @controller_actions
29
+ end
30
+
31
+ if @attributes.empty?
32
+ options[:skip_model] = true # default to skipping model if no attributes passed
33
+ if model_exists?
34
+ model_columns_for_attributes.each do |column|
35
+ @attributes << Rails::Generator::GeneratedAttribute.new(column.name.to_s, column.type.to_s)
36
+ end
37
+ else
38
+ @attributes << Rails::Generator::GeneratedAttribute.new('name', 'string')
39
+ end
40
+ end
41
+ end
42
+
2
43
  def manifest
3
44
  record do |m|
4
45
  # puts "#{module_name}, #{model_name}, #{class_name}, #{file_name}, #{file_path}"
@@ -62,6 +103,10 @@ class CukeminGenerator < Rails::Generator::NamedBase
62
103
  def plural_path_helper
63
104
  "#{File.dirname(file_path).gsub('/', '_')}_#{plural_name}"
64
105
  end
106
+
107
+ def all_actions
108
+ %w[index show new create edit update destroy]
109
+ end
65
110
 
66
111
  def after_generate
67
112
  puts "
@@ -1,4 +1,4 @@
1
- Feature: Managing <%= plural_name.titleize %>
1
+ Feature: Managing <%= plural_name.humanize.titleize %>
2
2
  In order to ...
3
3
  As a ...
4
4
  I want to be able to manage <%= plural_name %>
@@ -16,7 +16,7 @@ Feature: Managing <%= plural_name.titleize %>
16
16
  Then I should see "Biggles"
17
17
 
18
18
  Scenario: Editing an existing <%= singular_name %>
19
- Given a <%= singular_name %> "Goravia"
19
+ Given a <%= singular_name.humanize.downcase %> "Goravia"
20
20
  And I am on the admin dashboard
21
21
  And I follow "<%= plural_name.titleize %>"
22
22
  And I follow "Edit"
@@ -26,7 +26,7 @@ Feature: Managing <%= plural_name.titleize %>
26
26
  And I should not see "Goravia"
27
27
 
28
28
  Scenario: Deleting an existing <%= singular_name %>
29
- Given a <%= singular_name %> "Goravia"
29
+ Given a <%= singular_name.humanize.downcase %> "Goravia"
30
30
  And I am on the admin dashboard
31
31
  And I follow "<%= plural_name.titleize %>"
32
32
  And I follow "Delete"
@@ -1,7 +1,9 @@
1
1
  <%%- form_for(<%= form_object %>) do |f| -%>
2
2
  <%%= f.error_messages -%>
3
3
  <fieldset>
4
- <%%= f.label :name %> <%%= f.text_field :name %> <br />
4
+ <%- for attribute in attributes -%>
5
+ <%%= f.label :<%= attribute.name %> %> <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %> <br />
6
+ <%- end -%>
5
7
  </fieldset>
6
8
 
7
9
  <%%= f.submit "Save" %> or <%%= link_to "Cancel", <%= plural_path_helper %>_path %>
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
  <%%- if @<%= plural_name %>.empty? -%>
9
- <p>No <%= plural_name %> found.</p>
9
+ <p>No <%= plural_name.humanize.downcase %> found.</p>
10
10
  <%%- else -%>
11
11
  <table>
12
12
  <thead>
@@ -5,7 +5,7 @@ require 'rails_generator/scripts/generate'
5
5
  describe CukeminGenerator do
6
6
 
7
7
  before do
8
- Rails::Generator::Scripts::Generate.new.run(["cukemin", 'admin/place'], :destination => fake_rails_root, :backtrace => true)
8
+ Rails::Generator::Scripts::Generate.new.run(["cukemin", 'admin/place', 'name:string', 'description:text'], :destination => fake_rails_root, :backtrace => true)
9
9
  end
10
10
 
11
11
  let(:controller_file) { fake_rails_root + '/app/controllers/admin/places_controller.rb' }
@@ -73,6 +73,7 @@ describe CukeminGenerator do
73
73
  it "should output the form partial" do
74
74
  output = File.read(form_view_file)
75
75
  output.should include(%Q[<%- form_for([:admin, @place]) do |f| -%>])
76
+ output.should include(%Q[<%= f.label :name %> <%= f.text_field :name %> <br />])
76
77
  output.should include(%Q[<%= f.submit "Save" %> or <%= link_to "Cancel", admin_places_path %>])
77
78
  end
78
79
 
@@ -80,7 +81,7 @@ describe CukeminGenerator do
80
81
  File.exists?(feature_file).should be_true
81
82
  end
82
83
 
83
- it "should output the form partial" do
84
+ it "should output the feature file" do
84
85
  output = File.read(feature_file)
85
86
  output.should include(%Q[Feature: Managing Places])
86
87
  output.should include(%Q[Scenario: Creating a new place])
@@ -5623,5 +5623,185 @@
5623
5623
  SQL (0.3ms)  SELECT name
5624
5624
  FROM sqlite_master
5625
5625
  WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5626
+ 
5627
+ SQL (0.2ms) SELECT version FROM "schema_migrations"
5628
+ SQL (0.5ms) select sqlite_version(*)
5629
+ SQL (0.6ms)  SELECT name
5630
+ FROM sqlite_master
5631
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5632
+ 
5633
+ SQL (1.9ms) DROP TABLE "test_models"
5634
+ SQL (1.7ms) CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime) 
5635
+ SQL (0.4ms)  SELECT name
5636
+ FROM sqlite_master
5637
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5638
+ 
5639
+ SQL (0.2ms) SELECT version FROM "schema_migrations"
5640
+ SQL (0.2ms) select sqlite_version(*)
5641
+ SQL (0.4ms)  SELECT name
5642
+ FROM sqlite_master
5643
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5644
+ 
5645
+ SQL (2.4ms) DROP TABLE "test_models"
5646
+ SQL (1.2ms) CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime) 
5647
+ SQL (0.4ms)  SELECT name
5648
+ FROM sqlite_master
5649
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5650
+ 
5651
+ SQL (0.3ms) SELECT version FROM "schema_migrations"
5652
+ SQL (0.2ms) select sqlite_version(*)
5653
+ SQL (0.4ms)  SELECT name
5654
+ FROM sqlite_master
5655
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5656
+ 
5657
+ SQL (2.7ms) DROP TABLE "test_models"
5658
+ SQL (1.4ms) CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime) 
5659
+ SQL (0.3ms)  SELECT name
5660
+ FROM sqlite_master
5661
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5662
+ 
5663
+ SQL (0.2ms) SELECT version FROM "schema_migrations"
5664
+ SQL (0.2ms) select sqlite_version(*)
5665
+ SQL (0.4ms)  SELECT name
5666
+ FROM sqlite_master
5667
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5668
+ 
5669
+ SQL (2.5ms) DROP TABLE "test_models"
5670
+ SQL (1.6ms) CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime) 
5671
+ SQL (0.3ms)  SELECT name
5672
+ FROM sqlite_master
5673
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5674
+ 
5675
+ SQL (0.2ms) SELECT version FROM "schema_migrations"
5676
+ SQL (0.2ms) select sqlite_version(*)
5677
+ SQL (0.4ms)  SELECT name
5678
+ FROM sqlite_master
5679
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5680
+ 
5681
+ SQL (96.7ms) DROP TABLE "test_models"
5682
+ SQL (3.2ms) CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime) 
5683
+ SQL (0.8ms)  SELECT name
5684
+ FROM sqlite_master
5685
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5686
+ 
5687
+ SQL (1.3ms) SELECT version FROM "schema_migrations"
5688
+ SQL (0.2ms) select sqlite_version(*)
5689
+ SQL (0.4ms)  SELECT name
5690
+ FROM sqlite_master
5691
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5692
+ 
5693
+ SQL (2.8ms) DROP TABLE "test_models"
5694
+ SQL (1.7ms) CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime) 
5695
+ SQL (0.3ms)  SELECT name
5696
+ FROM sqlite_master
5697
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5698
+ 
5699
+ SQL (0.2ms) SELECT version FROM "schema_migrations"
5700
+ SQL (0.2ms) select sqlite_version(*)
5701
+ SQL (0.4ms)  SELECT name
5702
+ FROM sqlite_master
5703
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5704
+ 
5705
+ SQL (2.4ms) DROP TABLE "test_models"
5706
+ SQL (1.4ms) CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime) 
5707
+ SQL (0.3ms)  SELECT name
5708
+ FROM sqlite_master
5709
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5710
+ 
5711
+ SQL (0.2ms) SELECT version FROM "schema_migrations"
5712
+ SQL (0.2ms) select sqlite_version(*)
5713
+ SQL (0.4ms)  SELECT name
5714
+ FROM sqlite_master
5715
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5716
+ 
5717
+ SQL (2.4ms) DROP TABLE "test_models"
5718
+ SQL (1.4ms) CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime) 
5719
+ SQL (0.3ms)  SELECT name
5720
+ FROM sqlite_master
5721
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5722
+ 
5723
+ SQL (0.2ms) SELECT version FROM "schema_migrations"
5724
+ SQL (0.3ms) select sqlite_version(*)
5725
+ SQL (0.4ms)  SELECT name
5726
+ FROM sqlite_master
5727
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5728
+ 
5729
+ SQL (2.6ms) DROP TABLE "test_models"
5730
+ SQL (1.7ms) CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime) 
5731
+ SQL (0.3ms)  SELECT name
5732
+ FROM sqlite_master
5733
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5734
+ 
5735
+ SQL (0.2ms) SELECT version FROM "schema_migrations"
5736
+ SQL (0.2ms) select sqlite_version(*)
5737
+ SQL (0.4ms)  SELECT name
5738
+ FROM sqlite_master
5739
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5740
+ 
5741
+ SQL (2.4ms) DROP TABLE "test_models"
5742
+ SQL (1.4ms) CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime) 
5743
+ SQL (0.3ms)  SELECT name
5744
+ FROM sqlite_master
5745
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5746
+ 
5747
+ SQL (0.2ms) SELECT version FROM "schema_migrations"
5748
+ SQL (0.2ms) select sqlite_version(*)
5749
+ SQL (0.4ms)  SELECT name
5750
+ FROM sqlite_master
5751
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5752
+ 
5753
+ SQL (2.7ms) DROP TABLE "test_models"
5754
+ SQL (1.4ms) CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime) 
5755
+ SQL (0.3ms)  SELECT name
5756
+ FROM sqlite_master
5757
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5758
+ 
5759
+ SQL (0.2ms) SELECT version FROM "schema_migrations"
5760
+ SQL (0.2ms) select sqlite_version(*)
5761
+ SQL (0.4ms)  SELECT name
5762
+ FROM sqlite_master
5763
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5764
+ 
5765
+ SQL (2.6ms) DROP TABLE "test_models"
5766
+ SQL (1.4ms) CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime) 
5767
+ SQL (0.3ms)  SELECT name
5768
+ FROM sqlite_master
5769
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5770
+ 
5771
+ SQL (0.2ms) SELECT version FROM "schema_migrations"
5772
+ SQL (0.2ms) select sqlite_version(*)
5773
+ SQL (0.4ms)  SELECT name
5774
+ FROM sqlite_master
5775
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5776
+ 
5777
+ SQL (2.1ms) DROP TABLE "test_models"
5778
+ SQL (1.5ms) CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime) 
5779
+ SQL (0.3ms)  SELECT name
5780
+ FROM sqlite_master
5781
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5782
+ 
5783
+ SQL (0.2ms) SELECT version FROM "schema_migrations"
5784
+ SQL (0.2ms) select sqlite_version(*)
5785
+ SQL (0.4ms)  SELECT name
5786
+ FROM sqlite_master
5787
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5788
+ 
5789
+ SQL (1.5ms) DROP TABLE "test_models"
5790
+ SQL (1.6ms) CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime) 
5791
+ SQL (0.3ms)  SELECT name
5792
+ FROM sqlite_master
5793
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5794
+ 
5795
+ SQL (0.2ms) SELECT version FROM "schema_migrations"
5796
+ SQL (0.2ms) select sqlite_version(*)
5797
+ SQL (0.4ms)  SELECT name
5798
+ FROM sqlite_master
5799
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5800
+ 
5801
+ SQL (2.7ms) DROP TABLE "test_models"
5802
+ SQL (1.6ms) CREATE TABLE "test_models" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "created_at" datetime, "updated_at" datetime) 
5803
+ SQL (0.3ms)  SELECT name
5804
+ FROM sqlite_master
5805
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
5626
5806
  
5627
5807
  SQL (0.2ms) SELECT version FROM "schema_migrations"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cukemin
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Paul Campbell
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-05-24 00:00:00 +01:00
18
+ date: 2010-05-25 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21