thor_template 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +94 -0
- data/Guardfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +28 -0
- data/Rakefile +32 -0
- data/bin/thor_template +9 -0
- data/lib/starter_project/.gitignore +16 -0
- data/lib/starter_project/Gemfile +6 -0
- data/lib/starter_project/Gemfile.lock +85 -0
- data/lib/starter_project/Guardfile +12 -0
- data/lib/starter_project/LICENSE.txt +22 -0
- data/lib/starter_project/README.md +44 -0
- data/lib/starter_project/Rakefile +32 -0
- data/lib/starter_project/bin/thor_template +9 -0
- data/lib/starter_project/lib/thor_template.rb +7 -0
- data/lib/starter_project/lib/thor_template/cli.rb +41 -0
- data/lib/starter_project/lib/thor_template/cli/help.rb +13 -0
- data/lib/starter_project/lib/thor_template/version.rb +3 -0
- data/lib/starter_project/spec/lib/cli_spec.rb +19 -0
- data/lib/starter_project/spec/spec_helper.rb +37 -0
- data/lib/starter_project/thor_template.gemspec +32 -0
- data/lib/templates/Rakefile +22 -0
- data/lib/thor_template.rb +8 -0
- data/lib/thor_template/cli.rb +16 -0
- data/lib/thor_template/cli/help.rb +17 -0
- data/lib/thor_template/generator.rb +50 -0
- data/lib/thor_template/version.rb +3 -0
- data/spec/lib/cli_spec.rb +23 -0
- data/spec/lib/generator_spec.rb +22 -0
- data/spec/spec_helper.rb +37 -0
- data/thor_template.gemspec +32 -0
- metadata +221 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b58a6b18ecb5138445e48c9c1fb97ee40a6aac20
|
4
|
+
data.tar.gz: 57bc6452e5e9767f4f4082970c5dbee98169b757
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a043e0d058c991103e07541daae232ecedba3b201744f36f30e8743532ad28f044378d5e8ebd122a9d99cbb0206112dd83345ba811ae34137875cd9962961fff
|
7
|
+
data.tar.gz: e570e026e13973de98c196b87b449262ac8b026da222d0045cec59e10ac4b51dc84249c0ef81a9da99e68ae47477a9a4fc29aa4aa156ad892ad03134e67187bc
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
thor_template (0.0.1)
|
5
|
+
aws-sdk
|
6
|
+
colorize
|
7
|
+
hashie
|
8
|
+
thor
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
aws-sdk (1.31.3)
|
14
|
+
json (~> 1.4)
|
15
|
+
nokogiri (>= 1.4.4)
|
16
|
+
uuidtools (~> 2.1)
|
17
|
+
celluloid (0.15.2)
|
18
|
+
timers (~> 1.1.0)
|
19
|
+
codeclimate-test-reporter (0.3.0)
|
20
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
21
|
+
coderay (1.1.0)
|
22
|
+
colorize (0.6.0)
|
23
|
+
diff-lcs (1.2.5)
|
24
|
+
docile (1.1.3)
|
25
|
+
fakeweb (1.3.0)
|
26
|
+
ffi (1.9.3)
|
27
|
+
formatador (0.2.4)
|
28
|
+
guard (2.2.4)
|
29
|
+
formatador (>= 0.2.4)
|
30
|
+
listen (~> 2.1)
|
31
|
+
lumberjack (~> 1.0)
|
32
|
+
pry (>= 0.9.12)
|
33
|
+
thor (>= 0.18.1)
|
34
|
+
guard-bundler (2.0.0)
|
35
|
+
bundler (~> 1.0)
|
36
|
+
guard (~> 2.2)
|
37
|
+
guard-rspec (4.0.4)
|
38
|
+
guard (>= 2.1.1)
|
39
|
+
rspec (~> 2.14)
|
40
|
+
hashie (2.0.5)
|
41
|
+
json (1.8.1)
|
42
|
+
listen (2.2.0)
|
43
|
+
celluloid (>= 0.15.2)
|
44
|
+
rb-fsevent (>= 0.9.3)
|
45
|
+
rb-inotify (>= 0.9)
|
46
|
+
lumberjack (1.0.4)
|
47
|
+
method_source (0.8.2)
|
48
|
+
mini_portile (0.5.2)
|
49
|
+
multi_json (1.8.2)
|
50
|
+
nokogiri (1.6.1)
|
51
|
+
mini_portile (~> 0.5.0)
|
52
|
+
pry (0.9.12.4)
|
53
|
+
coderay (~> 1.0)
|
54
|
+
method_source (~> 0.8)
|
55
|
+
slop (~> 3.4)
|
56
|
+
rake (10.1.0)
|
57
|
+
rb-fsevent (0.9.3)
|
58
|
+
rb-inotify (0.9.2)
|
59
|
+
ffi (>= 0.5.0)
|
60
|
+
rspec (2.14.1)
|
61
|
+
rspec-core (~> 2.14.0)
|
62
|
+
rspec-expectations (~> 2.14.0)
|
63
|
+
rspec-mocks (~> 2.14.0)
|
64
|
+
rspec-core (2.14.7)
|
65
|
+
rspec-expectations (2.14.4)
|
66
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
67
|
+
rspec-mocks (2.14.4)
|
68
|
+
simplecov (0.8.2)
|
69
|
+
docile (~> 1.1.0)
|
70
|
+
multi_json
|
71
|
+
simplecov-html (~> 0.8.0)
|
72
|
+
simplecov-html (0.8.0)
|
73
|
+
slop (3.4.7)
|
74
|
+
thor (0.18.1)
|
75
|
+
thor-vcr (0.0.3)
|
76
|
+
fakeweb
|
77
|
+
multi_json
|
78
|
+
vcr
|
79
|
+
timers (1.1.0)
|
80
|
+
uuidtools (2.1.4)
|
81
|
+
vcr (2.8.0)
|
82
|
+
|
83
|
+
PLATFORMS
|
84
|
+
ruby
|
85
|
+
|
86
|
+
DEPENDENCIES
|
87
|
+
bundler (~> 1.3)
|
88
|
+
codeclimate-test-reporter
|
89
|
+
guard
|
90
|
+
guard-bundler
|
91
|
+
guard-rspec
|
92
|
+
rake
|
93
|
+
thor-vcr
|
94
|
+
thor_template!
|
data/Guardfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
guard 'rspec', :version => 2 do
|
2
|
+
watch(%r{^spec/.+_spec\.rb$})
|
3
|
+
watch(%r{^lib/(.+)\.rb$}) { "spec/thor_template_spec.rb" }
|
4
|
+
watch(%r{^lib/thor_template/(.+)\.rb$}) { "spec/thor_template_spec.rb" }
|
5
|
+
watch('spec/spec_helper.rb') { "spec/thor_template_spec.rb" }
|
6
|
+
end
|
7
|
+
|
8
|
+
guard 'bundler' do
|
9
|
+
watch('Gemfile')
|
10
|
+
watch(/^.+\.gemspec/)
|
11
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Tung Nguyen
|
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
|
+
# ThorTemplate
|
2
|
+
|
3
|
+
[](https://travis-ci.org/tongueroo/thor_template)
|
4
|
+
[](https://codeclimate.com/github/tongueroo/thor_template)
|
5
|
+
|
6
|
+
Generator that builds a starter cli project which is based on thor.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
<pre>
|
11
|
+
$ gem install thor_template
|
12
|
+
</pre>
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
<pre>
|
17
|
+
$ thor_template new hello
|
18
|
+
</pre>
|
19
|
+
|
20
|
+
This generates a starter cli project called hello.
|
21
|
+
|
22
|
+
## Contributing
|
23
|
+
|
24
|
+
1. Fork it
|
25
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
26
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
27
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
28
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
task :default => :spec
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new
|
7
|
+
|
8
|
+
# DELETE AFTER USING
|
9
|
+
desc "Rename project"
|
10
|
+
task :rename do
|
11
|
+
name = ENV['NAME'] || File.basename(Dir.pwd)
|
12
|
+
camelize = lambda do |str|
|
13
|
+
str.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
14
|
+
end
|
15
|
+
dir = Dir['**/thor_template*']
|
16
|
+
begin
|
17
|
+
from = dir.pop
|
18
|
+
if from
|
19
|
+
to = from.split('/')
|
20
|
+
to[-1].gsub!('thor_template', name)
|
21
|
+
FileUtils.mv(from, to.join('/'))
|
22
|
+
end
|
23
|
+
end while dir.length > 0
|
24
|
+
Dir["**/*"].each do |path|
|
25
|
+
if File.file?(path)
|
26
|
+
`sed -i 's/thor_template/#{name}/g' #{path}`
|
27
|
+
`sed -i 's/ThorTemplate/#{camelize.call(name)}/g' #{path}`
|
28
|
+
no_space = File.read(path).gsub(/\s+\z/, '')
|
29
|
+
File.open(path, 'w') { |f| f.write(no_space) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/bin/thor_template
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
thor_template (0.0.1)
|
5
|
+
aws-sdk
|
6
|
+
colorize
|
7
|
+
hashie
|
8
|
+
thor
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
aws-sdk (1.31.3)
|
14
|
+
json (~> 1.4)
|
15
|
+
nokogiri (>= 1.4.4)
|
16
|
+
uuidtools (~> 2.1)
|
17
|
+
celluloid (0.15.2)
|
18
|
+
timers (~> 1.1.0)
|
19
|
+
coderay (1.1.0)
|
20
|
+
colorize (0.6.0)
|
21
|
+
diff-lcs (1.2.5)
|
22
|
+
fakeweb (1.3.0)
|
23
|
+
ffi (1.9.3)
|
24
|
+
formatador (0.2.4)
|
25
|
+
guard (2.2.4)
|
26
|
+
formatador (>= 0.2.4)
|
27
|
+
listen (~> 2.1)
|
28
|
+
lumberjack (~> 1.0)
|
29
|
+
pry (>= 0.9.12)
|
30
|
+
thor (>= 0.18.1)
|
31
|
+
guard-bundler (2.0.0)
|
32
|
+
bundler (~> 1.0)
|
33
|
+
guard (~> 2.2)
|
34
|
+
guard-rspec (4.0.4)
|
35
|
+
guard (>= 2.1.1)
|
36
|
+
rspec (~> 2.14)
|
37
|
+
hashie (2.0.5)
|
38
|
+
json (1.8.1)
|
39
|
+
listen (2.2.0)
|
40
|
+
celluloid (>= 0.15.2)
|
41
|
+
rb-fsevent (>= 0.9.3)
|
42
|
+
rb-inotify (>= 0.9)
|
43
|
+
lumberjack (1.0.4)
|
44
|
+
method_source (0.8.2)
|
45
|
+
mini_portile (0.5.2)
|
46
|
+
multi_json (1.8.2)
|
47
|
+
nokogiri (1.6.1)
|
48
|
+
mini_portile (~> 0.5.0)
|
49
|
+
pry (0.9.12.4)
|
50
|
+
coderay (~> 1.0)
|
51
|
+
method_source (~> 0.8)
|
52
|
+
slop (~> 3.4)
|
53
|
+
rake (10.1.0)
|
54
|
+
rb-fsevent (0.9.3)
|
55
|
+
rb-inotify (0.9.2)
|
56
|
+
ffi (>= 0.5.0)
|
57
|
+
rspec (2.14.1)
|
58
|
+
rspec-core (~> 2.14.0)
|
59
|
+
rspec-expectations (~> 2.14.0)
|
60
|
+
rspec-mocks (~> 2.14.0)
|
61
|
+
rspec-core (2.14.7)
|
62
|
+
rspec-expectations (2.14.4)
|
63
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
64
|
+
rspec-mocks (2.14.4)
|
65
|
+
slop (3.4.7)
|
66
|
+
thor (0.18.1)
|
67
|
+
thor-vcr (0.0.3)
|
68
|
+
fakeweb
|
69
|
+
multi_json
|
70
|
+
vcr
|
71
|
+
timers (1.1.0)
|
72
|
+
uuidtools (2.1.4)
|
73
|
+
vcr (2.8.0)
|
74
|
+
|
75
|
+
PLATFORMS
|
76
|
+
ruby
|
77
|
+
|
78
|
+
DEPENDENCIES
|
79
|
+
bundler (~> 1.3)
|
80
|
+
guard
|
81
|
+
guard-bundler
|
82
|
+
guard-rspec
|
83
|
+
rake
|
84
|
+
thor-vcr
|
85
|
+
thor_template!
|
@@ -0,0 +1,12 @@
|
|
1
|
+
guard 'rspec', :version => 2 do
|
2
|
+
watch(%r{^spec/.+_spec\.rb$})
|
3
|
+
watch(%r{^lib/(.+)\.rb$}) { "spec/thor_template_spec.rb" }
|
4
|
+
watch(%r{^lib/thor_template/(.+)\.rb$}) { "spec/thor_template_spec.rb" }
|
5
|
+
watch('spec/spec_helper.rb') { "spec/thor_template_spec.rb" }
|
6
|
+
watch(%r{^lib/thor_template/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
end
|
8
|
+
|
9
|
+
guard 'bundler' do
|
10
|
+
watch('Gemfile')
|
11
|
+
watch(/^.+\.gemspec/)
|
12
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Tung Nguyen
|
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.
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# ThorTemplate
|
2
|
+
|
3
|
+
[](https://magnum.travis-ci.com/)
|
4
|
+
[](https://codeclimate.com/)
|
5
|
+
[](https://codeclimate.com/)
|
6
|
+
|
7
|
+
To these the thor_template, run these commands:
|
8
|
+
|
9
|
+
TODO: Write a gem description
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
gem 'thor_template'
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install thor_template
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
<pre>
|
28
|
+
git clone https://github.com/tongueroo/thor_template.git
|
29
|
+
mv thor_template <project_name>
|
30
|
+
cd <project_name>
|
31
|
+
rake rename
|
32
|
+
rm -rf .git
|
33
|
+
git init
|
34
|
+
git add .
|
35
|
+
git commit -m 'init commit'
|
36
|
+
</pre>
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create new Pull Request
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
task :default => :spec
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new
|
7
|
+
|
8
|
+
# DELETE AFTER USING
|
9
|
+
desc "Rename project"
|
10
|
+
task :rename do
|
11
|
+
name = ENV['NAME'] || File.basename(Dir.pwd)
|
12
|
+
camelize = lambda do |str|
|
13
|
+
str.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
14
|
+
end
|
15
|
+
dir = Dir['**/thor_template*']
|
16
|
+
begin
|
17
|
+
from = dir.pop
|
18
|
+
if from
|
19
|
+
to = from.split('/')
|
20
|
+
to[-1].gsub!('thor_template', name)
|
21
|
+
FileUtils.mv(from, to.join('/'))
|
22
|
+
end
|
23
|
+
end while dir.length > 0
|
24
|
+
Dir["**/*"].each do |path|
|
25
|
+
if File.file?(path)
|
26
|
+
`sed -i '' 's/thor_template/#{name}/g' #{path}`
|
27
|
+
`sed -i '' 's/ThorTemplate/#{camelize.call(name)}/g' #{path}`
|
28
|
+
no_space = File.read(path).gsub(/\s+\z/, '')
|
29
|
+
File.open(path, 'w') { |f| f.write(no_space) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'thor_template/cli/help'
|
3
|
+
|
4
|
+
module ThorTemplate
|
5
|
+
|
6
|
+
class Remote < Thor
|
7
|
+
desc "add <name> <url>", "Adds a remote named <name> for the repository at <url>"
|
8
|
+
long_desc Help.remote_add
|
9
|
+
option :t, :banner => "<branch>"
|
10
|
+
option :m, :banner => "<master>"
|
11
|
+
options :f => :boolean, :tags => :boolean, :mirror => :string
|
12
|
+
def add(name, url)
|
13
|
+
# implement git remote add
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "rename <old> <new>", "Rename the remote named <old> to <new>"
|
17
|
+
def rename(old, new)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class CLI < Thor
|
22
|
+
class_option :verbose, :type => :boolean
|
23
|
+
|
24
|
+
desc "hello NAME", "say hello to NAME"
|
25
|
+
option :from, :desc => 'from person'
|
26
|
+
def hello(name)
|
27
|
+
puts "from: #{options[:from]}" if options[:from]
|
28
|
+
puts "Hello #{name}"
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "fetch <repository> [<refspec>...]", "Download objects and refs from another repository"
|
32
|
+
options :all => :boolean, :multiple => :boolean
|
33
|
+
option :append, :type => :boolean, :aliases => :a, :desc => 'desc'
|
34
|
+
def fetch(respository, *refspec)
|
35
|
+
# implement git fetch here
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "remote SUBCOMMAND ...ARGS", "manage set of tracked repositories"
|
39
|
+
subcommand "remote", Remote
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ThorTemplate
|
2
|
+
class CLI < Thor
|
3
|
+
class Help
|
4
|
+
class << self
|
5
|
+
def hello(action)
|
6
|
+
<<-EOL
|
7
|
+
Adds a remote named <name> for the repository at <url>. The command git fetch <name> can then be used to create and update
|
8
|
+
EOL
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# to run specs with what's remembered from vcr
|
4
|
+
# $ rake
|
5
|
+
#
|
6
|
+
# to run specs with new fresh data from aws api calls
|
7
|
+
# $ rake clean:vcr ; time rake
|
8
|
+
describe ThorTemplate::CLI do
|
9
|
+
before(:all) do
|
10
|
+
@args = "--noop"
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "thor_template" do
|
14
|
+
it "should create base" do
|
15
|
+
out = execute("bin/thor_template base #{@args}")
|
16
|
+
out.should include("Creating base thor_template!")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Running specs by default will use VCR.
|
2
|
+
# Can disable via: VCR=0 rake or clean out vcr fixtures via rake clean:vcr.
|
3
|
+
# Using a ENV VCR flag so that both ruby and cli specs always either use
|
4
|
+
# vcr or do not use vcr. It's confusing to only have only ruby use vcr
|
5
|
+
# and cli specs not using vcr and vice versa.
|
6
|
+
ENV['VCR'] ? ENV['VCR'] : ENV['VCR'] = '1'
|
7
|
+
ENV['TEST'] = '1'
|
8
|
+
|
9
|
+
require "codeclimate-test-reporter"
|
10
|
+
CodeClimate::TestReporter.start
|
11
|
+
|
12
|
+
require "pp"
|
13
|
+
|
14
|
+
root = File.expand_path('../../', __FILE__)
|
15
|
+
require "#{root}/lib/thor_template"
|
16
|
+
|
17
|
+
module Helpers
|
18
|
+
def execute(cmd)
|
19
|
+
puts "Running: #{cmd}" if ENV['DEBUG']
|
20
|
+
out = `#{cmd}`
|
21
|
+
puts out if ENV['DEBUG']
|
22
|
+
out
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
RSpec.configure do |c|
|
27
|
+
c.include Helpers
|
28
|
+
c.around(:each) do |example|
|
29
|
+
VCR.use_cassette(example.metadata[:full_description], :serialize_with => :json) do
|
30
|
+
example.run
|
31
|
+
end if ENV['VCR'] == '1'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
VCR.configure do |config|
|
36
|
+
config.ignore_hosts 'codeclimate.com'
|
37
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'thor_template/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "thor_template"
|
8
|
+
spec.version = ThorTemplate::VERSION
|
9
|
+
spec.authors = ["Tung Nguyen"]
|
10
|
+
spec.email = ["tongueroo@gmail.com"]
|
11
|
+
spec.description = %q{TODO: Write a gem description}
|
12
|
+
spec.summary = %q{TODO: Write a gem summary}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "thor"
|
22
|
+
spec.add_dependency "aws-sdk"
|
23
|
+
spec.add_dependency "hashie"
|
24
|
+
spec.add_dependency "colorize"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "thor-vcr"
|
29
|
+
spec.add_development_dependency "guard"
|
30
|
+
spec.add_development_dependency "guard-bundler"
|
31
|
+
spec.add_development_dependency "guard-rspec"
|
32
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
task :default => :spec
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new
|
7
|
+
|
8
|
+
namespace :spec do
|
9
|
+
desc "Run acceptance specs, forces AWS calls by cleaning vcr fixtures first, ~/.br/aws.yml needs to be set up"
|
10
|
+
task :acceptance => %w[clean:vcr] do
|
11
|
+
ENV['LIVE'] = "1"
|
12
|
+
Rake::Task["spec"].invoke
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
task :clean => %w[clean:vcr]
|
17
|
+
namespace :clean do
|
18
|
+
desc "clean vcr_cassettes fixtures"
|
19
|
+
task :vcr do
|
20
|
+
FileUtils.rm_rf('spec/fixtures/vcr_cassettes')
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'thor_template/cli/help'
|
3
|
+
|
4
|
+
module ThorTemplate
|
5
|
+
|
6
|
+
class CLI < Thor
|
7
|
+
class_option :verbose, :type => :boolean
|
8
|
+
class_option :noop, :type => :boolean
|
9
|
+
|
10
|
+
desc "new NAME", "generates project based on thor template"
|
11
|
+
def new(name)
|
12
|
+
Generator.new(options.merge(name: name)).run
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module ThorTemplate
|
2
|
+
class Generator
|
3
|
+
attr_reader :options
|
4
|
+
def initialize(options={})
|
5
|
+
@options = options
|
6
|
+
@name = options[:name]
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
copy
|
11
|
+
rename
|
12
|
+
rewrite
|
13
|
+
puts "Created #{@name} project!"
|
14
|
+
end
|
15
|
+
|
16
|
+
def copy
|
17
|
+
project_root = @name
|
18
|
+
source_root = File.expand_path("../../starter_project", __FILE__)
|
19
|
+
paths = Dir.glob("#{source_root}/**/*").
|
20
|
+
select {|p| File.file?(p) }
|
21
|
+
paths.each do |src|
|
22
|
+
dest = src.gsub(%r{.*starter_project/},'')
|
23
|
+
dest = "#{project_root}/#{dest}"
|
24
|
+
|
25
|
+
if File.exist?(dest) and !options[:force]
|
26
|
+
puts "already exists: #{dest}" unless options[:quiet]
|
27
|
+
else
|
28
|
+
puts "creating: #{dest}" unless options[:quiet]
|
29
|
+
dirname = File.dirname(dest)
|
30
|
+
FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
|
31
|
+
FileUtils.cp(src, dest)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def rename
|
37
|
+
system("cd #{@name} && rake rename")
|
38
|
+
end
|
39
|
+
|
40
|
+
def rewrite
|
41
|
+
template("Rakefile", "Rakefile")
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def template(src,dest)
|
46
|
+
templates = File.expand_path("../../templates", __FILE__)
|
47
|
+
FileUtils.cp("#{templates}/#{src}", "#{@name}/#{dest}")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# to run specs with what's remembered from vcr
|
4
|
+
# $ rake
|
5
|
+
#
|
6
|
+
# to run specs with new fresh data from aws api calls
|
7
|
+
# $ rake clean:vcr ; time rake
|
8
|
+
describe ThorTemplate::CLI do
|
9
|
+
before(:all) do
|
10
|
+
@args = "--noop"
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "new" do
|
14
|
+
it "should generate" do
|
15
|
+
out = execute("bin/thor_template new hello #{@args}")
|
16
|
+
out.should include("Created hello project!")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
VCR.configure do |config|
|
22
|
+
config.ignore_hosts 'codeclimate.com'
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# to run specs with what's remembered from vcr
|
4
|
+
# $ rake
|
5
|
+
#
|
6
|
+
# to run specs with new fresh data from aws api calls
|
7
|
+
# $ rake clean:vcr ; time rake
|
8
|
+
describe ThorTemplate::Generator do
|
9
|
+
before(:each) do
|
10
|
+
FileUtils.rm_rf("tmp/hello")
|
11
|
+
options = {
|
12
|
+
name: "tmp/hello"
|
13
|
+
}
|
14
|
+
@generator = ThorTemplate::Generator.new(options)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should generate" do
|
18
|
+
@generator.run
|
19
|
+
File.exist?("tmp/hello").should be_true
|
20
|
+
File.exist?("tmp/hello/hello.gemspec").should be_true
|
21
|
+
end
|
22
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Running specs by default will use VCR.
|
2
|
+
# Can disable via: VCR=0 rake or clean out vcr fixtures via rake clean:vcr.
|
3
|
+
# Using a ENV VCR flag so that both ruby and cli specs always either use
|
4
|
+
# vcr or do not use vcr. It's confusing to only have only ruby use vcr
|
5
|
+
# and cli specs not using vcr and vice versa.
|
6
|
+
ENV['VCR'] ? ENV['VCR'] : ENV['VCR'] = '1'
|
7
|
+
ENV['TEST'] = '1'
|
8
|
+
|
9
|
+
require "codeclimate-test-reporter"
|
10
|
+
CodeClimate::TestReporter.start
|
11
|
+
|
12
|
+
require "pp"
|
13
|
+
|
14
|
+
root = File.expand_path('../../', __FILE__)
|
15
|
+
require "#{root}/lib/thor_template"
|
16
|
+
|
17
|
+
module Helpers
|
18
|
+
def execute(cmd)
|
19
|
+
puts "Running: #{cmd}" if ENV['DEBUG']
|
20
|
+
out = `#{cmd}`
|
21
|
+
puts out if ENV['DEBUG']
|
22
|
+
out
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
RSpec.configure do |c|
|
27
|
+
c.include Helpers
|
28
|
+
c.around(:each) do |example|
|
29
|
+
VCR.use_cassette(example.metadata[:full_description], :serialize_with => :json) do
|
30
|
+
example.run
|
31
|
+
end if ENV['VCR'] == '1'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
VCR.configure do |config|
|
36
|
+
config.ignore_hosts 'codeclimate.com'
|
37
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'thor_template/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "thor_template"
|
8
|
+
spec.version = ThorTemplate::VERSION
|
9
|
+
spec.authors = ["Tung Nguyen"]
|
10
|
+
spec.email = ["tongueroo@gmail.com"]
|
11
|
+
spec.description = %q{Generates starter cli tool project.}
|
12
|
+
spec.summary = %q{Generates starter cli tool project.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "thor"
|
22
|
+
spec.add_dependency "aws-sdk"
|
23
|
+
spec.add_dependency "hashie"
|
24
|
+
spec.add_dependency "colorize"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "thor-vcr"
|
29
|
+
spec.add_development_dependency "guard"
|
30
|
+
spec.add_development_dependency "guard-bundler"
|
31
|
+
spec.add_development_dependency "guard-rspec"
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: thor_template
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tung Nguyen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aws-sdk
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: hashie
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
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: colorize
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: thor-vcr
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: guard-bundler
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: guard-rspec
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: Generates starter cli tool project.
|
154
|
+
email:
|
155
|
+
- tongueroo@gmail.com
|
156
|
+
executables:
|
157
|
+
- thor_template
|
158
|
+
extensions: []
|
159
|
+
extra_rdoc_files: []
|
160
|
+
files:
|
161
|
+
- .gitignore
|
162
|
+
- Gemfile
|
163
|
+
- Gemfile.lock
|
164
|
+
- Guardfile
|
165
|
+
- LICENSE.txt
|
166
|
+
- README.md
|
167
|
+
- Rakefile
|
168
|
+
- bin/thor_template
|
169
|
+
- lib/starter_project/.gitignore
|
170
|
+
- lib/starter_project/Gemfile
|
171
|
+
- lib/starter_project/Gemfile.lock
|
172
|
+
- lib/starter_project/Guardfile
|
173
|
+
- lib/starter_project/LICENSE.txt
|
174
|
+
- lib/starter_project/README.md
|
175
|
+
- lib/starter_project/Rakefile
|
176
|
+
- lib/starter_project/bin/thor_template
|
177
|
+
- lib/starter_project/lib/thor_template.rb
|
178
|
+
- lib/starter_project/lib/thor_template/cli.rb
|
179
|
+
- lib/starter_project/lib/thor_template/cli/help.rb
|
180
|
+
- lib/starter_project/lib/thor_template/version.rb
|
181
|
+
- lib/starter_project/spec/lib/cli_spec.rb
|
182
|
+
- lib/starter_project/spec/spec_helper.rb
|
183
|
+
- lib/starter_project/thor_template.gemspec
|
184
|
+
- lib/templates/Rakefile
|
185
|
+
- lib/thor_template.rb
|
186
|
+
- lib/thor_template/cli.rb
|
187
|
+
- lib/thor_template/cli/help.rb
|
188
|
+
- lib/thor_template/generator.rb
|
189
|
+
- lib/thor_template/version.rb
|
190
|
+
- spec/lib/cli_spec.rb
|
191
|
+
- spec/lib/generator_spec.rb
|
192
|
+
- spec/spec_helper.rb
|
193
|
+
- thor_template.gemspec
|
194
|
+
homepage: ''
|
195
|
+
licenses:
|
196
|
+
- MIT
|
197
|
+
metadata: {}
|
198
|
+
post_install_message:
|
199
|
+
rdoc_options: []
|
200
|
+
require_paths:
|
201
|
+
- lib
|
202
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
203
|
+
requirements:
|
204
|
+
- - '>='
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '0'
|
207
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
208
|
+
requirements:
|
209
|
+
- - '>='
|
210
|
+
- !ruby/object:Gem::Version
|
211
|
+
version: '0'
|
212
|
+
requirements: []
|
213
|
+
rubyforge_project:
|
214
|
+
rubygems_version: 2.0.14
|
215
|
+
signing_key:
|
216
|
+
specification_version: 4
|
217
|
+
summary: Generates starter cli tool project.
|
218
|
+
test_files:
|
219
|
+
- spec/lib/cli_spec.rb
|
220
|
+
- spec/lib/generator_spec.rb
|
221
|
+
- spec/spec_helper.rb
|