gemstrapper 1.0.0
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/bin/gemstrapper +58 -0
- data/lib/gemstrapper/templates/project_name/Gemfile.erb +3 -0
- data/lib/gemstrapper/templates/project_name/lib/project_name/version.rb.erb +3 -0
- data/lib/gemstrapper/templates/project_name/project_name.gemspec.erb +14 -0
- data/lib/gemstrapper/utility/string_helpers.rb +17 -0
- data/lib/gemstrapper/version.rb +5 -0
- data/lib/gemstrapper.rb +65 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4e95bdaee08f3ec61e4862ab445eb88985586002
|
4
|
+
data.tar.gz: 3eee2eb775807f7d2c5b9033fdb602514cc86a8b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bc79d530f531fb473923846a8a831f43636dcaaf429232b3a7418b68183118eb577cc900529e311b6531cf56c42d9eec962459649b51bc8709ffc88b9fa92fdb
|
7
|
+
data.tar.gz: f09e32bd22623a2d73e146e451e1c7268a8b8c5b02b70068143a1f114f0fd3156243884279e34463833f2762c832b732ac851aba7d68283a97552d4853c70755
|
data/bin/gemstrapper
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'gemstrapper'
|
5
|
+
|
6
|
+
class OptionsParser
|
7
|
+
|
8
|
+
def self.parse(args)
|
9
|
+
subtext = %Q{
|
10
|
+
Commonly used command are:
|
11
|
+
init : creates a gem scaffolding in the current folder
|
12
|
+
See 'gemstrapper COMMAND --help' for more information on a specific command.}
|
13
|
+
|
14
|
+
options = {}
|
15
|
+
global = OptionParser.new do |opts|
|
16
|
+
opts.banner = "Usage: gemstrapper [options] [subcommand [options]]"
|
17
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
18
|
+
options[:verbose] = v
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
22
|
+
puts opts
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.separator ""
|
27
|
+
opts.separator subtext
|
28
|
+
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
subcommands = {
|
33
|
+
'init' => OptionParser.new do |opts|
|
34
|
+
opts.banner = "Usage: init <folder_name>"
|
35
|
+
end
|
36
|
+
}
|
37
|
+
|
38
|
+
global.order!
|
39
|
+
command = args.shift
|
40
|
+
project_name = args.shift
|
41
|
+
|
42
|
+
unless command and project_name
|
43
|
+
puts "Invalid argument: Command should be: gemstrapper init <project_name>"
|
44
|
+
exit(1)
|
45
|
+
end
|
46
|
+
|
47
|
+
options.update(project_name: project_name)
|
48
|
+
subcommands[command].order!
|
49
|
+
|
50
|
+
return command, options
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
command, options = OptionsParser.parse(ARGV)
|
56
|
+
Gemstrapper.send(command, options)
|
57
|
+
|
58
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative 'lib/<%= options[:project_name] %>/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = '<%= options[:project_name] %>'
|
5
|
+
s.version = <%= options[:module_name] %>::VERSION
|
6
|
+
s.license = 'MIT'
|
7
|
+
s.summary = "short summary here"
|
8
|
+
s.description = "longer description here"
|
9
|
+
s.author = 'user'
|
10
|
+
s.email = 'user@example.com'
|
11
|
+
s.require_paths = ['lib']
|
12
|
+
s.files = Dir['lib/**/*']
|
13
|
+
s.homepage = 'home page here'
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Gemstrapper
|
2
|
+
##
|
3
|
+
# Module for generic utitlity methods that can be reused throughout the code
|
4
|
+
module Utility
|
5
|
+
##
|
6
|
+
# Mix-in with additional methods for working with Strings
|
7
|
+
module StringHelpers
|
8
|
+
##
|
9
|
+
# Converts a given string into a valid Ruby module name
|
10
|
+
# @param [String] string The string to convert
|
11
|
+
# @return [String] The given string converted into valid Ruby syntax for constants
|
12
|
+
def module_name_for(string)
|
13
|
+
string.split(/[-,_]/).map {|w| w.capitalize}.join('')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/gemstrapper.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
require 'gemstrapper/utility/string_helpers'
|
5
|
+
|
6
|
+
##
|
7
|
+
# Top level module for the app.
|
8
|
+
module Gemstrapper
|
9
|
+
include Utility::StringHelpers
|
10
|
+
|
11
|
+
extend self
|
12
|
+
|
13
|
+
##
|
14
|
+
# Initialises a gem folder structure based on the project name passed in from the command
|
15
|
+
# line and populates it with command files and configuration
|
16
|
+
# @param [Hash] options The options passed in from the command line execution
|
17
|
+
# @return [void]
|
18
|
+
def init(options)
|
19
|
+
@options = options
|
20
|
+
|
21
|
+
new_files = []
|
22
|
+
|
23
|
+
@options[:module_name] = module_name_for(@options[:project_name])
|
24
|
+
# Getting a list of folders to create based on folder structure within lib/templates
|
25
|
+
templates_directory = File.expand_path('gemstrapper/templates', File.dirname(__FILE__))
|
26
|
+
|
27
|
+
files = Dir.chdir(templates_directory) do
|
28
|
+
Dir.glob('**/*.erb')
|
29
|
+
end
|
30
|
+
|
31
|
+
files.each do |file|
|
32
|
+
## creates directories
|
33
|
+
# converting project name placeholder to actual project name and stripping off erb extension
|
34
|
+
new_file_path = file.gsub('project_name', @options[:project_name]).gsub('.erb', '')
|
35
|
+
directory = File.dirname(new_file_path)
|
36
|
+
|
37
|
+
unless File.exist? directory
|
38
|
+
FileUtils.mkdir_p directory
|
39
|
+
end
|
40
|
+
|
41
|
+
data = process_template(File.join(templates_directory, file), options)
|
42
|
+
File.write(new_file_path, data)
|
43
|
+
new_files << new_file_path
|
44
|
+
end
|
45
|
+
|
46
|
+
#reporting
|
47
|
+
new_files.each do |nf|
|
48
|
+
puts "#{nf} created"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# Reads an ERB file and populates the templated data from info in the
|
54
|
+
# current execution scope
|
55
|
+
# @param [String] file_path The absolute path of the ERB file
|
56
|
+
# @param [Hash] options A Hash of options passed in from command line
|
57
|
+
# and generated dynamically. Is part of the execution scope so can be
|
58
|
+
# used as part of the ERB template
|
59
|
+
# @return [String] the data from the ERB file filled out with data
|
60
|
+
def process_template(file_path, options)
|
61
|
+
template_data = File.read(file_path)
|
62
|
+
|
63
|
+
ERB.new(template_data).result binding
|
64
|
+
end
|
65
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gemstrapper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tim Hoiberg
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: simplecov
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.11'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.10'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.10'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: yard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.8'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.8'
|
69
|
+
description: Creates gem scaffolding, complete with Gemfile and README
|
70
|
+
email: tim.hoiberg@gmail.com
|
71
|
+
executables:
|
72
|
+
- gemstrapper
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- bin/gemstrapper
|
77
|
+
- lib/gemstrapper.rb
|
78
|
+
- lib/gemstrapper/templates/project_name/Gemfile.erb
|
79
|
+
- lib/gemstrapper/templates/project_name/lib/project_name/version.rb.erb
|
80
|
+
- lib/gemstrapper/templates/project_name/project_name.gemspec.erb
|
81
|
+
- lib/gemstrapper/utility/string_helpers.rb
|
82
|
+
- lib/gemstrapper/version.rb
|
83
|
+
homepage: https://github.com/thoiberg/gemstrapper
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.4.6
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: A gem to generate gem scaffolding
|
107
|
+
test_files: []
|
108
|
+
has_rdoc:
|