gator 0.0.21.pre → 0.0.22.pre
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.
- data/Gemfile +3 -1
- data/Rakefile +3 -6
- data/VERSION +1 -1
- data/bin/gator +2 -3
- data/gator.gemspec +52 -30
- data/lib/gator.rb +6 -8
- data/lib/gator/core.rb +19 -0
- data/lib/gator/core/application/application.rb +41 -0
- data/lib/gator/core/application/application_configuration.rb +11 -0
- data/lib/gator/core/command/act_as_command.rb +40 -0
- data/lib/gator/core/command/act_as_command_collection.rb +63 -0
- data/lib/gator/core/command/command.rb +20 -0
- data/lib/gator/{task.rb → core/command/task.rb} +1 -4
- data/lib/gator/core/configuration/act_as_configuration.rb +30 -0
- data/lib/gator/core/configuration/configuration.rb +5 -0
- data/lib/gator/core/io/paths.rb +21 -0
- data/lib/gator/core/io/project_file_locator.rb +28 -0
- data/lib/gator/core/io/ruby_file_loader.rb +21 -0
- data/lib/gator/core/io/sandbox.rb +9 -0
- data/lib/gator/{project.rb → core/project/layout.rb} +3 -44
- data/lib/gator/core/project/project.rb +21 -0
- data/lib/gator/plugins/generators.rb +5 -0
- data/lib/gator/{generators/generator.rb → plugins/generators/act_as_template_generator.rb} +1 -5
- data/lib/gator/{commands/generate.rb → plugins/generators/generate_command.rb} +1 -1
- data/lib/gator/plugins/generators/generator.rb +6 -0
- data/lib/gator/plugins/scaffolding.rb +4 -0
- data/lib/gator/plugins/scaffolding/scaffold_command.rb +62 -0
- data/lib/gator/plugins/scaffolding/scaffolding_file_utils.rb +58 -0
- data/rake/jeweler.rb +17 -0
- data/rake/jeweler_prerelease_tasks.rb +50 -0
- data/rake/pre_release_gemspec.rb +80 -0
- data/rake/pre_release_to_git.rb +59 -0
- data/spec/core/application/application_configuration_spec.rb +21 -0
- data/spec/core/application/application_spec.rb +15 -0
- data/spec/core/command/command_spec.rb +117 -0
- data/spec/core/command/task_spec.rb +95 -0
- data/spec/core/configuration/configuration_spec.rb +55 -0
- data/spec/core/io/paths_spec.rb +44 -0
- data/spec/core/io/sandbox_spec.rb +11 -0
- data/spec/core/project/layout_spec.rb +64 -0
- data/spec/core/project/project_spec.rb +51 -0
- data/spec/fixtures/empty_gator_project/gator.rb +4 -0
- data/spec/fixtures/no_gator_file/.empty_directory +0 -0
- data/spec/plugins/scaffolding/scaffold_command_spec.rb +75 -0
- data/spec/spec_helper.rb +14 -9
- metadata +65 -36
- data/lib/gator/command.rb +0 -109
- data/lib/gator/commands.rb +0 -5
- data/lib/gator/commands/project.rb +0 -87
- data/lib/gator/config.rb +0 -23
- data/lib/gator/generators.rb +0 -1
- data/lib/gator/runner.rb +0 -21
- data/lib/gator/util.rb +0 -91
- data/spec/command_spec.rb +0 -84
- data/spec/config_spec.rb +0 -14
- data/spec/project_spec.rb +0 -15
- data/spec/runner_spec.rb +0 -9
- data/spec/task_spec.rb +0 -8
- data/spec/util_spec.rb +0 -60
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -25,6 +25,9 @@ Jeweler::Tasks.new do |gem|
|
|
25
25
|
end
|
26
26
|
Jeweler::RubygemsDotOrgTasks.new
|
27
27
|
|
28
|
+
require File.dirname(__FILE__)+"/rake/jeweler_prerelease_tasks"
|
29
|
+
Jeweler::PrereleaseTasks.new
|
30
|
+
|
28
31
|
require 'rspec/core'
|
29
32
|
require 'rspec/core/rake_task'
|
30
33
|
require 'ci/reporter/rake/rspec'
|
@@ -35,12 +38,6 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
35
38
|
end
|
36
39
|
|
37
40
|
task :spec => "ci:setup:rspec"
|
38
|
-
|
39
|
-
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
40
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
41
|
-
spec.rcov = true
|
42
|
-
end
|
43
|
-
|
44
41
|
task :test => :spec
|
45
42
|
task :default => :spec
|
46
43
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.22.pre
|
data/bin/gator
CHANGED
data/gator.gemspec
CHANGED
@@ -4,15 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "0.0.
|
7
|
+
s.name = "gator"
|
8
|
+
s.version = "0.0.22.pre"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Dominic Graefen"]
|
12
|
-
s.date =
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.email = %q{dominic.graefen@gmail.com}
|
12
|
+
s.date = "2011-10-12"
|
13
|
+
s.description = "gator - the friendly code-generator"
|
14
|
+
s.email = "dominic.graefen@gmail.com"
|
16
15
|
s.executables = ["gator"]
|
17
16
|
s.extra_rdoc_files = [
|
18
17
|
"LICENSE.txt",
|
@@ -29,31 +28,51 @@ Gem::Specification.new do |s|
|
|
29
28
|
"bin/gator",
|
30
29
|
"gator.gemspec",
|
31
30
|
"lib/gator.rb",
|
32
|
-
"lib/gator/
|
33
|
-
"lib/gator/
|
34
|
-
"lib/gator/
|
35
|
-
"lib/gator/
|
36
|
-
"lib/gator/
|
37
|
-
"lib/gator/
|
38
|
-
"lib/gator/
|
39
|
-
"lib/gator/
|
40
|
-
"lib/gator/
|
41
|
-
"lib/gator/
|
42
|
-
"lib/gator/
|
43
|
-
"
|
44
|
-
"
|
31
|
+
"lib/gator/core.rb",
|
32
|
+
"lib/gator/core/application/application.rb",
|
33
|
+
"lib/gator/core/application/application_configuration.rb",
|
34
|
+
"lib/gator/core/command/act_as_command.rb",
|
35
|
+
"lib/gator/core/command/act_as_command_collection.rb",
|
36
|
+
"lib/gator/core/command/command.rb",
|
37
|
+
"lib/gator/core/command/task.rb",
|
38
|
+
"lib/gator/core/configuration/act_as_configuration.rb",
|
39
|
+
"lib/gator/core/configuration/configuration.rb",
|
40
|
+
"lib/gator/core/io/paths.rb",
|
41
|
+
"lib/gator/core/io/project_file_locator.rb",
|
42
|
+
"lib/gator/core/io/ruby_file_loader.rb",
|
43
|
+
"lib/gator/core/io/sandbox.rb",
|
44
|
+
"lib/gator/core/project/layout.rb",
|
45
|
+
"lib/gator/core/project/project.rb",
|
46
|
+
"lib/gator/plugins/generators.rb",
|
47
|
+
"lib/gator/plugins/generators/act_as_template_generator.rb",
|
48
|
+
"lib/gator/plugins/generators/generate_command.rb",
|
49
|
+
"lib/gator/plugins/generators/generator.rb",
|
50
|
+
"lib/gator/plugins/scaffolding.rb",
|
51
|
+
"lib/gator/plugins/scaffolding/scaffold_command.rb",
|
52
|
+
"lib/gator/plugins/scaffolding/scaffolding_file_utils.rb",
|
53
|
+
"rake/jeweler.rb",
|
54
|
+
"rake/jeweler_prerelease_tasks.rb",
|
55
|
+
"rake/pre_release_gemspec.rb",
|
56
|
+
"rake/pre_release_to_git.rb",
|
57
|
+
"spec/core/application/application_configuration_spec.rb",
|
58
|
+
"spec/core/application/application_spec.rb",
|
59
|
+
"spec/core/command/command_spec.rb",
|
60
|
+
"spec/core/command/task_spec.rb",
|
61
|
+
"spec/core/configuration/configuration_spec.rb",
|
62
|
+
"spec/core/io/paths_spec.rb",
|
63
|
+
"spec/core/io/sandbox_spec.rb",
|
64
|
+
"spec/core/project/layout_spec.rb",
|
65
|
+
"spec/core/project/project_spec.rb",
|
45
66
|
"spec/fixtures/empty_gator_project/gator.rb",
|
46
|
-
"spec/
|
47
|
-
"spec/
|
48
|
-
"spec/spec_helper.rb"
|
49
|
-
"spec/task_spec.rb",
|
50
|
-
"spec/util_spec.rb"
|
67
|
+
"spec/fixtures/no_gator_file/.empty_directory",
|
68
|
+
"spec/plugins/scaffolding/scaffold_command_spec.rb",
|
69
|
+
"spec/spec_helper.rb"
|
51
70
|
]
|
52
|
-
s.homepage =
|
71
|
+
s.homepage = "http://github.com/devboy/gator"
|
53
72
|
s.licenses = ["MIT"]
|
54
73
|
s.require_paths = ["lib"]
|
55
|
-
s.rubygems_version =
|
56
|
-
s.summary =
|
74
|
+
s.rubygems_version = "1.8.10"
|
75
|
+
s.summary = "gator - the friendly code-generator"
|
57
76
|
|
58
77
|
if s.respond_to? :specification_version then
|
59
78
|
s.specification_version = 3
|
@@ -64,14 +83,16 @@ Gem::Specification.new do |s|
|
|
64
83
|
s.add_development_dependency(%q<ci_reporter>, ["~> 1.6.5"])
|
65
84
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
66
85
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
|
67
|
-
s.add_development_dependency(%q<
|
86
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
87
|
+
s.add_development_dependency(%q<simplecov-rcov>, [">= 0"])
|
68
88
|
else
|
69
89
|
s.add_dependency(%q<thor>, ["~> 0.14.6"])
|
70
90
|
s.add_dependency(%q<rspec>, ["~> 2.3.0"])
|
71
91
|
s.add_dependency(%q<ci_reporter>, ["~> 1.6.5"])
|
72
92
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
73
93
|
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
74
|
-
s.add_dependency(%q<
|
94
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
95
|
+
s.add_dependency(%q<simplecov-rcov>, [">= 0"])
|
75
96
|
end
|
76
97
|
else
|
77
98
|
s.add_dependency(%q<thor>, ["~> 0.14.6"])
|
@@ -79,7 +100,8 @@ Gem::Specification.new do |s|
|
|
79
100
|
s.add_dependency(%q<ci_reporter>, ["~> 1.6.5"])
|
80
101
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
81
102
|
s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
|
82
|
-
s.add_dependency(%q<
|
103
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
104
|
+
s.add_dependency(%q<simplecov-rcov>, [">= 0"])
|
83
105
|
end
|
84
106
|
end
|
85
107
|
|
data/lib/gator.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
|
4
|
-
require File.dirname(__FILE__) + '/gator/
|
5
|
-
require File.dirname(__FILE__) + '/gator/
|
6
|
-
require File.dirname(__FILE__) + '/gator/
|
7
|
-
require File.dirname(__FILE__) + '/gator/runner'
|
8
|
-
require File.dirname(__FILE__) + '/gator/commands'
|
1
|
+
require "thor"
|
2
|
+
require "thor/group"
|
3
|
+
|
4
|
+
require File.dirname(__FILE__) + '/gator/core'
|
5
|
+
require File.dirname(__FILE__) + '/gator/plugins/generators'
|
6
|
+
require File.dirname(__FILE__) + '/gator/plugins/scaffolding'
|
data/lib/gator/core.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path( File.dirname(__FILE__) + '/core/command/act_as_command' )
|
2
|
+
require File.expand_path( File.dirname(__FILE__) + '/core/command/act_as_command_collection' )
|
3
|
+
require File.expand_path( File.dirname(__FILE__) + '/core/command/command' )
|
4
|
+
require File.expand_path( File.dirname(__FILE__) + '/core/command/task' )
|
5
|
+
|
6
|
+
require File.expand_path( File.dirname(__FILE__) + '/core/io/paths' )
|
7
|
+
require File.expand_path( File.dirname(__FILE__) + '/core/io/ruby_file_loader' )
|
8
|
+
require File.expand_path(File.dirname(__FILE__) + '/core/io/project_file_locator')
|
9
|
+
require File.expand_path( File.dirname(__FILE__) + '/core/io/sandbox' )
|
10
|
+
|
11
|
+
require File.expand_path( File.dirname(__FILE__) + '/core/configuration/act_as_configuration' )
|
12
|
+
require File.expand_path( File.dirname(__FILE__) + '/core/configuration/configuration' )
|
13
|
+
|
14
|
+
require File.expand_path( File.dirname(__FILE__) + '/core/project/layout' )
|
15
|
+
require File.expand_path( File.dirname(__FILE__) + '/core/project/project' )
|
16
|
+
|
17
|
+
require File.expand_path( File.dirname(__FILE__) + '/core/application/application' )
|
18
|
+
require File.expand_path( File.dirname(__FILE__) + '/core/application/application_configuration' )
|
19
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
class Gator
|
4
|
+
class Application < Command
|
5
|
+
#include Singleton
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
desc "version", "Show Gator version"
|
9
|
+
def version
|
10
|
+
version_file = File.dirname(__FILE__) + '/../../../../VERSION'
|
11
|
+
say File.exist?(version_file) ? File.read(version_file) : ""
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(*args)
|
15
|
+
bootstrap
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
no_tasks {
|
20
|
+
|
21
|
+
def bootstrap
|
22
|
+
Gator::Sandbox.add_getter :gator, Gator::ApplicationConfiguration.new
|
23
|
+
load_configuration
|
24
|
+
load_project
|
25
|
+
end
|
26
|
+
|
27
|
+
def load_configuration
|
28
|
+
file = Gator::Paths.env_file
|
29
|
+
say "No environment file (env.rb) could be found in gator home directory.(#{Gator::Paths.gator_home})", :yellow unless File.exist? file
|
30
|
+
RubyFileLoader.new(Gator::Sandbox).exec_file file if File.exist? file
|
31
|
+
end
|
32
|
+
|
33
|
+
def load_project
|
34
|
+
file = Gator::Paths.project_file
|
35
|
+
say "No project file (gator.rb) could be found in this directory.(#{Dir.pwd})", :yellow if file.nil?
|
36
|
+
RubyFileLoader.new(Gator::Sandbox).exec_file file unless file.nil?
|
37
|
+
end
|
38
|
+
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class Gator
|
2
|
+
module ActAsCommand
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
base.extend(ClassMethods)
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
|
10
|
+
attr_reader :definition, :parent
|
11
|
+
|
12
|
+
def define(definition)
|
13
|
+
@definition = definition
|
14
|
+
end
|
15
|
+
|
16
|
+
def parent_command=(klass)
|
17
|
+
@parent = klass
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def parent
|
23
|
+
self.class.parent
|
24
|
+
end
|
25
|
+
|
26
|
+
def definition
|
27
|
+
self.class.definition
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_subcommand(*args)
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
|
34
|
+
def resolve_subcommand(command, fallback=nil)
|
35
|
+
return nil unless parent
|
36
|
+
parent.resolve_subcommand(command, fallback)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class Gator
|
2
|
+
module ActAsCommandCollection
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
base.extend(ClassMethods)
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
|
10
|
+
def subcommand_classes
|
11
|
+
@subcommand_classes ||= {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def register_subcommand(klass)
|
15
|
+
d = klass.definition
|
16
|
+
register klass, d[:command], d[:usage], d[:description], d[:options] || {}
|
17
|
+
map [d[:short]] => d[:command] unless d[:short].nil?
|
18
|
+
subcommand_classes[d[:command]] = klass
|
19
|
+
klass.parent_command = self
|
20
|
+
end
|
21
|
+
|
22
|
+
alias :<< :register_subcommand
|
23
|
+
|
24
|
+
|
25
|
+
def get_subcommand(*args)
|
26
|
+
klass = self
|
27
|
+
args.each do |arg|
|
28
|
+
return nil unless klass.subcommand_classes.has_key? arg
|
29
|
+
klass = klass.subcommand_classes[arg]
|
30
|
+
end
|
31
|
+
klass
|
32
|
+
end
|
33
|
+
|
34
|
+
def resolve_subcommand(command, fallback=nil)
|
35
|
+
|
36
|
+
subcommand = get_subcommand *command
|
37
|
+
return subcommand unless subcommand.nil?
|
38
|
+
|
39
|
+
if command.respond_to?(:first) && command.first == definition[:command]
|
40
|
+
command_stripped = command.dup
|
41
|
+
command_stripped.shift
|
42
|
+
subcommand = command_stripped.empty? ? self : get_subcommand(*command_stripped)
|
43
|
+
return subcommand unless subcommand.nil?
|
44
|
+
end
|
45
|
+
|
46
|
+
subcommand = parent.resolve_subcommand command unless parent.nil?
|
47
|
+
return subcommand unless subcommand.nil?
|
48
|
+
|
49
|
+
resolve_subcommand fallback unless fallback.nil?
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_subcommand(*args)
|
55
|
+
self.class.get_subcommand *args
|
56
|
+
end
|
57
|
+
|
58
|
+
def resolve_subcommand(command, fallback=nil)
|
59
|
+
self.class.resolve_subcommand command, fallback
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Gator
|
2
|
+
class Command < Thor
|
3
|
+
include ActAsCommand
|
4
|
+
include ActAsCommandCollection
|
5
|
+
|
6
|
+
#The following lines fix a bug in thor see: https://github.com/wycats/thor/pull/150
|
7
|
+
class << self
|
8
|
+
def register(klass, subcommand_name, usage, description, options={})
|
9
|
+
if klass <= Thor::Group
|
10
|
+
desc usage, description, options
|
11
|
+
define_method(subcommand_name) { |*args| invoke klass }
|
12
|
+
else
|
13
|
+
desc usage, description, options
|
14
|
+
subcommand subcommand_name, klass
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class Gator
|
2
|
+
module ActAsConfiguration
|
3
|
+
|
4
|
+
def add_getter name, val
|
5
|
+
self.class.send :attr_reader, name
|
6
|
+
instance_variable_set "@#{name}", val
|
7
|
+
end
|
8
|
+
|
9
|
+
def add_configuration(name, val=nil)
|
10
|
+
|
11
|
+
create_method "#{name.to_s}=" do |val|
|
12
|
+
instance_variable_set("@#{name}", val)
|
13
|
+
end
|
14
|
+
|
15
|
+
create_method name do |&block|
|
16
|
+
block.call(instance_variable_get("@#{name}")) if block
|
17
|
+
instance_variable_get("@#{name}")
|
18
|
+
end
|
19
|
+
|
20
|
+
instance_variable_set("@#{name}", val) if val
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def create_method(name, &block)
|
26
|
+
self.class.send(:define_method, name, &block)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class Gator
|
2
|
+
class Paths
|
3
|
+
|
4
|
+
def self.gator_home
|
5
|
+
File.join(Thor::Util.user_home, ".gator").gsub(/\\/, '/')
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.env_file
|
9
|
+
File.join gator_home, "environment.rb"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.project_home
|
13
|
+
Gator::ProjectFileLocator.new.find_project_dir
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.project_file
|
17
|
+
Gator::ProjectFileLocator.new.find_project_file
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|