tooler 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/License +8 -0
- data/README.md +26 -0
- data/bin/tooler +21 -0
- data/lib/cuba_template.rb +29 -0
- data/lib/error.rb +5 -0
- data/lib/sinatra_template.rb +27 -0
- data/lib/template.rb +44 -0
- data/lib/tooler.rb +44 -0
- data/lib/version.rb +3 -0
- data/templates/README.md +7 -0
- data/templates/cuba/Gemfile +4 -0
- data/templates/cuba/Procfile +1 -0
- data/templates/cuba/config.ru +3 -0
- data/templates/cuba/cuba_template.rb +10 -0
- data/templates/gitignore +5 -0
- data/templates/license/mit.txt +8 -0
- data/templates/sinatra/Gemfile +4 -0
- data/templates/sinatra/Procfile +1 -0
- data/templates/sinatra/config.ru +4 -0
- data/templates/sinatra/template.rb +4 -0
- data/tooler.gemspec +25 -0
- metadata +69 -0
data/License
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
Copyright (c) 2012 Revath S Kumar
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Tooler
|
2
|
+
## Ruby Project bolerplater
|
3
|
+
|
4
|
+
### What it does
|
5
|
+
* Generate minimum code need to run
|
6
|
+
* Add README.md
|
7
|
+
* Add License
|
8
|
+
* Add .gitignore
|
9
|
+
* Add Gemfile
|
10
|
+
* Add Procfile
|
11
|
+
|
12
|
+
### Current Support
|
13
|
+
* Cuba
|
14
|
+
* Sinatra
|
15
|
+
|
16
|
+
### TODO
|
17
|
+
* Initialize git
|
18
|
+
* Ask some questions from users
|
19
|
+
* Add support to create a ruby gem
|
20
|
+
* Write tests for tooler
|
21
|
+
* Generate test template
|
22
|
+
* Generate spec template
|
23
|
+
|
24
|
+
|
25
|
+
### License
|
26
|
+
Please see [License](License)
|
data/bin/tooler
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Now load
|
4
|
+
require "fileutils"
|
5
|
+
require "template"
|
6
|
+
require "tooler"
|
7
|
+
require "error"
|
8
|
+
|
9
|
+
|
10
|
+
# And run with ARGV
|
11
|
+
begin
|
12
|
+
tooler = Tooler::CLI.new :arguments => ARGV
|
13
|
+
tooler.start
|
14
|
+
rescue Interrupt
|
15
|
+
p "Quitting..."
|
16
|
+
exit 1
|
17
|
+
rescue Tooler::Error => error
|
18
|
+
p error.message
|
19
|
+
p "------------------"
|
20
|
+
exit 1
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Tooler
|
2
|
+
module Template
|
3
|
+
|
4
|
+
def copy_template_cuba
|
5
|
+
gitignore
|
6
|
+
license
|
7
|
+
readme
|
8
|
+
create_dir "lib"
|
9
|
+
create_dir "spec"
|
10
|
+
create_dir "log"
|
11
|
+
template
|
12
|
+
config_ru
|
13
|
+
gemfile
|
14
|
+
procfile
|
15
|
+
end
|
16
|
+
|
17
|
+
def config_ru
|
18
|
+
contents = file_read @options[:template_path]+'cuba/config.ru'
|
19
|
+
contents = contents % {name: @options[:name]}
|
20
|
+
file_write @options[:pwd]+"/config.ru", contents
|
21
|
+
end
|
22
|
+
|
23
|
+
def template
|
24
|
+
contents = file_read @options[:template_path]+'cuba/cuba_template.rb'
|
25
|
+
contents = contents % {name: @options[:name]}
|
26
|
+
file_write @options[:pwd]+"/lib/#{@options[:name]}.rb", contents
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/error.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module Tooler
|
2
|
+
module Template
|
3
|
+
|
4
|
+
def copy_template_sinatra
|
5
|
+
gitignore
|
6
|
+
license
|
7
|
+
readme
|
8
|
+
create_dir "lib"
|
9
|
+
create_dir "spec"
|
10
|
+
create_dir "log"
|
11
|
+
template
|
12
|
+
gemfile
|
13
|
+
procfile
|
14
|
+
config_ru
|
15
|
+
end
|
16
|
+
|
17
|
+
def template
|
18
|
+
::FileUtils.cp @options[:template_path]+"sinatra/template.rb", @options[:pwd]+"lib/#{@options[:name]}.rb"
|
19
|
+
end
|
20
|
+
|
21
|
+
def config_ru
|
22
|
+
contents = file_read @options[:template_path]+'sinatra/config.ru'
|
23
|
+
contents = contents % {name: @options[:name]}
|
24
|
+
file_write @options[:pwd]+"/config.ru", contents
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/template.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
module Tooler
|
2
|
+
module Template
|
3
|
+
|
4
|
+
def gemfile
|
5
|
+
::FileUtils.cp @options[:template_path]+"#{@options[:template]}/Gemfile", @options[:pwd]+"/Gemfile"
|
6
|
+
end
|
7
|
+
|
8
|
+
def procfile
|
9
|
+
::FileUtils.cp @options[:template_path]+"#{@options[:template]}/Procfile", @options[:pwd]+"/Procfile"
|
10
|
+
end
|
11
|
+
|
12
|
+
def gitignore
|
13
|
+
::FileUtils.cp @options[:template_path]+"gitignore", @options[:pwd]+"/.gitignore"
|
14
|
+
end
|
15
|
+
|
16
|
+
def license name=nil
|
17
|
+
p "Copying license"
|
18
|
+
::FileUtils.cp @options[:template_path]+"license/#{name||'mit'}.txt", @options[:pwd]+"/License"
|
19
|
+
end
|
20
|
+
|
21
|
+
def readme
|
22
|
+
p "Copying README"
|
23
|
+
contents = file_read @options[:template_path]+"README.md"
|
24
|
+
contents = contents % {name: @options[:name], description: ""}
|
25
|
+
file_write @options[:pwd]+"/README.md", contents
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_dir name
|
29
|
+
p "create dir #{name}"
|
30
|
+
::FileUtils.mkdir @options[:pwd]+"/"+name
|
31
|
+
end
|
32
|
+
|
33
|
+
def file_read file_path
|
34
|
+
File.read(file_path)
|
35
|
+
end
|
36
|
+
|
37
|
+
def file_write file_path, contents
|
38
|
+
File.open(file_path, 'w+') do |f2|
|
39
|
+
f2.puts contents
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/lib/tooler.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
|
2
|
+
module Tooler
|
3
|
+
class CLI
|
4
|
+
include Tooler::Template
|
5
|
+
|
6
|
+
def initialize args
|
7
|
+
@options = {template: "", name: ""}
|
8
|
+
parse args[:arguments]
|
9
|
+
@options[:pwd] = ::FileUtils.pwd + "/"
|
10
|
+
@options[:name] = @options[:pwd].split('/').last
|
11
|
+
@options[:template_path] = File.dirname(__FILE__) + "/../templates/"
|
12
|
+
end
|
13
|
+
|
14
|
+
def start
|
15
|
+
p "Initializing #{@options[:template]}"
|
16
|
+
p "Project Name #{@options[:name]}"
|
17
|
+
begin
|
18
|
+
require "#{@options[:template]}_template"
|
19
|
+
rescue LoadError
|
20
|
+
p "Invalid template name"
|
21
|
+
end
|
22
|
+
send("copy_template_#{@options[:template]}")
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def parse args
|
28
|
+
@options[:template] = args[0].downcase
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_name
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def method_missing method_name, args
|
36
|
+
p "method_missing #{method}"
|
37
|
+
if method_name[/^copy_template_/]
|
38
|
+
raise Tooler::Error, "Invalid template"
|
39
|
+
else
|
40
|
+
super
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/version.rb
ADDED
data/templates/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
web: bundle exec thin -R config.ru start -p $PORT
|
data/templates/gitignore
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
Copyright (c) 2012 Revath S Kumar
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
5
|
+
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
7
|
+
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1 @@
|
|
1
|
+
web: bundle exec thin -R config.ru start -p $PORT
|
data/tooler.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('../lib',__FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require "version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = 'tooler'
|
9
|
+
s.version = Tooler::VERSION
|
10
|
+
s.date = Time.new.strftime("%Y-%m-%d")
|
11
|
+
s.summary = "Tooler"
|
12
|
+
s.description = "Ruby boilerplater"
|
13
|
+
s.authors = ["Revath S Kumar"]
|
14
|
+
s.email = ["rsk@revathskumar.com"]
|
15
|
+
s.homepage = "http://blog.revathskumar.com"
|
16
|
+
s.files = ["License", "README.md","tooler.gemspec"]
|
17
|
+
s.files += Dir.glob("lib/*.rb")
|
18
|
+
s.files += Dir.glob("templates/*")
|
19
|
+
s.files += Dir.glob("templates/**/*")
|
20
|
+
s.files += Dir.glob("bin/*")
|
21
|
+
s.license = 'MIT'
|
22
|
+
s.bindir = 'bin'
|
23
|
+
s.require_paths = ['lib']
|
24
|
+
s.executables = %w(tooler)
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tooler
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Revath S Kumar
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-13 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Ruby boilerplater
|
15
|
+
email:
|
16
|
+
- rsk@revathskumar.com
|
17
|
+
executables:
|
18
|
+
- tooler
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- License
|
23
|
+
- README.md
|
24
|
+
- tooler.gemspec
|
25
|
+
- lib/version.rb
|
26
|
+
- lib/template.rb
|
27
|
+
- lib/cuba_template.rb
|
28
|
+
- lib/tooler.rb
|
29
|
+
- lib/error.rb
|
30
|
+
- lib/sinatra_template.rb
|
31
|
+
- templates/gitignore
|
32
|
+
- templates/README.md
|
33
|
+
- templates/license/mit.txt
|
34
|
+
- templates/sinatra/config.ru
|
35
|
+
- templates/sinatra/template.rb
|
36
|
+
- templates/sinatra/Procfile
|
37
|
+
- templates/sinatra/Gemfile
|
38
|
+
- templates/cuba/config.ru
|
39
|
+
- templates/cuba/cuba_template.rb
|
40
|
+
- templates/cuba/Procfile
|
41
|
+
- templates/cuba/Gemfile
|
42
|
+
- bin/tooler
|
43
|
+
homepage: http://blog.revathskumar.com
|
44
|
+
licenses:
|
45
|
+
- MIT
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.8.10
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: Tooler
|
68
|
+
test_files: []
|
69
|
+
has_rdoc:
|