project_templater 0.2.1 → 0.3.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/README.md +11 -1
- data/bin/project_templater +11 -2
- data/lib/generators/html_proto.rb +1 -6
- data/lib/generators/js_project.rb +0 -1
- data/lib/generators/sinatra_basic.rb +23 -6
- data/lib/project_templater.rb +16 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Project Templater
|
2
2
|
|
3
|
-
__V0.
|
3
|
+
__V0.3.1__
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -60,6 +60,16 @@ Similarly, there is a `pre_install` method which is run just before `run`. Again
|
|
60
60
|
|
61
61
|
## Changelog
|
62
62
|
|
63
|
+
__0.3.1__
|
64
|
+
- No nasty exception if the generator doesn't exist.
|
65
|
+
|
66
|
+
__0.3.0__
|
67
|
+
- Remove all references to `nodefetch`
|
68
|
+
- Fix Sinatra generator. Makes views directory in right place and now sets up layout.erb properly.
|
69
|
+
|
70
|
+
__0.2.1__
|
71
|
+
- release date within gemspec was incorrect.
|
72
|
+
|
63
73
|
__0.2.0__
|
64
74
|
- added `jekyll_basic` generator
|
65
75
|
- add `pre_install` method for generators
|
data/bin/project_templater
CHANGED
@@ -6,5 +6,14 @@ require "project_templater"
|
|
6
6
|
template = ARGV[0]
|
7
7
|
base_dir = ARGV[1]
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
if template.nil?
|
10
|
+
puts "Available Templates"
|
11
|
+
# TODO: programmatically get this list
|
12
|
+
%w{html_proto jekyll_basic js_project ruby_project sinatra_basic}.each do |t|
|
13
|
+
puts "-> #{t}"
|
14
|
+
end
|
15
|
+
|
16
|
+
else
|
17
|
+
pt = ProjectTemplater.new(template)
|
18
|
+
pt.run(base_dir) if pt.valid?
|
19
|
+
end
|
@@ -6,7 +6,7 @@ class HtmlProto < Generator
|
|
6
6
|
%Q|<!DOCTYPE html>
|
7
7
|
<html>
|
8
8
|
<head>
|
9
|
-
<title
|
9
|
+
<title></title>
|
10
10
|
<link rel="stylesheet" href="css/style.css">
|
11
11
|
<script src="js/jquery.min.js"></script>
|
12
12
|
<script src="js/app.js"></script>
|
@@ -23,9 +23,4 @@ class HtmlProto < Generator
|
|
23
23
|
make_file("js/app.js")
|
24
24
|
make_file("css/style.css")
|
25
25
|
end
|
26
|
-
|
27
|
-
def post_install
|
28
|
-
`cd #{@base}js && nodefetch jquery`
|
29
|
-
end
|
30
|
-
|
31
26
|
end
|
@@ -6,8 +6,15 @@ class SinatraBasic < Generator
|
|
6
6
|
"source 'http://rubygems.org'\ngem 'sinatra'"
|
7
7
|
}
|
8
8
|
make_file("app.rb") {
|
9
|
-
|
9
|
+
%Q|
|
10
|
+
require 'sinatra'
|
11
|
+
|
12
|
+
get '/' do
|
13
|
+
erb :index
|
14
|
+
end
|
15
|
+
|
|
10
16
|
}
|
17
|
+
|
11
18
|
make_file("config.ru") {
|
12
19
|
"require './app'\nrun Sinatra::Application"
|
13
20
|
}
|
@@ -16,14 +23,24 @@ class SinatraBasic < Generator
|
|
16
23
|
make_dir("public")
|
17
24
|
make_dir("public/css")
|
18
25
|
make_dir("public/js")
|
19
|
-
make_dir("
|
26
|
+
make_dir("views")
|
27
|
+
make_file("views/layout.erb") {
|
28
|
+
%Q|<!DOCTYPE html>
|
29
|
+
<html>
|
30
|
+
<head>
|
31
|
+
<title></title>
|
32
|
+
<link rel="stylesheet" href="/css/style.css">
|
33
|
+
</head>
|
34
|
+
<body>
|
35
|
+
<%= yield %>
|
36
|
+
</body>
|
37
|
+
</html> |
|
38
|
+
}
|
39
|
+
make_file("views/index.erb") { "Hello World" }
|
20
40
|
make_file("public/css/style.css")
|
21
|
-
make_file("public/js/app.js")
|
22
|
-
make_file("public/views/layout.erb")
|
23
41
|
end
|
24
42
|
|
25
43
|
def post_install
|
26
|
-
`cd #{@base} && git init && bundle`
|
27
|
-
`cd #{@base}/public/js && nodefetch jquery`
|
44
|
+
puts `cd #{@base} && git init && bundle`
|
28
45
|
end
|
29
46
|
end
|
data/lib/project_templater.rb
CHANGED
@@ -12,7 +12,11 @@ class ProjectTemplater
|
|
12
12
|
def initialize(template)
|
13
13
|
@template = template
|
14
14
|
# load in the right generator
|
15
|
-
|
15
|
+
puts "That generator doesn't exist." unless generator_exists?
|
16
|
+
end
|
17
|
+
|
18
|
+
def valid?
|
19
|
+
generator_exists?
|
16
20
|
end
|
17
21
|
|
18
22
|
def run(base_dir)
|
@@ -23,5 +27,16 @@ class ProjectTemplater
|
|
23
27
|
instance.run
|
24
28
|
instance.post_install
|
25
29
|
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def generator_exists?
|
34
|
+
begin
|
35
|
+
require "generators/#{@template}.rb"
|
36
|
+
true
|
37
|
+
rescue Exception
|
38
|
+
false
|
39
|
+
end
|
40
|
+
end
|
26
41
|
end
|
27
42
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: project_templater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-07-14 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A gem for creating file and folder structures.
|
15
15
|
email: jack@jackfranklin.net
|