padrino-gen 0.1.0

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 (37) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +7 -0
  5. data/Rakefile +60 -0
  6. data/VERSION +1 -0
  7. data/bin/padrino-gen +5 -0
  8. data/lib/generators/actions.rb +81 -0
  9. data/lib/generators/base_app/.gitignore +7 -0
  10. data/lib/generators/base_app/Gemfile +13 -0
  11. data/lib/generators/base_app/config/dependencies.rb.tt +41 -0
  12. data/lib/generators/base_app/test/test_config.rb.tt +5 -0
  13. data/lib/generators/components/actions.rb +49 -0
  14. data/lib/generators/components/mocks/mocha_gen.rb +16 -0
  15. data/lib/generators/components/mocks/rr_gen.rb +16 -0
  16. data/lib/generators/components/orms/activerecord_gen.rb +60 -0
  17. data/lib/generators/components/orms/couchrest_gen.rb +29 -0
  18. data/lib/generators/components/orms/datamapper_gen.rb +27 -0
  19. data/lib/generators/components/orms/mongomapper_gen.rb +54 -0
  20. data/lib/generators/components/orms/sequel_gen.rb +28 -0
  21. data/lib/generators/components/renderers/erb_gen.rb +15 -0
  22. data/lib/generators/components/renderers/haml_gen.rb +16 -0
  23. data/lib/generators/components/scripts/jquery_gen.rb +15 -0
  24. data/lib/generators/components/scripts/prototype_gen.rb +16 -0
  25. data/lib/generators/components/scripts/rightjs_gen.rb +16 -0
  26. data/lib/generators/components/tests/bacon_test_gen.rb +27 -0
  27. data/lib/generators/components/tests/riot_test_gen.rb +27 -0
  28. data/lib/generators/components/tests/rspec_test_gen.rb +26 -0
  29. data/lib/generators/components/tests/shoulda_test_gen.rb +26 -0
  30. data/lib/generators/components/tests/testspec_test_gen.rb +26 -0
  31. data/lib/generators/skeleton.rb +53 -0
  32. data/lib/padrino-gen.rb +1 -0
  33. data/padrino-gen.gemspec +104 -0
  34. data/test/active_support_helpers.rb +7 -0
  35. data/test/helper.rb +73 -0
  36. data/test/test_skeleton_generator.rb +188 -0
  37. metadata +175 -0
@@ -0,0 +1,27 @@
1
+ module Padrino
2
+ module Generators
3
+ module Components
4
+ module Orms
5
+
6
+ module DatamapperGen
7
+
8
+ DM = (<<-DM).gsub(/^ {10}/, '')
9
+ module DataMapperInitializer
10
+ def self.registered(app)
11
+ app.configure(:development) { DataMapper.setup(:default, 'your_dev_db_here') }
12
+ app.configure(:production) { DataMapper.setup(:default, 'your_production_db_here') }
13
+ app.configure(:test) { DataMapper.setup(:default, 'your_test_db_here') }
14
+ end
15
+ end
16
+ DM
17
+
18
+ def setup_orm
19
+ require_dependencies 'dm-core', 'dm-validations'
20
+ create_file("config/initializers/data_mapper.rb", DM)
21
+ end
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,54 @@
1
+ module Padrino
2
+ module Generators
3
+ module Components
4
+ module Orms
5
+
6
+ module MongomapperGen
7
+
8
+ MONGO = (<<-MONGO).gsub(/^ {10}/, '')
9
+ class MongoDBConnectionFailure < RuntimeError; end
10
+
11
+ module MongoDbInitializer
12
+ def self.registered(app)
13
+ app.configure :development do
14
+ MongoMapper.connection = Mongo::Connection.new('localhost')
15
+ MongoMapper.database = 'your_dev_db_here'
16
+ end
17
+
18
+ app.configure :production do
19
+ MongoMapper.connection = Mongo::Connection.new('localhost')
20
+ MongoMapper.database = 'your_production_db_here'
21
+ end
22
+
23
+ app.configure :test do
24
+ MongoMapper.connection = Mongo::Connection.new('localhost')
25
+ MongoMapper.database = 'your_test_db_here'
26
+ end
27
+ end
28
+ end
29
+ MONGO
30
+
31
+ CONCERNED = (<<-CONCERN).gsub(/^ {10}/, '')
32
+ module MongoMapper
33
+ module Document
34
+ module ClassMethods
35
+ # TODO find a cleaner way for it to know where to look for dependencies
36
+ def concerned_with(*concerns)
37
+ concerns.each { |concern| require_dependency "./app/models/\#{name.underscore}/\#{concern}" }
38
+ end
39
+ end
40
+ end
41
+ end
42
+ CONCERN
43
+
44
+ def setup_orm
45
+ require_dependencies 'mongo_mapper'
46
+ create_file("config/initializers/mongo_db.rb", MONGO)
47
+ create_file("lib/ext/mongo_mapper.rb", CONCERNED)
48
+ end
49
+ end
50
+
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,28 @@
1
+ module Padrino
2
+ module Generators
3
+ module Components
4
+ module Orms
5
+
6
+ module SequelGen
7
+
8
+ SEQUEL = (<<-SEQUEL).gsub(/^ {10}/, '')
9
+ module SequelInitializer
10
+ def self.registered(app)
11
+ Sequel::Model.plugin(:schema)
12
+ app.configure(:development) { Sequel.connect('your_dev_db_here') }
13
+ app.configure(:production) { Sequel.connect('your_production_db_here') }
14
+ app.configure(:test) { Sequel.connect('your_test_db_here') }
15
+ end
16
+ end
17
+ SEQUEL
18
+
19
+ def setup_orm
20
+ require_dependencies 'sequel'
21
+ create_file("config/initializers/sequel.rb", SEQUEL)
22
+ end
23
+ end
24
+
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,15 @@
1
+ module Padrino
2
+ module Generators
3
+ module Components
4
+ module Renderers
5
+
6
+ module ErbGen
7
+ def setup_renderer
8
+ require_dependencies 'erubis'
9
+ end
10
+ end
11
+
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ module Padrino
2
+ module Generators
3
+ module Components
4
+ module Renderers
5
+
6
+ module HamlGen
7
+
8
+ def setup_renderer
9
+ require_dependencies 'haml'
10
+ end
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ module Padrino
2
+ module Generators
3
+ module Components
4
+ module Scripts
5
+
6
+ module JqueryGen
7
+ def setup_script
8
+ get("http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js", "public/javascripts/jquery.min.js")
9
+ end
10
+ end
11
+
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ module Padrino
2
+ module Generators
3
+ module Components
4
+ module Scripts
5
+
6
+ module PrototypeGen
7
+ def setup_script
8
+ get("http://prototypejs.org/assets/2009/8/31/prototype.js", "public/javascripts/prototype.js")
9
+ get('http://github.com/nesquena/lowpro/raw/master/dist/lowpro.js', "public/javascripts/lowpro.js")
10
+ end
11
+ end
12
+
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ module Padrino
2
+ module Generators
3
+ module Components
4
+ module Scripts
5
+
6
+ module RightjsGen
7
+ def setup_script
8
+ get("http://rightjs.org/builds/current/right-min.js", "public/javascripts/right-min.js")
9
+ end
10
+ end
11
+
12
+
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,27 @@
1
+ module Padrino
2
+ module Generators
3
+ module Components
4
+ module Tests
5
+
6
+ module BaconGen
7
+ BACON_SETUP = (<<-TEST).gsub(/^ {10}/, '')
8
+ class Bacon::Context
9
+ include Rack::Test::Methods
10
+ end
11
+
12
+ def app
13
+ CLASS_NAME.tap { |app| app.set :environment, :test }
14
+ end
15
+ TEST
16
+
17
+ def setup_test
18
+ require_dependencies 'bacon', :env => :testing
19
+ insert_test_suite_setup BACON_SETUP
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,27 @@
1
+ module Padrino
2
+ module Generators
3
+ module Components
4
+ module Tests
5
+
6
+ module RiotGen
7
+ RIOT_SETUP = (<<-TEST).gsub(/^ {10}/, '')
8
+ class Riot::Situation
9
+ include Rack::Test::Methods
10
+
11
+ def app
12
+ CLASS_NAME.tap { |app| app.set :environment, :test }
13
+ end
14
+ end
15
+ TEST
16
+
17
+ def setup_test
18
+ require_dependencies 'riot', :env => :testing
19
+ insert_test_suite_setup RIOT_SETUP
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ module Padrino
2
+ module Generators
3
+ module Components
4
+ module Tests
5
+
6
+ module RspecGen
7
+ RSPEC_SETUP = (<<-TEST).gsub(/^ {10}/, '')
8
+ Spec::Runner.configure do |conf|
9
+ conf.include Rack::Test::Methods
10
+ end
11
+
12
+ def app
13
+ CLASS_NAME.tap { |app| app.set :environment, :test }
14
+ end
15
+ TEST
16
+
17
+ def setup_test
18
+ require_dependencies 'spec', :env => :testing
19
+ insert_test_suite_setup RSPEC_SETUP
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module Padrino
2
+ module Generators
3
+ module Components
4
+ module Tests
5
+
6
+ module ShouldaGen
7
+ SHOULDA_SETUP = (<<-TEST).gsub(/^ {10}/, '')
8
+ class Test::Unit::TestCase
9
+ include Rack::Test::Methods
10
+
11
+ def app
12
+ CLASS_NAME.tap { |app| app.set :environment, :test }
13
+ end
14
+ end
15
+ TEST
16
+
17
+ def setup_test
18
+ require_dependencies 'test/unit', 'shoulda', :env => :testing
19
+ insert_test_suite_setup SHOULDA_SETUP
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ module Padrino
2
+ module Generators
3
+ module Components
4
+ module Tests
5
+
6
+ module TestspecGen
7
+ TESTSPEC_SETUP = (<<-TEST).gsub(/^ {10}/, '')
8
+ class Test::Unit::TestCase
9
+ include Rack::Test::Methods
10
+
11
+ def app
12
+ CLASS_NAME.tap { |app| app.set :environment, :test }
13
+ end
14
+ end
15
+ TEST
16
+
17
+ def setup_test
18
+ require_dependencies 'test/spec', :path => "test/test_config.rb"
19
+ insert_test_suite_setup TESTSPEC_SETUP
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,53 @@
1
+ require 'thor'
2
+
3
+ module Padrino
4
+ module Generators
5
+ class Skeleton < Thor::Group
6
+ # Define the source template root
7
+ def self.source_root; File.dirname(__FILE__); end
8
+ def self.banner; "padrino-gen [app_name] [path] [options]"; end
9
+
10
+ # Include related modules
11
+ include Thor::Actions
12
+ include Padrino::Generators::Actions
13
+ include Padrino::Generators::Components::Actions
14
+
15
+ desc "Description:\n\n\tpadrino-gen generate a Padrino skeleton or application."
16
+
17
+ argument :name, :desc => "The name of your sinatra app"
18
+ argument :path, :desc => "The path to create your app"
19
+ class_option :run_bundler, :aliases => '-b', :default => false, :type => :boolean
20
+
21
+ # Definitions for the available customizable components
22
+ component_option :orm, "database engine", :aliases => '-d', :choices => [:datamapper, :mongomapper, :activerecord, :sequel, :couchrest]
23
+ component_option :test, "testing framework", :aliases => '-t', :choices => [:bacon, :shoulda, :rspec, :testspec, :riot]
24
+ component_option :mock, "mocking library", :aliases => '-m', :choices => [:mocha, :rr]
25
+ component_option :script, "javascript library", :aliases => '-s', :choices => [:jquery, :prototype, :rightjs]
26
+ component_option :renderer, "template engine", :aliases => '-r', :choices => [:erb, :haml]
27
+
28
+ # Copies over the base sinatra starting application
29
+ def setup_skeleton
30
+ self.destination_root = File.join(path, name)
31
+ @class_name = name.classify
32
+ directory("base_app/", self.destination_root)
33
+ store_component_config('.components')
34
+ end
35
+
36
+ # For each component, retrieve a valid choice and then execute the associated generator
37
+ def setup_components
38
+ self.class.component_types.each do |comp|
39
+ choice = resolve_valid_choice(comp)
40
+ execute_component_setup(comp, choice)
41
+ end
42
+ end
43
+
44
+ # Bundle all required components using bundler and Gemfile
45
+ def bundle_dependencies
46
+ if options[:run_bundle]
47
+ say "Bundling application dependencies using bundler..."
48
+ in_root { run 'gem bundle' }
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1 @@
1
+ Dir[File.dirname(__FILE__) + "/generators/**/*.rb"].each { |lib| require lib }
@@ -0,0 +1,104 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{padrino-gen}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu"]
12
+ s.date = %q{2009-11-16}
13
+ s.default_executable = %q{padrino-gen}
14
+ s.description = %q{Generators for easily creating and building padrino applications from the console}
15
+ s.email = %q{nesquena@gmail.com}
16
+ s.executables = ["padrino-gen"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/padrino-gen",
29
+ "lib/generators/actions.rb",
30
+ "lib/generators/base_app/.gitignore",
31
+ "lib/generators/base_app/Gemfile",
32
+ "lib/generators/base_app/config/dependencies.rb.tt",
33
+ "lib/generators/base_app/test/test_config.rb.tt",
34
+ "lib/generators/components/actions.rb",
35
+ "lib/generators/components/mocks/mocha_gen.rb",
36
+ "lib/generators/components/mocks/rr_gen.rb",
37
+ "lib/generators/components/orms/activerecord_gen.rb",
38
+ "lib/generators/components/orms/couchrest_gen.rb",
39
+ "lib/generators/components/orms/datamapper_gen.rb",
40
+ "lib/generators/components/orms/mongomapper_gen.rb",
41
+ "lib/generators/components/orms/sequel_gen.rb",
42
+ "lib/generators/components/renderers/erb_gen.rb",
43
+ "lib/generators/components/renderers/haml_gen.rb",
44
+ "lib/generators/components/scripts/jquery_gen.rb",
45
+ "lib/generators/components/scripts/prototype_gen.rb",
46
+ "lib/generators/components/scripts/rightjs_gen.rb",
47
+ "lib/generators/components/tests/bacon_test_gen.rb",
48
+ "lib/generators/components/tests/riot_test_gen.rb",
49
+ "lib/generators/components/tests/rspec_test_gen.rb",
50
+ "lib/generators/components/tests/shoulda_test_gen.rb",
51
+ "lib/generators/components/tests/testspec_test_gen.rb",
52
+ "lib/generators/skeleton.rb",
53
+ "lib/padrino-gen.rb",
54
+ "padrino-gen.gemspec",
55
+ "test/active_support_helpers.rb",
56
+ "test/helper.rb",
57
+ "test/test_skeleton_generator.rb"
58
+ ]
59
+ s.homepage = %q{http://github.com/padrino/padrino-gen}
60
+ s.rdoc_options = ["--charset=UTF-8"]
61
+ s.require_paths = ["lib"]
62
+ s.rubygems_version = %q{1.3.5}
63
+ s.summary = %q{Generators for easily creating and building padrino applications}
64
+ s.test_files = [
65
+ "test/active_support_helpers.rb",
66
+ "test/helper.rb",
67
+ "test/test_skeleton_generator.rb"
68
+ ]
69
+
70
+ if s.respond_to? :specification_version then
71
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
72
+ s.specification_version = 3
73
+
74
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
75
+ s.add_runtime_dependency(%q<sinatra>, [">= 0.9.2"])
76
+ s.add_runtime_dependency(%q<thor>, [">= 0.11.8"])
77
+ s.add_runtime_dependency(%q<bundler>, [">= 0"])
78
+ s.add_development_dependency(%q<haml>, [">= 2.2.1"])
79
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
80
+ s.add_development_dependency(%q<mocha>, [">= 0.9.7"])
81
+ s.add_development_dependency(%q<rack-test>, [">= 0.5.0"])
82
+ s.add_development_dependency(%q<webrat>, [">= 0.5.1"])
83
+ else
84
+ s.add_dependency(%q<sinatra>, [">= 0.9.2"])
85
+ s.add_dependency(%q<thor>, [">= 0.11.8"])
86
+ s.add_dependency(%q<bundler>, [">= 0"])
87
+ s.add_dependency(%q<haml>, [">= 2.2.1"])
88
+ s.add_dependency(%q<shoulda>, [">= 0"])
89
+ s.add_dependency(%q<mocha>, [">= 0.9.7"])
90
+ s.add_dependency(%q<rack-test>, [">= 0.5.0"])
91
+ s.add_dependency(%q<webrat>, [">= 0.5.1"])
92
+ end
93
+ else
94
+ s.add_dependency(%q<sinatra>, [">= 0.9.2"])
95
+ s.add_dependency(%q<thor>, [">= 0.11.8"])
96
+ s.add_dependency(%q<bundler>, [">= 0"])
97
+ s.add_dependency(%q<haml>, [">= 2.2.1"])
98
+ s.add_dependency(%q<shoulda>, [">= 0"])
99
+ s.add_dependency(%q<mocha>, [">= 0.9.7"])
100
+ s.add_dependency(%q<rack-test>, [">= 0.5.0"])
101
+ s.add_dependency(%q<webrat>, [">= 0.5.1"])
102
+ end
103
+ end
104
+