conventional_models 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ tmp
23
+ .idea
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+
data/Gemfile CHANGED
@@ -1,20 +1,5 @@
1
1
  source :gemcutter
2
2
 
3
- group :features do
4
- gem "cucumber", "0.7.2"
5
- gem "aruba"
6
- gem "open4"
7
- end
3
+ gemspec
8
4
 
9
- group :specs do
10
- gem "rspec", "1.3.0"
11
- end
12
-
13
- group :development do
14
- gem "jeweler"
15
- gem "rake"
16
- gem "ZenTest"
17
- end
18
-
19
- gem "activerecord", "2.3.5"
20
5
  gem "sqlite3-ruby"
data/Gemfile.lock CHANGED
@@ -1,81 +1,61 @@
1
- ---
2
- dependencies:
3
- ZenTest:
4
- group:
5
- - :development
6
- version: ">= 0"
7
- activerecord:
8
- group:
9
- - :default
10
- version: = 2.3.5
11
- sqlite3-ruby:
12
- group:
13
- - :default
14
- version: ">= 0"
15
- rake:
16
- group:
17
- - :development
18
- version: ">= 0"
19
- rspec:
20
- group:
21
- - :specs
22
- version: = 1.3.0
23
- aruba:
24
- group:
25
- - :features
26
- version: ">= 0"
27
- jeweler:
28
- group:
29
- - :development
30
- version: ">= 0"
31
- cucumber:
32
- group:
33
- - :features
34
- version: = 0.7.2
35
- open4:
36
- group:
37
- - :features
38
- version: ">= 0"
39
- specs:
40
- - rake:
41
- version: 0.8.7
42
- - ZenTest:
43
- version: 4.3.1
44
- - activesupport:
45
- version: 2.3.5
46
- - activerecord:
47
- version: 2.3.5
48
- - aruba:
49
- version: 0.1.9
50
- - builder:
51
- version: 2.1.2
52
- - bundler:
53
- version: 0.9.24
54
- - diff-lcs:
55
- version: 1.1.2
56
- - trollop:
57
- version: 1.16.2
58
- - gherkin:
59
- version: 1.0.25
60
- - json_pure:
61
- version: 1.4.3
62
- - term-ansicolor:
63
- version: 1.0.5
64
- - cucumber:
65
- version: 0.7.2
66
- - gemcutter:
67
- version: 0.5.0
68
- - git:
69
- version: 1.2.5
70
- - jeweler:
71
- version: 1.4.0
72
- - open4:
73
- version: 1.0.1
74
- - rspec:
75
- version: 1.3.0
76
- - sqlite3-ruby:
77
- version: 1.2.5
78
- hash: 49b2ba6893f5940e80f19c400ec7f4a2d38964a5
79
- sources:
80
- - Rubygems:
81
- uri: http://gemcutter.org
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ conventional_models (0.3.0)
5
+ activerecord (>= 2.3.5)
6
+ rdoc
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ activemodel (3.0.5)
12
+ activesupport (= 3.0.5)
13
+ builder (~> 2.1.2)
14
+ i18n (~> 0.4)
15
+ activerecord (3.0.5)
16
+ activemodel (= 3.0.5)
17
+ activesupport (= 3.0.5)
18
+ arel (~> 2.0.2)
19
+ tzinfo (~> 0.3.23)
20
+ activesupport (3.0.5)
21
+ arel (2.0.9)
22
+ aruba (0.2.7)
23
+ background_process
24
+ cucumber (~> 0.10.0)
25
+ background_process (1.2)
26
+ builder (2.1.2)
27
+ cucumber (0.10.0)
28
+ builder (>= 2.1.2)
29
+ diff-lcs (~> 1.1.2)
30
+ gherkin (~> 2.3.2)
31
+ json (~> 1.4.6)
32
+ term-ansicolor (~> 1.0.5)
33
+ diff-lcs (1.1.2)
34
+ gherkin (2.3.3)
35
+ json (~> 1.4.6)
36
+ i18n (0.5.0)
37
+ json (1.4.6)
38
+ rdoc (3.5.3)
39
+ rspec (2.5.0)
40
+ rspec-core (~> 2.5.0)
41
+ rspec-expectations (~> 2.5.0)
42
+ rspec-mocks (~> 2.5.0)
43
+ rspec-core (2.5.1)
44
+ rspec-expectations (2.5.0)
45
+ diff-lcs (~> 1.1.2)
46
+ rspec-mocks (2.5.0)
47
+ sqlite3 (1.3.3)
48
+ sqlite3-ruby (1.3.3)
49
+ sqlite3 (>= 1.3.3)
50
+ term-ansicolor (1.0.5)
51
+ tzinfo (0.3.24)
52
+
53
+ PLATFORMS
54
+ ruby
55
+
56
+ DEPENDENCIES
57
+ aruba (>= 0.1.7)
58
+ conventional_models!
59
+ cucumber (>= 0.6.4)
60
+ rspec (>= 2.3)
61
+ sqlite3-ruby
data/README.rdoc CHANGED
@@ -15,7 +15,6 @@ We have a table called Page and another called ContentItems (not following Activ
15
15
  require 'active_record'
16
16
  ActiveRecord::Base.establish_connection(:database => 'db.sqlite', :adapter => 'sqlite3')
17
17
 
18
- # set your conventions
19
18
  require 'conventional_models'
20
19
  ConventionalModels.configure do
21
20
  primary_key_name "Id"
@@ -84,12 +83,6 @@ You can use this from rake as follows:
84
83
  IRB.start
85
84
  end
86
85
 
87
-
88
- == Why?
89
-
90
- I use this for data migrations or quick scripting tasks on databases that don't follow rails
91
- conventions.
92
-
93
86
  == Multiple databases
94
87
 
95
88
  Given a table called pages in both development.sqlite and test.sqlite:
@@ -142,4 +135,4 @@ Given a table called pages in both development.sqlite and test.sqlite:
142
135
 
143
136
  == Copyright
144
137
 
145
- Copyright (c) 2010 Steve Hodgkiss. See LICENSE for details.
138
+ Copyright (c) 2011 Steve Hodgkiss. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ require 'cucumber/rake/task'
8
+ Cucumber::Rake::Task.new(:features)
9
+
10
+ task :default => :spec
data/bin/cmconsole CHANGED
@@ -41,5 +41,5 @@ rescue LoadError
41
41
  require File.dirname(__FILE__) + '/../lib/conventional_models'
42
42
  end
43
43
  end
44
- cli = ConventionalModels::CLI.new(ARGV)
45
- cli.run
44
+ cli = ConventionalModels::CLI.new
45
+ cli.run(ARGV)
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "conventional_models/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = %q{conventional_models}
7
+ s.version = ConventionalModels::VERSION::STRING
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Steve Hodgkiss"]
10
+ s.email = %q{steve@hodgkiss.me.uk}
11
+ s.homepage = %q{http://github.com/stevehodgkiss/conventional_models}
12
+ s.summary = %q{Generate ActiveRecord models. For lazy people.}
13
+ s.description = %q{Generate ActiveRecord models automatically with basic relationships based on conventions.}
14
+ s.default_executable = %q{cmconsole}
15
+
16
+ s.rubyforge_project = "conventional_models"
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+
22
+ s.require_paths = ["lib"]
23
+
24
+ s.add_development_dependency("rspec", [">= 2.3"])
25
+ s.add_development_dependency("cucumber", [">= 0.6.4"])
26
+ s.add_development_dependency("aruba", [">= 0.1.7"])
27
+ s.add_runtime_dependency("activerecord", [">= 2.3.5"])
28
+ s.add_runtime_dependency("rdoc")
29
+ end
@@ -1,4 +1,3 @@
1
- @wip
2
1
  Feature: Cmconsole
3
2
  In order to play with models generated against other projects with ease
4
3
  As a user
@@ -26,9 +25,9 @@ Feature: Cmconsole
26
25
  timeout: 5000
27
26
  """
28
27
  And a table "pages"
29
- When I run "../../bin/cmconsole" as child "irb"
30
- Then I should see ">> " from child "irb"
31
-
32
-
33
-
34
-
28
+ When I run "../../bin/cmconsole" interactively
29
+ And I type "Page.count"
30
+ And I type "Page.superclass"
31
+ And I type "exit"
32
+ Then the output should contain "0"
33
+ And the output should contain "ActiveRecord::Base"
@@ -16,7 +16,7 @@ Feature: ConventionalModels
16
16
  puts "Number of records: #{<model_name>.count}"
17
17
  """
18
18
  When I run "ruby my_script.rb"
19
- Then I should see "Number of records: 0"
19
+ Then the output should contain "Number of records: 0"
20
20
 
21
21
  Examples:
22
22
  | table_name | model_name |
@@ -36,7 +36,7 @@ Feature: ConventionalModels
36
36
  puts "Number of records: #{<model_name>.count}"
37
37
  """
38
38
  When I run "ruby my_script.rb"
39
- Then I should see "Number of records: 0"
39
+ Then the output should contain "Number of records: 0"
40
40
 
41
41
  Examples:
42
42
  | table_name | model_name |
@@ -68,6 +68,6 @@ Feature: ConventionalModels
68
68
  puts "My page's content item name: #{page.content_items.first.Name}"
69
69
  """
70
70
  When I run "ruby my_script.rb"
71
- Then I should see "My page's content item name: content1"
71
+ Then the output should contain "My page's content item name: content1"
72
72
 
73
73
 
@@ -38,5 +38,5 @@ Feature: Multiple database connection
38
38
  puts "Number of production records: #{Test::Page.count}"
39
39
  """
40
40
  When I run "ruby my_script.rb"
41
- Then I should see "Number of development records: 2"
42
- Then I should see "Number of production records: 1"
41
+ Then the output should contain "Number of development records: 2"
42
+ Then the output should contain "Number of production records: 1"
@@ -1,6 +1,5 @@
1
1
  Then /^within "([^\"]*)" I should see:$/ do |within, table|
2
- puts combined_output
3
- output = combined_output.scan(/#{within}:\<\<(.*)\>\>/m).to_s
2
+ output = all_output.match(/#{within}:\<\<(.*)\>\>/m)[0]
4
3
  table.hashes.each do |row|
5
4
  output.should =~ /#{row["line"]}/
6
5
  end
@@ -1,9 +1,10 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
2
  require 'conventional_models'
3
3
 
4
- require 'spec/expectations'
4
+ require 'rspec'
5
5
 
6
- require 'aruba'
6
+ require 'aruba/cucumber'
7
+ require 'aruba/api'
7
8
  require 'active_record'
8
9
 
9
10
  Before do
@@ -8,7 +8,6 @@ require 'conventional_models/table'
8
8
  require 'conventional_models/column'
9
9
  require 'conventional_models/active_record_base_model_for'
10
10
  require 'conventional_models/options'
11
- require 'conventional_models/option_parser'
12
11
  require 'conventional_models/cli'
13
12
  require 'irb'
14
13
  require 'irb/completion'
@@ -1,5 +1,4 @@
1
1
  require 'optparse'
2
- require 'rdoc/usage'
3
2
  require 'ostruct'
4
3
  require 'date'
5
4
 
@@ -7,20 +6,24 @@ module ConventionalModels
7
6
  class CLI
8
7
  attr_reader :options
9
8
 
10
- def initialize(arguments)
11
- @arguments = arguments
12
- @option_parser = OptionParser.new(arguments)
13
- @options = @option_parser.options
14
- end
15
-
16
- def run
17
- if @option_parser.parsed_options?
18
- return output_help if @options.output_help
9
+ def run(args)
10
+ opts = OptionParser.new
11
+ @options = Options.new
12
+ opts.on('-v', '--version') { @options.output_version = true }
13
+ opts.on('-h', '--help') { @options.output_help = opts }
14
+ opts.on('-s', '--skip-configure') { @options.skip_configure = true }
15
+ opts.on('-c', '--config FILE') { |file| @options.config = file }
16
+ opts.on('-e', '--environment ENV') { |env| @options.environment = env }
17
+ opts.on('-V', '--verbose') { |env| @options.verbose = true }
18
+
19
+ begin
20
+ opts.parse!(args)
19
21
  return output_version if @options.output_version
22
+ return output_help(@options.output_help) if @options.output_help
20
23
  output_options if @options.verbose
21
24
  run_console
22
- else
23
- output_usage
25
+ rescue
26
+ puts opts
24
27
  end
25
28
  end
26
29
 
@@ -44,18 +47,13 @@ module ConventionalModels
44
47
  puts " #{name} = #{val}"
45
48
  end
46
49
  end
47
-
48
- def output_help
49
- output_version
50
- RDoc::usage()
51
- end
52
-
53
- def output_usage
54
- RDoc::usage('usage')
55
- end
56
-
50
+
57
51
  def output_version
58
52
  puts "ConventionalModels version #{ConventionalModels::VERSION::STRING}"
59
53
  end
54
+
55
+ def output_help(options)
56
+ puts options
57
+ end
60
58
  end
61
59
  end
@@ -7,7 +7,8 @@ module ConventionalModels
7
7
  def initialize(config)
8
8
  if config.connection.nil?
9
9
  @connection = ::ActiveRecord::Base.connection
10
- else
10
+ end
11
+ if config.module_name
11
12
  base_class_code = []
12
13
  base_class_code << "module ::#{config.module_name}"
13
14
  base_class_code << " class Base < ActiveRecord::Base;"
@@ -15,6 +16,7 @@ module ConventionalModels
15
16
  base_class_code << " end;"
16
17
  base_class_code << "end"
17
18
  eval base_class_code.join
19
+
18
20
  @base_class = "::#{config.module_name}::Base".constantize
19
21
  @base_class.class_eval do
20
22
  establish_connection config.connection
@@ -1,8 +1,8 @@
1
1
  module ConventionalModels #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 2
5
- BUILD = 2
4
+ MINOR = 3
5
+ BUILD = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, BUILD].join('.')
8
8
  end
@@ -2,18 +2,12 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  module ConventionalModels
4
4
  describe CLI do
5
- let(:option_parser) { mock(OptionParser, :options => @options) }
6
5
  before(:each) do
7
6
  @args = []
8
7
  @options = Options.new
9
- OptionParser.stub(:new).and_return(option_parser)
10
8
  File.stub(:exists?).with(@options.config).and_return(true)
11
9
  end
12
10
 
13
- it "should create a new option parser with args" do
14
- OptionParser.should_receive(:new).with(@args)
15
- CLI.new(@args)
16
- end
17
11
 
18
12
  describe "run" do
19
13
  before(:each) do
@@ -24,14 +18,13 @@ module ConventionalModels
24
18
  $stdout = @stdout_orig
25
19
  end
26
20
 
27
- def run
21
+ def run(args = [])
28
22
  @cli = CLI.new(@args)
29
- @cli.run
23
+ @cli.run(Array.wrap(args))
30
24
  end
31
25
 
32
26
  context "with parsed options" do
33
27
  before(:each) do
34
- option_parser.stub(:parsed_options?).and_return(true)
35
28
  ConventionalModels.stub(:configure)
36
29
  ConventionalModels.stub(:model_code)
37
30
  ConventionalModels.stub(:configure_active_record)
@@ -77,26 +70,22 @@ module ConventionalModels
77
70
 
78
71
  context "with skip-configure option" do
79
72
  it "does not call configure" do
80
- @options.skip_configure = true
81
73
  ConventionalModels.should_not_receive(:configure)
82
- run
74
+ run("-s")
83
75
  end
84
76
  end
85
77
 
86
78
  context "with help option" do
87
79
  it "outputs help" do
88
- RDoc.should_receive(:usage)
89
- @options.output_help = true
90
80
  ConventionalModels.should_not_receive(:configure_active_record)
91
- run
81
+ run("-h")
92
82
  end
93
83
  end
94
84
 
95
85
  context "with output version option" do
96
86
  it "outputs the version" do
97
- @options.output_version = true
98
87
  ConventionalModels.should_not_receive(:configure_active_record)
99
- run
88
+ run("-v")
100
89
  $stdout.string.should =~ /#{VERSION::STRING}/
101
90
  end
102
91
  end
@@ -104,9 +93,8 @@ module ConventionalModels
104
93
 
105
94
  context "with invalid options" do
106
95
  it "prints usage" do
107
- RDoc.should_receive(:usage).with('usage')
108
- option_parser.stub(:parsed_options?).and_return(false)
109
- run
96
+ run("-d invalid")
97
+ $stdout.string.should =~ /Usage:/
110
98
  end
111
99
  end
112
100
  end
@@ -3,14 +3,14 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
3
3
  module ConventionalModels
4
4
  describe Database do
5
5
  let(:table) { mock(Table, :apply_conventions => nil, :belongs_to_names => [], :name => "Test") }
6
- let(:config) { mock(Config, :ignored_tables => [], :connection => nil) }
6
+ let(:config) { mock(Config, :ignored_tables => [], :connection => nil, :module_name => nil) }
7
7
  let(:connection) do
8
8
  mock(::ActiveRecord::ConnectionAdapters::AbstractAdapter, :tables => ["Test"], :columns => columns)
9
9
  end
10
10
  let(:columns) { [mock(Column)] }
11
11
 
12
12
  before do
13
- ::ActiveRecord::Base.stub(:connection).and_return(connection)
13
+ ::ActiveRecord::Base.stub(:connection => connection)
14
14
  Table.stub(:new => table)
15
15
  end
16
16
 
@@ -3,13 +3,14 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  module ConventionalModels
4
4
  describe ConventionalModels do
5
5
  let(:config) { mock(Config) }
6
- let(:generated_code) { mock(String) }
6
+ let(:generated_code) { "class TestCode; end" }
7
7
  let(:database) { mock(Database, :code => generated_code, :apply_conventions => nil) }
8
8
 
9
9
  before do
10
10
  Config.stub(:new => config)
11
11
  Database.stub(:new => database)
12
12
  ConventionalModels.stub(:run_code)
13
+ ConventionalModels.class_eval { @@model_code = [] }
13
14
  end
14
15
 
15
16
  describe ".configure" do
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,10 @@
1
1
  require 'rubygems'
2
- require 'bundler'
3
- Bundler.setup(:specs)
2
+ require 'bundler/setup'
4
3
 
5
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
6
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
6
  require 'conventional_models'
8
- require 'spec'
9
- require 'spec/autorun'
7
+ require 'rspec'
10
8
 
11
- Spec::Runner.configure do |config|
9
+ RSpec.configure do |config|
12
10
  end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conventional_models
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 2
9
- version: 0.2.2
4
+ prerelease:
5
+ version: 0.3.0
10
6
  platform: ruby
11
7
  authors:
12
8
  - Steve Hodgkiss
@@ -14,34 +10,28 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2010-05-09 00:00:00 +01:00
13
+ date: 2011-03-02 00:00:00 +00:00
18
14
  default_executable: cmconsole
19
15
  dependencies:
20
16
  - !ruby/object:Gem::Dependency
21
17
  name: rspec
22
18
  prerelease: false
23
19
  requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
24
21
  requirements:
25
22
  - - ">="
26
23
  - !ruby/object:Gem::Version
27
- segments:
28
- - 1
29
- - 3
30
- - 0
31
- version: 1.3.0
24
+ version: "2.3"
32
25
  type: :development
33
26
  version_requirements: *id001
34
27
  - !ruby/object:Gem::Dependency
35
28
  name: cucumber
36
29
  prerelease: false
37
30
  requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
38
32
  requirements:
39
33
  - - ">="
40
34
  - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- - 6
44
- - 4
45
35
  version: 0.6.4
46
36
  type: :development
47
37
  version_requirements: *id002
@@ -49,13 +39,10 @@ dependencies:
49
39
  name: aruba
50
40
  prerelease: false
51
41
  requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
52
43
  requirements:
53
44
  - - ">="
54
45
  - !ruby/object:Gem::Version
55
- segments:
56
- - 0
57
- - 1
58
- - 7
59
46
  version: 0.1.7
60
47
  type: :development
61
48
  version_requirements: *id003
@@ -63,39 +50,68 @@ dependencies:
63
50
  name: activerecord
64
51
  prerelease: false
65
52
  requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
66
54
  requirements:
67
55
  - - ">="
68
56
  - !ruby/object:Gem::Version
69
- segments:
70
- - 2
71
- - 3
72
- - 5
73
57
  version: 2.3.5
74
58
  type: :runtime
75
59
  version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rdoc
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ type: :runtime
70
+ version_requirements: *id005
76
71
  description: Generate ActiveRecord models automatically with basic relationships based on conventions.
77
72
  email: steve@hodgkiss.me.uk
78
73
  executables:
79
74
  - cmconsole
80
75
  extensions: []
81
76
 
82
- extra_rdoc_files:
77
+ extra_rdoc_files: []
78
+
79
+ files:
80
+ - .document
81
+ - .gitignore
82
+ - .rspec
83
+ - Gemfile
84
+ - Gemfile.lock
83
85
  - LICENSE
84
86
  - README.rdoc
85
- files:
87
+ - Rakefile
88
+ - bin/cmconsole
89
+ - conventional_models.gemspec
90
+ - features/cmconsole.feature
91
+ - features/conventional_models.feature
92
+ - features/multiple_databases.feature
93
+ - features/output_model_code.feature
94
+ - features/step_definitions/cmconsole_steps.rb
95
+ - features/step_definitions/conventional_models_steps.rb
96
+ - features/step_definitions/multiple_databases.rb
97
+ - features/step_definitions/output_model_code_steps.rb
98
+ - features/support/env.rb
99
+ - lib/conventional_models.rb
86
100
  - lib/conventional_models/active_record_base_model_for.rb
87
101
  - lib/conventional_models/cli.rb
88
102
  - lib/conventional_models/column.rb
89
103
  - lib/conventional_models/config.rb
90
104
  - lib/conventional_models/database.rb
91
- - lib/conventional_models/option_parser.rb
92
105
  - lib/conventional_models/options.rb
93
106
  - lib/conventional_models/table.rb
94
107
  - lib/conventional_models/version.rb
95
- - lib/conventional_models.rb
96
- - bin/cmconsole
97
- - LICENSE
98
- - README.rdoc
108
+ - spec/conventional_models/cli_spec.rb
109
+ - spec/conventional_models/config_spec.rb
110
+ - spec/conventional_models/database_spec.rb
111
+ - spec/conventional_models/options_spec.rb
112
+ - spec/conventional_models/table_spec.rb
113
+ - spec/conventional_models_spec.rb
114
+ - spec/spec_helper.rb
99
115
  has_rdoc: true
100
116
  homepage: http://github.com/stevehodgkiss/conventional_models
101
117
  licenses: []
@@ -106,37 +122,25 @@ rdoc_options: []
106
122
  require_paths:
107
123
  - lib
108
124
  required_ruby_version: !ruby/object:Gem::Requirement
125
+ none: false
109
126
  requirements:
110
127
  - - ">="
111
128
  - !ruby/object:Gem::Version
112
- segments:
113
- - 0
114
129
  version: "0"
115
130
  required_rubygems_version: !ruby/object:Gem::Requirement
131
+ none: false
116
132
  requirements:
117
133
  - - ">="
118
134
  - !ruby/object:Gem::Version
119
- segments:
120
- - 1
121
- - 3
122
- - 6
123
- version: 1.3.6
135
+ version: "0"
124
136
  requirements: []
125
137
 
126
138
  rubyforge_project: conventional_models
127
- rubygems_version: 1.3.6
139
+ rubygems_version: 1.5.2
128
140
  signing_key:
129
141
  specification_version: 3
130
142
  summary: Generate ActiveRecord models. For lazy people.
131
143
  test_files:
132
- - spec/conventional_models/cli_spec.rb
133
- - spec/conventional_models/config_spec.rb
134
- - spec/conventional_models/database_spec.rb
135
- - spec/conventional_models/option_parser_spec.rb
136
- - spec/conventional_models/options_spec.rb
137
- - spec/conventional_models/table_spec.rb
138
- - spec/conventional_models_spec.rb
139
- - spec/spec_helper.rb
140
144
  - features/cmconsole.feature
141
145
  - features/conventional_models.feature
142
146
  - features/multiple_databases.feature
@@ -146,5 +150,10 @@ test_files:
146
150
  - features/step_definitions/multiple_databases.rb
147
151
  - features/step_definitions/output_model_code_steps.rb
148
152
  - features/support/env.rb
149
- - Gemfile
150
- - Gemfile.lock
153
+ - spec/conventional_models/cli_spec.rb
154
+ - spec/conventional_models/config_spec.rb
155
+ - spec/conventional_models/database_spec.rb
156
+ - spec/conventional_models/options_spec.rb
157
+ - spec/conventional_models/table_spec.rb
158
+ - spec/conventional_models_spec.rb
159
+ - spec/spec_helper.rb
@@ -1,50 +0,0 @@
1
- require 'optparse'
2
- require 'rdoc/usage'
3
- require 'ostruct'
4
- require 'date'
5
-
6
- module ConventionalModels
7
- class OptionParser
8
-
9
- attr_reader :options
10
-
11
- def initialize(arguments)
12
- @arguments = arguments
13
-
14
- @options = Options.new
15
-
16
- @parsed_options = true
17
- parse
18
- end
19
-
20
- def parsed_options?
21
- @parsed_options
22
- end
23
-
24
- def parse
25
- opts = ::OptionParser.new
26
- opts.on('-v', '--version') { @options.output_version = true }
27
- opts.on('-h', '--help') { @options.output_help = true }
28
- opts.on('-s', '--skip-configure') { @options.skip_configure = true }
29
- opts.on('-c', '--config FILE') { |file| @options.config = file }
30
- opts.on('-e', '--environment ENV') { |env| @options.environment = env }
31
- opts.on('-V', '--verbose') { |env| @options.verbose = true }
32
-
33
- opts.parse!(@arguments) rescue @parsed_options = false
34
- end
35
-
36
- protected
37
- def output_help
38
- output_version
39
- RDoc::usage()
40
- end
41
-
42
- def output_usage
43
- RDoc::usage('usage')
44
- end
45
-
46
- def output_version
47
- puts "ConventionalModels version #{ConventionalModels::VERSION}"
48
- end
49
- end
50
- end
@@ -1,44 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module ConventionalModels
4
- describe OptionParser do
5
- def options_for(args)
6
- @option_parser = OptionParser.new(args)
7
- @option_parser.options
8
- end
9
-
10
- context "parsing" do
11
- it "accepts a database config file" do
12
- options_for(["-c", "config/db.yml"]).config.should == "config/db.yml"
13
- options_for(["--config", "config/db.yml"]).config.should == "config/db.yml"
14
- end
15
-
16
- it "accepts an environment flag" do
17
- options_for(["-e", "production"]).environment.should == "production"
18
- options_for(["--environment", "production"]).environment.should == "production"
19
- end
20
-
21
- it "accepts a skip configure flag" do
22
- options_for(["-s"]).skip_configure.should == true
23
- options_for(["--skip-configure"]).skip_configure.should == true
24
- end
25
-
26
- it "accepts an output version flag" do
27
- options_for(["-v"]).output_version.should == true
28
- options_for(["--version"]).output_version.should == true
29
- end
30
-
31
- it "accepts an output help flag" do
32
- options_for(["-h"]).output_help.should == true
33
- options_for(["--help"]).output_help.should == true
34
- end
35
- end
36
-
37
- context "invalid arguments" do
38
- it "should set parsed_options? to false" do
39
- options_for(["--boobs"])
40
- @option_parser.parsed_options?.should == false
41
- end
42
- end
43
- end
44
- end