p 0.1.5 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +11 -4
- data/lib/p.rb +5 -2
- data/lib/p/actions/template_file.rb +20 -7
- data/lib/p/command.rb +14 -7
- data/lib/templates/default.rb +3 -0
- metadata +16 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9b5b90054250b8514feb0b2f8cd7ec7f4a97160b
|
4
|
+
data.tar.gz: 791fc6a01d87d71174a3d0636d9e964a45480192
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 20dd37bc3b5357e72a09a54d8f67dada41f23d92be718412827aa9ebfa57ea5e3f7ec88ac67f10e530c97613ccedd401f0be8717950c650394dbce9360a50f6c
|
7
|
+
data.tar.gz: 84c7668b191b6452f82ca0c3ee51e8866753ef235277bc83cfd2b777f4bbc911acbaee562102bcbeb24a557c96d77e49951434ad15cd24d0605f7e3eb28562f7
|
data/README.md
CHANGED
@@ -6,14 +6,21 @@
|
|
6
6
|
Usage
|
7
7
|
-----
|
8
8
|
|
9
|
-
`p
|
9
|
+
`p new [--template=<template>] <project-name>`
|
10
10
|
|
11
|
-
The command will
|
11
|
+
The `new` command will generate a new project by creating a new directory called `project-name` and using the specified template. There are built-in templates (explained below), but you can also define your own templates and place them in `~/.p`. If you do not specify a template, it will use the default template which is just a README.
|
12
12
|
|
13
|
+
### Built-in Templates
|
13
14
|
|
14
|
-
|
15
|
+
- **Default**: `p new <gem-name>` - See <https://github.com/Lytol/p/blob/master/lib/templates/default.rb>
|
16
|
+
- **Rubygem**: `p new -t gem <gem-name>` - See <https://github.com/Lytol/p/blob/master/lib/templates/gem.rb>
|
17
|
+
- **Sinatra**: `p new -t sinatra <app-name>` - See <https://github.com/Lytol/p/blob/master/lib/templates/sinatra.rb>
|
15
18
|
|
16
|
-
|
19
|
+
|
20
|
+
Creating your own templates
|
21
|
+
---------------------------
|
22
|
+
|
23
|
+
You can create your own templates within your home directory at `~/.p`. The template name will be the filename without the `.rb` extension. For example, if you create a template file called `go.rb`, then you could generate a Go project with `p new --template=go myapp`.
|
17
24
|
|
18
25
|
|
19
26
|
Contributing
|
data/lib/p.rb
CHANGED
@@ -2,10 +2,13 @@ require 'fileutils'
|
|
2
2
|
|
3
3
|
module P
|
4
4
|
|
5
|
-
VERSION = "0.1
|
5
|
+
VERSION = "0.2.1"
|
6
6
|
|
7
7
|
def self.template_paths
|
8
|
-
|
8
|
+
template_paths = []
|
9
|
+
template_paths << File.join(ENV['HOME'], ".p") # ~/.p directory
|
10
|
+
template_paths << File.join(File.dirname(__FILE__), "templates") # Built-in template directory
|
11
|
+
template_paths
|
9
12
|
end
|
10
13
|
end
|
11
14
|
|
@@ -7,6 +7,7 @@ module P
|
|
7
7
|
@builder = builder
|
8
8
|
@source = source
|
9
9
|
@destination = destination
|
10
|
+
@content = nil
|
10
11
|
end
|
11
12
|
|
12
13
|
def source(src = nil)
|
@@ -17,16 +18,28 @@ module P
|
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
20
|
-
def
|
21
|
-
|
22
|
-
|
21
|
+
def content(content = nil)
|
22
|
+
if content.nil?
|
23
|
+
@content
|
24
|
+
else
|
25
|
+
@content = content
|
23
26
|
end
|
27
|
+
end
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
IO.write(@destination, content)
|
29
|
+
def run!
|
30
|
+
if @content
|
31
|
+
IO.write(@destination, @content)
|
28
32
|
else
|
29
|
-
|
33
|
+
unless File.exists?(@source)
|
34
|
+
raise(P::FileNotFound, "missing template file `#{@source}`")
|
35
|
+
end
|
36
|
+
|
37
|
+
if File.extname(@source) == ".erb"
|
38
|
+
content = ERB.new(IO.read(@source)).result(@builder._binding)
|
39
|
+
IO.write(@destination, content)
|
40
|
+
else
|
41
|
+
FileUtils.cp(@source, @destination)
|
42
|
+
end
|
30
43
|
end
|
31
44
|
end
|
32
45
|
end
|
data/lib/p/command.rb
CHANGED
@@ -1,16 +1,23 @@
|
|
1
1
|
require 'thor'
|
2
2
|
|
3
3
|
module P
|
4
|
-
class Command < Thor
|
5
|
-
desc "Generate a project using TEMPLATE and NAME"
|
4
|
+
class Command < Thor
|
6
5
|
namespace ''
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
t
|
7
|
+
desc "new NAME", "Generate a new project for NAME"
|
8
|
+
option :template,
|
9
|
+
type: :string,
|
10
|
+
desc: "The template to use for the project",
|
11
|
+
aliases: :t,
|
12
|
+
default: 'default'
|
13
|
+
def new(name)
|
14
|
+
t = P::Template.new(options[:template], name)
|
13
15
|
P::Builder.run!(t)
|
14
16
|
end
|
17
|
+
|
18
|
+
desc "version", "Show the version"
|
19
|
+
def version
|
20
|
+
puts P::VERSION
|
21
|
+
end
|
15
22
|
end
|
16
23
|
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: p
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Brian Smith
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-03-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: thor
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: minitest
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -67,55 +60,55 @@ extensions: []
|
|
67
60
|
extra_rdoc_files: []
|
68
61
|
files:
|
69
62
|
- lib/ext/string.rb
|
70
|
-
- lib/p
|
63
|
+
- lib/p.rb
|
71
64
|
- lib/p/actions.rb
|
65
|
+
- lib/p/actions/template_file.rb
|
72
66
|
- lib/p/builder.rb
|
73
67
|
- lib/p/command.rb
|
74
68
|
- lib/p/template.rb
|
75
|
-
- lib/
|
69
|
+
- lib/templates/default.rb
|
70
|
+
- lib/templates/gem.rb
|
76
71
|
- lib/templates/gem/Gemfile
|
72
|
+
- lib/templates/gem/Rakefile
|
77
73
|
- lib/templates/gem/gemspec.erb
|
78
74
|
- lib/templates/gem/lib.erb
|
79
|
-
- lib/templates/gem/Rakefile
|
80
75
|
- lib/templates/gem/test.erb
|
81
|
-
- lib/templates/
|
82
|
-
- lib/templates/sinatra/app.erb
|
76
|
+
- lib/templates/sinatra.rb
|
83
77
|
- lib/templates/sinatra/Gemfile
|
84
|
-
- lib/templates/sinatra/Rakefile
|
85
78
|
- lib/templates/sinatra/README.erb
|
79
|
+
- lib/templates/sinatra/Rakefile
|
80
|
+
- lib/templates/sinatra/app.erb
|
86
81
|
- lib/templates/sinatra/test.erb
|
87
82
|
- lib/templates/sinatra/test_helper.erb
|
88
|
-
- lib/templates/sinatra.rb
|
89
83
|
- Gemfile
|
90
84
|
- Gemfile.lock
|
91
|
-
- Rakefile
|
92
85
|
- README.md
|
86
|
+
- Rakefile
|
93
87
|
- test/p_test.rb
|
94
88
|
- bin/p
|
95
89
|
homepage: https://github.com/Lytol/p
|
96
90
|
licenses:
|
97
91
|
- MIT
|
92
|
+
metadata: {}
|
98
93
|
post_install_message:
|
99
94
|
rdoc_options: []
|
100
95
|
require_paths:
|
101
96
|
- lib
|
102
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
-
none: false
|
104
98
|
requirements:
|
105
|
-
- -
|
99
|
+
- - '>='
|
106
100
|
- !ruby/object:Gem::Version
|
107
101
|
version: '0'
|
108
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
-
none: false
|
110
103
|
requirements:
|
111
|
-
- -
|
104
|
+
- - '>='
|
112
105
|
- !ruby/object:Gem::Version
|
113
106
|
version: '0'
|
114
107
|
requirements: []
|
115
108
|
rubyforge_project:
|
116
|
-
rubygems_version:
|
109
|
+
rubygems_version: 2.0.14
|
117
110
|
signing_key:
|
118
|
-
specification_version:
|
111
|
+
specification_version: 4
|
119
112
|
summary: p is a project generator - for anything
|
120
113
|
test_files:
|
121
114
|
- test/p_test.rb
|