gem_bootstrap 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +6 -0
- data/README.md +0 -1
- data/gem_bootstrap.gemspec +6 -9
- data/lib/gem_bootstrap/cli.rb +1 -8
- data/lib/gem_bootstrap/gem_bootstrap.rb +6 -9
- data/lib/gem_bootstrap/git_utils.rb +22 -14
- data/lib/gem_bootstrap/misc_utils.rb +14 -10
- data/lib/gem_bootstrap/version.rb +1 -1
- data/lib/gem_bootstrap.rb +12 -5
- data/templates/dot_gitignore +0 -1
- data/templates/lib/newgem.rb +0 -1
- data/templates/newgem-minitest.gemspec.tt +5 -6
- data/templates/newgem-rspec.gemspec.tt +5 -8
- metadata +12 -12
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/gem_bootstrap.gemspec
CHANGED
@@ -26,22 +26,19 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
27
27
|
spec.test_files = Dir.glob('test/**/*')
|
28
28
|
spec.require_paths = ['lib']
|
29
|
-
|
30
|
-
# runtime dependencies
|
31
29
|
spec.add_runtime_dependency 'activesupport-core-ext', '~> 4.0.0.2'
|
32
30
|
spec.add_runtime_dependency 'grit', '~> 2.5.0'
|
33
31
|
spec.add_runtime_dependency 'thor', '~> 0.19.1'
|
34
|
-
|
35
|
-
# development dependencies
|
36
32
|
spec.add_development_dependency 'awesome_print', '~> 1.2.0'
|
37
|
-
spec.add_development_dependency 'bundler', '~> 1.7.
|
33
|
+
spec.add_development_dependency 'bundler', '~> 1.7.3'
|
38
34
|
spec.add_development_dependency 'gem-ctags', '~> 1.0.6'
|
39
35
|
spec.add_development_dependency 'guard', '~> 2.6.1'
|
40
|
-
spec.add_development_dependency 'guard-minitest', '~> 2.3.
|
41
|
-
spec.add_development_dependency 'minitest', '~> 5.4.
|
36
|
+
spec.add_development_dependency 'guard-minitest', '~> 2.3.2'
|
37
|
+
spec.add_development_dependency 'minitest', '~> 5.4.2'
|
42
38
|
spec.add_development_dependency 'minitest-spec-context', '~> 0.0.3'
|
43
|
-
spec.add_development_dependency 'pry', '~> 0.10.
|
39
|
+
spec.add_development_dependency 'pry', '~> 0.10.1'
|
40
|
+
spec.add_development_dependency 'pry-byebug', '~> 2.0.0' if RUBY_VERSION >= '2.0.0'
|
44
41
|
spec.add_development_dependency 'rake', '~> 10.3.2'
|
45
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
42
|
+
spec.add_development_dependency 'rubocop', '~> 0.26.1'
|
46
43
|
spec.add_development_dependency 'yard', '~> 0.8.7'
|
47
44
|
end
|
data/lib/gem_bootstrap/cli.rb
CHANGED
@@ -1,13 +1,6 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'active_support'
|
3
|
-
require 'active_support/core_ext/object/blank'
|
4
|
-
require 'active_support/core_ext/hash/keys'
|
5
|
-
require 'active_support/core_ext/hash/indifferent_access'
|
6
|
-
require_relative './misc_utils'
|
7
|
-
require_relative './git_utils'
|
8
1
|
module GemBootstrap
|
9
|
-
# The common template directory
|
10
2
|
TEMPLATES_DIR = '../../templates'
|
3
|
+
|
11
4
|
class CLI < Thor::Group
|
12
5
|
include Thor::Actions
|
13
6
|
argument :name
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require_relative './cli'
|
3
1
|
module GemBootstrap
|
4
2
|
class MainCLI < Thor
|
5
3
|
register GemBootstrap::CLI,
|
@@ -11,15 +9,14 @@ module GemBootstrap
|
|
11
9
|
def usage
|
12
10
|
generate_usage = <<-EOT
|
13
11
|
|
14
|
-
Usage/Synopsis:
|
12
|
+
# Usage/Synopsis:
|
13
|
+
gem_bootstrap [GEM_NAME] -g, --github-id [GITHUB_ID] -e, --email [EMAIL] -a, --author [AUTHOR] --test-framework [FRAMEWORK]
|
15
14
|
|
16
|
-
|
15
|
+
# Create a gem name 'awesome_gem'
|
16
|
+
gem_bootstrap awesome_gem -g awesome_developer -e cool@awesomedev.com -a 'John Guru II'
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
Choose test framework --test-framework or -t (defaults to minitest)
|
22
|
-
$gem_bootstrap awesome_gem -g awesome_developer -e cool@awesomedev.com -a 'John Guru II' -t rspec
|
18
|
+
# Choose test framework --test-framework or -t (defaults to minitest)
|
19
|
+
gem_bootstrap awesome_gem -g awesome_developer -e cool@awesomedev.com -a 'John Guru II' -t rspec
|
23
20
|
|
24
21
|
EOT
|
25
22
|
puts generate_usage
|
@@ -1,13 +1,12 @@
|
|
1
|
-
require 'grit'
|
2
1
|
module GemBootstrap
|
3
2
|
class GitUtils
|
4
3
|
class << self
|
5
|
-
# create new git
|
4
|
+
# create new git repository from a given directory
|
6
5
|
#
|
7
6
|
# @param [String] base_dir the starting directory
|
8
7
|
# @param [String] gem_name the name of the gem we are creating
|
9
8
|
def create_git_project(base_dir, gem_name)
|
10
|
-
base_dir =
|
9
|
+
base_dir = expand_path(base_dir)
|
11
10
|
files = MiscUtils.files base_dir: base_dir,
|
12
11
|
non_exts: %w(Gemfile
|
13
12
|
Rakefile
|
@@ -18,32 +17,41 @@ module GemBootstrap
|
|
18
17
|
.gitignore) << gem_name,
|
19
18
|
exts: %w(md rb gemspec yml),
|
20
19
|
recursive: true
|
21
|
-
git_init(base_dir
|
22
|
-
git_add(
|
20
|
+
git_init(base_dir)
|
21
|
+
git_add(base_dir, files)
|
23
22
|
end
|
24
23
|
|
25
|
-
# Run the git init on a given directory
|
24
|
+
# Run the `git init` on a given directory
|
26
25
|
#
|
27
|
-
# @param [String] base_dir the
|
28
|
-
def git_init(
|
29
|
-
|
30
|
-
|
26
|
+
# @param [String] base_dir the starting directory
|
27
|
+
def git_init(base_dir)
|
28
|
+
base_dir = expand_path(base_dir)
|
29
|
+
# Note: need to be in the right directory for this to work
|
31
30
|
Dir.chdir(base_dir)
|
32
31
|
MiscUtils.shell(%w(git init) << base_dir)
|
33
|
-
Dir.chdir(current_dir)
|
34
32
|
end
|
35
33
|
|
36
|
-
|
37
|
-
|
34
|
+
# Add files and perform initial commit to the repository
|
35
|
+
#
|
36
|
+
# @param [String] base_dir the starting directory
|
37
|
+
# @param [Array<String>] files list of files to be used
|
38
|
+
def git_add(base_dir, files)
|
39
|
+
base_dir = expand_path(base_dir)
|
38
40
|
Dir.chdir(base_dir) do
|
39
41
|
git = Grit::Repo.new(File.expand_path('.'))
|
40
42
|
files.each do |file|
|
41
|
-
# puts "Add '#{file}' to repository"
|
42
43
|
git.add(file)
|
43
44
|
end
|
44
45
|
git.commit_index('Initial commit')
|
45
46
|
end
|
46
47
|
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def expand_path(base_dir)
|
52
|
+
raise "Invalid directory name `{base_dir}`" if base_dir.nil? || !File.directory?(File.new(base_dir))
|
53
|
+
File.expand_path(base_dir)
|
54
|
+
end
|
47
55
|
end
|
48
56
|
end
|
49
57
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'open3'
|
2
1
|
module GemBootstrap
|
3
2
|
class MiscUtils
|
4
3
|
CustomError = Class.new(StandardError)
|
@@ -23,7 +22,9 @@ module GemBootstrap
|
|
23
22
|
str.split('_').map { |i| i.capitalize }.join
|
24
23
|
end
|
25
24
|
|
26
|
-
# List files base on
|
25
|
+
# List files base on simple criteria
|
26
|
+
#
|
27
|
+
# @param [Hash<Symbol, Object>] args keys and values of argument
|
27
28
|
def files(args = {})
|
28
29
|
opts = {
|
29
30
|
base_dir: Dir.pwd,
|
@@ -45,9 +46,12 @@ module GemBootstrap
|
|
45
46
|
(file_with_extension + file_with_no_extension).sort
|
46
47
|
end
|
47
48
|
|
48
|
-
# List files that do not have
|
49
|
+
# List files that do not have any extension
|
49
50
|
#
|
50
|
-
# @
|
51
|
+
# @param [String] base_dir the starting directory
|
52
|
+
# @param [String] wildcard the wildcard string e.g. '**' or '' (empty string)
|
53
|
+
# @param [Array<String>] non_exts list of file without extension
|
54
|
+
# @return [Array<String> list of matching files that do not have any extension
|
51
55
|
def no_extension_files(base_dir, wildcard, non_exts = [])
|
52
56
|
list = []
|
53
57
|
unless non_exts.empty?
|
@@ -61,13 +65,13 @@ module GemBootstrap
|
|
61
65
|
# @param [Array<String>] commands list of command
|
62
66
|
# @return [String] result of the command as the string
|
63
67
|
def shell(commands = [])
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
raise "Problem processing #{command}, #{e.message}"
|
69
|
-
end
|
68
|
+
raise "commands list must be valid and not empty" unless commands.present?
|
69
|
+
# Join the list of commands to a single string
|
70
|
+
command = commands.join(' ')
|
71
|
+
stdin, _stderr, _status = Open3.capture3(command)
|
70
72
|
stdin
|
73
|
+
rescue => e
|
74
|
+
raise "Problem processing `#{command}`, #{e.message}"
|
71
75
|
end
|
72
76
|
end
|
73
77
|
end
|
data/lib/gem_bootstrap.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
require 'grit'
|
2
|
+
require 'open3'
|
3
|
+
require 'thor'
|
4
|
+
require 'active_support'
|
5
|
+
require 'active_support/core_ext/object/blank'
|
6
|
+
require 'active_support/core_ext/hash/keys'
|
7
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
8
|
+
require_relative 'gem_bootstrap/version'
|
9
|
+
require_relative 'gem_bootstrap/cli'
|
10
|
+
require_relative 'gem_bootstrap/git_utils'
|
11
|
+
require_relative 'gem_bootstrap/misc_utils'
|
12
|
+
require_relative 'gem_bootstrap/gem_bootstrap'
|
6
13
|
include GemBootstrap
|
data/templates/dot_gitignore
CHANGED
data/templates/lib/newgem.rb
CHANGED
@@ -16,19 +16,18 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ['lib']
|
19
|
-
|
20
19
|
spec.add_runtime_dependency 'activesupport-core-ext', '~> 4.0.0.2'
|
21
20
|
spec.add_runtime_dependency 'thor', '~> 0.19.1'
|
22
|
-
|
23
21
|
spec.add_development_dependency 'awesome_print', '~> 1.2.0'
|
24
|
-
spec.add_development_dependency 'bundler', '~> 1.7.
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.7.3'
|
25
23
|
spec.add_development_dependency 'gem-ctags', '~> 1.0.6'
|
26
24
|
spec.add_development_dependency 'guard', '~> 2.6.1'
|
27
|
-
spec.add_development_dependency 'guard-minitest', '~> 2.3.
|
28
|
-
spec.add_development_dependency 'minitest', '~> 5.4.
|
25
|
+
spec.add_development_dependency 'guard-minitest', '~> 2.3.2'
|
26
|
+
spec.add_development_dependency 'minitest', '~> 5.4.2'
|
29
27
|
spec.add_development_dependency 'minitest-spec-context', '~> 0.0.3'
|
30
28
|
spec.add_development_dependency 'pry', '~> 0.10.0'
|
29
|
+
spec.add_development_dependency 'pry-byebug', '~> 2.0.0' if RUBY_VERSION >= '2.0.0'
|
31
30
|
spec.add_development_dependency 'rake', '~> 10.3.2'
|
32
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
31
|
+
spec.add_development_dependency 'rubocop', '~> 0.26.1'
|
33
32
|
spec.add_development_dependency 'yard', '~> 0.8.7'
|
34
33
|
end
|
@@ -16,20 +16,17 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ['lib']
|
19
|
-
|
20
|
-
# runtime dependencies
|
21
19
|
spec.add_runtime_dependency 'activesupport-core-ext', '~> 4.0.0.2'
|
22
20
|
spec.add_runtime_dependency 'thor', '~> 0.19.1'
|
23
|
-
|
24
|
-
# development dependencies
|
25
21
|
spec.add_development_dependency 'awesome_print', '~> 1.2.0'
|
26
|
-
spec.add_development_dependency 'bundler', '~> 1.7.
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.7.3'
|
27
23
|
spec.add_development_dependency 'gem-ctags', '~> 1.0.6'
|
28
24
|
spec.add_development_dependency 'guard', '~> 2.6.1'
|
29
25
|
spec.add_development_dependency 'guard-rspec', '~> 4.3.1'
|
30
|
-
spec.add_development_dependency 'pry', '~> 0.10.
|
26
|
+
spec.add_development_dependency 'pry', '~> 0.10.1'
|
27
|
+
spec.add_development_dependency 'pry-byebug', '~> 2.0.0' if RUBY_VERSION >= '2.0.0'
|
31
28
|
spec.add_development_dependency 'rake', '~> 10.3.2'
|
32
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
33
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.1.0'
|
30
|
+
spec.add_development_dependency 'rubocop', '~> 0.26.1'
|
34
31
|
spec.add_development_dependency 'yard', '~> 0.8.7'
|
35
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem_bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-09-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport-core-ext
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
requirements:
|
83
83
|
- - ~>
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 1.7.
|
85
|
+
version: 1.7.3
|
86
86
|
type: :development
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 1.7.
|
93
|
+
version: 1.7.3
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: gem-ctags
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,7 +130,7 @@ dependencies:
|
|
130
130
|
requirements:
|
131
131
|
- - ~>
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
version: 2.3.
|
133
|
+
version: 2.3.2
|
134
134
|
type: :development
|
135
135
|
prerelease: false
|
136
136
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -138,7 +138,7 @@ dependencies:
|
|
138
138
|
requirements:
|
139
139
|
- - ~>
|
140
140
|
- !ruby/object:Gem::Version
|
141
|
-
version: 2.3.
|
141
|
+
version: 2.3.2
|
142
142
|
- !ruby/object:Gem::Dependency
|
143
143
|
name: minitest
|
144
144
|
requirement: !ruby/object:Gem::Requirement
|
@@ -146,7 +146,7 @@ dependencies:
|
|
146
146
|
requirements:
|
147
147
|
- - ~>
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version: 5.4.
|
149
|
+
version: 5.4.2
|
150
150
|
type: :development
|
151
151
|
prerelease: false
|
152
152
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -154,7 +154,7 @@ dependencies:
|
|
154
154
|
requirements:
|
155
155
|
- - ~>
|
156
156
|
- !ruby/object:Gem::Version
|
157
|
-
version: 5.4.
|
157
|
+
version: 5.4.2
|
158
158
|
- !ruby/object:Gem::Dependency
|
159
159
|
name: minitest-spec-context
|
160
160
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,7 +178,7 @@ dependencies:
|
|
178
178
|
requirements:
|
179
179
|
- - ~>
|
180
180
|
- !ruby/object:Gem::Version
|
181
|
-
version: 0.10.
|
181
|
+
version: 0.10.1
|
182
182
|
type: :development
|
183
183
|
prerelease: false
|
184
184
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -186,7 +186,7 @@ dependencies:
|
|
186
186
|
requirements:
|
187
187
|
- - ~>
|
188
188
|
- !ruby/object:Gem::Version
|
189
|
-
version: 0.10.
|
189
|
+
version: 0.10.1
|
190
190
|
- !ruby/object:Gem::Dependency
|
191
191
|
name: rake
|
192
192
|
requirement: !ruby/object:Gem::Requirement
|
@@ -210,7 +210,7 @@ dependencies:
|
|
210
210
|
requirements:
|
211
211
|
- - ~>
|
212
212
|
- !ruby/object:Gem::Version
|
213
|
-
version: 0.
|
213
|
+
version: 0.26.1
|
214
214
|
type: :development
|
215
215
|
prerelease: false
|
216
216
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -218,7 +218,7 @@ dependencies:
|
|
218
218
|
requirements:
|
219
219
|
- - ~>
|
220
220
|
- !ruby/object:Gem::Version
|
221
|
-
version: 0.
|
221
|
+
version: 0.26.1
|
222
222
|
- !ruby/object:Gem::Dependency
|
223
223
|
name: yard
|
224
224
|
requirement: !ruby/object:Gem::Requirement
|