wrench 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +20 -0
- data/LICENSE +20 -0
- data/README.md +5 -0
- data/Rakefile +2 -0
- data/bin/wrench +4 -0
- data/conf/config.yaml +26 -0
- data/docs/backlog +3 -0
- data/lib/wrench/cli.rb +116 -0
- data/lib/wrench/templates/Gemfile.erb +2 -0
- data/lib/wrench/templates/Rakefile.erb +2 -0
- data/lib/wrench/templates/main.rb.erb +5 -0
- data/lib/wrench/templates/version.rb.erb +4 -0
- data/lib/wrench/version.rb +3 -0
- data/lib/wrench.rb +24 -0
- data/wrench.gemspec +20 -0
- metadata +64 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
Copyright (c) 2013 Stephen Hu
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
this software and associated documentation files (the "Software"), to deal in
|
6
|
+
the Software without restriction, including without limitation the rights to
|
7
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
8
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
9
|
+
so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
12
|
+
copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/wrench
ADDED
data/conf/config.yaml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
assets:
|
2
|
+
- name: bootstrap
|
3
|
+
url: http://twitter.github.com/bootstrap/assets/bootstrap.zip
|
4
|
+
- name: jqueryui
|
5
|
+
url: https://github.com/jquery/jquery-ui/archive/master.zip
|
6
|
+
directories:
|
7
|
+
- conf
|
8
|
+
- docs
|
9
|
+
- lib
|
10
|
+
- lib/public
|
11
|
+
- lib/public/css
|
12
|
+
- lib/public/img
|
13
|
+
- lib/public/js
|
14
|
+
- lib/views
|
15
|
+
- lib/@
|
16
|
+
- spec
|
17
|
+
files:
|
18
|
+
- template: Gemfile.erb
|
19
|
+
destination: .
|
20
|
+
- template: Rakefile.erb
|
21
|
+
destination: .
|
22
|
+
- template: version.rb.erb
|
23
|
+
destination: lib/@
|
24
|
+
- template: main.rb.erb
|
25
|
+
destination: lib
|
26
|
+
|
data/docs/backlog
ADDED
data/lib/wrench/cli.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
module Wrench
|
2
|
+
|
3
|
+
class CLI < Thor
|
4
|
+
|
5
|
+
def initialize(*args)
|
6
|
+
|
7
|
+
super
|
8
|
+
@config = YAML.load_file( File.join( File.dirname(__FILE__),
|
9
|
+
"../../conf/config.yaml" ) )
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
desc( "up NAME", "create project skeleton" )
|
14
|
+
def up(name)
|
15
|
+
|
16
|
+
create_directories(name)
|
17
|
+
create_files(name)
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
desc( "down ASSET", "download asset" )
|
22
|
+
def down(asset)
|
23
|
+
|
24
|
+
sel = @config[ASSETS].find {|a| a["name"] == asset }
|
25
|
+
|
26
|
+
download(sel["url"]) unless sel.nil?
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
desc( "list", "list all assets" )
|
31
|
+
def list
|
32
|
+
|
33
|
+
@config[ASSETS].each do |a|
|
34
|
+
puts " + #{a[NAME]}"
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
no_tasks do
|
40
|
+
|
41
|
+
def create_directories(name)
|
42
|
+
|
43
|
+
@config[DIRECTORIES].each do |d|
|
44
|
+
|
45
|
+
dir = d
|
46
|
+
|
47
|
+
if d.include?("@")
|
48
|
+
dir = d.sub( "@", "#{name}" )
|
49
|
+
end
|
50
|
+
|
51
|
+
unless File.directory?("#{name}/#{dir}")
|
52
|
+
|
53
|
+
FileUtils.mkdir_p("#{name}/#{dir}")
|
54
|
+
puts " created directory #{name}/#{dir}".green
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
def create_files(name)
|
63
|
+
|
64
|
+
module_name = name.slice(0,1).capitalize + name.slice(1..-1)
|
65
|
+
|
66
|
+
@config[FILES].each do |f|
|
67
|
+
|
68
|
+
e = ERB.new( File.read( File.join( File.dirname(__FILE__),
|
69
|
+
TEMPLATES, f[TEMPLATE] ) ) )
|
70
|
+
|
71
|
+
spec = "#{name}/"
|
72
|
+
|
73
|
+
unless f[DESTINATION].include?(".")
|
74
|
+
spec = spec + f[DESTINATION].sub( "@", name ) + "/"
|
75
|
+
end
|
76
|
+
|
77
|
+
filename = f[TEMPLATE].sub( ".erb", "" )
|
78
|
+
|
79
|
+
if filename == MAINRB
|
80
|
+
filename = "#{name}.rb"
|
81
|
+
end
|
82
|
+
|
83
|
+
puts " created file #{spec + filename}".green
|
84
|
+
|
85
|
+
n = File.open( spec + filename, "w" )
|
86
|
+
n.write(e.result(binding))
|
87
|
+
n.close
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
def download(url)
|
94
|
+
|
95
|
+
bin = open(url)
|
96
|
+
|
97
|
+
Zip::ZipFile.open(bin.path) do |z|
|
98
|
+
|
99
|
+
z.each do |f|
|
100
|
+
|
101
|
+
path = File.join( ".", f.name )
|
102
|
+
FileUtils.mkdir_p(File.dirname(path))
|
103
|
+
z.extract( f, path ) unless File.exist?(path)
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
data/lib/wrench.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "colorize"
|
2
|
+
require "erb"
|
3
|
+
require "open3"
|
4
|
+
require "open-uri"
|
5
|
+
require "thor"
|
6
|
+
require "yaml"
|
7
|
+
require "zip/zip"
|
8
|
+
|
9
|
+
require File.join( File.dirname(__FILE__), "wrench", "cli" )
|
10
|
+
require File.join( File.dirname(__FILE__), "wrench", "version" )
|
11
|
+
|
12
|
+
module Wrench
|
13
|
+
|
14
|
+
ASSETS = "assets"
|
15
|
+
NAME = "name"
|
16
|
+
DIRECTORIES = "directories"
|
17
|
+
FILES = "files"
|
18
|
+
DESTINATION = "destination"
|
19
|
+
TEMPLATE = "template"
|
20
|
+
TEMPLATES = "templates"
|
21
|
+
MAINRB = "main.rb"
|
22
|
+
|
23
|
+
end
|
24
|
+
|
data/wrench.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/wrench/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["stephenhu"]
|
6
|
+
gem.email = ["epynonymous@outlook.com"]
|
7
|
+
gem.license = "MIT"
|
8
|
+
gem.description = %q{tool for ruby web development}
|
9
|
+
gem.summary = %q{command line tool for ruby web development}
|
10
|
+
gem.homepage = "http://github.com/stephenhu/wrench"
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.bindir = "bin"
|
14
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
15
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
|
+
gem.name = "wrench"
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
gem.version = Wrench::VERSION
|
19
|
+
end
|
20
|
+
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wrench
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- stephenhu
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-01 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: tool for ruby web development
|
15
|
+
email:
|
16
|
+
- epynonymous@outlook.com
|
17
|
+
executables:
|
18
|
+
- wrench
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
25
|
+
- LICENSE
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- bin/wrench
|
29
|
+
- conf/config.yaml
|
30
|
+
- docs/backlog
|
31
|
+
- lib/wrench.rb
|
32
|
+
- lib/wrench/cli.rb
|
33
|
+
- lib/wrench/templates/Gemfile.erb
|
34
|
+
- lib/wrench/templates/Rakefile.erb
|
35
|
+
- lib/wrench/templates/main.rb.erb
|
36
|
+
- lib/wrench/templates/version.rb.erb
|
37
|
+
- lib/wrench/version.rb
|
38
|
+
- wrench.gemspec
|
39
|
+
homepage: http://github.com/stephenhu/wrench
|
40
|
+
licenses:
|
41
|
+
- MIT
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.8.23
|
61
|
+
signing_key:
|
62
|
+
specification_version: 3
|
63
|
+
summary: command line tool for ruby web development
|
64
|
+
test_files: []
|