alonzo 0.0.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.
- data/Gemfile +2 -0
- data/Gemfile.lock +53 -0
- data/README.rdoc +6 -0
- data/Rakefile +42 -0
- data/alonzo.gemspec +38 -0
- data/alonzo.rdoc +5 -0
- data/bin/alonzo +55 -0
- data/lib/alonzo.rb +11 -0
- data/lib/alonzo/commands.rb +7 -0
- data/lib/alonzo/commands/gen.rb +33 -0
- data/lib/alonzo/generator.rb +111 -0
- data/lib/alonzo/version.rb +3 -0
- metadata +167 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
alonzo (0.0.1)
|
5
|
+
gli (= 2.5.4)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
active_support (3.0.0)
|
11
|
+
activesupport (= 3.0.0)
|
12
|
+
activesupport (3.0.0)
|
13
|
+
aruba (0.5.1)
|
14
|
+
childprocess (~> 0.3.6)
|
15
|
+
cucumber (>= 1.1.1)
|
16
|
+
rspec-expectations (>= 2.7.0)
|
17
|
+
builder (3.2.0)
|
18
|
+
childprocess (0.3.9)
|
19
|
+
ffi (~> 1.0, >= 1.0.11)
|
20
|
+
cucumber (1.2.3)
|
21
|
+
builder (>= 2.1.2)
|
22
|
+
diff-lcs (>= 1.1.3)
|
23
|
+
gherkin (~> 2.11.6)
|
24
|
+
multi_json (~> 1.3)
|
25
|
+
diff-lcs (1.2.1)
|
26
|
+
ffi (1.4.0)
|
27
|
+
gherkin (2.11.6)
|
28
|
+
json (>= 1.7.6)
|
29
|
+
gli (2.5.4)
|
30
|
+
json (1.7.7)
|
31
|
+
multi_json (1.6.1)
|
32
|
+
rake (10.0.3)
|
33
|
+
rdoc (4.0.0)
|
34
|
+
json (~> 1.4)
|
35
|
+
rspec (2.13.0)
|
36
|
+
rspec-core (~> 2.13.0)
|
37
|
+
rspec-expectations (~> 2.13.0)
|
38
|
+
rspec-mocks (~> 2.13.0)
|
39
|
+
rspec-core (2.13.0)
|
40
|
+
rspec-expectations (2.13.0)
|
41
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
42
|
+
rspec-mocks (2.13.0)
|
43
|
+
|
44
|
+
PLATFORMS
|
45
|
+
ruby
|
46
|
+
|
47
|
+
DEPENDENCIES
|
48
|
+
active_support
|
49
|
+
alonzo!
|
50
|
+
aruba
|
51
|
+
rake
|
52
|
+
rdoc
|
53
|
+
rspec
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rake/clean'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rubygems/package_task'
|
4
|
+
require 'rdoc/task'
|
5
|
+
require 'cucumber'
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
Rake::RDocTask.new do |rd|
|
8
|
+
rd.main = "README.rdoc"
|
9
|
+
rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
|
10
|
+
rd.title = 'Your application title'
|
11
|
+
end
|
12
|
+
|
13
|
+
spec = eval(File.read('alonzo.gemspec'))
|
14
|
+
|
15
|
+
Gem::PackageTask.new(spec) do |pkg|
|
16
|
+
end
|
17
|
+
CUKE_RESULTS = 'results.html'
|
18
|
+
CLEAN << CUKE_RESULTS
|
19
|
+
desc 'Run features'
|
20
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
21
|
+
opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
|
22
|
+
opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
|
23
|
+
t.cucumber_opts = opts
|
24
|
+
t.fork = false
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Run features tagged as work-in-progress (@wip)'
|
28
|
+
Cucumber::Rake::Task.new('features:wip') do |t|
|
29
|
+
tag_opts = ' --tags ~@pending'
|
30
|
+
tag_opts = ' --tags @wip'
|
31
|
+
t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
|
32
|
+
t.fork = false
|
33
|
+
end
|
34
|
+
|
35
|
+
task :cucumber => :features
|
36
|
+
task 'cucumber:wip' => 'features:wip'
|
37
|
+
task :wip => 'features:wip'
|
38
|
+
|
39
|
+
require 'rspec/core/rake_task'
|
40
|
+
RSpec::Core::RakeTask.new(:spec)
|
41
|
+
|
42
|
+
task :default => [:spec,:features]
|
data/alonzo.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Ensure we require the local version and not one we might have installed already
|
2
|
+
require File.join([File.dirname(__FILE__),'lib','alonzo','version.rb'])
|
3
|
+
spec = Gem::Specification.new do |s|
|
4
|
+
s.name = 'alonzo'
|
5
|
+
s.version = Alonzo::VERSION
|
6
|
+
s.author = 'Joshua Schairbaum'
|
7
|
+
s.email = 'joshua.schairbaum@gmail.com'
|
8
|
+
s.homepage = 'https://github.com/jschairb/alonzo'
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.summary = 'Your command-line butler and confidant'
|
11
|
+
# Add your other files here if you make them
|
12
|
+
s.files = %w(
|
13
|
+
Gemfile
|
14
|
+
Gemfile.lock
|
15
|
+
README.rdoc
|
16
|
+
Rakefile
|
17
|
+
alonzo.gemspec
|
18
|
+
alonzo.rdoc
|
19
|
+
bin/alonzo
|
20
|
+
lib/alonzo/commands/gen.rb
|
21
|
+
lib/alonzo/commands.rb
|
22
|
+
lib/alonzo/generator.rb
|
23
|
+
lib/alonzo/version.rb
|
24
|
+
lib/alonzo.rb
|
25
|
+
)
|
26
|
+
s.require_paths << 'lib'
|
27
|
+
s.has_rdoc = true
|
28
|
+
s.extra_rdoc_files = ['README.rdoc','alonzo.rdoc']
|
29
|
+
s.rdoc_options << '--title' << 'alonzo' << '--main' << 'README.rdoc' << '-ri'
|
30
|
+
s.bindir = 'bin'
|
31
|
+
s.executables << 'alonzo'
|
32
|
+
s.add_development_dependency('active_support')
|
33
|
+
s.add_development_dependency('rake')
|
34
|
+
s.add_development_dependency('rdoc')
|
35
|
+
s.add_development_dependency('aruba')
|
36
|
+
s.add_development_dependency('rspec')
|
37
|
+
s.add_runtime_dependency('gli','2.5.4')
|
38
|
+
end
|
data/alonzo.rdoc
ADDED
data/bin/alonzo
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'gli'
|
3
|
+
begin # XXX: Remove this begin/rescue before distributing your app
|
4
|
+
require 'alonzo'
|
5
|
+
rescue LoadError
|
6
|
+
STDERR.puts "In development, you need to use `bundle exec bin/alonzo` to run your app"
|
7
|
+
STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the load path"
|
8
|
+
STDERR.puts "Feel free to remove this message from bin/alonzo now"
|
9
|
+
exit 64
|
10
|
+
end
|
11
|
+
|
12
|
+
include GLI::App
|
13
|
+
|
14
|
+
program_desc 'A commandline butler and confidant'
|
15
|
+
|
16
|
+
version Alonzo::VERSION
|
17
|
+
|
18
|
+
pre do |global, command, options, args|
|
19
|
+
# Pre logic here
|
20
|
+
# Return true to proceed; false to abort and not call the
|
21
|
+
# chosen command
|
22
|
+
# Use skips_pre before a command to skip this block
|
23
|
+
# on that command only
|
24
|
+
true
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Generate boilerplate files"
|
28
|
+
arg_name 'template_args'
|
29
|
+
command :gen do |c|
|
30
|
+
c.action do |global, options, args|
|
31
|
+
arguments = { args: args, global: global, options: options }
|
32
|
+
Alonzo::Commands::Gen.run(arguments)
|
33
|
+
end
|
34
|
+
|
35
|
+
c.flag [:r, :root], default_value: Alonzo::Commands::Gen.defaults[:project_root],
|
36
|
+
arg_name: 'project_root',
|
37
|
+
desc: 'The root directory for the project'
|
38
|
+
c.flag [:t, :type], default_value: Alonzo::Commands::Gen.defaults[:template_type],
|
39
|
+
arg_name: 'template_type',
|
40
|
+
desc: 'The type of template to generate'
|
41
|
+
end
|
42
|
+
|
43
|
+
post do |global, command, options, args|
|
44
|
+
# Post logic here
|
45
|
+
# Use skips_post before a command to skip this
|
46
|
+
# block on that command only
|
47
|
+
end
|
48
|
+
|
49
|
+
on_error do |exception|
|
50
|
+
# Error logic here
|
51
|
+
# return false to skip default error handling
|
52
|
+
true
|
53
|
+
end
|
54
|
+
|
55
|
+
exit run(ARGV)
|
data/lib/alonzo.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Alonzo
|
2
|
+
module Commands
|
3
|
+
class Gen
|
4
|
+
DEFAULTS = {
|
5
|
+
project_root: Dir.pwd,
|
6
|
+
template_type: :rb_class
|
7
|
+
}
|
8
|
+
|
9
|
+
attr_accessor :args, :global, :options, :output
|
10
|
+
|
11
|
+
def self.run(cmd_opts_and_args, options = {})
|
12
|
+
gen = new(cmd_opts_and_args, options)
|
13
|
+
gen.run
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.defaults
|
17
|
+
DEFAULTS
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(cmd_opts_and_args = {}, options = {})
|
21
|
+
cmd_opts_and_args.each do |key, value|
|
22
|
+
self.send("#{key}=", value)
|
23
|
+
end
|
24
|
+
|
25
|
+
self.output = options.delete(:output) || STDOUT
|
26
|
+
end
|
27
|
+
|
28
|
+
def run
|
29
|
+
Generator.generate(args, { output: output, root: options[:root], type: options[:type] })
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'active_support/inflector'
|
3
|
+
|
4
|
+
module Alonzo
|
5
|
+
class Generator
|
6
|
+
|
7
|
+
class RbClassGenerator
|
8
|
+
attr_accessor :klass_names, :root
|
9
|
+
attr_reader :files
|
10
|
+
|
11
|
+
def initialize(klass_names, root)
|
12
|
+
self.klass_names = klass_names
|
13
|
+
self.root = root
|
14
|
+
|
15
|
+
@files = []
|
16
|
+
|
17
|
+
klass_names.each do |klass_name|
|
18
|
+
@files << klass_file(klass_name)
|
19
|
+
@files << spec_file(klass_name)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def klass_file(klass_name)
|
24
|
+
{ name: klass_file_path(klass_name),
|
25
|
+
content: klass_file_template(klass_name) }
|
26
|
+
end
|
27
|
+
|
28
|
+
def klass_file_path(klass_name)
|
29
|
+
File.join(root, "lib", "#{klass_name.underscore}.rb")
|
30
|
+
end
|
31
|
+
|
32
|
+
def klass_file_template(klass_name)
|
33
|
+
template = ""
|
34
|
+
wrap_modules(template, klass_name.split("::"))
|
35
|
+
template
|
36
|
+
end
|
37
|
+
|
38
|
+
def spec_file(klass_name)
|
39
|
+
{ name: spec_file_path(klass_name),
|
40
|
+
content: spec_file_template(klass_name) }
|
41
|
+
end
|
42
|
+
|
43
|
+
def spec_file_path(klass_name)
|
44
|
+
File.join(root, "spec", "#{klass_name.underscore}_spec.rb")
|
45
|
+
end
|
46
|
+
|
47
|
+
def spec_file_template(klass_name)
|
48
|
+
template = "require 'spec_helper'\n\n"
|
49
|
+
wrap_modules(template, klass_name.split("::"), 0, true)
|
50
|
+
template
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def indent(size)
|
56
|
+
" " * size
|
57
|
+
end
|
58
|
+
|
59
|
+
def statement_begin(type, name, indent_level = 0)
|
60
|
+
"#{indent(indent_level)}#{type} #{name}#{" do" if type == :describe}\n"
|
61
|
+
end
|
62
|
+
|
63
|
+
def statement_end(indent_level = 0)
|
64
|
+
"#{indent(indent_level)}end\n"
|
65
|
+
end
|
66
|
+
|
67
|
+
def wrap_modules(template, modules, indent = 0, spec = false)
|
68
|
+
module_name = modules.shift
|
69
|
+
type = if modules.any?
|
70
|
+
:module
|
71
|
+
elsif spec
|
72
|
+
:describe
|
73
|
+
else
|
74
|
+
:class
|
75
|
+
end
|
76
|
+
return if module_name.nil?
|
77
|
+
template << statement_begin(type, module_name, indent)
|
78
|
+
wrap_modules(template, modules, indent + 2, spec)
|
79
|
+
template << statement_end(indent)
|
80
|
+
template
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
attr_accessor :args, :output, :root
|
85
|
+
attr_reader :generator, :generator_class
|
86
|
+
|
87
|
+
def self.generate(args, options = {})
|
88
|
+
generator = new(args, options)
|
89
|
+
generator.generate
|
90
|
+
end
|
91
|
+
|
92
|
+
def initialize(args, options = {})
|
93
|
+
self.args = args
|
94
|
+
self.output = options.delete(:output) || STDOUT
|
95
|
+
self.root = options.delete(:root) || Dir.pwd
|
96
|
+
|
97
|
+
generator_klass_name = "#{options[:type]}_generator".classify
|
98
|
+
@generator_class = "#{self.class.name}::#{generator_klass_name}".constantize
|
99
|
+
@generator = generator_class.new(args, root)
|
100
|
+
end
|
101
|
+
|
102
|
+
def generate
|
103
|
+
output.puts "Generating #{generator_class} files"
|
104
|
+
generator.files.each do |file|
|
105
|
+
output.puts " #{file[:name]}"
|
106
|
+
FileUtils.mkdir_p(File.dirname(file[:name]))
|
107
|
+
File.open(file[:name], "w") { |f| f << file[:content] }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: alonzo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Joshua Schairbaum
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: active_support
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rdoc
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: aruba
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: gli
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - '='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 2.5.4
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - '='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 2.5.4
|
110
|
+
description:
|
111
|
+
email: joshua.schairbaum@gmail.com
|
112
|
+
executables:
|
113
|
+
- alonzo
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files:
|
116
|
+
- README.rdoc
|
117
|
+
- alonzo.rdoc
|
118
|
+
files:
|
119
|
+
- Gemfile
|
120
|
+
- Gemfile.lock
|
121
|
+
- README.rdoc
|
122
|
+
- Rakefile
|
123
|
+
- alonzo.gemspec
|
124
|
+
- alonzo.rdoc
|
125
|
+
- bin/alonzo
|
126
|
+
- lib/alonzo/commands/gen.rb
|
127
|
+
- lib/alonzo/commands.rb
|
128
|
+
- lib/alonzo/generator.rb
|
129
|
+
- lib/alonzo/version.rb
|
130
|
+
- lib/alonzo.rb
|
131
|
+
homepage: https://github.com/jschairb/alonzo
|
132
|
+
licenses: []
|
133
|
+
post_install_message:
|
134
|
+
rdoc_options:
|
135
|
+
- --title
|
136
|
+
- alonzo
|
137
|
+
- --main
|
138
|
+
- README.rdoc
|
139
|
+
- -ri
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
none: false
|
145
|
+
requirements:
|
146
|
+
- - ! '>='
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
segments:
|
150
|
+
- 0
|
151
|
+
hash: 1496399600581775297
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
segments:
|
159
|
+
- 0
|
160
|
+
hash: 1496399600581775297
|
161
|
+
requirements: []
|
162
|
+
rubyforge_project:
|
163
|
+
rubygems_version: 1.8.23
|
164
|
+
signing_key:
|
165
|
+
specification_version: 3
|
166
|
+
summary: Your command-line butler and confidant
|
167
|
+
test_files: []
|