boiler 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/boiler +31 -0
- data/boiler.gemspec +20 -0
- data/lib/boiler/generator/base.rb +29 -0
- data/lib/boiler/generator/script.rb +72 -0
- data/lib/boiler/generator/suite.rb +110 -0
- data/lib/boiler/generator.rb +6 -0
- data/lib/boiler/version.rb +3 -0
- data/lib/boiler.rb +5 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Greg Brockman
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Boiler
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'boiler'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install boiler
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/boiler
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'escort'
|
3
|
+
require 'boiler'
|
4
|
+
|
5
|
+
Escort::App.create do |app|
|
6
|
+
app.version Boiler::VERSION
|
7
|
+
app.summary "Generates boilerplate for you."
|
8
|
+
app.description "A boilerplate generation library"
|
9
|
+
|
10
|
+
app.command(:script) do |command|
|
11
|
+
command.summary "Generate a Ruby script"
|
12
|
+
command.description "Generate a Ruby script"
|
13
|
+
|
14
|
+
command.action do |options, arguments|
|
15
|
+
Boiler::Generator::Script.new(options, arguments).execute
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
app.command(:suite) do |command|
|
20
|
+
command.summary "Generate a test suite"
|
21
|
+
command.description "Generate a test suite"
|
22
|
+
|
23
|
+
command.action do |options, arguments|
|
24
|
+
Boiler::Generator::Suite.new(options, arguments).execute
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
app.action do |options, arguments|
|
29
|
+
raise "Must provide an argument. Run -h for options."
|
30
|
+
end
|
31
|
+
end
|
data/boiler.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'boiler/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "boiler"
|
8
|
+
gem.version = Boiler::VERSION
|
9
|
+
gem.authors = ["Greg Brockman"]
|
10
|
+
gem.email = ["gdb@gregbrockman.com"]
|
11
|
+
gem.description = "A boilerplate generator"
|
12
|
+
gem.summary = "Generates boilerplate for you"
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.add_dependency 'escort'
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Boiler::Generator
|
4
|
+
class Base
|
5
|
+
def initialize(options, arguments)
|
6
|
+
@options = options
|
7
|
+
@arguments = arguments
|
8
|
+
end
|
9
|
+
|
10
|
+
def execute
|
11
|
+
raise NotImplementedError.new('Override in subclass')
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def write_file(file, contents)
|
17
|
+
# TODO: disable O_CREAT
|
18
|
+
File.open(file, 'w') {|f| f.print(contents)}
|
19
|
+
end
|
20
|
+
|
21
|
+
def chmod(perms, file)
|
22
|
+
FileUtils.chmod(0755, file)
|
23
|
+
end
|
24
|
+
|
25
|
+
def mkdir(dir)
|
26
|
+
FileUtils.mkdir(dir)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Boiler::Generator
|
2
|
+
class Script < Base
|
3
|
+
def execute
|
4
|
+
file = @arguments.first
|
5
|
+
|
6
|
+
if file
|
7
|
+
write_file(file, template)
|
8
|
+
chmod(0755, file)
|
9
|
+
else
|
10
|
+
puts template
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def template
|
17
|
+
<<-EOF
|
18
|
+
#!/usr/bin/env ruby
|
19
|
+
require 'logger'
|
20
|
+
require 'optparse'
|
21
|
+
|
22
|
+
$log = Logger.new(STDOUT)
|
23
|
+
$log.level = Logger::WARN
|
24
|
+
|
25
|
+
module MyScript
|
26
|
+
class MyRunner
|
27
|
+
def initialize
|
28
|
+
end
|
29
|
+
|
30
|
+
def run
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def main
|
36
|
+
options = {}
|
37
|
+
optparse = OptionParser.new do |opts|
|
38
|
+
opts.banner = "Usage: \#{$0} [options]"
|
39
|
+
|
40
|
+
opts.on('-v', '--verbosity', 'Verbosity of debugging output') do
|
41
|
+
$log.level -= 1
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on('-h', '--help', 'Display this message') do
|
45
|
+
puts opts
|
46
|
+
exit(1)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
optparse.parse!
|
50
|
+
|
51
|
+
if ARGV.length != 0
|
52
|
+
puts optparse
|
53
|
+
return 1
|
54
|
+
end
|
55
|
+
|
56
|
+
runner = MyScript::MyRunning.new
|
57
|
+
runner.run
|
58
|
+
return 0
|
59
|
+
end
|
60
|
+
|
61
|
+
if $0 == __FILE__
|
62
|
+
ret = main
|
63
|
+
begin
|
64
|
+
exit(ret)
|
65
|
+
rescue TypeError
|
66
|
+
exit(0)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
EOF
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Boiler::Generator
|
4
|
+
class Suite < Base
|
5
|
+
def execute
|
6
|
+
raise "Must provide a base directory" unless directory = @arguments.first
|
7
|
+
@directory = directory
|
8
|
+
|
9
|
+
make_subdirectories
|
10
|
+
write_files
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def relative_mkdir(subdir)
|
16
|
+
path = File.join(@directory, subdir)
|
17
|
+
mkdir(path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def relative_write_file(file, contents)
|
21
|
+
path = File.join(@directory, file)
|
22
|
+
write_file(path, contents)
|
23
|
+
end
|
24
|
+
|
25
|
+
def make_subdirectories
|
26
|
+
[
|
27
|
+
'test',
|
28
|
+
'test/unit',
|
29
|
+
'test/integration',
|
30
|
+
'test/functional',
|
31
|
+
'test/meta'
|
32
|
+
].each do |subdir|
|
33
|
+
relative_mkdir(subdir)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def write_files
|
38
|
+
relative_write_file('test/_lib.rb', <<EOF)
|
39
|
+
require 'rubygems'
|
40
|
+
require 'bundler/setup'
|
41
|
+
|
42
|
+
require 'minitest/autorun'
|
43
|
+
require 'minitest/spec'
|
44
|
+
require 'mocha'
|
45
|
+
|
46
|
+
module Critic
|
47
|
+
class Test < ::MiniTest::Spec
|
48
|
+
def setup
|
49
|
+
# Put any stubs here that you want to apply globally
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
EOF
|
54
|
+
|
55
|
+
relative_write_file('test/unit/_lib.rb', <<EOF)
|
56
|
+
require File.expand_path('../../_lib', __FILE__)
|
57
|
+
|
58
|
+
module Critic::Unit
|
59
|
+
module Stubs
|
60
|
+
end
|
61
|
+
|
62
|
+
class Test < ContextCritic::Test
|
63
|
+
include Stubs
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
MiniTest::Unit.runner = MiniTest::Unit.new
|
68
|
+
EOF
|
69
|
+
|
70
|
+
relative_write_file('test/functional/_lib.rb', <<EOF)
|
71
|
+
require File.expand_path('../../_lib', __FILE__)
|
72
|
+
|
73
|
+
module Critic::Functional
|
74
|
+
module Stubs
|
75
|
+
end
|
76
|
+
|
77
|
+
class Test < Critic::Test
|
78
|
+
include Stubs
|
79
|
+
end
|
80
|
+
end
|
81
|
+
EOF
|
82
|
+
|
83
|
+
relative_write_file('test/integration/_lib.rb', <<EOF)
|
84
|
+
require File.expand_path('../../_lib', __FILE__)
|
85
|
+
|
86
|
+
module Critic::Integration
|
87
|
+
module Stubs
|
88
|
+
end
|
89
|
+
|
90
|
+
class Test < Critic::Test
|
91
|
+
include Stubs
|
92
|
+
end
|
93
|
+
end
|
94
|
+
EOF
|
95
|
+
|
96
|
+
relative_write_file('test/meta/_lib.rb', <<EOF)
|
97
|
+
require File.expand_path('../../_lib', __FILE__)
|
98
|
+
|
99
|
+
module Critic::Meta
|
100
|
+
module Stubs
|
101
|
+
end
|
102
|
+
|
103
|
+
class Test < Critic::Test
|
104
|
+
include Stubs
|
105
|
+
end
|
106
|
+
end
|
107
|
+
EOF
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
data/lib/boiler.rb
ADDED
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: boiler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Greg Brockman
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: escort
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
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
|
+
description: A boilerplate generator
|
31
|
+
email:
|
32
|
+
- gdb@gregbrockman.com
|
33
|
+
executables:
|
34
|
+
- boiler
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- .gitignore
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE.txt
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- bin/boiler
|
44
|
+
- boiler.gemspec
|
45
|
+
- lib/boiler.rb
|
46
|
+
- lib/boiler/generator.rb
|
47
|
+
- lib/boiler/generator/base.rb
|
48
|
+
- lib/boiler/generator/script.rb
|
49
|
+
- lib/boiler/generator/suite.rb
|
50
|
+
- lib/boiler/version.rb
|
51
|
+
homepage: ''
|
52
|
+
licenses: []
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
requirements: []
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.8.23
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: Generates boilerplate for you
|
75
|
+
test_files: []
|
76
|
+
has_rdoc:
|