bundlegem 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/bin/bundlegem +45 -4
- data/changelog +13 -5
- data/lib/bundlegem/cli/gem.rb +97 -36
- data/lib/bundlegem/cli.rb +12 -3
- data/lib/bundlegem/templates/newgem/{newgem.gemspec.tt → #{name}.gemspec.tt} +2 -2
- data/lib/bundlegem/templates/newgem/{exe/newgem.tt → bin/#{name}.tt} +0 -0
- data/lib/bundlegem/templates/newgem/ext/{newgem/newgem.c.tt → #{name}/#{newgem}.c.tt} +0 -0
- data/lib/bundlegem/templates/newgem/ext/{newgem/newgem.h.tt → #{name}/#{newgem}.h.tt} +0 -0
- data/lib/bundlegem/templates/newgem/ext/{newgem → #{name}}/extconf.rb.tt +0 -0
- data/lib/bundlegem/templates/newgem/lib/{newgem → #{name}}/version.rb.tt +0 -0
- data/lib/bundlegem/templates/newgem/lib/{newgem.rb.tt → #{name}.rb.tt} +0 -0
- data/lib/bundlegem/templates/newgem/spec/{newgem_spec.rb.tt → #{name}_spec.rb.tt} +0 -0
- data/lib/bundlegem/templates/service/#{name}.gemspec.tt +34 -0
- data/lib/bundlegem/templates/service/.travis.yml.tt +3 -0
- data/lib/bundlegem/templates/service/Gemfile.tt +4 -0
- data/lib/bundlegem/templates/service/LICENSE.txt.tt +21 -0
- data/lib/bundlegem/templates/service/README.md +7 -0
- data/lib/bundlegem/templates/service/README.md.tt +23 -0
- data/lib/bundlegem/templates/service/Rakefile.tt +25 -0
- data/lib/bundlegem/templates/service/bin/#{name}.tt +27 -0
- data/lib/bundlegem/templates/service/changelog.tt +6 -0
- data/lib/bundlegem/templates/service/gitignore.tt +10 -0
- data/lib/bundlegem/templates/service/lib/#{name}/version.rb.tt +7 -0
- data/lib/bundlegem/templates/service/lib/#{name}.rb.tt +26 -0
- data/lib/bundlegem/templates/service/rspec.tt +2 -0
- data/lib/bundlegem/templates/service/spec/newgem_spec.rb.tt +11 -0
- data/lib/bundlegem/templates/{newgem/test/minitest_helper.rb.tt → service/spec/spec_helper.rb.tt} +0 -2
- data/lib/bundlegem/version.rb +1 -1
- metadata +25 -13
- data/lib/bundlegem/templates/newgem/bin/setup.tt +0 -7
- data/lib/bundlegem/templates/newgem/test/test_newgem.rb.tt +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43a7ecbc5c9caf18ef4fd7dfd978a173d9b6aecb
|
4
|
+
data.tar.gz: 03d52dc639b8a2c2fa3ee266810911a808f5da2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60ecbdf011e4fea8998857e06b49af05f66ed26d301c651766680056bf6b96fc1f8d5fa61ac062465658ee8ef910594e9b74347c611fc56fb838960baa490316
|
7
|
+
data.tar.gz: 3c830a24a7fd96398cd6093e4d215598aa87adcd843fe4d89f66e4a10f365a793bbfb0697b12d38786039ffd546710718bbf5ecb40043e6a046ee61a46c46a1c
|
data/README.md
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
|
4
4
|
I've more or less taken the code out of Bundler's `bundle gem` command, expanded on it and made it available as this repos.
|
5
5
|
|
6
|
+
The benefits of using this repo to create gems rather than bundler is that you can choose to create 'classes' of gems.
|
7
|
+
By classes, I mean that there are different typs of 'gems', there are basic library gems, that are just code and can only be used from other code, there are command line application gems, those are gems that are run on the command line and include a binary file, and there are also web interface gems, those are gems which spin up a simple web interface and request that the user connect to it's server on what ever port it has spun up on.
|
8
|
+
|
9
|
+
All of these 'classes of gems' as I refer to them, start out with a different code base, consistent with all other gems of there class.
|
10
|
+
This 'class based' aproach to gem creation is different from the addative approach that other gem genorators are based on.
|
11
|
+
|
12
|
+
The most benificial aspect of this gem is that it allows users to specify exactly how they want their 'default starting gem' to look like, rather than rely on what someone else thought their default starting gem should look like.
|
13
|
+
|
6
14
|
### Installation and usage
|
7
15
|
|
8
16
|
First install it:
|
data/bin/bundlegem
CHANGED
@@ -2,12 +2,53 @@
|
|
2
2
|
|
3
3
|
# Exit cleanly from an early interrupt
|
4
4
|
Signal.trap("INT") { exit 1 }
|
5
|
-
|
6
5
|
require 'bundler'
|
7
6
|
require 'bundlegem'
|
8
|
-
|
9
7
|
# require 'bundlergem/friendly_errors'
|
10
|
-
|
11
8
|
require 'bundlegem/cli'
|
12
|
-
|
9
|
+
require 'bundlegem/cli/gem'
|
10
|
+
|
11
|
+
if ARGV.length < 1
|
12
|
+
puts "error: you need to specify a gemname at least"
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
|
16
|
+
if ARGV[0] == "--help"
|
17
|
+
puts "Usage: "
|
18
|
+
puts " # creates a gem based on default template"
|
19
|
+
puts " $ bundlegem gem_name "
|
20
|
+
puts
|
21
|
+
puts " # creates a gem using the service template built into gem"
|
22
|
+
puts " $ bundlegem gem_name -t service "
|
23
|
+
puts
|
24
|
+
puts " # not implemented, but shoud create a new gem template in ~/.bundlegem/templates"
|
25
|
+
puts " # that you'll love customizing to your personal preference"
|
26
|
+
puts " $ bundlegem --newtemplate "
|
27
|
+
puts
|
28
|
+
puts " $ bundlegem --help # shows these strings"
|
29
|
+
exit 0
|
30
|
+
end
|
31
|
+
|
32
|
+
if ARGV[0] == "--newtemplate"
|
33
|
+
puts "Sorry, I haven't been implemented, I don't have a lot of free time atm :("
|
34
|
+
exit 0
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
options = {"bin"=>false, "ext"=>false, :coc=> false}
|
40
|
+
name = ARGV[0] # gem name
|
41
|
+
|
42
|
+
if ARGV.length > 1
|
43
|
+
if ARGV[1] != "-t"
|
44
|
+
puts "you can ONLY use -t as an argument cause I'm quite busy and should be doing something else right now!"
|
45
|
+
exit 1
|
46
|
+
end
|
47
|
+
|
48
|
+
options.merge!({"template" => ARGV[2]})
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
Bundlegem::CLI::Gem.new(options, name, self).run
|
53
|
+
|
13
54
|
|
data/changelog
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
** 0.0.x **
|
2
|
+
- Default templates:
|
3
|
+
* CLI file system app,
|
4
|
+
* CLI with web client
|
5
|
+
- Restore the original UI that was in bundler
|
2
6
|
- Ability to load templates from github
|
7
|
+
- CMD: --list to list templates (with descriptions)
|
8
|
+
- CMD: --newtemplate to start new template
|
9
|
+
- Behavior: gems in the ~/.bundlegem/templates folder take precidence over
|
10
|
+
built in gems
|
11
|
+
|
12
|
+
** 0.0.2 **
|
13
|
+
- Added default gem template 'service'
|
3
14
|
- Better syntax of bundlegem gem_name -t template_name
|
4
|
-
-
|
5
|
-
|
6
|
-
- Restore the original UI that was in bundler
|
7
|
-
- Cleanness and goodness
|
8
|
-
- Soapy bubbles that smell like spring time in a box marked surplus kittens
|
15
|
+
- CMD: --help to display a help message
|
16
|
+
|
9
17
|
|
10
18
|
** 0.0.1 **
|
11
19
|
- Very basic prototype that allows you to specify templates in
|
data/lib/bundlegem/cli/gem.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'pathname'
|
2
|
+
require 'pry'
|
2
3
|
|
3
4
|
module Bundlegem
|
4
5
|
class CLI::Gem
|
@@ -43,25 +44,20 @@ module Bundlegem
|
|
43
44
|
}
|
44
45
|
ensure_safe_gem_name(name, constant_array)
|
45
46
|
|
46
|
-
# Hmmm... generate dynamically instead?
|
47
|
+
# Hmmm... generate dynamically instead? Yes, overwritten below
|
47
48
|
templates = {
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
"bin/setup.tt" => "bin/setup"
|
49
|
+
'Gemfile.tt' => "Gemfile",
|
50
|
+
'changelog.tt' => "changelog",
|
51
|
+
'gitignore.tt' => ".gitignore",
|
52
|
+
'lib/#{name}.rb.tt' => "lib/#{namespaced_path}.rb",
|
53
|
+
'lib/#{name}/version.rb.tt' => "lib/#{namespaced_path}/version.rb",
|
54
|
+
'#{name}.gemspec.tt' => "#{name}.gemspec",
|
55
|
+
'Rakefile.tt' => "Rakefile",
|
56
|
+
'README.md.tt' => "README.md",
|
57
|
+
'bin/console.tt' => "bin/console"
|
58
58
|
}
|
59
59
|
|
60
60
|
|
61
|
-
templates = dynamically_generate_templates || templates
|
62
|
-
|
63
|
-
|
64
|
-
|
65
61
|
if ask_and_set(:coc, "Do you want to include a code of conduct in gems you generate?",
|
66
62
|
"Codes of conduct can increase contributions to your project by contributors who " \
|
67
63
|
"prefer collaborative, safe spaces. You can read more about the code of conduct at " \
|
@@ -71,6 +67,7 @@ module Bundlegem
|
|
71
67
|
)
|
72
68
|
templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
|
73
69
|
end
|
70
|
+
|
74
71
|
|
75
72
|
if ask_and_set(:mit, "Do you want to license your code permissively under the MIT license?",
|
76
73
|
"This means that any other developer or company will be legally allowed to use your code " \
|
@@ -89,7 +86,7 @@ module Bundlegem
|
|
89
86
|
templates.merge!(
|
90
87
|
"rspec.tt" => ".rspec",
|
91
88
|
"spec/spec_helper.rb.tt" => "spec/spec_helper.rb",
|
92
|
-
|
89
|
+
'spec/#{name}_spec.rb.tt' => "spec/#{namespaced_path}_spec.rb"
|
93
90
|
)
|
94
91
|
when 'minitest'
|
95
92
|
templates.merge!(
|
@@ -108,12 +105,12 @@ module Bundlegem
|
|
108
105
|
"ext/newgem/newgem.c.tt" => "ext/#{name}/#{underscored_name}.c"
|
109
106
|
)
|
110
107
|
end
|
111
|
-
|
112
|
-
|
108
|
+
|
113
109
|
template_src = match_template_src
|
114
|
-
|
110
|
+
templates = dynamically_generate_templates || templates
|
111
|
+
|
115
112
|
templates.each do |src, dst|
|
116
|
-
|
113
|
+
template("#{template_src}/#{src}", target.join(dst), config)
|
117
114
|
end
|
118
115
|
|
119
116
|
# Bundler.ui.info "Initializing git repo in #{target}"
|
@@ -143,26 +140,33 @@ module Bundlegem
|
|
143
140
|
|
144
141
|
def match_template_src
|
145
142
|
template_src = get_template_src
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
143
|
+
|
144
|
+
return template_src if template_exists_within_repo?(template_src) or File.exists?(template_src) # 'newgem' refers to the built in template that comes with the gem
|
145
|
+
|
146
|
+
# else message the user that the template could not be found
|
147
|
+
err_missing_template = "Could not find template folder #{options["template"]} in `~/.bundle/gem_templates/`. Please check to make sure your desired template exists."
|
148
|
+
puts err_missing_template
|
149
|
+
Bundler.ui.error err_missing_template
|
150
|
+
exit 1
|
154
151
|
end
|
155
152
|
|
156
153
|
def get_template_src
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
154
|
+
template_name = options["template"].nil? ? "newgem" : options["template"]
|
155
|
+
|
156
|
+
if template_exists_within_repo?(template_name) # if template_exists_within_repo?(template_name)
|
157
|
+
gem_template_location = get_internal_template_location
|
161
158
|
else
|
162
|
-
gem_template_location = File.expand_path("~/.bundle/gem_templates")
|
163
|
-
gem_template = options["template"]
|
164
|
-
template_src = "#{gem_template_location}#{gem_template}"
|
159
|
+
gem_template_location = File.expand_path("~/.bundle/gem_templates")
|
165
160
|
end
|
161
|
+
template_src = "#{gem_template_location}/#{template_name}"
|
162
|
+
end
|
163
|
+
|
164
|
+
def template_exists_within_repo?(template_name)
|
165
|
+
file_in_source?(template_name)
|
166
|
+
end
|
167
|
+
|
168
|
+
def get_internal_template_location
|
169
|
+
File.expand_path("#{File.dirname(__FILE__)}/../templates")
|
166
170
|
end
|
167
171
|
|
168
172
|
def resolve_name(name)
|
@@ -170,7 +174,7 @@ module Bundlegem
|
|
170
174
|
end
|
171
175
|
|
172
176
|
def ask_and_set(key, header, message)
|
173
|
-
choice = options[key] || Bundler.settings["gem.#{key}"]
|
177
|
+
choice = options[key] # || Bundler.settings["gem.#{key}"]
|
174
178
|
|
175
179
|
if choice.nil?
|
176
180
|
Bundler.ui.confirm header
|
@@ -228,6 +232,63 @@ module Bundlegem
|
|
228
232
|
exit 1
|
229
233
|
end
|
230
234
|
end
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
#
|
239
|
+
# EDIT: Reworked from Thor to not rely on Thor (or do so much unneeded stuff)
|
240
|
+
#
|
241
|
+
# Gets an ERB template at the relative source, executes it and makes a copy
|
242
|
+
# at the relative destination. If the destination is not given it's assumed
|
243
|
+
# to be equal to the source removing .tt from the filename.
|
244
|
+
#
|
245
|
+
# ==== Parameters
|
246
|
+
# source<String>:: the relative path to the source root.
|
247
|
+
# destination<String>:: the relative path to the destination root.
|
248
|
+
# config<Hash>:: give :verbose => false to not log the status.
|
249
|
+
#
|
250
|
+
# ==== Examples
|
251
|
+
#
|
252
|
+
# template "README", "doc/README"
|
253
|
+
#
|
254
|
+
# template "doc/README"
|
255
|
+
#
|
256
|
+
def template(source, *args, &block)
|
257
|
+
config = args.last.is_a?(Hash) ? args.pop : {}
|
258
|
+
destination = args.first || source.sub(/#{TEMPLATE_EXTNAME}$/, "")
|
259
|
+
|
260
|
+
source = File.expand_path(find_in_source_paths(source.to_s))
|
261
|
+
context = instance_eval("binding")
|
262
|
+
|
263
|
+
make_file(destination, config) do
|
264
|
+
content = ERB.new(::File.binread(source), nil, "-", "@output_buffer").result(context)
|
265
|
+
content = block.call(content) if block
|
266
|
+
content
|
267
|
+
end
|
268
|
+
|
269
|
+
end
|
270
|
+
|
271
|
+
#
|
272
|
+
# EDIT: Reworked from Thor to not rely on Thor (or do so much unneeded stuff)
|
273
|
+
#
|
274
|
+
def find_in_source_paths(target)
|
275
|
+
src_in_source_path = "#{File.dirname(__FILE__)}/../templates/#{target}"
|
276
|
+
return src_in_source_path if File.exists?(src_in_source_path)
|
277
|
+
target # failed, hopefully full path to a user specified gem template file
|
278
|
+
end
|
279
|
+
|
280
|
+
def file_in_source?(target)
|
281
|
+
src_in_source_path = "#{File.dirname(__FILE__)}/../templates/#{target}"
|
282
|
+
File.exists?(src_in_source_path)
|
283
|
+
end
|
284
|
+
|
285
|
+
#
|
286
|
+
# EDIT: Reworked from Thor to not rely on Thor (or do so much unneeded stuff)
|
287
|
+
#
|
288
|
+
def make_file(destination, config, &block)
|
289
|
+
FileUtils.mkdir_p(File.dirname(destination))
|
290
|
+
File.open(destination, "wb") { |f| f.write block.call }
|
291
|
+
end
|
231
292
|
|
232
293
|
end
|
233
294
|
end
|
data/lib/bundlegem/cli.rb
CHANGED
@@ -10,6 +10,7 @@ module Bundlegem
|
|
10
10
|
super
|
11
11
|
rescue Exception => e
|
12
12
|
# Bundlegem.ui = UI::Shell.new
|
13
|
+
puts e
|
13
14
|
raise e
|
14
15
|
ensure
|
15
16
|
# Bundlegem.cleanup
|
@@ -34,7 +35,7 @@ module Bundlegem
|
|
34
35
|
check_unknown_options!(:except => [:config, :exec])
|
35
36
|
stop_on_unknown_option! :exec
|
36
37
|
|
37
|
-
default_task :
|
38
|
+
default_task :gem
|
38
39
|
class_option "no-color", :type => :boolean, :desc => "Disable colorization in output"
|
39
40
|
class_option "retry", :type => :numeric, :aliases => "-r", :banner => "NUM",
|
40
41
|
:desc => "Specify the number of times you wish to attempt network commands"
|
@@ -71,9 +72,14 @@ module Bundlegem
|
|
71
72
|
end
|
72
73
|
|
73
74
|
def self.handle_no_command_error(command, has_namespace = $thor_runner)
|
74
|
-
|
75
|
+
require 'bundlegem/cli/gem'
|
76
|
+
Gem.new(options, name, self).run
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
# return super unless command_path = Bundlegem.which("Bundlegem-#{command}")
|
75
81
|
|
76
|
-
Kernel.exec(command_path, *ARGV[1..-1])
|
82
|
+
# Kernel.exec(command_path, *ARGV[1..-1])
|
77
83
|
end
|
78
84
|
|
79
85
|
desc "init [OPTIONS]", "Generates a Gemfile into the current working directory"
|
@@ -109,6 +115,9 @@ module Bundlegem
|
|
109
115
|
:desc => "Generate a test directory for your library, either rspec or minitest. Set a default with `bundle config gem.test rspec`."
|
110
116
|
method_option :template, :type => :string, :lazy_default => "newgem", :aliases => '-u', :banner => "default", :desc => "Generate a gem based on the user's predefined template."
|
111
117
|
def gem(name)
|
118
|
+
# options = {"bin"=>false, "ext"=>false}
|
119
|
+
# name = "gem_name"
|
120
|
+
# self.class == Bundlegem::CLI
|
112
121
|
require 'bundlegem/cli/gem'
|
113
122
|
Gem.new(options, name, self).run
|
114
123
|
end
|
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = [<%=config[:email].inspect%>]
|
11
11
|
|
12
12
|
spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
|
13
|
-
spec.description = %q{TODO:
|
14
|
-
spec.homepage = "
|
13
|
+
spec.description = %q{TODO: delete this line since you're in a hurry.}
|
14
|
+
spec.homepage = "https://github.com/<%=config[:author]%>/<%=config[:name]%>"
|
15
15
|
<%- if config[:mit] -%>
|
16
16
|
spec.license = "MIT"
|
17
17
|
<%- end -%>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require '<%=config[:namespaced_path]%>/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = <%=config[:name].inspect%>
|
8
|
+
spec.version = <%=config[:constant_name]%>::VERSION
|
9
|
+
spec.authors = [<%=config[:author].inspect%>]
|
10
|
+
spec.email = [<%=config[:email].inspect%>]
|
11
|
+
|
12
|
+
spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
|
13
|
+
spec.description = %q{TODO: delete this line since you're in a hurry.}
|
14
|
+
spec.homepage = "https://github.com/<%=config[:author]%>/<%=config[:name]%>"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
|
23
|
+
if spec.respond_to?(:metadata)
|
24
|
+
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
|
25
|
+
end
|
26
|
+
|
27
|
+
spec.add_dependency "thor"
|
28
|
+
spec.add_dependency "service_installer"
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> <%= config[:bundler_version] %>"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "pry"
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) <%=Time.now.year%> <%=config[:author]%>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,7 @@
|
|
1
|
+
== What's This?
|
2
|
+
|
3
|
+
This is a gem skeleton template. Ideally you can define your own and place them into ~/.bundle/gem_templates and specify to use that template instead of the default template defined in bundler.
|
4
|
+
|
5
|
+
This skelton would be helpful if you needed to create a new ruby app that ran as a service on the installed machine. This skelton should include the base code required for building a daemon style ruby app, including an installation command, a start/stop/restart/status interface and of course a spot that says "# your daemon code goes here" where you could easily drop in, say, a write to a log file and a sleep 5000 instruction and you'd be pretty much set for rapidly spinning up a new gem of the daemon type.
|
6
|
+
|
7
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# <%=config[:constant_name]%>
|
2
|
+
|
3
|
+
This is a service type gem! It runs as a daemon in the background!
|
4
|
+
|
5
|
+
TODO: Describe specifically what the service does, and why people would want to.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Install the gem:
|
10
|
+
|
11
|
+
$ gem install <%=config[:name]%>
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
TODO: Write usage instructions here
|
16
|
+
|
17
|
+
## Contributing
|
18
|
+
|
19
|
+
1. Fork it ( https://github.com/[my-github-username]/<%=config[:name]%>/fork )
|
20
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
21
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
22
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
23
|
+
5. Create a new Pull Request
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
<% if config[:test] == 'minitest' -%>
|
3
|
+
require "rake/testtask"
|
4
|
+
|
5
|
+
Rake::TestTask.new(:test) do |t|
|
6
|
+
t.libs << "test"
|
7
|
+
end
|
8
|
+
|
9
|
+
task :default => :test
|
10
|
+
<% elsif config[:test] == 'rspec' -%>
|
11
|
+
require "rspec/core/rake_task"
|
12
|
+
|
13
|
+
RSpec::Core::RakeTask.new(:spec)
|
14
|
+
|
15
|
+
task :default => :spec
|
16
|
+
<% end -%>
|
17
|
+
<% if config[:ext] -%>
|
18
|
+
require "rake/extensiontask"
|
19
|
+
|
20
|
+
task :build => :compile
|
21
|
+
|
22
|
+
Rake::ExtensionTask.new("<%=config[:underscored_name]%>") do |ext|
|
23
|
+
ext.lib_dir = "lib/<%=config[:namespaced_path]%>"
|
24
|
+
end
|
25
|
+
<% end -%>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
require '<%=config[:namespaced_path]%>'
|
5
|
+
|
6
|
+
class BinRunner < Thor
|
7
|
+
|
8
|
+
desc "about", "About this file"
|
9
|
+
def about
|
10
|
+
<%=config[:constant_name]%>.about
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "install", "This command checks the OS you're on and installs the gem as a service"
|
14
|
+
def install
|
15
|
+
<%=config[:constant_name]%>.install
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "uninstall", "This command uninstalls the service from the OS"
|
19
|
+
def uninstall
|
20
|
+
<%=config[:constant_name]%>.uninstall
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
BinRunner.start
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "service_installer"
|
2
|
+
|
3
|
+
require "<%=config[:namespaced_path]%>/version"
|
4
|
+
|
5
|
+
<%- config[:constant_array].each_with_index do |c,i| -%>
|
6
|
+
<%= ' '*i %>module <%= c %>
|
7
|
+
<%- end -%>
|
8
|
+
|
9
|
+
<%= ' '*config[:constant_array].size %># Your code goes here...k
|
10
|
+
|
11
|
+
<%= ' '*config[:constant_array].size %>def self.About
|
12
|
+
<%= ' '*config[:constant_array].size %>end
|
13
|
+
|
14
|
+
<%= ' '*config[:constant_array].size %>def self.Install
|
15
|
+
<%= ' '*config[:constant_array].size %> # s = ServiceInstaller.new
|
16
|
+
<%= ' '*config[:constant_array].size %> # s.install
|
17
|
+
<%= ' '*config[:constant_array].size %>end
|
18
|
+
|
19
|
+
<%= ' '*config[:constant_array].size %>def self.Uninstall
|
20
|
+
<%= ' '*config[:constant_array].size %>end
|
21
|
+
|
22
|
+
<%- (config[:constant_array].size-1).downto(0) do |i| -%>
|
23
|
+
|
24
|
+
<%= ' '*i %>end
|
25
|
+
|
26
|
+
<%- end -%>
|
data/lib/bundlegem/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bundlegem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TheNotary
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -105,28 +105,40 @@ files:
|
|
105
105
|
- lib/bundlegem/templates/Executable
|
106
106
|
- lib/bundlegem/templates/Executable.standalone
|
107
107
|
- lib/bundlegem/templates/Gemfile
|
108
|
+
- lib/bundlegem/templates/newgem/#{name}.gemspec.tt
|
108
109
|
- lib/bundlegem/templates/newgem/.travis.yml.tt
|
109
110
|
- lib/bundlegem/templates/newgem/CODE_OF_CONDUCT.md.tt
|
110
111
|
- lib/bundlegem/templates/newgem/Gemfile.tt
|
111
112
|
- lib/bundlegem/templates/newgem/LICENSE.txt.tt
|
112
113
|
- lib/bundlegem/templates/newgem/README.md.tt
|
113
114
|
- lib/bundlegem/templates/newgem/Rakefile.tt
|
115
|
+
- lib/bundlegem/templates/newgem/bin/#{name}.tt
|
114
116
|
- lib/bundlegem/templates/newgem/bin/console.tt
|
115
|
-
- lib/bundlegem/templates/newgem/bin/setup.tt
|
116
117
|
- lib/bundlegem/templates/newgem/changelog.tt
|
117
|
-
- lib/bundlegem/templates/newgem/
|
118
|
-
- lib/bundlegem/templates/newgem/ext
|
119
|
-
- lib/bundlegem/templates/newgem/ext/
|
120
|
-
- lib/bundlegem/templates/newgem/ext/newgem/newgem.h.tt
|
118
|
+
- lib/bundlegem/templates/newgem/ext/#{name}/#{newgem}.c.tt
|
119
|
+
- lib/bundlegem/templates/newgem/ext/#{name}/#{newgem}.h.tt
|
120
|
+
- lib/bundlegem/templates/newgem/ext/#{name}/extconf.rb.tt
|
121
121
|
- lib/bundlegem/templates/newgem/gitignore.tt
|
122
|
-
- lib/bundlegem/templates/newgem/lib
|
123
|
-
- lib/bundlegem/templates/newgem/lib/
|
124
|
-
- lib/bundlegem/templates/newgem/newgem.gemspec.tt
|
122
|
+
- lib/bundlegem/templates/newgem/lib/#{name}.rb.tt
|
123
|
+
- lib/bundlegem/templates/newgem/lib/#{name}/version.rb.tt
|
125
124
|
- lib/bundlegem/templates/newgem/rspec.tt
|
126
|
-
- lib/bundlegem/templates/newgem/spec
|
125
|
+
- lib/bundlegem/templates/newgem/spec/#{name}_spec.rb.tt
|
127
126
|
- lib/bundlegem/templates/newgem/spec/spec_helper.rb.tt
|
128
|
-
- lib/bundlegem/templates/
|
129
|
-
- lib/bundlegem/templates/
|
127
|
+
- lib/bundlegem/templates/service/#{name}.gemspec.tt
|
128
|
+
- lib/bundlegem/templates/service/.travis.yml.tt
|
129
|
+
- lib/bundlegem/templates/service/Gemfile.tt
|
130
|
+
- lib/bundlegem/templates/service/LICENSE.txt.tt
|
131
|
+
- lib/bundlegem/templates/service/README.md
|
132
|
+
- lib/bundlegem/templates/service/README.md.tt
|
133
|
+
- lib/bundlegem/templates/service/Rakefile.tt
|
134
|
+
- lib/bundlegem/templates/service/bin/#{name}.tt
|
135
|
+
- lib/bundlegem/templates/service/changelog.tt
|
136
|
+
- lib/bundlegem/templates/service/gitignore.tt
|
137
|
+
- lib/bundlegem/templates/service/lib/#{name}.rb.tt
|
138
|
+
- lib/bundlegem/templates/service/lib/#{name}/version.rb.tt
|
139
|
+
- lib/bundlegem/templates/service/rspec.tt
|
140
|
+
- lib/bundlegem/templates/service/spec/newgem_spec.rb.tt
|
141
|
+
- lib/bundlegem/templates/service/spec/spec_helper.rb.tt
|
130
142
|
- lib/bundlegem/version.rb
|
131
143
|
- spec/bundlegem_spec.rb
|
132
144
|
- spec/spec_helper.rb
|