gbud 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b7e2f94ee9de9401c74cf7ccba14ebe62bf010f1
4
- data.tar.gz: 84e58b4233481373ebc72bc027cccf8da80dcd4f
2
+ SHA256:
3
+ metadata.gz: '08400d19d7eaebaa06fa06c93e65cda305fdeb19a5157777eb5ae5710f302a1b'
4
+ data.tar.gz: 29ef7e5b4ba0e28cc7980e25f2fccbb2faedef4d9a321cc7e112907a0411b65a
5
5
  SHA512:
6
- metadata.gz: b7ed8be48ba2c998643ecc1f6dc0326e046724dd6e1aec61e6eca160cb5d4cc1aaef4a11b435f7642879f4954d86a87beaa6738e8343522e01feb5ecf33993e4
7
- data.tar.gz: d344a20157fb5e102f22fac06037b4995a6e3b219ef5c4f3497ed94258effa1ea3884cd54c3e2a5a2fdae4cf772648919f9cff2fd07d1455ef69d773cc274bdf
6
+ metadata.gz: 7e1583d70fc000685405151618599f59486c1bafa2f49a3862ea13c0c886e1ebc48e6d417d94bacc5b1d6b3ddb9ca02b5fcccd48f30331d2c61c62c6eec8062e
7
+ data.tar.gz: ca8446b4b303f74c3697a4cf4cf329398373217bc6bbf104aa1c46fe6134153b9aea0b79e19dec8538759b323d78398d5e603d4119509c11f38f934a9427f55b
data/bin/gbud CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  # Copyright 2017 Richard Davis
3
5
  #
4
6
  # This file is part of gbud.
data/lib/gbud.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2017 Richard Davis
2
4
  #
3
5
  # This file is part of gbud.
@@ -15,89 +17,14 @@
15
17
  # You should have received a copy of the GNU General Public License
16
18
  # along with gbud. If not, see <http://www.gnu.org/licenses/>.
17
19
 
20
+ require 'gbud/base'
21
+
18
22
  ##
19
- # = gbud.rb
23
+ # = GBud
20
24
  # Author:: Richard Davis
21
25
  # Copyright:: Copyright 2017 Richard Davis
22
26
  # License:: GNU Public License 3
23
27
  #
24
- # The main script for handling user input and program execution.
25
- require 'fileutils'
26
- require 'optparse'
27
- require 'erb'
28
-
29
- require 'gbud/user_prompt'
30
- require 'gbud/project_metadata'
31
- require 'gbud/project_builder'
32
-
33
- trap('INT') do
34
- puts "\nTerminating..."
35
- exit
28
+ # Module for namespacing application classes.
29
+ module GBud
36
30
  end
37
-
38
- options = {}
39
-
40
- optparse = OptionParser.new do |opts|
41
- opts.banner = 'Usage: gbud [options]'
42
-
43
- opts.on('-n', '--new NAME', 'Creates a project given a name') do |name|
44
- options[:name] = name
45
- end
46
-
47
- opts.on('--cli', 'Creates an executable with option parsing') do
48
- options[:cli] = true
49
- end
50
-
51
- opts.on('--no-cli', 'Creates an executable without option parsing') do
52
- options[:cli] = false
53
- end
54
-
55
- opts.on('-l', '--license', 'Displays the copyright notice') do
56
- puts "This program is free software: you can redistribute it and/or modify
57
- it under the terms of the GNU General Public License as published by
58
- the Free Software Foundation, either version 3 of the License, or
59
- (at your option) any later version.
60
- "
61
- end
62
-
63
- opts.on('-w', '--warranty', 'Displays the warranty statement') do
64
- puts "This program is distributed in the hope that it will be useful,
65
- but WITHOUT ANY WARRANTY; without even the implied warranty of
66
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67
- GNU General Public License for more details.
68
- "
69
- end
70
-
71
- opts.on_tail('-h', '--help', 'Displays the help screen') do
72
- puts opts
73
- exit
74
- end
75
- end
76
-
77
- optparse.parse!
78
-
79
- if options[:name]
80
- metadata = GBud::ProjectMetadata.new
81
- metadata.name = options[:name]
82
- if metadata.name.nil?
83
- puts 'Invalid gem name. See RubyGems for gem naming conventions.'
84
- exit 1
85
- end
86
- metadata.authors = GBud::UserPrompt.get_value 'Project authors => '
87
- loop do
88
- metadata.email = GBud::UserPrompt.get_value 'Project email => '
89
- break unless metadata.email.nil?
90
- puts 'Please enter a valid email address.'
91
- end
92
- loop do
93
- metadata.url = GBud::UserPrompt.get_value 'Project website => '
94
- break unless metadata.url.nil?
95
- puts 'Please enter a valid project URL'
96
- end
97
- metadata.summary = GBud::UserPrompt.get_value 'Enter a short summary of the project => '
98
- metadata.description = GBud::UserPrompt.get_value 'Enter a description of the project => '
99
- options[:cli] = true if options[:cli].nil?
100
- project = GBud::ProjectBuilder.new metadata.to_hash, options[:cli]
101
- project.build
102
- end
103
-
data/lib/gbud/base.rb ADDED
@@ -0,0 +1,107 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2017 Richard Davis
4
+ #
5
+ # This file is part of gbud.
6
+ #
7
+ # gbud is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # gbud is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with gbud. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ ##
21
+ # = base.rb
22
+ # Author:: Richard Davis
23
+ # Copyright:: Copyright 2017 Richard Davis
24
+ # License:: GNU Public License 3
25
+ #
26
+ # The main script for handling user input and program execution.
27
+ require 'fileutils'
28
+ require 'optparse'
29
+ require 'erb'
30
+ require 'English'
31
+
32
+ require 'gbud/user_prompt'
33
+ require 'gbud/project_metadata'
34
+ require 'gbud/project_builder'
35
+ require 'gbud/messages'
36
+ require 'gbud/helpers'
37
+
38
+ trap('INT') do
39
+ puts "\nTerminating..."
40
+ exit
41
+ end
42
+
43
+ options = {}
44
+
45
+ optparse = OptionParser.new do |opts|
46
+ opts.banner = 'Usage: gbud [options]'
47
+
48
+ opts.on('-n', '--new NAME', 'Creates a project given a name') do |name|
49
+ options[:name] = name
50
+ end
51
+
52
+ opts.on('--cli', 'Creates an executable with option parsing') do
53
+ options[:cli] = true
54
+ end
55
+
56
+ opts.on('--no-cli', 'Creates an executable without option parsing') do
57
+ options[:cli] = false
58
+ end
59
+
60
+ opts.on('-l', '--license', 'Displays the copyright notice') do
61
+ puts GBud::Messages.license
62
+ end
63
+
64
+ opts.on('-w', '--warranty', 'Displays the warranty statement') do
65
+ puts GBud::Messages.warranty
66
+ end
67
+
68
+ opts.on_tail('-h', '--help', 'Displays the help screen') do
69
+ puts opts
70
+ exit
71
+ end
72
+ end
73
+
74
+ begin
75
+ optparse.parse!
76
+ rescue OptionParser::InvalidOption, OptionParser::MissingArgument
77
+ puts $ERROR_INFO.to_s
78
+ puts 'Use -h or --help for options.'
79
+ exit 1
80
+ end
81
+
82
+ if options[:name]
83
+ metadata = GBud::ProjectMetadata.new
84
+ metadata.name = options[:name]
85
+ if metadata.name.nil?
86
+ puts 'Invalid gem name. See RubyGems for gem naming conventions.'
87
+ exit 1
88
+ end
89
+ metadata.authors = GBud::UserPrompt.get_value 'Project authors => '
90
+ loop do
91
+ metadata.email = GBud::UserPrompt.get_value 'Project email => '
92
+ break unless metadata.email.nil?
93
+
94
+ puts 'Please enter a valid email address.'
95
+ end
96
+ loop do
97
+ metadata.url = GBud::UserPrompt.get_value 'Project website => '
98
+ break unless metadata.url.nil?
99
+
100
+ puts 'Please enter a valid project URL'
101
+ end
102
+ metadata.summary = GBud::UserPrompt.get_value 'Enter a short summary => '
103
+ metadata.description = GBud::UserPrompt.get_value 'Enter a description => '
104
+ options[:cli] = true if options[:cli].nil?
105
+ project = GBud::ProjectBuilder.new metadata.to_hash, options[:cli]
106
+ project.build
107
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2017 Richard Davis
4
+ #
5
+ # This file is part of gbud.
6
+ #
7
+ # gbud is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # gbud is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with gbud. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ module GBud
21
+ ##
22
+ # = Messages
23
+ # Author:: Richard Davis
24
+ # Copyright:: Copyright 2017 Richard Davis
25
+ # License:: GNU Public License 3
26
+ #
27
+ # Module containing methods used to prompt the user for program
28
+ # input.
29
+ module Messages
30
+ ##
31
+ # Returns the license message.
32
+ def self.license
33
+ "This program is free software: you can redistribute it and/or modify
34
+ it under the terms of the GNU General Public License as published by
35
+ the Free Software Foundation, either version 3 of the License, or
36
+ (at your option) any later version."
37
+ end
38
+
39
+ ##
40
+ # Returns the warranty message.
41
+ def self.warranty
42
+ "This program is distributed in the hope that it will be useful,
43
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
44
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45
+ GNU General Public License for more details."
46
+ end
47
+ end
48
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2017 Richard Davis
2
4
  #
3
5
  # This file is part of gbud.
@@ -40,20 +42,18 @@ module GBud
40
42
 
41
43
  ##
42
44
  # Instantiates a ProjectBuilder object
43
- def initialize metadata, cli
45
+ def initialize(metadata, cli)
44
46
  @metadata = metadata
45
-
46
47
  @cli = cli
47
48
  @templates = {
48
49
  'readme.md': 'README.md',
49
50
  'gemspec.rb': "#{metadata[:name]}.gemspec",
50
51
  'gemfile.rb': 'Gemfile',
51
- 'guardfile.rb': 'Guardfile',
52
52
  'rakefile.rb': 'Rakefile',
53
- 'main.rb': "#{metadata[:name]}.rb",
53
+ 'base.rb': 'base.rb',
54
54
  'hello.rb': 'hello.rb',
55
55
  'test_hello.rb': 'test_hello.rb',
56
- 'namespace.rb': 'namespace.rb'
56
+ 'namespace.rb': "#{metadata[:name].to_s.tr('-', '_')}.rb"
57
57
  }
58
58
  @assets = {
59
59
  license: 'LICENSE'
@@ -62,12 +62,11 @@ module GBud
62
62
  project_dir: "#{metadata[:name]}/",
63
63
  project_lib_dir: "#{metadata[:name]}/lib/",
64
64
  project_lib_project_dir: "#{metadata[:name]}/lib/#{metadata[:name]}/",
65
- project_test_dir: "#{metadata[:name]}/test/",
65
+ project_test_dir: "#{metadata[:name]}/test/"
66
66
  }
67
- if cli == true
68
- @templates[:'executable.rb'] = "#{metadata[:name]}"
69
- @paths[:project_bin_dir] = "#{metadata[:name]}/bin/"
70
- end
67
+ exit unless cli == true
68
+ @templates[:'executable.rb'] = metadata[:name].to_s
69
+ @paths[:project_bin_dir] = "#{metadata[:name]}/bin/"
71
70
  end
72
71
 
73
72
  ##
@@ -83,7 +82,7 @@ module GBud
83
82
  ##
84
83
  # Creates the project directories
85
84
  def make_directories
86
- @paths.each do |path, dir|
85
+ @paths.each do |_path, dir|
87
86
  FileUtils.mkdir_p(dir)
88
87
  end
89
88
  end
@@ -94,7 +93,7 @@ module GBud
94
93
  @templates.each do |template, filename|
95
94
  directory = map_template template
96
95
  file = File.new "#{directory}#{filename}", 'w+'
97
- file.puts(render template)
96
+ file.puts(render(template))
98
97
  file.close
99
98
  make_executable if template == :'executable.rb'
100
99
  end
@@ -102,32 +101,32 @@ module GBud
102
101
 
103
102
  ##
104
103
  # Maps each templated file to correct directory
105
- def map_template template
104
+ def map_template(template)
106
105
  case template
107
- when :'readme.md'
108
- @paths[:project_dir]
109
- when :'gemspec.rb'
110
- @paths[:project_dir]
111
- when :'gemfile.rb'
112
- @paths[:project_dir]
113
- when :'guardfile.rb'
114
- @paths[:project_dir]
115
- when :'rakefile.rb'
116
- @paths[:project_dir]
117
- when :'main.rb'
118
- @paths[:project_lib_dir]
119
- when :'hello.rb'
120
- @paths[:project_lib_project_dir]
121
- when :'executable.rb'
122
- @paths[:project_bin_dir]
123
- when :'test_hello.rb'
124
- @paths[:project_test_dir]
106
+ when :'readme.md'
107
+ @paths[:project_dir]
108
+ when :'gemspec.rb'
109
+ @paths[:project_dir]
110
+ when :'gemfile.rb'
111
+ @paths[:project_dir]
112
+ when :'rakefile.rb'
113
+ @paths[:project_dir]
114
+ when :'base.rb'
115
+ @paths[:project_lib_project_dir]
116
+ when :'hello.rb'
117
+ @paths[:project_lib_project_dir]
118
+ when :'executable.rb'
119
+ @paths[:project_bin_dir]
120
+ when :'test_hello.rb'
121
+ @paths[:project_test_dir]
122
+ when :'namespace.rb'
123
+ @paths[:project_lib_dir]
125
124
  end
126
125
  end
127
126
 
128
127
  ##
129
128
  # Renders the templates into files
130
- def render template
129
+ def render(template)
131
130
  path = File.expand_path(File.join(File.dirname(__FILE__),
132
131
  '..',
133
132
  'templates',
@@ -138,7 +137,7 @@ module GBud
138
137
  ##
139
138
  # Flags the CLI file as executable
140
139
  def make_executable
141
- File.chmod(0755, "#{@paths[:project_bin_dir]}#{@templates[:'executable.rb']}")
140
+ File.chmod(0o755, "#{@paths[:project_bin_dir]}#{@templates[:'executable.rb']}")
142
141
  end
143
142
 
144
143
  ##
@@ -147,22 +146,40 @@ module GBud
147
146
  @assets.each do |asset, filename|
148
147
  directory = map_asset asset
149
148
  FileUtils.cp(File.expand_path(File.join(File.dirname(__FILE__),
150
- '..',
151
- 'assets',
152
- "#{filename}")),
153
- "#{directory}#{filename}")
149
+ '..',
150
+ 'assets',
151
+ filename.to_s)),
152
+ "#{directory}#{filename}")
154
153
  end
155
154
  end
156
155
 
157
156
  ##
158
157
  # Maps each asset file to correct directory
159
- def map_asset asset
158
+ def map_asset(asset)
160
159
  case asset
161
- when :gitignore
162
- @paths[:project_dir]
163
- when :license
164
- @paths[:project_dir]
160
+ when :gitignore
161
+ @paths[:project_dir]
162
+ when :license
163
+ @paths[:project_dir]
165
164
  end
166
165
  end
166
+
167
+ ##
168
+ # Returns the string in camel case.
169
+ def camel_case(str)
170
+ str.split(/-|_/).each(&:capitalize!).join
171
+ end
172
+
173
+ ##
174
+ # Returns the string in snake case.
175
+ def snake_case(str)
176
+ str.to_s.tr('-', '_')
177
+ end
178
+
179
+ ##
180
+ # Returns an enumberable as string separated by commas
181
+ def listify(arr)
182
+ arr.join(', ')
183
+ end
167
184
  end
168
185
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2017 Richard Davis
2
4
  #
3
5
  # This file is part of gbud.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2017 Richard Davis
2
4
  #
3
5
  # This file is part of gbud.
@@ -51,6 +53,7 @@ module GBud
51
53
  print 'Is this correct? (Y/N) => '
52
54
  confirm = gets.chomp.to_s.upcase
53
55
  return false unless confirm == 'Y'
56
+
54
57
  true
55
58
  end
56
59
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ <%= render 'copyright_snippet.rb' %>
4
+
5
+ ##
6
+ # = /lib/<%= snake_case(@metadata[:name]) %>.rb
7
+ # Author:: <%= listify(@metadata[:authors]) %>
8
+ # Copyright:: Copyright <%= Date.today.year %> <%= listify(@metadata[:authors]) %>
9
+ # License:: GNU Public License 3
10
+ #
11
+ # Main application file that loads other files.
12
+ require '<%= @metadata[:name] %>/hello'
13
+
14
+ <%= render 'cli.rb' if @cli == true %>
15
+ # NOTE: You should replace the greet functionality with some of your own code.
16
+ # Use the hello.rb file as a guide for structuring your code, and ensure
17
+ # that you adjust the require statement as well as the CLI option (if
18
+ # included), adding additional files/CLI options in a similar fashion.
@@ -1,4 +1,5 @@
1
1
  require 'optparse'
2
+ require 'English'
2
3
 
3
4
  trap('INT') do
4
5
  puts "\nTerminating..."
@@ -36,8 +37,15 @@ GNU General Public License for more details.
36
37
  end
37
38
  end
38
39
 
39
- optparse.parse!
40
+ begin
41
+ optparse.parse!
42
+ rescue OptionParser::InvalidOption, OptionParser::MissingArgument
43
+ puts $ERROR_INFO.to_s
44
+ puts 'Use -h or --help for options.'
45
+ exit 1
46
+ end
40
47
 
41
48
  if options[:greet]
42
- puts <%= @metadata[:name].split(/-|_/).each{ |s| s.capitalize! }.join %>::Hello.greeting(options[:greet])
49
+ # Displays the greeting which serves as a functional test
50
+ puts <%= camel_case(@metadata[:name]) %>::Hello.greeting(options[:greet])
43
51
  end
@@ -1,4 +1,4 @@
1
- # Copyright <%= Date.today.year %> <%= @metadata[:authors].join(', ') %>
1
+ # Copyright <%= Date.today.year %> <%= listify(@metadata[:authors]) %>
2
2
  #
3
3
  # This file is part of <%= @metadata[:name] %>.
4
4
  #
@@ -14,12 +14,3 @@
14
14
  #
15
15
  # You should have received a copy of the GNU General Public License
16
16
  # along with <%= @metadata[:name] %>. If not, see <http://www.gnu.org/licenses/>.
17
-
18
- directories(%w[lib test])\
19
- .select { |d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist") }
20
-
21
- guard :minitest do
22
- watch(%r{^test/(.*)\/?test_(.*)\.rb$})
23
- watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
24
- watch(%r{^test/test_helper\.rb$}) { 'test' }
25
- end
@@ -1,31 +1,18 @@
1
1
  #!/usr/bin/env ruby'
2
- # Copyright <%= Date.today.year %> <%= @metadata[:authors].join(', ') %>
3
- #
4
- # This file is part of <%= @metadata[:name] %>.
5
- #
6
- # <%= @metadata[:name] %> is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # <%= @metadata[:name] %> is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with <%= @metadata[:name] %>. If not, see <http://www.gnu.org/licenses/>.
2
+ # frozen_string_literal: true
3
+
4
+ <%= render 'copyright_snippet.rb' %>
18
5
 
19
6
  ##
20
7
  # = /bin/<%= @metadata[:name] %>
21
- # Author:: <%= @metadata[:authors].join(', ') %>
22
- # Copyright:: Copyright <%= Date.today.year %> <%= @metadata[:authors].join(', ') %>
8
+ # Author:: <%= listify(@metadata[:authors]) %>
9
+ # Copyright:: Copyright <%= Date.today.year %> <%= listify(@metadata[:authors]) %>
23
10
  # License:: GNU Public License 3
24
11
  #
25
12
  # Project executable file.
26
13
  begin
27
- require '<%= @metadata[:name] %>'
14
+ require '<%= snake_case(@metadata[:name])%>'
28
15
  rescue LoadError
29
16
  require 'rubygems'
30
- require '<%= @metadata[:name] %>'
17
+ require '<%= snake_case(@metadata[:name])%>'
31
18
  end
@@ -1,33 +1,22 @@
1
- # Copyright <%= Date.today.year %> <%= @metadata[:authors].join(', ') %>
2
- #
3
- # This file is part of <%= @metadata[:name] %>.
4
- #
5
- # <%= @metadata[:name] %> is free software: you can redistribute it and/or modify
6
- # it under the terms of the GNU General Public License as published by
7
- # the Free Software Foundation, either version 3 of the License, or
8
- # (at your option) any later version.
9
- #
10
- # <%= @metadata[:name] %> is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- # GNU General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License
16
- # along with <%= @metadata[:name] %>. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
3
+ <%= render 'copyright_snippet.rb' %>
17
4
 
18
5
  source 'https://rubygems.org'
19
- ruby '2.4.1'
6
+ ruby '2.5.1'
20
7
 
21
- group :development do
8
+ group :development, :test do
22
9
  # Minitest for unit tests
23
- gem 'minitest', '~> 5.0'
24
- # Use Guard to run automated tests
25
- gem 'guard', '~> 2.14', '>= 2.14.1'
26
- gem 'guard-minitest', '~> 2.4', '>= 2.4.6'
10
+ gem 'minitest', '~> 5.11', '>= 5.11.3'
27
11
  # Rake executes tasks defined in the Rakefile
28
- gem 'rake', '~> 12.0'
12
+ gem 'rake', '~> 12.3', '>= 12.3.1'
13
+ end
14
+
15
+ group :development do
16
+ # Pry for debugging/REPL
17
+ gem 'pry', '~> 0.11.3'
29
18
  # Rubocop for code style guidelines
30
- gem 'rubocop', '~> 0.48.1'
19
+ gem 'rubocop', '~> 0.59.2'
31
20
  # RDoc for generating documentation
32
21
  gem 'rdoc', '~> 5.1'
33
22
  end
@@ -1,40 +1,26 @@
1
- # -*- encoding: utf-8 -*-
2
- # Copyright <%= Date.today.year %> <%= @metadata[:authors].join(', ') %>
3
- #
4
- # This file is part of <%= @metadata[:name] %>.
5
- #
6
- # <%= @metadata[:name] %> is free software: you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation, either version 3 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # <%= @metadata[:name] %> is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with <%= @metadata[:name] %>. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
18
2
 
19
- lib = File.expand_path('../lib', __FILE__)
3
+ <%= render 'copyright_snippet.rb' %>
4
+
5
+ lib = File.expand_path('../lib', __dir__)
20
6
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
21
7
 
22
8
  Gem::Specification.new do |s|
23
9
  s.name = '<%= @metadata[:name] %>'
24
10
  s.version = '<%= @metadata[:version] %>'
25
11
  s.platform = Gem::Platform::RUBY
26
- s.authors = <%= @metadata[:authors] %>
12
+ s.authors = <%= @metadata[:authors].to_s.tr('"', "'") %>
27
13
  s.email = '<%= @metadata[:email] %>'
28
14
  s.homepage = '<%= @metadata[:url] %>'
29
15
  s.summary = '<%= @metadata[:summary] %>'
30
- s.description = <<-EOF
31
- <%= @metadata[:description] %>
32
- EOF
16
+ s.description = <<~HEREDOC
17
+ <%= @metadata[:description] %>
18
+ HEREDOC
33
19
  s.license = '<%= @metadata[:license] %>'
34
20
  s.files = Dir['lib/**/*']
35
- <% if @cli == true %>
36
- s.executables = ['<%= @metadata[:name] %>']
37
- <% end %>
21
+ <% if @cli == true %>
22
+ s.executables = ['<%= @metadata[:name] %>']
23
+ <% end %>
38
24
  s.test_files = Dir['test/**/*']
39
25
  s.require_path = ['lib']
40
26
  end
@@ -1,30 +1,19 @@
1
- # Copyright <%= Date.today.year %> <%= @metadata[:authors].join(', ') %>
2
- #
3
- # This file is part of <%= @metadata[:name] %>.
4
- #
5
- # <%= @metadata[:name] %> is free software: you can redistribute it and/or modify
6
- # it under the terms of the GNU General Public License as published by
7
- # the Free Software Foundation, either version 3 of the License, or
8
- # (at your option) any later version.
9
- #
10
- # <%= @metadata[:name] %> is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- # GNU General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License
16
- # along with <%= @metadata[:name] %>. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
17
2
 
18
- ##
19
- # = Hello
20
- # Author:: <%= @metadata[:authors].join(', ') %>
21
- # Copyright:: Copyright <%= Date.today.year %> <%= @metadata[:authors].join(', ') %>
22
- # License:: GNU Public License 3
23
- #
24
- # Contains modularized code for project; given example provides a greeting
25
- module <%= @metadata[:name].split(/-|_/).each{ |s| s.capitalize! }.join %>
3
+ <%= render 'copyright_snippet.rb' %>
4
+
5
+ module <%= camel_case(@metadata[:name]) %>
6
+ ##
7
+ # = Hello
8
+ # Author:: <%= listify(@metadata[:authors]) %>
9
+ # Copyright:: Copyright <%= Date.today.year %> <%= listify(@metadata[:authors]) %>
10
+ # License:: GNU Public License 3
11
+ #
12
+ # Contains modularized code for project; given example provides a greeting
26
13
  class Hello
27
- def self.greeting name
14
+ ##
15
+ # Returns a greeting provided a name.
16
+ def self.greeting(name)
28
17
  "Hello, #{name}."
29
18
  end
30
19
  end
@@ -1,26 +1,15 @@
1
- # Copyright <%= Date.today.year %> <%= @metadata[:authors].join(', ') %>
2
- #
3
- # This file is part of <%= @metadata[:name] %>.
4
- #
5
- # <%= @metadata[:name] %> is free software: you can redistribute it and/or modify
6
- # it under the terms of the GNU General Public License as published by
7
- # the Free Software Foundation, either version 3 of the License, or
8
- # (at your option) any later version.
9
- #
10
- # <%= @metadata[:name] %> is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- # GNU General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License
16
- # along with <%= @metadata[:name] %>. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
3
+ <%= render 'copyright_snippet.rb' %>
4
+
5
+ require '<%= metadata[:name] %>/base'
17
6
 
18
7
  ##
19
- # = <%= @metadata[:name].split(/-|_/).each{ |s| s.capitalize! }.join %>
20
- # Author:: <%= @metadata[:authors].join(', ') %>
21
- # Copyright:: Copyright <%= Date.today.year %> <%= @metadata[:authors].join(', ') %>
8
+ # = <%= camel_case(@metadata[:name]) %>
9
+ # Author:: <%= listify(@metadata[:authors]) %>
10
+ # Copyright:: Copyright <%= Date.today.year %> <%= listify(@metadata[:authors]) %>
22
11
  # License:: GNU Public License 3
23
12
  #
24
13
  # Module for namespacing application classes.
25
- module <%= @metadata[:name].split(/-|_/).each{ |s| s.capitalize! }.join %>
14
+ module <%= camel_case(@metadata[:name]) %>
26
15
  end
@@ -1,25 +1,12 @@
1
- # Copyright <%= Date.today.year %> <%= @metadata[:authors].join(', ') %>
2
- #
3
- # This file is part of <%= @metadata[:name] %>.
4
- #
5
- # <%= @metadata[:name] %> is free software: you can redistribute it and/or modify
6
- # it under the terms of the GNU General Public License as published by
7
- # the Free Software Foundation, either version 3 of the License, or
8
- # (at your option) any later version.
9
- #
10
- # <%= @metadata[:name] %> is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- # GNU General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License
16
- # along with <%= @metadata[:name] %>. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
3
+ <%= render 'copyright_snippet.rb' %>
17
4
 
18
5
  require 'rake/testtask'
19
6
  require 'rdoc/task'
20
7
 
21
8
  Rake::TestTask.new do |t|
22
- t.libs << 'test'
9
+ t.libs << 'test'
23
10
  end
24
11
 
25
12
  RDoc::Task.new :rdoc do |rdoc|
@@ -6,7 +6,7 @@
6
6
  * Execute `gem build foobar.gemspec` to build your gem
7
7
  * Execute `gem install foobar-0.0.1.gem` to install your gem
8
8
  * Share!
9
- # Name
9
+ # <%= @metadata[:name] %>
10
10
  <%= @metadata[:description] %>
11
11
 
12
12
  ## Table of Contents
@@ -1,30 +1,17 @@
1
- # Copyright <%= Date.today.year %> <%= @metadata[:authors].join(', ') %>
2
- #
3
- # This file is part of <%= @metadata[:name] %>.
4
- #
5
- # <%= @metadata[:name] %> is free software: you can redistribute it and/or modify
6
- # it under the terms of the GNU General Public License as published by
7
- # the Free Software Foundation, either version 3 of the License, or
8
- # (at your option) any later version.
9
- #
10
- # <%= @metadata[:name] %> is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- # GNU General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License
16
- # along with <%= @metadata[:name] %>. If not, see <http://www.gnu.org/licenses/>.
1
+ # frozen_string_literal: true
2
+
3
+ <%= render 'copyright_snippet.rb' %>
17
4
 
18
5
  require 'minitest/autorun'
19
6
  require_relative '../lib/<%= @metadata[:name] %>/hello'
20
7
 
21
8
  ##
22
9
  # = HelloTest
23
- # Author:: <%= @metadata[:authors].join(', ') %>
24
- # Copyright:: Copyright <%= Date.today.year %> <%= @metadata[:authors].join(', ') %>
10
+ # Author:: <%= listify(@metadata[:authors]) %>
11
+ # Copyright:: Copyright <%= Date.today.year %> <%= listify(@metadata[:authors]) %>
25
12
  # License:: GNU Public License 3
26
13
  #
27
- # Contains modularized code for project; given example provides a greeting
14
+ # Contains tests for Hello class.
28
15
  class HelloTest < Minitest::Test
29
16
  ##
30
17
  # Initializes test with sample data
@@ -35,6 +22,6 @@ class HelloTest < Minitest::Test
35
22
  ##
36
23
  # Ensures the greeter is behaving as expected
37
24
  def test_hello
38
- assert_equal('Hello, friend.', <%= @metadata[:name].split(/-|_/).each{ |s| s.capitalize! }.join %>::Hello.greeting(@name))
25
+ assert_equal('Hello, friend.', <%= camel_case(@metadata[:name]) %>::Hello.greeting(@name))
39
26
  end
40
27
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # gbud is free software: you can redistribute it and/or modify
2
4
  # it under the terms of the GNU General Public License as published by
3
5
  # the Free Software Foundation, either version 3 of the License, or
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # gbud is free software: you can redistribute it and/or modify
2
4
  # it under the terms of the GNU General Public License as published by
3
5
  # the Free Software Foundation, either version 3 of the License, or
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gbud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Davis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-23 00:00:00.000000000 Z
11
+ date: 2018-10-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |2
14
- This project aims to make starting a new gem project simple by automating
15
- the creation of all required files and directories for you.
13
+ description: |
14
+ This project aims to make starting a new gem project simple by automating
15
+ the creation of all required files and directories for you.
16
16
  email: rvdavis@member.fsf.org
17
17
  executables:
18
18
  - gbud
@@ -22,17 +22,18 @@ files:
22
22
  - bin/gbud
23
23
  - lib/assets/LICENSE
24
24
  - lib/gbud.rb
25
- - lib/gbud/namespace.rb
25
+ - lib/gbud/base.rb
26
+ - lib/gbud/messages.rb
26
27
  - lib/gbud/project_builder.rb
27
28
  - lib/gbud/project_metadata.rb
28
29
  - lib/gbud/user_prompt.rb
30
+ - lib/templates/base.rb.erb
29
31
  - lib/templates/cli.rb.erb
32
+ - lib/templates/copyright_snippet.rb.erb
30
33
  - lib/templates/executable.rb.erb
31
34
  - lib/templates/gemfile.rb.erb
32
35
  - lib/templates/gemspec.rb.erb
33
- - lib/templates/guardfile.rb.erb
34
36
  - lib/templates/hello.rb.erb
35
- - lib/templates/main.rb.erb
36
37
  - lib/templates/namespace.rb.erb
37
38
  - lib/templates/rakefile.rb.erb
38
39
  - lib/templates/readme.md.erb
@@ -59,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
60
  version: '0'
60
61
  requirements: []
61
62
  rubyforge_project:
62
- rubygems_version: 2.6.11
63
+ rubygems_version: 2.7.6
63
64
  signing_key:
64
65
  specification_version: 4
65
66
  summary: Initializes the basic structure of a gem
@@ -1,26 +0,0 @@
1
- # Copyright 2017 Richard Davis
2
- #
3
- # This file is part of gbud.
4
- #
5
- # gbud is free software: you can redistribute it and/or modify
6
- # it under the terms of the GNU General Public License as published by
7
- # the Free Software Foundation, either version 3 of the License, or
8
- # (at your option) any later version.
9
- #
10
- # gbud is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- # GNU General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License
16
- # along with gbud. If not, see <http://www.gnu.org/licenses/>.
17
-
18
- ##
19
- # = GBud
20
- # Author:: Richard Davis
21
- # Copyright:: Copyright 2017 Richard Davis
22
- # License:: GNU Public License 3
23
- #
24
- # Module for namespacing application classes.
25
- module GBud
26
- end
@@ -1,27 +0,0 @@
1
- # Copyright <%= Date.today.year %> <%= @metadata[:authors].join(', ') %>
2
- #
3
- # This file is part of <%= @metadata[:name] %>.
4
- #
5
- # <%= @metadata[:name] %> is free software: you can redistribute it and/or modify
6
- # it under the terms of the GNU General Public License as published by
7
- # the Free Software Foundation, either version 3 of the License, or
8
- # (at your option) any later version.
9
- #
10
- # <%= @metadata[:name] %> is distributed in the hope that it will be useful,
11
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- # GNU General Public License for more details.
14
- #
15
- # You should have received a copy of the GNU General Public License
16
- # along with <%= @metadata[:name] %>. If not, see <http://www.gnu.org/licenses/>.
17
-
18
- ##
19
- # = /lib/<%= @metadata[:name] %>.rb
20
- # Author:: <%= @metadata[:authors].join(', ') %>
21
- # Copyright:: Copyright <%= Date.today.year %> <%= @metadata[:authors].join(', ') %>
22
- # License:: GNU Public License 3
23
- #
24
- # Main application file that loads other files.
25
- require '<%= @metadata[:name] %>/hello'
26
-
27
- <%= render 'cli.rb' if @cli == true %>