stencil 0.1.5 → 0.1.8
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.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +9 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +28 -0
- data/Rakefile +5 -2
- data/lib/stencil.rb +8 -44
- data/lib/stencil/branches.rb +27 -21
- data/lib/stencil/cmd.rb +8 -1
- data/lib/stencil/merge.rb +34 -86
- data/lib/stencil/msg.rb +2 -43
- data/spec/spec_helper.rb +6 -4
- data/spec/stencil_spec.rb +145 -0
- data/stencil.gemspec +24 -0
- metadata +100 -49
- data/MIT-LICENSE +0 -18
- data/README.markdown +0 -44
- data/gemspec.rb +0 -18
- data/lib/stencil/config.rb +0 -57
- data/lib/stencil/hash.rb +0 -6
- data/require.rb +0 -30
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: adb2323d48c908164223e12c4b935ad37c07d564
|
4
|
+
data.tar.gz: 2d4ceda53ffa04c9593ef4d2581b54cc70205b8c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 18e267c35e803ed9b6bf129484092400a1378d8d5be51fa78be69243ea971b5aa02644aabae6cec8e81aba296102a8dad42912a3af92cfbf00d7e006133716ae
|
7
|
+
data.tar.gz: 159e114fd5b0e8e3cd348bfe94f8df4385c5e3d350f07935c1a7fde896b319d093a856a9449a82ed2f63b86682028a9bfcf52ab5996c85b2fc7b07070418cac4
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
stencil
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0-p247
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013
|
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,28 @@
|
|
1
|
+
##Stencil
|
2
|
+
|
3
|
+
Project template manager.
|
4
|
+
|
5
|
+
[](http://travis-ci.org/winton/stencil)
|
6
|
+
|
7
|
+
### Merge branches
|
8
|
+
|
9
|
+
Stencil allows you to run a git-based project template with a [branching structure](https://github.com/winton/gem_template/branches) that allows for adding distinct features to a template.
|
10
|
+
|
11
|
+
To easily merge those branches, you can do something like this:
|
12
|
+
|
13
|
+
cd gem_template
|
14
|
+
stencil push
|
15
|
+
|
16
|
+
Remove the `push` if you do not wish to push upstream.
|
17
|
+
|
18
|
+
### Contribute
|
19
|
+
|
20
|
+
[Create an issue](https://github.com/winton/stencil/issues/new) to discuss template changes.
|
21
|
+
|
22
|
+
Pull requests for template changes and new branches are even better.
|
23
|
+
|
24
|
+
### Stay up to date
|
25
|
+
|
26
|
+
[Star this project](https://github.com/winton/stencil#) on Github.
|
27
|
+
|
28
|
+
[Follow Winton Welsh](http://twitter.com/intent/user?screen_name=wintonius) on Twitter.
|
data/Rakefile
CHANGED
data/lib/stencil.rb
CHANGED
@@ -1,50 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
$:.unshift File.dirname(__FILE__)
|
2
|
+
|
3
|
+
require 'stencil/branches'
|
4
|
+
require 'stencil/cmd'
|
5
|
+
require 'stencil/merge'
|
6
|
+
require 'stencil/msg'
|
4
7
|
|
5
8
|
class Stencil
|
6
9
|
|
7
|
-
def initialize(args)
|
10
|
+
def initialize(args=[])
|
8
11
|
path = Dir.pwd
|
9
|
-
|
10
|
-
|
11
|
-
# If template, do a template merge
|
12
|
-
if Config.exists?(:templates, path)
|
13
|
-
Merge.template(path, args.include?('push'))
|
14
|
-
|
15
|
-
# If project
|
16
|
-
elsif Config.exists?(:projects, path)
|
17
|
-
|
18
|
-
# If upstream commit, merge upstream
|
19
|
-
if args.first == '^'
|
20
|
-
Merge.upstream *args[1..-1].unshift(name) and return
|
21
|
-
|
22
|
-
# If template specified, update config
|
23
|
-
elsif args.first
|
24
|
-
Config.update(:projects => {
|
25
|
-
name => {
|
26
|
-
:template => args.shift,
|
27
|
-
:branches => args
|
28
|
-
}
|
29
|
-
})
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
# Do a project merge
|
34
|
-
Merge.project(name, path)
|
35
|
-
|
36
|
-
# If not configured
|
37
|
-
else
|
38
|
-
|
39
|
-
# Update config
|
40
|
-
Msg.is_template_or_project?(name)
|
41
|
-
Config.update((STDIN.gets[0..0].downcase == 't' ? :templates : :projects) => {
|
42
|
-
name => { :path => path }
|
43
|
-
})
|
44
|
-
|
45
|
-
# Re-run
|
46
|
-
initialize args
|
47
|
-
|
48
|
-
end
|
12
|
+
Merge.template(path, args.include?('push'))
|
49
13
|
end
|
50
14
|
end
|
data/lib/stencil/branches.rb
CHANGED
@@ -4,31 +4,37 @@ class Stencil
|
|
4
4
|
class Branches
|
5
5
|
class <<self
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
7
|
+
@@branches = {}
|
8
|
+
|
9
|
+
def read(path, type=:all)
|
10
|
+
key = "#{type}:#{path}"
|
11
|
+
|
12
|
+
if type == :all
|
13
|
+
(read(path, :remote) + read(path, :local)).uniq
|
14
|
+
elsif type == :remote && !@@branches[key]
|
15
|
+
branches = Cmd.run path, 'git branch -a'
|
16
|
+
@@branches[key] = branches.scan(/origin\/([\w-]+\b$)/).flatten.uniq
|
17
|
+
elsif type == :remote
|
18
|
+
@@branches[key]
|
19
|
+
elsif !@@branches[key]
|
20
|
+
branches = Cmd.run path, 'git branch'
|
21
|
+
branches = branches.split(/[\s\*]+/)
|
22
|
+
branches.delete ''
|
23
|
+
branches.sort!
|
24
|
+
@@branches[key] = branches
|
25
|
+
else
|
26
|
+
@@branches[key]
|
22
27
|
end
|
23
|
-
groups
|
24
28
|
end
|
25
29
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
def grouped(path)
|
31
|
+
branches = (read(path) - [ 'master' ]).inject({}) do |hash, branch|
|
32
|
+
branch.split('-').inject(hash) do |h, b|
|
33
|
+
h[b] ||= {}
|
34
|
+
end
|
35
|
+
hash
|
31
36
|
end
|
37
|
+
{ 'master' => branches }
|
32
38
|
end
|
33
39
|
end
|
34
40
|
end
|
data/lib/stencil/cmd.rb
CHANGED
data/lib/stencil/merge.rb
CHANGED
@@ -2,102 +2,50 @@ class Stencil
|
|
2
2
|
class Merge
|
3
3
|
class <<self
|
4
4
|
|
5
|
-
def project(name, path)
|
6
|
-
template = Config.read[:projects][name][:template]
|
7
|
-
branches = Config.read[:projects][name][:branches]
|
8
|
-
Msg.error_specify_template unless template
|
9
|
-
template = Config.read[:templates][template.intern]
|
10
|
-
if template && File.exists?(template[:path])
|
11
|
-
|
12
|
-
# Add remote template to project
|
13
|
-
origin = get_origin template[:path]
|
14
|
-
Msg.template_url origin
|
15
|
-
add_remote 'template', path, origin
|
16
|
-
|
17
|
-
# Pull template into master if no branches specified
|
18
|
-
branches = %w(master) if branches.empty?
|
19
|
-
|
20
|
-
# Pull template into each branch
|
21
|
-
branches.each do |branch|
|
22
|
-
Msg.merge_remote_branch branch
|
23
|
-
Cmd.run path, "git pull template #{branch}"
|
24
|
-
end
|
25
|
-
else
|
26
|
-
Msg.template_not_found template
|
27
|
-
Msg.error_specify_template
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
5
|
def template(path, push)
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
Cmd.run path, "git checkout master"
|
37
|
-
end
|
38
|
-
|
39
|
-
def upstream(name, commit=nil, *branches)
|
40
|
-
# Project variables
|
41
|
-
project = Config.read[:projects][name]
|
42
|
-
branches = project[:branches] if branches.empty?
|
43
|
-
|
44
|
-
# Template variables
|
45
|
-
template = Config.read[:templates][project[:template].intern]
|
46
|
-
path = template[:path]
|
47
|
-
|
48
|
-
# Add remote project to template and fetch
|
49
|
-
origin = get_origin project[:path]
|
50
|
-
Msg.project_url origin
|
51
|
-
add_remote 'project', path, origin
|
52
|
-
Cmd.run path, "git fetch project"
|
53
|
-
|
54
|
-
# Get last commit if none specified
|
55
|
-
unless commit
|
56
|
-
cmd = "git log HEAD~1..HEAD --pretty=format:'%H'"
|
57
|
-
commit = Cmd.run(template[:path], cmd).strip
|
6
|
+
Cmd.run(path, "git fetch --all")
|
7
|
+
|
8
|
+
Branches.grouped(path).each do |merger, mergees|
|
9
|
+
progressive_merge(path, merger, mergees, push)
|
58
10
|
end
|
59
11
|
|
60
|
-
|
61
|
-
branches.each do |branch|
|
62
|
-
output = Cmd.run path, "git checkout #{branch}"
|
63
|
-
Msg.error(output) if output.downcase.include?('error')
|
64
|
-
Msg.cherry_pick branch, commit
|
65
|
-
output = Cmd.run path, "git cherry-pick #{commit}"
|
66
|
-
Msg.error(output) if output.downcase.include?('fatal')
|
67
|
-
end
|
12
|
+
Cmd.run(path, "git checkout master")
|
68
13
|
end
|
69
14
|
|
70
15
|
private
|
71
|
-
|
72
|
-
def
|
73
|
-
|
74
|
-
|
16
|
+
|
17
|
+
def checkout(path, branch)
|
18
|
+
locals = Branches.read(path, :local)
|
19
|
+
remotes = Branches.read(path, :remote)
|
20
|
+
|
21
|
+
if locals.include?(branch)
|
22
|
+
Cmd.run(path, "git checkout #{branch}")
|
23
|
+
elsif remotes.include?(branch)
|
24
|
+
Cmd.run(path, "git checkout -t origin/#{branch}")
|
75
25
|
end
|
76
|
-
Cmd.run path, "git remote add #{name} #{url}"
|
77
26
|
end
|
78
27
|
|
79
|
-
def
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
28
|
+
def progressive_merge(path, merger, mergees, push)
|
29
|
+
branches = Branches.read(path)
|
30
|
+
return unless branches.include?(merger)
|
31
|
+
|
32
|
+
unless mergees.empty?
|
33
|
+
checkout(path, merger)
|
34
|
+
Cmd.run(path, "git pull origin #{merger}")
|
35
|
+
end
|
36
|
+
|
37
|
+
mergees = mergees.sort_by { |k, v| k }
|
38
|
+
mergees.each do |(mergee, mergee_mergees)|
|
39
|
+
mergee = "#{merger}-#{mergee}" unless merger == 'master'
|
40
|
+
|
41
|
+
next unless branches.include?(mergee)
|
42
|
+
|
43
|
+
checkout(path, mergee)
|
44
|
+
Cmd.run(path, "git merge #{merger}")
|
45
|
+
Cmd.run(path, "git push origin #{mergee}") if push
|
46
|
+
|
47
|
+
progressive_merge(path, mergee, mergee_mergees, push)
|
99
48
|
end
|
100
|
-
progressive(path, branches, push) unless branches.empty?
|
101
49
|
end
|
102
50
|
end
|
103
51
|
end
|
data/lib/stencil/msg.rb
CHANGED
@@ -2,56 +2,15 @@ class Stencil
|
|
2
2
|
class Msg
|
3
3
|
class <<self
|
4
4
|
|
5
|
-
def cherry_pick(branch, commit)
|
6
|
-
space
|
7
|
-
puts "Cherry picked #{commit} to \"#{branch}\""
|
8
|
-
end
|
9
|
-
|
10
5
|
def error(output)
|
11
6
|
space
|
12
|
-
puts "Oops
|
13
|
-
exit
|
14
|
-
end
|
15
|
-
|
16
|
-
def error_specify_template
|
17
|
-
space
|
18
|
-
puts "Please tell stencil what template you want to receive updates from:"
|
19
|
-
puts " stencil TEMPLATE [BRANCH BRANCH ...]"
|
7
|
+
puts "Oops: #{output}"
|
20
8
|
exit
|
21
9
|
end
|
22
|
-
|
23
|
-
def is_template_or_project?(name)
|
24
|
-
space
|
25
|
-
puts "Is \"#{name}\" a template or a project?"
|
26
|
-
end
|
27
|
-
|
28
|
-
def merge_remote_branch(branch)
|
29
|
-
space
|
30
|
-
puts "Merging remote branch \"#{branch}\""
|
31
|
-
end
|
32
|
-
|
33
|
-
def merging_x_into_y(x, y)
|
34
|
-
puts "Merging \"#{x}\" into \"#{y}\""
|
35
|
-
end
|
36
|
-
|
37
|
-
def project_url(url)
|
38
|
-
space
|
39
|
-
puts "Found project URL: #{url}"
|
40
|
-
end
|
41
|
-
|
10
|
+
|
42
11
|
def space
|
43
12
|
puts ''
|
44
13
|
end
|
45
|
-
|
46
|
-
def template_not_found(template)
|
47
|
-
space
|
48
|
-
puts "Template \"#{template}\" not found."
|
49
|
-
end
|
50
|
-
|
51
|
-
def template_url(url)
|
52
|
-
space
|
53
|
-
puts "Found template URL: #{url}"
|
54
|
-
end
|
55
14
|
end
|
56
15
|
end
|
57
16
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
unless ENV['CI']
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.start
|
4
|
+
end
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
+
$root = File.expand_path('../../', __FILE__)
|
7
|
+
require "#{$root}/lib/stencil"
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Stencil do
|
4
|
+
before :all do
|
5
|
+
@fixture = "#{$root}/spec/fixture"
|
6
|
+
|
7
|
+
FileUtils.rm_rf(@fixture)
|
8
|
+
FileUtils.mkdir_p(@fixture)
|
9
|
+
|
10
|
+
Dir.chdir(@fixture)
|
11
|
+
FileUtils.touch("master.txt")
|
12
|
+
|
13
|
+
`git init .`
|
14
|
+
`git add .`
|
15
|
+
`git commit -a -m "master"`
|
16
|
+
|
17
|
+
@branches = %w(
|
18
|
+
a
|
19
|
+
a-a
|
20
|
+
a-b
|
21
|
+
b
|
22
|
+
b-a
|
23
|
+
b-a-c
|
24
|
+
)
|
25
|
+
|
26
|
+
@branches.each do |branch|
|
27
|
+
`git branch #{branch}`
|
28
|
+
end
|
29
|
+
|
30
|
+
@branches.each do |branch|
|
31
|
+
`git checkout #{branch}`
|
32
|
+
|
33
|
+
FileUtils.touch("#{branch}.txt")
|
34
|
+
|
35
|
+
`git add .`
|
36
|
+
`git commit -m "#{branch}"`
|
37
|
+
end
|
38
|
+
|
39
|
+
Stencil::Branches.read(@fixture) # warm up @@branches cache
|
40
|
+
end
|
41
|
+
|
42
|
+
describe :initialize do
|
43
|
+
before :all do
|
44
|
+
@cmds = [
|
45
|
+
"git fetch --all",
|
46
|
+
"git checkout master",
|
47
|
+
"git pull origin master",
|
48
|
+
"git checkout a",
|
49
|
+
"git merge master",
|
50
|
+
"git push origin a",
|
51
|
+
"git checkout a",
|
52
|
+
"git pull origin a",
|
53
|
+
"git checkout a-a",
|
54
|
+
"git merge a",
|
55
|
+
"git push origin a-a",
|
56
|
+
"git checkout a-b",
|
57
|
+
"git merge a",
|
58
|
+
"git push origin a-b",
|
59
|
+
"git checkout b",
|
60
|
+
"git merge master",
|
61
|
+
"git push origin b",
|
62
|
+
"git checkout b",
|
63
|
+
"git pull origin b",
|
64
|
+
"git checkout b-a",
|
65
|
+
"git merge b",
|
66
|
+
"git push origin b-a",
|
67
|
+
"git checkout b-a",
|
68
|
+
"git pull origin b-a",
|
69
|
+
"git checkout b-a-c",
|
70
|
+
"git merge b-a",
|
71
|
+
"git push origin b-a-c",
|
72
|
+
"git checkout master"
|
73
|
+
]
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should execute correct commands" do
|
77
|
+
@cmds.each do |cmd|
|
78
|
+
if cmd == "git branch"
|
79
|
+
Stencil::Cmd.should_receive(:run).with(@fixture, cmd).ordered.and_call_original
|
80
|
+
else
|
81
|
+
Stencil::Cmd.should_receive(:run).with(@fixture, cmd).ordered
|
82
|
+
end
|
83
|
+
end
|
84
|
+
Stencil.new([ "push" ])
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should merge properly" do
|
88
|
+
@cmds.each do |cmd|
|
89
|
+
if cmd.include?('push') || cmd.include?('pull')
|
90
|
+
Stencil::Cmd.should_receive(:run).with(@fixture, cmd).ordered
|
91
|
+
else
|
92
|
+
Stencil::Cmd.should_receive(:run).with(@fixture, cmd).ordered.and_call_original
|
93
|
+
end
|
94
|
+
end
|
95
|
+
Stencil.new([ "push" ])
|
96
|
+
# TODO: check merge happened
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should exit on merge conflict" do
|
100
|
+
@cmds[0..@cmds.index("git push origin a")-1].each do |cmd|
|
101
|
+
if cmd.include?('push') || cmd.include?('pull')
|
102
|
+
Stencil::Cmd.should_receive(:run).with(@fixture, cmd).ordered
|
103
|
+
else
|
104
|
+
Stencil::Cmd.should_receive(:run).with(@fixture, cmd).ordered.and_call_original
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
`git checkout master`
|
109
|
+
File.open("#{@fixture}/master.txt", 'w') do |f|
|
110
|
+
f.write("conflict")
|
111
|
+
end
|
112
|
+
`git commit -a -m "master conflict"`
|
113
|
+
|
114
|
+
`git checkout a`
|
115
|
+
File.open("#{@fixture}/master.txt", 'w') do |f|
|
116
|
+
f.write("conflict2")
|
117
|
+
end
|
118
|
+
`git commit -a -m "a conflict"`
|
119
|
+
|
120
|
+
lambda { Stencil.new([ "push" ]) }.should raise_error SystemExit
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
describe Stencil::Branches do
|
125
|
+
it "should return branch names" do
|
126
|
+
Stencil::Branches.read(@fixture).should == @branches + [ 'master' ]
|
127
|
+
end
|
128
|
+
|
129
|
+
it "should return grouped branch names" do
|
130
|
+
Stencil::Branches.grouped(@fixture).should == {
|
131
|
+
"master" => {
|
132
|
+
"a" => {
|
133
|
+
"a" => {},
|
134
|
+
"b" => {}
|
135
|
+
},
|
136
|
+
"b" => {
|
137
|
+
"a" => {
|
138
|
+
"c" => {}
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
data/stencil.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "stencil"
|
7
|
+
spec.version = "0.1.8"
|
8
|
+
spec.authors = ["Winton Welsh"]
|
9
|
+
spec.email = ["mail@wintoni.us"]
|
10
|
+
spec.description = %q{Project template manager}
|
11
|
+
spec.summary = %q{Project template manager.}
|
12
|
+
spec.homepage = "https://github.com/winton/stencil"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
spec.add_development_dependency "rspec"
|
23
|
+
spec.add_development_dependency "simplecov"
|
24
|
+
end
|
metadata
CHANGED
@@ -1,69 +1,120 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: stencil
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.1.5
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.8
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
6
|
+
authors:
|
8
7
|
- Winton Welsh
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
date: 2013-11-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Project template manager
|
70
|
+
email:
|
71
|
+
- mail@wintoni.us
|
72
|
+
executables:
|
20
73
|
- stencil
|
21
74
|
extensions: []
|
22
|
-
|
23
|
-
|
24
|
-
-
|
25
|
-
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- .ruby-gemset
|
79
|
+
- .ruby-version
|
80
|
+
- .travis.yml
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
26
85
|
- bin/stencil
|
27
|
-
-
|
86
|
+
- lib/stencil.rb
|
28
87
|
- lib/stencil/branches.rb
|
29
88
|
- lib/stencil/cmd.rb
|
30
|
-
- lib/stencil/config.rb
|
31
|
-
- lib/stencil/hash.rb
|
32
89
|
- lib/stencil/merge.rb
|
33
90
|
- lib/stencil/msg.rb
|
34
|
-
- lib/stencil.rb
|
35
|
-
- MIT-LICENSE
|
36
|
-
- Rakefile
|
37
|
-
- README.markdown
|
38
|
-
- require.rb
|
39
91
|
- spec/spec_helper.rb
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
92
|
+
- spec/stencil_spec.rb
|
93
|
+
- stencil.gemspec
|
94
|
+
homepage: https://github.com/winton/stencil
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
44
98
|
post_install_message:
|
45
99
|
rdoc_options: []
|
46
|
-
|
47
|
-
require_paths:
|
100
|
+
require_paths:
|
48
101
|
- lib
|
49
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: "0"
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
61
112
|
requirements: []
|
62
|
-
|
63
113
|
rubyforge_project:
|
64
|
-
rubygems_version:
|
114
|
+
rubygems_version: 2.0.3
|
65
115
|
signing_key:
|
66
|
-
specification_version:
|
67
|
-
summary: Project template manager
|
68
|
-
test_files:
|
69
|
-
|
116
|
+
specification_version: 4
|
117
|
+
summary: Project template manager.
|
118
|
+
test_files:
|
119
|
+
- spec/spec_helper.rb
|
120
|
+
- spec/stencil_spec.rb
|
data/MIT-LICENSE
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
Copyright (c) 2009 Winton Welsh
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
-
this software and associated documentation files (the "Software"), to deal in
|
5
|
-
the Software without restriction, including without limitation the rights to
|
6
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
7
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
8
|
-
subject to the following conditions:
|
9
|
-
|
10
|
-
The above copyright notice and this permission notice shall be included in all
|
11
|
-
copies or substantial portions of the Software.
|
12
|
-
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
15
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
16
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
17
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
18
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
Stencil
|
2
|
-
=======
|
3
|
-
|
4
|
-
Project template manager.
|
5
|
-
|
6
|
-
Requirements
|
7
|
-
------------
|
8
|
-
|
9
|
-
<pre>
|
10
|
-
sudo gem install stencil
|
11
|
-
</pre>
|
12
|
-
|
13
|
-
Setup the template
|
14
|
-
------------------
|
15
|
-
|
16
|
-
You only have to do this once.
|
17
|
-
|
18
|
-
<pre>
|
19
|
-
git clone git@github.com:winton/gem_template.git
|
20
|
-
cd gem_template
|
21
|
-
stencil
|
22
|
-
</pre>
|
23
|
-
|
24
|
-
Setup a new project
|
25
|
-
-------------------
|
26
|
-
|
27
|
-
Do this for every new project.
|
28
|
-
|
29
|
-
<pre>
|
30
|
-
mkdir my_project
|
31
|
-
cd my_project
|
32
|
-
git init
|
33
|
-
stencil gem_template [BRANCH, BRANCH, ...]
|
34
|
-
rake rename
|
35
|
-
</pre>
|
36
|
-
|
37
|
-
The last command does a find-replace (gem\_template -> my\_project) on files and filenames.
|
38
|
-
|
39
|
-
Commit from project to template
|
40
|
-
-------------------------------
|
41
|
-
|
42
|
-
<pre>
|
43
|
-
stencil ^ [COMMIT HASH]
|
44
|
-
</pre>
|
data/gemspec.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
GEM_NAME = 'stencil'
|
2
|
-
GEM_FILES = FileList['**/*'] - FileList['coverage', 'coverage/**/*', 'pkg', 'pkg/**/*']
|
3
|
-
GEM_SPEC = Gem::Specification.new do |s|
|
4
|
-
# == CONFIGURE ==
|
5
|
-
s.author = "Winton Welsh"
|
6
|
-
s.email = "mail@wintoni.us"
|
7
|
-
s.homepage = "http://github.com/winton/#{GEM_NAME}"
|
8
|
-
s.summary = "Project template manager"
|
9
|
-
# == CONFIGURE ==
|
10
|
-
s.executables << GEM_NAME
|
11
|
-
s.extra_rdoc_files = [ "README.markdown" ]
|
12
|
-
s.files = GEM_FILES.to_a
|
13
|
-
s.has_rdoc = false
|
14
|
-
s.name = GEM_NAME
|
15
|
-
s.platform = Gem::Platform::RUBY
|
16
|
-
s.require_path = "lib"
|
17
|
-
s.version = "0.1.5"
|
18
|
-
end
|
data/lib/stencil/config.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
|
-
class Stencil
|
4
|
-
class Config
|
5
|
-
class <<self
|
6
|
-
|
7
|
-
@@cache = nil
|
8
|
-
@@path = File.expand_path('~/.stencil.yml')
|
9
|
-
|
10
|
-
def create
|
11
|
-
write(:projects => {}, :templates => {})
|
12
|
-
end
|
13
|
-
|
14
|
-
def read
|
15
|
-
if @@cache
|
16
|
-
@@cache
|
17
|
-
elsif File.exists?(@@path)
|
18
|
-
File.open(@@path, 'r') do |f|
|
19
|
-
@@cache = YAML::load f
|
20
|
-
end
|
21
|
-
else
|
22
|
-
create
|
23
|
-
@@cache = read
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def update(hash)
|
28
|
-
write read.deep_merge(hash)
|
29
|
-
end
|
30
|
-
|
31
|
-
def delete
|
32
|
-
@@cache = nil
|
33
|
-
File.unlink @@path
|
34
|
-
end
|
35
|
-
|
36
|
-
def exists?(type, name)
|
37
|
-
read[type] &&
|
38
|
-
(
|
39
|
-
read[type][name.intern] ||
|
40
|
-
(
|
41
|
-
read[type][File.basename(name).intern] &&
|
42
|
-
read[type][File.basename(name).intern][:path] == name
|
43
|
-
)
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def write(hash)
|
50
|
-
@@cache = nil
|
51
|
-
File.open(@@path, 'w') do |f|
|
52
|
-
f.write YAML::dump(hash)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
data/lib/stencil/hash.rb
DELETED
data/require.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
gem 'require'
|
3
|
-
require 'require'
|
4
|
-
|
5
|
-
Require do
|
6
|
-
gem :require, '=0.2.7'
|
7
|
-
gem(:rake, '=0.8.7') { require 'rake' }
|
8
|
-
gem :rspec, '=1.3.0'
|
9
|
-
|
10
|
-
gemspec do
|
11
|
-
author 'Winton Welsh'
|
12
|
-
email 'mail@wintoni.us'
|
13
|
-
name 'stencil'
|
14
|
-
homepage "http://github.com/winton/#{name}"
|
15
|
-
summary "Project template manager"
|
16
|
-
version '0.1.5'
|
17
|
-
end
|
18
|
-
|
19
|
-
rakefile do
|
20
|
-
gem(:rake) { require 'rake/gempackagetask' }
|
21
|
-
gem(:rspec) { require 'spec/rake/spectask' }
|
22
|
-
require 'require/tasks'
|
23
|
-
end
|
24
|
-
|
25
|
-
spec_helper do
|
26
|
-
require 'require/spec_helper'
|
27
|
-
require 'lib/gem_template'
|
28
|
-
require 'pp'
|
29
|
-
end
|
30
|
-
end
|