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 CHANGED
@@ -1,3 +1,9 @@
1
+ #### 0.2.5
2
+
3
+ - Update the gem's dependencies
4
+ - Improve the code structure
5
+ - Misc code cleanup
6
+
1
7
  #### 0.2.4
2
8
 
3
9
  - Merge 2nd pull request by [Nick den Engelsman][] - Thanks!
data/README.md CHANGED
@@ -10,7 +10,6 @@
10
10
 
11
11
  Generate the starting template for creating ruby gem in ruby in just one command.
12
12
 
13
- TL;DR;
14
13
  First install the gem
15
14
 
16
15
  ```sh
@@ -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.0'
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.1'
41
- spec.add_development_dependency 'minitest', '~> 5.4.0'
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.0'
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.24.1'
42
+ spec.add_development_dependency 'rubocop', '~> 0.26.1'
46
43
  spec.add_development_dependency 'yard', '~> 0.8.7'
47
44
  end
@@ -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
- $gem_bootstrap [GEM_NAME] -g, --github-id [GITHUB_ID] -e, --email [EMAIL] -a, --author [AUTHOR] --test-framework [FRAMEWORK]
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
- e.g. create a gem name 'awesome_gem'
19
- $gem_bootstrap awesome_gem -g awesome_developer -e cool@awesomedev.com -a 'John Guru II'
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 repo from a given directory
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 = File.expand_path(base_dir) # so that it works with ~/codes/etc
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: base_dir)
22
- git_add(files, base_dir: base_dir, gem_name: gem_name)
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 base directory
28
- def git_init(options = {})
29
- current_dir = File.expand_path(options[:base_dir])
30
- base_dir = options[:base_dir] || Dir.pwd
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
- def git_add(files, options = {})
37
- base_dir = File.expand_path(options[:base_dir])
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 some extension
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 the extension
49
+ # List files that do not have any extension
49
50
  #
50
- # @return list of files that does not have any extension
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
- begin
65
- command = commands.join(' ')
66
- stdin, _stderr, _status = Open3.capture3(command)
67
- rescue => e
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
@@ -1,3 +1,3 @@
1
1
  module GemBootstrap
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
data/lib/gem_bootstrap.rb CHANGED
@@ -1,6 +1,13 @@
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'
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
@@ -15,5 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
- # Custom generated files
19
18
  .ruby-version
@@ -1,4 +1,3 @@
1
- # Make use of core_extension (don't invent the wheel)
2
1
  require 'active_support'
3
2
  require 'active_support/core_ext/object/blank'
4
3
  require 'active_support/core_ext/hash/keys'
@@ -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.0'
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.1'
28
- spec.add_development_dependency 'minitest', '~> 5.4.0'
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.24.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.0'
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.0'
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.0.0'
33
- spec.add_development_dependency 'rubocop', '~> 0.24.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
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-08-20 00:00:00.000000000 Z
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.0
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.0
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.1
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.1
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.0
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.0
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.0
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.0
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.24.1
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.24.1
221
+ version: 0.26.1
222
222
  - !ruby/object:Gem::Dependency
223
223
  name: yard
224
224
  requirement: !ruby/object:Gem::Requirement