skelegem 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.semver +6 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +38 -0
- data/Rakefile +7 -0
- data/bin/skelegem +4 -0
- data/docs/index.md +279 -0
- data/lib/skelegem.rb +8 -0
- data/lib/skelegem/cli.rb +78 -0
- data/lib/skelegem/store.rb +9 -0
- data/lib/skelegem/templates.rb +4 -0
- data/lib/skelegem/templates/gemspec/gemspec.rb +23 -0
- data/lib/skelegem/templates/gemspec/gemspec.tt +26 -0
- data/lib/skelegem/templates/semver_init/semver_init.rb +39 -0
- data/lib/skelegem/templates/semver_init/version.tt +5 -0
- data/lib/skelegem/templates/thor_cli/bin.tt +4 -0
- data/lib/skelegem/templates/thor_cli/cli.tt +13 -0
- data/lib/skelegem/templates/thor_cli/thor_cli.rb +26 -0
- data/lib/skelegem/version.rb +5 -0
- data/skelegem.gemspec +27 -0
- data/spec/skelegem_spec.rb +11 -0
- data/spec/spec_helper.rb +2 -0
- metadata +142 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3d79b2984e5ee3c2cf8dafca68a0cc16e49b9e35
|
4
|
+
data.tar.gz: 71e41f8f8b490214438b11d45e27b0563a5d2e0f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 21bf7da9b7c91e3d9fdb60b0d13fc66cfd47e88f8fad837394e114cac3590c74ae4b706090ae078790a1581f4ac0730c71afd8f45554ab23d9146bb437cb3e6e
|
7
|
+
data.tar.gz: 3f3309dc4cef7f1f5048605719a59972e31e8771fb59ad22ddcad4ba65b884c8b3805201ae0941179d2cab1bae17d0991872703c4800304a110928d644d7baf9
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.semver
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 defektive
|
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,38 @@
|
|
1
|
+
# Skelegem
|
2
|
+
|
3
|
+
Generate gems with custom dependencies, and templates
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'skelegem'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install skelegem
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
skelegem [master●●] % skelegem
|
24
|
+
Commands:
|
25
|
+
skelegem edit # edit gemspec
|
26
|
+
skelegem help [COMMAND] # Describe available commands or one specific command
|
27
|
+
skelegem new # create a new gem
|
28
|
+
skelegem version # print out the app version
|
29
|
+
|
30
|
+
## [How this came to be](docs/index.md)
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it ( https://github.com/[my-github-username]/skelegem/fork )
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/skelegem
ADDED
data/docs/index.md
ADDED
@@ -0,0 +1,279 @@
|
|
1
|
+
# Useful title goes here
|
2
|
+
|
3
|
+
## Creating a basic gem
|
4
|
+
|
5
|
+
### Prereqs
|
6
|
+
|
7
|
+
Bundler - who doesn't use this
|
8
|
+
Semver2 semantic versioning made bearable
|
9
|
+
|
10
|
+
```
|
11
|
+
gem install semver2 bundler
|
12
|
+
```
|
13
|
+
|
14
|
+
If you use rbenv now would be a good to to run `rbenv rehash`
|
15
|
+
|
16
|
+
### Generate gem skeleton
|
17
|
+
Bundler can create a gem skeleton for you
|
18
|
+
|
19
|
+
```bash
|
20
|
+
defektive/gems [ bundle help gem ] 12:03 PM
|
21
|
+
Usage:
|
22
|
+
bundle gem GEM [OPTIONS]
|
23
|
+
|
24
|
+
Options:
|
25
|
+
-b, [--bin=Generate a binary for your library.]
|
26
|
+
-t, [--test=Generate a test directory for your library: 'rspec' is the default, but 'minitest' is also supported.]
|
27
|
+
-e, [--edit=/path/to/your/editor] # Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)
|
28
|
+
[--ext=Generate the boilerplate for C extension code]
|
29
|
+
[--no-color=Disable colorization in output]
|
30
|
+
-V, [--verbose=Enable verbose output mode]
|
31
|
+
-r, [--retry=Specify the number of times you wish to attempt network commands]
|
32
|
+
|
33
|
+
Creates a skeleton for creating a rubygem
|
34
|
+
```
|
35
|
+
|
36
|
+
Lets try it out
|
37
|
+
```
|
38
|
+
bundle gem skelegem -bte
|
39
|
+
|
40
|
+
# Your editor should have opened up with your new gemspec
|
41
|
+
# update the description and summary
|
42
|
+
# add the following dependencies
|
43
|
+
#
|
44
|
+
# spec.add_runtime_dependency "semver2", '~>3.4'
|
45
|
+
# spec.add_runtime_dependency "thor", '0.19.1'
|
46
|
+
|
47
|
+
cd skelegem
|
48
|
+
bundle
|
49
|
+
semver init
|
50
|
+
```
|
51
|
+
|
52
|
+
### Update our **version.rb**
|
53
|
+
In order to leverage the awesomeness of semver, you'll have to update
|
54
|
+
the version.rb to look something like this
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
require 'semver'
|
58
|
+
|
59
|
+
module Skelegem
|
60
|
+
VERSION = SemVer.find(File.dirname(__FILE__)+ "/../../").format "%M.%m.%p%s"
|
61
|
+
end
|
62
|
+
```
|
63
|
+
|
64
|
+
### Add our first command
|
65
|
+
|
66
|
+
Add `require "skelegem/cli"` to the top of *lib/skelegem.rb*. Create
|
67
|
+
*lib/skelegem/cli.rb* with the following contents
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
require "skelegem/version"
|
71
|
+
require "thor"
|
72
|
+
|
73
|
+
module Skelegem
|
74
|
+
# Lets extend Thor
|
75
|
+
class CLI < Thor
|
76
|
+
# map -v to the version so we can do skelegem -v to get version info
|
77
|
+
map "-v" => :version
|
78
|
+
|
79
|
+
# a very basic action
|
80
|
+
desc "version", "print out the app version"
|
81
|
+
def version()
|
82
|
+
puts "#{self.class.name.split("::")[0]} #{Skelegem::VERSION}"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
### Summary
|
89
|
+
|
90
|
+
We should now have a basic gem. Test it out by running `bundle exec bin/skelegem`.
|
91
|
+
Notice how the `desc` line of code is what shows up here to describe what the
|
92
|
+
action does. Try out `bundle exec bin/skelegem -v`. Run `semver inc patch` and
|
93
|
+
then run `bundle exec bin/skelegem -v`, you should get something like
|
94
|
+
|
95
|
+
```bash
|
96
|
+
gems/skelegem [ bundle exec skelegem -v
|
97
|
+
Skelegem 0.0.1
|
98
|
+
```
|
99
|
+
|
100
|
+
You can now run `rake install` to intall the gem. Again if you use rbenv, you should do a `rbenv rehash` now.
|
101
|
+
|
102
|
+
Now you should be able to use the gem without bundle exec. Try it. `skelegem -v`
|
103
|
+
|
104
|
+
I think we are ready to commit all of our progress.
|
105
|
+
|
106
|
+
```bash
|
107
|
+
git add .
|
108
|
+
git ci -am "Initial commit"
|
109
|
+
```
|
110
|
+
|
111
|
+
## Adding usefullness
|
112
|
+
|
113
|
+
Now its time to make our lives easier. All that stuff above was pretty tedious. Lets make it easy to do things like that.
|
114
|
+
|
115
|
+
(after going through the the steps. this was much bigger than i anticipated)
|
116
|
+
|
117
|
+
|
118
|
+
### Thor templates
|
119
|
+
|
120
|
+
Lets create a directory called templates in `lib/skelegem`. We will also want to create a `templates.rb` in lib. Our
|
121
|
+
directory tree will end up looking something like
|
122
|
+
|
123
|
+
```bash
|
124
|
+
lib/skelegem/templates
|
125
|
+
├── gemspec
|
126
|
+
│ ├── gemspec.rb
|
127
|
+
│ └── gemspec.tt
|
128
|
+
├── semver_init
|
129
|
+
│ ├── semver_init.rb
|
130
|
+
│ └── version.tt
|
131
|
+
└── thor_cli
|
132
|
+
├── bin.tt
|
133
|
+
├── cli.tt
|
134
|
+
└── thor_cli.rb
|
135
|
+
```
|
136
|
+
|
137
|
+
Here we will create Thor::Groups and templates.
|
138
|
+
|
139
|
+
#### The gemspec
|
140
|
+
|
141
|
+
`lib/skelegem/templates/gemspec/gemspec.tt`
|
142
|
+
|
143
|
+
# coding: utf-8
|
144
|
+
lib = File.expand_path('../lib', __FILE__)
|
145
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
146
|
+
require '<%= config[:my_spec].name %>/version'
|
147
|
+
|
148
|
+
Gem::Specification.new do |spec|
|
149
|
+
spec.name = "<%= config[:my_spec].name %>"
|
150
|
+
spec.version = <%= (config[:my_spec].name.split("_").map{|f| f.capitalize}.join) %>::VERSION
|
151
|
+
spec.authors = <%= config[:my_spec].authors.to_s %>
|
152
|
+
spec.email = <%= config[:my_spec].email.to_s %>
|
153
|
+
spec.summary = %q{<%= config[:my_spec].summary %>}
|
154
|
+
spec.description = %q{<%= config[:my_spec].description %>}
|
155
|
+
spec.homepage = "<%= config[:my_spec].homepage %>"
|
156
|
+
spec.license = "<%= config[:my_spec].license %>"
|
157
|
+
|
158
|
+
spec.files = `git ls-files -z`.split("\x0")
|
159
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
160
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
161
|
+
spec.require_paths = <%= config[:my_spec].require_paths.to_s %>
|
162
|
+
|
163
|
+
<% config[:my_spec].runtime_dependencies.each do |dep| %>
|
164
|
+
spec.add_runtime_dependency "<%= dep.name %>", '<%= dep.requirement.to_s %>'<% end %>
|
165
|
+
|
166
|
+
<% config[:my_spec].development_dependencies.each do |dep| %>
|
167
|
+
spec.add_development_dependency "<%= dep.name %>", '<%= dep.requirement.to_s %>'<% end %>
|
168
|
+
end
|
169
|
+
|
170
|
+
`lib/skelegem/templates/gemspec/gemspec.rb`
|
171
|
+
|
172
|
+
```ruby
|
173
|
+
require "thor"
|
174
|
+
require "rubygems"
|
175
|
+
|
176
|
+
module Skelegem
|
177
|
+
module Templates
|
178
|
+
|
179
|
+
class Gemspec < Thor::Group
|
180
|
+
|
181
|
+
include Thor::Actions
|
182
|
+
argument :name
|
183
|
+
|
184
|
+
def self.source_root
|
185
|
+
File.dirname(__FILE__)
|
186
|
+
end
|
187
|
+
|
188
|
+
def create_lib_file
|
189
|
+
my_spec = Skelegem::Store.gemspec
|
190
|
+
File.delete "#{name}.gemspec"
|
191
|
+
template('gemspec.tt', "#{name}.gemspec", :my_spec => my_spec)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
```
|
197
|
+
|
198
|
+
We've modified the default bundler gemspec template to be more configurable. Setup a `Thor::Group` to save out
|
199
|
+
a gemspec object. The real magic happens back in `cli.rb`. We need to add a new edit method, and some other util
|
200
|
+
methods
|
201
|
+
|
202
|
+
```ruby
|
203
|
+
|
204
|
+
# [code not shown] ....
|
205
|
+
|
206
|
+
desc "edit", "edit gemspec"
|
207
|
+
# method_option :name, :type => :boolean, :aliases => "-n"
|
208
|
+
def edit()
|
209
|
+
summary = ask("Summary: <#{my_spec.summary}>")
|
210
|
+
my_spec.summary = summary unless summary.empty?
|
211
|
+
|
212
|
+
description = ask("Description: <#{my_spec.description}>")
|
213
|
+
my_spec.description = description unless description.empty?
|
214
|
+
|
215
|
+
puts "Current dependencies"
|
216
|
+
my_spec.runtime_dependencies.each do |rdep|
|
217
|
+
puts rdep.name
|
218
|
+
end
|
219
|
+
|
220
|
+
dependencies = ask("Any additional dependencies you'd like added? [empty for none]")
|
221
|
+
unless dependencies.empty?
|
222
|
+
dependencies = dependencies.split(" ").each do |dep|
|
223
|
+
puts "adding #{dep}"
|
224
|
+
|
225
|
+
# this will come in handy later
|
226
|
+
invoke Skelegem::Templates::ThorCLI if dep == "thor"
|
227
|
+
|
228
|
+
tmp_spec = Gem::Specification::from_yaml( exec "gem spec #{dep} -r" )
|
229
|
+
my_spec.add_dependency tmp_spec.name, tmp_spec.version.to_s
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
no_commands {
|
235
|
+
# [code not shown] ....
|
236
|
+
|
237
|
+
def my_spec_file
|
238
|
+
@my_spec_file ||= Dir.glob("*.gemspec").first
|
239
|
+
end
|
240
|
+
|
241
|
+
def my_spec
|
242
|
+
@my_spec ||= Gem::Specification::load my_spec_file
|
243
|
+
end
|
244
|
+
}
|
245
|
+
```
|
246
|
+
|
247
|
+
We've used some new methods here. `ask` does just what it sounds like. It will prompt the user for some input.
|
248
|
+
|
249
|
+
#### I am tired. and I procrastinated.
|
250
|
+
|
251
|
+
After reading docs and source code for the gem specification, thor, and ruby(I didn't read the ruby source code)(I am new to this ruby thing). Let me summarize.
|
252
|
+
|
253
|
+
If your using semver and you haven't ran `semver init`. Attempting to run `bundle install` will peg your cpu
|
254
|
+
until you kill it.
|
255
|
+
|
256
|
+
Gem::Specification.to_ruby isn't as cool as it sounds. Yes you get ruby code. You will also lose an custom code
|
257
|
+
you have added to the gemspec. :(
|
258
|
+
|
259
|
+
Thor templates are pretty useful. Skelegem is basically a thor file and some custom templates.
|
260
|
+
|
261
|
+
Thor's documentation sucks. I found myself reading the code to see whats happening.
|
262
|
+
|
263
|
+
Pry seems very awesome. I wanted to use it to add a interactive sheel to skelegem
|
264
|
+
|
265
|
+
There has to be a better way to share thor instance vars with the templates.
|
266
|
+
|
267
|
+
Not sure if you noticed, but documentation is cool.
|
268
|
+
|
269
|
+
I chose to automate gem creation for this. I have used this to
|
270
|
+
|
271
|
+
- Automate console connections to prod
|
272
|
+
- Automatically fetch all the logs from an appserver for a given context
|
273
|
+
- Grepping kibana
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
data/lib/skelegem.rb
ADDED
data/lib/skelegem/cli.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
require "skelegem/version"
|
2
|
+
require "thor"
|
3
|
+
require "rubygems"
|
4
|
+
|
5
|
+
module Skelegem
|
6
|
+
class CLI < Thor
|
7
|
+
map "-v" => :version
|
8
|
+
|
9
|
+
desc "version", "print out the app version"
|
10
|
+
def version()
|
11
|
+
puts "#{self.class.name.split("::")[0]} #{Skelegem::VERSION}"
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "new", "create a new gem"
|
15
|
+
method_option :edit, :type => :string, :aliases => "-e", :default => false
|
16
|
+
def new(name=nil)
|
17
|
+
if name == nil
|
18
|
+
name = ask("What would you like your gem called? ")
|
19
|
+
end
|
20
|
+
|
21
|
+
puts "Generating #{name}"
|
22
|
+
execute "bundle gem #{name} -bt"
|
23
|
+
|
24
|
+
Dir.chdir name
|
25
|
+
Skelegem::Store.gemspec my_spec
|
26
|
+
|
27
|
+
invoke Skelegem::Templates::SemverInit
|
28
|
+
edit if options[:edit]
|
29
|
+
invoke Skelegem::Templates::Gemspec
|
30
|
+
Kernel.exec "bundle install"
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "edit", "edit gemspec"
|
34
|
+
# method_option :name, :type => :boolean, :aliases => "-n"
|
35
|
+
def edit()
|
36
|
+
|
37
|
+
summary = ask("Summary: <#{my_spec.summary}>")
|
38
|
+
my_spec.summary = summary unless summary.empty?
|
39
|
+
|
40
|
+
description = ask("Description: <#{my_spec.description}>")
|
41
|
+
my_spec.description = description unless description.empty?
|
42
|
+
|
43
|
+
puts "Current dependencies"
|
44
|
+
my_spec.runtime_dependencies.each do |rdep|
|
45
|
+
puts rdep.name
|
46
|
+
end
|
47
|
+
|
48
|
+
dependencies = ask("Any additional dependencies you'd like added? [empty for none]")
|
49
|
+
unless dependencies.empty?
|
50
|
+
dependencies = dependencies.split(" ").each do |dep|
|
51
|
+
puts "adding #{dep}"
|
52
|
+
invoke Skelegem::Templates::ThorCLI if dep == "thor"
|
53
|
+
|
54
|
+
tmp_spec = Gem::Specification::from_yaml( exec "gem spec #{dep} -r" )
|
55
|
+
my_spec.add_dependency tmp_spec.name, tmp_spec.version.to_s
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
no_commands {
|
61
|
+
def execute(cmd)
|
62
|
+
system(cmd)
|
63
|
+
end
|
64
|
+
|
65
|
+
def exec(cmd)
|
66
|
+
`#{cmd}`
|
67
|
+
end
|
68
|
+
|
69
|
+
def my_spec_file
|
70
|
+
@my_spec_file ||= Dir.glob("*.gemspec").first
|
71
|
+
end
|
72
|
+
|
73
|
+
def my_spec
|
74
|
+
@my_spec ||= Gem::Specification::load my_spec_file
|
75
|
+
end
|
76
|
+
}
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "rubygems"
|
3
|
+
|
4
|
+
module Skelegem
|
5
|
+
module Templates
|
6
|
+
|
7
|
+
class Gemspec < Thor::Group
|
8
|
+
|
9
|
+
include Thor::Actions
|
10
|
+
argument :name
|
11
|
+
|
12
|
+
def self.source_root
|
13
|
+
File.dirname(__FILE__)
|
14
|
+
end
|
15
|
+
|
16
|
+
def create_lib_file
|
17
|
+
my_spec = Skelegem::Store.gemspec
|
18
|
+
File.delete "#{name}.gemspec"
|
19
|
+
template('gemspec.tt', "#{name}.gemspec", :my_spec => my_spec)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require '<%= config[:my_spec].name %>/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "<%= config[:my_spec].name %>"
|
8
|
+
spec.version = <%= (config[:my_spec].name.split("_").map{|f| f.capitalize}.join) %>::VERSION
|
9
|
+
spec.authors = <%= config[:my_spec].authors.to_s %>
|
10
|
+
spec.email = <%= config[:my_spec].email.to_s %>
|
11
|
+
spec.summary = %q{<%= config[:my_spec].summary %>}
|
12
|
+
spec.description = %q{<%= config[:my_spec].description %>}
|
13
|
+
spec.homepage = "<%= config[:my_spec].homepage %>"
|
14
|
+
spec.license = "<%= config[:my_spec].license %>"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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 = <%= config[:my_spec].require_paths.to_s %>
|
20
|
+
|
21
|
+
<% config[:my_spec].runtime_dependencies.each do |dep| %>
|
22
|
+
spec.add_runtime_dependency "<%= dep.name %>", '<%= dep.requirement.to_s %>'<% end %>
|
23
|
+
|
24
|
+
<% config[:my_spec].development_dependencies.each do |dep| %>
|
25
|
+
spec.add_development_dependency "<%= dep.name %>", '<%= dep.requirement.to_s %>'<% end %>
|
26
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "rubygems"
|
3
|
+
|
4
|
+
module Skelegem
|
5
|
+
module Templates
|
6
|
+
|
7
|
+
class SemverInit < Thor::Group
|
8
|
+
|
9
|
+
include Thor::Actions
|
10
|
+
|
11
|
+
argument :name
|
12
|
+
|
13
|
+
def self.source_root
|
14
|
+
File.dirname(__FILE__)
|
15
|
+
end
|
16
|
+
|
17
|
+
def init_semver
|
18
|
+
version = SemVer.new
|
19
|
+
version.save ".semver"
|
20
|
+
|
21
|
+
# Object.send(:remove_const, :SemVer)
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_lib_file
|
25
|
+
File.delete "lib/#{name}/version.rb"
|
26
|
+
template('version.tt', "lib/#{name}/version.rb")
|
27
|
+
end
|
28
|
+
|
29
|
+
def update_gemspec
|
30
|
+
my_spec = Skelegem::Store.gemspec
|
31
|
+
tmp_spec = Gem::Specification::from_yaml( `gem spec semver2 -r` )
|
32
|
+
|
33
|
+
|
34
|
+
# puts "Adding #{tmp_spec.name}, #{tmp_spec.requirement.to_s}"
|
35
|
+
my_spec.add_dependency tmp_spec.name, tmp_spec.version.to_s
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "<%= name %>/version"
|
2
|
+
require "thor"
|
3
|
+
|
4
|
+
module <%= name.split("_").map {|f| f.capitalize}.join %>
|
5
|
+
class CLI < Thor
|
6
|
+
map "-v" => :version
|
7
|
+
|
8
|
+
desc "version", "print out the app version"
|
9
|
+
def version()
|
10
|
+
puts "#{self.class.name.split("::")[0]} #{<%= name.split("_").map {|f| f.capitalize}.join %>::VERSION}"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "rubygems"
|
3
|
+
|
4
|
+
module Skelegem
|
5
|
+
module Templates
|
6
|
+
|
7
|
+
class ThorCLI < Thor::Group
|
8
|
+
|
9
|
+
include Thor::Actions
|
10
|
+
|
11
|
+
argument :name
|
12
|
+
|
13
|
+
def self.source_root
|
14
|
+
File.dirname __FILE__
|
15
|
+
end
|
16
|
+
|
17
|
+
def setup_files
|
18
|
+
template "cli.tt", "lib/#{name}/cli.rb"
|
19
|
+
|
20
|
+
File.delete "bin/#{name}"
|
21
|
+
template "bin.tt", "bin/#{name}"
|
22
|
+
chmod "bin/#{name}", 0755
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/skelegem.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'skelegem/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "skelegem"
|
8
|
+
spec.version = Skelegem::VERSION
|
9
|
+
spec.authors = ["defektive"]
|
10
|
+
spec.email = ["sirbradleyd@gmail.com"]
|
11
|
+
spec.summary = %q{Make things easier}
|
12
|
+
spec.description = %q{Do it once. Set it and forget it.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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_runtime_dependency "semver2", '~>3.4'
|
22
|
+
spec.add_runtime_dependency "thor", '0.19.1'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec"
|
27
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: skelegem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- defektive
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: semver2
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.19.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.19.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Do it once. Set it and forget it.
|
84
|
+
email:
|
85
|
+
- sirbradleyd@gmail.com
|
86
|
+
executables:
|
87
|
+
- skelegem
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".semver"
|
94
|
+
- ".travis.yml"
|
95
|
+
- Gemfile
|
96
|
+
- LICENSE.txt
|
97
|
+
- README.md
|
98
|
+
- Rakefile
|
99
|
+
- bin/skelegem
|
100
|
+
- docs/index.md
|
101
|
+
- lib/skelegem.rb
|
102
|
+
- lib/skelegem/cli.rb
|
103
|
+
- lib/skelegem/store.rb
|
104
|
+
- lib/skelegem/templates.rb
|
105
|
+
- lib/skelegem/templates/gemspec/gemspec.rb
|
106
|
+
- lib/skelegem/templates/gemspec/gemspec.tt
|
107
|
+
- lib/skelegem/templates/semver_init/semver_init.rb
|
108
|
+
- lib/skelegem/templates/semver_init/version.tt
|
109
|
+
- lib/skelegem/templates/thor_cli/bin.tt
|
110
|
+
- lib/skelegem/templates/thor_cli/cli.tt
|
111
|
+
- lib/skelegem/templates/thor_cli/thor_cli.rb
|
112
|
+
- lib/skelegem/version.rb
|
113
|
+
- skelegem.gemspec
|
114
|
+
- spec/skelegem_spec.rb
|
115
|
+
- spec/spec_helper.rb
|
116
|
+
homepage: ''
|
117
|
+
licenses:
|
118
|
+
- MIT
|
119
|
+
metadata: {}
|
120
|
+
post_install_message:
|
121
|
+
rdoc_options: []
|
122
|
+
require_paths:
|
123
|
+
- lib
|
124
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
requirements: []
|
135
|
+
rubyforge_project:
|
136
|
+
rubygems_version: 2.2.2
|
137
|
+
signing_key:
|
138
|
+
specification_version: 4
|
139
|
+
summary: Make things easier
|
140
|
+
test_files:
|
141
|
+
- spec/skelegem_spec.rb
|
142
|
+
- spec/spec_helper.rb
|