gem_bootstrap 0.1.0 → 0.1.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 +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +93 -5
- data/CHANGELOGS.md +4 -0
- data/Gemfile +1 -1
- data/README.md +25 -12
- data/Rakefile +10 -10
- data/bin/gem_bootstrap +6 -2
- data/gem_bootstrap.gemspec +26 -26
- data/lib/gem_bootstrap.rb +6 -6
- data/lib/gem_bootstrap/cli.rb +29 -29
- data/lib/gem_bootstrap/gem_bootstrap.rb +17 -20
- data/lib/gem_bootstrap/git_utils.rb +7 -7
- data/lib/gem_bootstrap/misc_utils.rb +8 -9
- data/lib/gem_bootstrap/version.rb +1 -1
- data/templates/bin/newgem +5 -1
- data/templates/lib/newgem/cli.rb +1 -1
- data/templates/lib/newgem/newgem.rb +0 -1
- data/test/lib/gem_bootstrap/test_gem_bootstrap.rb +5 -5
- data/test/test_helper.rb +7 -7
- metadata +4 -4
- data/rubocop-todo.yml +0 -36
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 70e85f8995690989efad2c33397d4dc60f86ed00
|
|
4
|
+
data.tar.gz: 8f860ee501e0ce369de06cb9fa67d49fc5daca85
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c26a592d0c238ecdea5706eb9ddd0f59e7e77bfacda73fad5f428e2d1beb859ebdd2bd2e2bd59cdb55a8393e99e33b9ff41fe6aa294edda5654aec25a95327a4
|
|
7
|
+
data.tar.gz: 270bd46ca637b4f503cf27f95dba25e520ee78db82110749e7bbc0d4b233d8ea5b7c5f1a01556fa108e12a7a4728f1c0f22cb4df9ed389eb357d70955b5fa28f
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,9 +1,97 @@
|
|
|
1
|
-
# This is the configuration used to check the rubocop source code.
|
|
2
1
|
AllCops:
|
|
3
2
|
Include:
|
|
4
|
-
-
|
|
5
|
-
-
|
|
6
|
-
-
|
|
3
|
+
- Gemfile
|
|
4
|
+
- Rakefile
|
|
5
|
+
- bin/*
|
|
6
|
+
- gem_bootstrap.gemspec
|
|
7
|
+
- lib/**/*.rb
|
|
8
|
+
- test/**/*.rb
|
|
7
9
|
Exclude:
|
|
8
10
|
- templates/**/*
|
|
9
|
-
|
|
11
|
+
# Avoid long parameter lists
|
|
12
|
+
ParameterLists:
|
|
13
|
+
Max: 5
|
|
14
|
+
CountKeywordArgs: true
|
|
15
|
+
|
|
16
|
+
MethodLength:
|
|
17
|
+
CountComments: false
|
|
18
|
+
Max: 15
|
|
19
|
+
|
|
20
|
+
# Avoid more than `Max` levels of nesting.
|
|
21
|
+
BlockNesting:
|
|
22
|
+
Max: 4
|
|
23
|
+
|
|
24
|
+
# Align with the style guide.
|
|
25
|
+
CollectionMethods:
|
|
26
|
+
PreferredMethods:
|
|
27
|
+
collect: 'map'
|
|
28
|
+
inject: 'reduce'
|
|
29
|
+
find: 'detect'
|
|
30
|
+
find_all: 'select'
|
|
31
|
+
|
|
32
|
+
# Do not force public/protected/private keyword to be indented at the same
|
|
33
|
+
# level as the def keyword. My personal preference is to outdent these keywords
|
|
34
|
+
# because I think when scanning code it makes it easier to identify the
|
|
35
|
+
# sections of code and visually separate them. When the keyword is at the same
|
|
36
|
+
# level I think it sort of blends in with the def keywords and makes it harder
|
|
37
|
+
# to scan the code and see where the sections are.
|
|
38
|
+
AccessModifierIndentation:
|
|
39
|
+
Enabled: false
|
|
40
|
+
|
|
41
|
+
# Limit line length
|
|
42
|
+
LineLength:
|
|
43
|
+
Enabled: false
|
|
44
|
+
|
|
45
|
+
# Disable documentation checking until a class needs to be documented once
|
|
46
|
+
Documentation:
|
|
47
|
+
Enabled: false
|
|
48
|
+
|
|
49
|
+
# Enforce Ruby 1.8-compatible hash syntax
|
|
50
|
+
HashSyntax:
|
|
51
|
+
Enabled: true
|
|
52
|
+
|
|
53
|
+
# No spaces inside hash literals
|
|
54
|
+
SpaceInsideHashLiteralBraces:
|
|
55
|
+
EnforcedStyle: no_space
|
|
56
|
+
|
|
57
|
+
# Allow dots at the end of lines
|
|
58
|
+
DotPosition:
|
|
59
|
+
Enabled: false
|
|
60
|
+
|
|
61
|
+
# Don't require magic comment at the top of every file
|
|
62
|
+
Encoding:
|
|
63
|
+
Enabled: false
|
|
64
|
+
|
|
65
|
+
# Enforce outdenting of access modifiers (i.e. public, private, protected)
|
|
66
|
+
AccessModifierIndentation:
|
|
67
|
+
EnforcedStyle: outdent
|
|
68
|
+
|
|
69
|
+
EmptyLinesAroundAccessModifier:
|
|
70
|
+
Enabled: true
|
|
71
|
+
|
|
72
|
+
# Align ends correctly
|
|
73
|
+
EndAlignment:
|
|
74
|
+
AlignWith: variable
|
|
75
|
+
|
|
76
|
+
# Indentation of when/else
|
|
77
|
+
CaseIndentation:
|
|
78
|
+
IndentWhenRelativeTo: end
|
|
79
|
+
IndentOneStep: false
|
|
80
|
+
|
|
81
|
+
DoubleNegation:
|
|
82
|
+
Enabled: false
|
|
83
|
+
|
|
84
|
+
PercentLiteralDelimiters:
|
|
85
|
+
PreferredDelimiters:
|
|
86
|
+
'%': ()
|
|
87
|
+
'%i': ()
|
|
88
|
+
'%q': ()
|
|
89
|
+
'%Q': ()
|
|
90
|
+
'%r': '{}'
|
|
91
|
+
'%s': ()
|
|
92
|
+
'%w': '[]'
|
|
93
|
+
'%W': '[]'
|
|
94
|
+
'%x': ()
|
|
95
|
+
|
|
96
|
+
StringLiterals:
|
|
97
|
+
EnforcedStyle: double_quotes
|
data/CHANGELOGS.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -11,9 +11,24 @@
|
|
|
11
11
|
Generate the starting template for creating ruby gem in ruby in just one command.
|
|
12
12
|
|
|
13
13
|
TL;DR
|
|
14
|
+
First install the gem
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
gem install gem_bootstrap
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
then generate the new gem
|
|
21
|
+
|
|
14
22
|
```sh
|
|
15
|
-
|
|
23
|
+
gem_bootstrap awesome_gem --github-id awesome_developer --email cool@awesomedev.com --author 'John Guru II'
|
|
16
24
|
```
|
|
25
|
+
|
|
26
|
+
or the shot version
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
gem_bootstrap awesome_gem -g awesome_developer -e cool@awesomedev.com -a 'John Guru II'
|
|
30
|
+
```
|
|
31
|
+
|
|
17
32
|
Note: this gem will be release following the [Semantic Versioning][] start from `0.1.0`
|
|
18
33
|
|
|
19
34
|
### Features:
|
|
@@ -50,22 +65,20 @@ gem install gem_bootstrap
|
|
|
50
65
|
Then just run the `gem_bootstrap` without any argument for list of help
|
|
51
66
|
|
|
52
67
|
```
|
|
53
|
-
gem_bootstrap
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
68
|
+
gem_bootstrap [GEM_NAME]
|
|
69
|
+
-g, --github-id [GITHUB_ID]
|
|
70
|
+
-e, --email [EMAIL]
|
|
71
|
+
-a, --author [AUTHOR]
|
|
57
72
|
e.g.
|
|
58
|
-
gem_bootstrap
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
gem_bootstrap help [COMMAND] # Describe available commands or one specific command
|
|
63
|
-
gem_bootstrap usage # Display help screen
|
|
73
|
+
gem_bootstrap awesome_gem
|
|
74
|
+
--github-id awesome_developer
|
|
75
|
+
--email cool@awesomedev.com
|
|
76
|
+
--author 'John Guru II'
|
|
64
77
|
```
|
|
65
78
|
To generate the gem just type the command like
|
|
66
79
|
|
|
67
80
|
```
|
|
68
|
-
gem_bootstrap
|
|
81
|
+
gem_bootstrap awesome_gem --github-id awesome_developer -- email cool@awesomedev.com --author 'John Guru II'
|
|
69
82
|
```
|
|
70
83
|
Which should output something like
|
|
71
84
|
|
data/Rakefile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
project_name =
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
require "rake/testtask"
|
|
3
|
+
project_name = "gem_bootstrap"
|
|
4
4
|
|
|
5
5
|
Rake::TestTask.new do |t|
|
|
6
6
|
t.libs << "lib/#{project_name}"
|
|
@@ -11,20 +11,20 @@ end
|
|
|
11
11
|
task default: [:test, :rubocop]
|
|
12
12
|
|
|
13
13
|
task :pry do
|
|
14
|
-
require
|
|
15
|
-
require
|
|
16
|
-
require_relative
|
|
14
|
+
require "pry"
|
|
15
|
+
require "awesome_print"
|
|
16
|
+
require_relative "lib/gem_bootstrap"
|
|
17
17
|
include GemBootstrap
|
|
18
18
|
ARGV.clear
|
|
19
19
|
Pry.start
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
require
|
|
23
|
-
desc
|
|
22
|
+
require "rubocop/rake_task"
|
|
23
|
+
desc "Run RuboCop on the lib directory"
|
|
24
24
|
Rubocop::RakeTask.new(:rubocop) do |task|
|
|
25
|
-
task.patterns = [
|
|
25
|
+
task.patterns = ["lib/**/*.rb"]
|
|
26
26
|
# only show the files with failures
|
|
27
|
-
task.formatters = [
|
|
27
|
+
task.formatters = ["files"]
|
|
28
28
|
# don't abort rake on failure
|
|
29
29
|
task.fail_on_error = false
|
|
30
30
|
end
|
data/bin/gem_bootstrap
CHANGED
data/gem_bootstrap.gemspec
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
|
-
lib = File.expand_path(
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require
|
|
4
|
+
require "gem_bootstrap/version"
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name =
|
|
7
|
+
spec.name = "gem_bootstrap"
|
|
8
8
|
spec.version = GemBootstrap::VERSION
|
|
9
|
-
spec.authors = [
|
|
10
|
-
spec.email = [
|
|
9
|
+
spec.authors = ["Burin Choomnuan"]
|
|
10
|
+
spec.email = ["agilecreativity@gmail.com"]
|
|
11
11
|
spec.summary = %q(Bootstrap the creation of ruby gem so that you don't have to start from scratch)
|
|
12
12
|
spec.description = %q(Bootstrap the creation of ruby gem so that you don't have to start from scratch.
|
|
13
|
-
Build with simple, sensible default and very easy to extend
|
|
14
|
-
|
|
15
|
-
spec.
|
|
16
|
-
spec.
|
|
13
|
+
Build with simple, sensible default and very easy to extend.
|
|
14
|
+
TL;DR `gem_bootstrap [GEMNAME] -g github_id -e your@email.com -a 'John Guru')
|
|
15
|
+
spec.homepage = "https://github.com/agilecreativity/gem_bootstrap"
|
|
16
|
+
spec.license = "MIT"
|
|
17
|
+
spec.files = Dir.glob("{bin,lib,templates}/**/*") + %w[Gemfile
|
|
17
18
|
Rakefile
|
|
18
19
|
gem_bootstrap.gemspec
|
|
19
20
|
README.md
|
|
20
21
|
CHANGELOGS.md
|
|
21
22
|
LICENSE
|
|
22
23
|
.rubocop.yml
|
|
23
|
-
.gitignore
|
|
24
|
-
rubocop-todo.yml)
|
|
24
|
+
.gitignore]
|
|
25
25
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
26
|
-
spec.test_files = Dir.glob(
|
|
27
|
-
spec.require_paths = [
|
|
28
|
-
spec.add_runtime_dependency
|
|
29
|
-
spec.add_runtime_dependency
|
|
30
|
-
spec.add_development_dependency
|
|
31
|
-
spec.add_development_dependency
|
|
32
|
-
spec.add_development_dependency
|
|
33
|
-
spec.add_development_dependency
|
|
34
|
-
spec.add_development_dependency
|
|
35
|
-
spec.add_development_dependency
|
|
36
|
-
spec.add_development_dependency
|
|
37
|
-
spec.add_development_dependency
|
|
38
|
-
spec.add_development_dependency
|
|
39
|
-
spec.add_development_dependency
|
|
40
|
-
spec.add_development_dependency
|
|
26
|
+
spec.test_files = Dir.glob("test/**/*")
|
|
27
|
+
spec.require_paths = ["lib"]
|
|
28
|
+
spec.add_runtime_dependency "thor", "~> 0.19"
|
|
29
|
+
spec.add_runtime_dependency "grit", "~> 2.5"
|
|
30
|
+
spec.add_development_dependency "awesome_print", "~> 1.2"
|
|
31
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
|
32
|
+
spec.add_development_dependency "gem-ctags", "~> 1.0"
|
|
33
|
+
spec.add_development_dependency "minitest", "~> 5.3"
|
|
34
|
+
spec.add_development_dependency "minitest-spec-context", "~> 0.0.3"
|
|
35
|
+
spec.add_development_dependency "guard", "~> 2.6"
|
|
36
|
+
spec.add_development_dependency "guard-minitest", "~> 2.2"
|
|
37
|
+
spec.add_development_dependency "pry", "~> 0.9"
|
|
38
|
+
spec.add_development_dependency "rake", "~> 10.3"
|
|
39
|
+
spec.add_development_dependency "rubocop", "~> 0.21"
|
|
40
|
+
spec.add_development_dependency "yard", "~> 0.8.7"
|
|
41
41
|
end
|
data/lib/gem_bootstrap.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
require_relative
|
|
2
|
-
require_relative
|
|
3
|
-
require_relative
|
|
4
|
-
require_relative
|
|
5
|
-
require_relative
|
|
6
|
-
require_relative
|
|
1
|
+
require_relative "./gem_bootstrap/version"
|
|
2
|
+
require_relative "./gem_bootstrap/cli"
|
|
3
|
+
require_relative "./gem_bootstrap/git_utils"
|
|
4
|
+
require_relative "./gem_bootstrap/misc_utils"
|
|
5
|
+
require_relative "./gem_bootstrap/gem_bootstrap"
|
|
6
|
+
require_relative "./gem_bootstrap/core_ext/object/blank"
|
|
7
7
|
include GemBootstrap
|
data/lib/gem_bootstrap/cli.rb
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
require
|
|
2
|
-
require_relative
|
|
3
|
-
require_relative
|
|
1
|
+
require "thor"
|
|
2
|
+
require_relative "./misc_utils"
|
|
3
|
+
require_relative "./git_utils"
|
|
4
4
|
module GemBootstrap
|
|
5
5
|
class CLI < Thor::Group
|
|
6
6
|
include Thor::Actions
|
|
7
7
|
argument :name
|
|
8
8
|
class_option :github_id,
|
|
9
|
-
aliases:
|
|
10
|
-
desc:
|
|
9
|
+
aliases: "-g",
|
|
10
|
+
desc: "github profile id",
|
|
11
11
|
required: true
|
|
12
12
|
class_option :author,
|
|
13
|
-
aliases:
|
|
14
|
-
desc:
|
|
13
|
+
aliases: "-a",
|
|
14
|
+
desc: "Full name of the author",
|
|
15
15
|
required: true
|
|
16
16
|
class_option :email,
|
|
17
|
-
aliases:
|
|
18
|
-
desc:
|
|
17
|
+
aliases: "-e",
|
|
18
|
+
desc: "Email for github",
|
|
19
19
|
required: true
|
|
20
20
|
def self.source_root
|
|
21
21
|
File.dirname(__FILE__)
|
|
@@ -23,30 +23,30 @@ module GemBootstrap
|
|
|
23
23
|
|
|
24
24
|
# rubocop:disable MethodLength, LineLength
|
|
25
25
|
def create_lib_file
|
|
26
|
-
template
|
|
27
|
-
template
|
|
28
|
-
template
|
|
29
|
-
template
|
|
30
|
-
template
|
|
31
|
-
template
|
|
32
|
-
template
|
|
33
|
-
template
|
|
34
|
-
template
|
|
35
|
-
template
|
|
36
|
-
template
|
|
37
|
-
template
|
|
38
|
-
template
|
|
39
|
-
template
|
|
40
|
-
template
|
|
41
|
-
template
|
|
42
|
-
template
|
|
43
|
-
template
|
|
44
|
-
template
|
|
26
|
+
template "../../templates/README.md", "#{name}/README.md"
|
|
27
|
+
template "../../templates/CHANGELOGS.md", "#{name}/CHANGELOGS.md"
|
|
28
|
+
template "../../templates/dot_yardopts", "#{name}/.yardopts"
|
|
29
|
+
template "../../templates/dot_gitignore", "#{name}/.gitignore"
|
|
30
|
+
template "../../templates/Gemfile", "#{name}/Gemfile"
|
|
31
|
+
template "../../templates/Rakefile", "#{name}/Rakefile"
|
|
32
|
+
template "../../templates/Guardfile", "#{name}/Guardfile"
|
|
33
|
+
template "../../templates/dot_rubocop.yml", "#{name}/.rubocop.yml"
|
|
34
|
+
template "../../templates/rubocop-todo.yml", "#{name}/rubocop-todo.yml"
|
|
35
|
+
template "../../templates/newgem.gemspec.tt", "#{name}/#{name}.gemspec"
|
|
36
|
+
template "../../templates/bin/newgem", "#{name}/bin/#{name}"
|
|
37
|
+
template "../../templates/lib/newgem.rb", "#{name}/lib/#{name}.rb"
|
|
38
|
+
template "../../templates/lib/newgem/version.rb", "#{name}/lib/#{name}/version.rb"
|
|
39
|
+
template "../../templates/lib/newgem/logger.rb", "#{name}/lib/#{name}/logger.rb"
|
|
40
|
+
template "../../templates/lib/newgem/cli.rb", "#{name}/lib/#{name}/cli.rb"
|
|
41
|
+
template "../../templates/lib/newgem/newgem.rb", "#{name}/lib/#{name}/#{name}.rb"
|
|
42
|
+
template "../../templates/lib/newgem/core_ext/hash/keys.rb", "#{name}/lib/#{name}/core_ext/hash/keys.rb"
|
|
43
|
+
template "../../templates/test/test_helper.rb", "#{name}/test/test_helper.rb"
|
|
44
|
+
template "../../templates/test/lib/newgem/test_newgem.rb", "#{name}/test/lib/#{name}/test_#{name}.rb"
|
|
45
45
|
end
|
|
46
46
|
# rubocop:enable all
|
|
47
47
|
|
|
48
48
|
def copy_licence
|
|
49
|
-
copy_file
|
|
49
|
+
copy_file "../../templates/MIT_LICENSE", "#{name}/LICENSE"
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
# Create the git project to store our generated code
|
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
require
|
|
2
|
-
require_relative
|
|
1
|
+
require "thor"
|
|
2
|
+
require_relative "./cli"
|
|
3
3
|
module GemBootstrap
|
|
4
4
|
class MainCLI < Thor
|
|
5
5
|
register GemBootstrap::CLI,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
"generate",
|
|
7
|
+
"generate",
|
|
8
|
+
"Generate the starting template for CLI"
|
|
9
9
|
|
|
10
|
-
desc
|
|
10
|
+
desc "usage", "Display help screen"
|
|
11
11
|
def usage
|
|
12
12
|
generate_usage = <<-EOT
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
|
|
14
|
+
Usage/Synopsis:
|
|
15
|
+
|
|
16
|
+
$gem_bootstrap [GEM_NAME] -g, --github-id [GITHUB_ID] -e, --email [EMAIL] -a, --author [AUTHOR]
|
|
17
|
+
|
|
17
18
|
e.g. create a gem name 'awesome_gem'
|
|
18
|
-
gem_bootstrap
|
|
19
|
-
--github-id awesome_developer
|
|
20
|
-
--email cool@awesomedev.com
|
|
21
|
-
--author 'John Guru II'
|
|
22
|
-
EOT
|
|
19
|
+
$gem_bootstrap awesome_gem -g awesome_developer -e cool@awesomedev.com -a 'John Guru II'
|
|
23
20
|
|
|
24
|
-
help_text = <<-EOT
|
|
25
|
-
gem_bootstrap help [COMMAND] # Describe available commands or one specific command
|
|
26
|
-
gem_bootstrap usage # Display help screen
|
|
27
21
|
EOT
|
|
28
|
-
|
|
22
|
+
# help_text = <<-EOT
|
|
23
|
+
# gem_bootstrap help [COMMAND] # Describe available commands or one specific command
|
|
24
|
+
# gem_bootstrap usage # Display help screen
|
|
25
|
+
# EOT
|
|
29
26
|
puts generate_usage
|
|
30
|
-
puts help_text.gsub(/^\s+/, '')
|
|
27
|
+
# puts help_text.gsub(/^\s+/, '')
|
|
31
28
|
end
|
|
32
29
|
|
|
33
30
|
default_task :usage
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "grit"
|
|
2
2
|
module GemBootstrap
|
|
3
3
|
class GitUtils
|
|
4
4
|
class << self
|
|
@@ -9,14 +9,14 @@ module GemBootstrap
|
|
|
9
9
|
def create_git_project(base_dir, gem_name)
|
|
10
10
|
base_dir = File.expand_path(base_dir) # so that it works with ~/codes/etc
|
|
11
11
|
files = MiscUtils.files base_dir: base_dir,
|
|
12
|
-
non_exts: %w
|
|
12
|
+
non_exts: %w[Gemfile
|
|
13
13
|
Rakefile
|
|
14
14
|
Guardfile
|
|
15
15
|
LICENSE
|
|
16
16
|
.rubocop.yml
|
|
17
17
|
.yardopts
|
|
18
|
-
.gitignore
|
|
19
|
-
exts: %w
|
|
18
|
+
.gitignore] << gem_name,
|
|
19
|
+
exts: %w[md rb gemspec yml],
|
|
20
20
|
recursive: true
|
|
21
21
|
git_init(base_dir: base_dir)
|
|
22
22
|
git_add(files, base_dir: base_dir, gem_name: gem_name)
|
|
@@ -29,19 +29,19 @@ module GemBootstrap
|
|
|
29
29
|
current_dir = File.expand_path(options[:base_dir])
|
|
30
30
|
base_dir = options[:base_dir] || Dir.pwd
|
|
31
31
|
Dir.chdir(base_dir)
|
|
32
|
-
MiscUtils.shell(%w
|
|
32
|
+
MiscUtils.shell(%w[git init] << base_dir)
|
|
33
33
|
Dir.chdir(current_dir)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def git_add(files, options = {})
|
|
37
37
|
base_dir = File.expand_path(options[:base_dir])
|
|
38
38
|
Dir.chdir(base_dir) do
|
|
39
|
-
git = Grit::Repo.new(File.expand_path(
|
|
39
|
+
git = Grit::Repo.new(File.expand_path("."))
|
|
40
40
|
files.each do |file|
|
|
41
41
|
# puts "Add '#{file}' to repository"
|
|
42
42
|
git.add(file)
|
|
43
43
|
end
|
|
44
|
-
git.commit_index(
|
|
44
|
+
git.commit_index("Initial commit")
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "open3"
|
|
2
2
|
module GemBootstrap
|
|
3
3
|
class MiscUtils
|
|
4
|
-
|
|
5
4
|
CustomError = Class.new(StandardError)
|
|
6
5
|
|
|
7
6
|
class << self
|
|
@@ -11,7 +10,7 @@ module GemBootstrap
|
|
|
11
10
|
# @param [String] str the input string
|
|
12
11
|
def snake_case(str)
|
|
13
12
|
return str.downcase if str =~ /^[A-Z_]+$/
|
|
14
|
-
str.gsub(/\B[A-Z]/, '_\&').squeeze(
|
|
13
|
+
str.gsub(/\B[A-Z]/, '_\&').squeeze("_") =~ /_*(.*)/
|
|
15
14
|
$+.downcase
|
|
16
15
|
end
|
|
17
16
|
|
|
@@ -21,7 +20,7 @@ module GemBootstrap
|
|
|
21
20
|
# @param [String] str the input string
|
|
22
21
|
def camel_case(str)
|
|
23
22
|
return str if str !~ /_/ && str =~ /[A-Z]+.*/
|
|
24
|
-
str.split(
|
|
23
|
+
str.split("_").map { |i| i.capitalize }.join
|
|
25
24
|
end
|
|
26
25
|
|
|
27
26
|
# List files base on some extension
|
|
@@ -36,11 +35,11 @@ module GemBootstrap
|
|
|
36
35
|
base_dir = opts[:base_dir]
|
|
37
36
|
fail CustomError, "The directory #{base_dir} is not valid or or not readable!" unless File.exist?(base_dir)
|
|
38
37
|
|
|
39
|
-
wildcard = opts[:recursive] ?
|
|
38
|
+
wildcard = opts[:recursive] ? "**" : ""
|
|
40
39
|
exts = opts[:exts]
|
|
41
40
|
non_exts = opts[:non_exts]
|
|
42
41
|
|
|
43
|
-
file_with_extension = Dir.glob(File.join(base_dir, wildcard, "*.{#{exts.join(
|
|
42
|
+
file_with_extension = Dir.glob(File.join(base_dir, wildcard, "*.{#{exts.join(",")}}"))
|
|
44
43
|
file_with_no_extension = no_extension_files(base_dir, wildcard, non_exts)
|
|
45
44
|
|
|
46
45
|
(file_with_extension + file_with_no_extension).sort
|
|
@@ -52,7 +51,7 @@ module GemBootstrap
|
|
|
52
51
|
def no_extension_files(base_dir, wildcard, non_exts = [])
|
|
53
52
|
list = []
|
|
54
53
|
unless non_exts.empty?
|
|
55
|
-
list = Dir.glob(File.join(base_dir, wildcard, "{#{non_exts.join(
|
|
54
|
+
list = Dir.glob(File.join(base_dir, wildcard, "{#{non_exts.join(",")}}"))
|
|
56
55
|
end
|
|
57
56
|
list
|
|
58
57
|
end
|
|
@@ -63,9 +62,9 @@ module GemBootstrap
|
|
|
63
62
|
# @return [String] result of the command as the string
|
|
64
63
|
def shell(commands = [])
|
|
65
64
|
begin
|
|
66
|
-
command = commands.join(
|
|
65
|
+
command = commands.join(" ")
|
|
67
66
|
stdin, _stderr, _status = Open3.capture3(command)
|
|
68
|
-
rescue
|
|
67
|
+
rescue => e
|
|
69
68
|
raise "Problem processing #{command}, #{e.message}"
|
|
70
69
|
end
|
|
71
70
|
stdin
|
data/templates/bin/newgem
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
require_relative '../lib/<%= name %>'
|
|
3
3
|
include <%= MiscUtils.camel_case(name) %>
|
|
4
|
-
|
|
4
|
+
if ARGV.empty?
|
|
5
|
+
<%= MiscUtils.camel_case(name) %>::CLI.start(%w[usage])
|
|
6
|
+
else
|
|
7
|
+
<%= MiscUtils.camel_case(name) %>::CLI.start(%w[execute].concat(ARGV))
|
|
8
|
+
end
|
data/templates/lib/newgem/cli.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require_relative
|
|
2
|
-
require
|
|
1
|
+
require_relative "../../test_helper"
|
|
2
|
+
require "fileutils"
|
|
3
3
|
describe GemBootstrap do
|
|
4
|
-
context
|
|
5
|
-
it
|
|
6
|
-
|
|
4
|
+
context "#dummy_test" do
|
|
5
|
+
it "must pass the simple test" do
|
|
6
|
+
"string".wont_be_nil
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
end
|
data/test/test_helper.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
7
|
-
require_relative
|
|
1
|
+
require "minitest"
|
|
2
|
+
require "minitest/autorun"
|
|
3
|
+
require "minitest/pride"
|
|
4
|
+
require "minitest-spec-context"
|
|
5
|
+
require "pry"
|
|
6
|
+
require "awesome_print"
|
|
7
|
+
require_relative "../lib/gem_bootstrap"
|
|
8
8
|
include GemBootstrap
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gem_bootstrap
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Burin Choomnuan
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-05-
|
|
11
|
+
date: 2014-05-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -194,7 +194,8 @@ dependencies:
|
|
|
194
194
|
version: 0.8.7
|
|
195
195
|
description: |-
|
|
196
196
|
Bootstrap the creation of ruby gem so that you don't have to start from scratch.
|
|
197
|
-
Build with simple, sensible default and very easy to extend
|
|
197
|
+
Build with simple, sensible default and very easy to extend.
|
|
198
|
+
TL;DR `gem_bootstrap [GEMNAME] -g github_id -e your@email.com -a 'John Guru'
|
|
198
199
|
email:
|
|
199
200
|
- agilecreativity@gmail.com
|
|
200
201
|
executables:
|
|
@@ -219,7 +220,6 @@ files:
|
|
|
219
220
|
- lib/gem_bootstrap/git_utils.rb
|
|
220
221
|
- lib/gem_bootstrap/misc_utils.rb
|
|
221
222
|
- lib/gem_bootstrap/version.rb
|
|
222
|
-
- rubocop-todo.yml
|
|
223
223
|
- templates/CHANGELOGS.md
|
|
224
224
|
- templates/GNU_LICENSE
|
|
225
225
|
- templates/Gemfile
|
data/rubocop-todo.yml
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# This configuration was generated by `rubocop --auto-gen-config`
|
|
2
|
-
# on 2014-05-09 13:05:30 +1000 using RuboCop version 0.21.0.
|
|
3
|
-
# The point is for the user to remove these configuration records
|
|
4
|
-
# one by one as the offenses are removed from the code base.
|
|
5
|
-
# Note that changes in the inspected code, or installation of new
|
|
6
|
-
# versions of RuboCop, may require this file to be generated again.
|
|
7
|
-
|
|
8
|
-
# Offense count: 1
|
|
9
|
-
AsciiComments:
|
|
10
|
-
Enabled: false
|
|
11
|
-
|
|
12
|
-
# Offense count: 14
|
|
13
|
-
Documentation:
|
|
14
|
-
Enabled: false
|
|
15
|
-
|
|
16
|
-
# Offense count: 7
|
|
17
|
-
LineLength:
|
|
18
|
-
Max: 91
|
|
19
|
-
|
|
20
|
-
# Offense count: 2
|
|
21
|
-
# Configuration parameters: CountComments.
|
|
22
|
-
MethodLength:
|
|
23
|
-
Max: 20
|
|
24
|
-
|
|
25
|
-
# Offense count: 4
|
|
26
|
-
RescueModifier:
|
|
27
|
-
Enabled: false
|
|
28
|
-
|
|
29
|
-
# Offense count: 1
|
|
30
|
-
# Cop supports --auto-correct.
|
|
31
|
-
SpaceAroundOperators:
|
|
32
|
-
Enabled: true
|
|
33
|
-
|
|
34
|
-
# Offense count: 1
|
|
35
|
-
Void:
|
|
36
|
-
Enabled: false
|