gbud 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/gbud +16 -0
- data/lib/assets/LICENSE +674 -0
- data/lib/gbud.rb +91 -3
- data/lib/gbud/project_builder.rb +113 -0
- data/lib/gbud/project_metadata.rb +83 -0
- data/lib/gbud/user_prompt.rb +43 -0
- data/lib/templates/executable.rb.erb +24 -0
- data/lib/templates/gemfile.rb.erb +24 -0
- data/lib/templates/gemspec.rb.erb +40 -0
- data/lib/templates/guardfile.erb.rb +0 -0
- data/lib/templates/hello.rb.erb +24 -0
- data/lib/templates/main.rb.erb +19 -0
- data/lib/templates/rakefile.rb.erb +22 -0
- data/lib/templates/readme.rb.erb +12 -0
- data/lib/templates/test_hello.rb.erb +25 -0
- data/test/test_project_builder.rb +33 -0
- data/test/test_project_metadata.rb +90 -0
- metadata +22 -10
- data/lib/gbud/base.rb +0 -91
- data/lib/gbud/getinfo.rb +0 -29
- data/test/test_getinfo.rb +0 -54
@@ -0,0 +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/>.
|
17
|
+
|
18
|
+
require '<%= @metadata[:name] %>/hello'
|
19
|
+
puts <%= @metadata[:name].split('-').each{ |s| s.capitalize! }.join %>::Hello.greeting
|
@@ -0,0 +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/>.
|
17
|
+
|
18
|
+
require 'rake/testtask'
|
19
|
+
|
20
|
+
Rake::TestTask.new do |t|
|
21
|
+
t.libs << 'test'
|
22
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#<%= @metadata[:name] %>
|
2
|
+
##Description
|
3
|
+
<%= @metadata[:description] %>
|
4
|
+
##Next Steps
|
5
|
+
* Initiate a git repo with `git init`
|
6
|
+
* Run `bundle install` to get the dependencies
|
7
|
+
* Write some code!
|
8
|
+
* Execute `gem build foobar.gemspec` to build your gem
|
9
|
+
* Execute `gem install foobar-0.0.1.gem` to install your gem
|
10
|
+
* Share!
|
11
|
+
##License
|
12
|
+
See `LICENSE` in the project root directory for license information.
|
@@ -0,0 +1,25 @@
|
|
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
|
+
require 'minitest/autorun'
|
19
|
+
require '<%= @metadata[:name] %>'
|
20
|
+
|
21
|
+
class HelloTest < Minitest::Test
|
22
|
+
def test_hello
|
23
|
+
assert_equal('Hello, friend.', <%= <%= @metadata[:name].split('-').each{ |s| s.capitalize! }.join %>::Hello.greeting
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright 2016 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
|
+
require 'minitest/autorun'
|
19
|
+
require_relative '../lib/gbud/project_builder'
|
20
|
+
|
21
|
+
class ProjectBuilderTest < Minitest::Test
|
22
|
+
def setup
|
23
|
+
metadata = {
|
24
|
+
name: 'gbud-test',
|
25
|
+
authors: 'Richard Davis, d3d1rty',
|
26
|
+
email: 'rvdavis@member.fsf.org',
|
27
|
+
url: 'https://test.com',
|
28
|
+
summary: 'This is a test summary.',
|
29
|
+
description: 'This is a test description.'
|
30
|
+
}
|
31
|
+
@builder = GBud::ProjectBuilder.new metadata, false
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# Copyright 2016 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
|
+
require 'minitest/autorun'
|
19
|
+
require_relative '../lib/gbud/project_metadata'
|
20
|
+
|
21
|
+
class ProjectMetadataTest < Minitest::Test
|
22
|
+
def setup
|
23
|
+
@metadata = GBud::ProjectMetadata.new
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_name_mutator_negative
|
27
|
+
@metadata.name = '-test'
|
28
|
+
assert_nil @metadata.name
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_name_mutator_positive
|
32
|
+
@metadata.name = 'gbud-test'
|
33
|
+
assert_equal 'gbud-test', @metadata.name
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_validate_name_negative
|
37
|
+
assert_nil @metadata.validate_name('-fail')
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_validate_name_positive
|
41
|
+
assert_equal 0, @metadata.validate_name('test-gem')
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_validate_email_negative
|
45
|
+
assert_nil @metadata.validate_email('rvdavis')
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_validate_email_positive
|
49
|
+
assert_equal 0, @metadata.validate_email('rvdavis@member.fsf.org')
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_validate_url_negative
|
53
|
+
assert_nil @metadata.validate_url('github.com')
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_validate_url_positive
|
57
|
+
assert_equal 0, @metadata.validate_url('https://github.com/d3d1rty/gbud')
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_authors_mutator
|
61
|
+
@metadata.authors = 'Richard Davis, d3d1rty'
|
62
|
+
assert_equal ['Richard Davis', 'd3d1rty'], @metadata.authors
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_summary_mutator
|
66
|
+
assert_equal 'This is a test', @metadata.summary = 'This is a test'
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_description_mutator
|
70
|
+
assert_equal 'This is a test', @metadata.description = 'This is a test'
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_version_accessor
|
74
|
+
assert_equal '0.0.1', @metadata.version
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_license_accessor
|
78
|
+
assert_equal 'GPL-3.0', @metadata.license
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_to_hash
|
82
|
+
@metadata.name = 'gbud-test'
|
83
|
+
@metadata.authors = 'Richard Davis, d3d1rty'
|
84
|
+
@metadata.email = 'rvdavis@member.fsf.org'
|
85
|
+
@metadata.url = 'https://test.com'
|
86
|
+
@metadata.summary = 'This is a test summary.'
|
87
|
+
@metadata.description = 'This is a test description.'
|
88
|
+
assert_instance_of Hash, @metadata.to_hash
|
89
|
+
end
|
90
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gbud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Davis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
This project aims to make starting a new gem project simple by automating
|
15
|
-
|
16
|
-
email:
|
15
|
+
the creation of all required files and directories for you.
|
16
|
+
email: rvdavis@member.fsf.org
|
17
17
|
executables:
|
18
18
|
- gbud
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
22
|
- bin/gbud
|
23
|
+
- lib/assets/LICENSE
|
23
24
|
- lib/gbud.rb
|
24
|
-
- lib/gbud/
|
25
|
-
- lib/gbud/
|
26
|
-
-
|
25
|
+
- lib/gbud/project_builder.rb
|
26
|
+
- lib/gbud/project_metadata.rb
|
27
|
+
- lib/gbud/user_prompt.rb
|
28
|
+
- lib/templates/executable.rb.erb
|
29
|
+
- lib/templates/gemfile.rb.erb
|
30
|
+
- lib/templates/gemspec.rb.erb
|
31
|
+
- lib/templates/guardfile.erb.rb
|
32
|
+
- lib/templates/hello.rb.erb
|
33
|
+
- lib/templates/main.rb.erb
|
34
|
+
- lib/templates/rakefile.rb.erb
|
35
|
+
- lib/templates/readme.rb.erb
|
36
|
+
- lib/templates/test_hello.rb.erb
|
37
|
+
- test/test_project_builder.rb
|
38
|
+
- test/test_project_metadata.rb
|
27
39
|
homepage: http://www.github.com/d3d1rty/gbud
|
28
40
|
licenses:
|
29
41
|
- GPL-3.0
|
@@ -44,10 +56,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
56
|
version: '0'
|
45
57
|
requirements: []
|
46
58
|
rubyforge_project:
|
47
|
-
rubygems_version: 2.
|
59
|
+
rubygems_version: 2.4.8
|
48
60
|
signing_key:
|
49
61
|
specification_version: 4
|
50
62
|
summary: Initializes the basic structure of a gem
|
51
63
|
test_files:
|
52
|
-
- test/
|
53
|
-
|
64
|
+
- test/test_project_metadata.rb
|
65
|
+
- test/test_project_builder.rb
|
data/lib/gbud/base.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
# gbud base script
|
2
|
-
# Copyright 2015 Richard Davis GPL v3
|
3
|
-
require 'fileutils'
|
4
|
-
require 'gbud/getinfo'
|
5
|
-
|
6
|
-
p_name = GetInfo.new('Project name => ').user_prompt
|
7
|
-
version = GetInfo.new('Version number => ').user_prompt
|
8
|
-
authors = GetInfo.new('Project authors => ').user_prompt.delete(' ').split(',')
|
9
|
-
email = GetInfo.new('Project email => ').user_prompt
|
10
|
-
site = GetInfo.new('Project website => ').user_prompt
|
11
|
-
summary = GetInfo.new('Enter a short summary of the project => ').user_prompt
|
12
|
-
description = GetInfo.new('Enter a description of the project => ').user_prompt
|
13
|
-
license = GetInfo.new('Project\'s license => ').user_prompt
|
14
|
-
|
15
|
-
# sets up directory structure
|
16
|
-
FileUtils.mkdir_p([
|
17
|
-
"#{p_name}/bin/",
|
18
|
-
"#{p_name}/lib/#{p_name}",
|
19
|
-
"#{p_name}/test"
|
20
|
-
])
|
21
|
-
|
22
|
-
# creates lib/base script
|
23
|
-
FileUtils.touch("#{p_name}/lib/#{p_name}/base.rb")
|
24
|
-
|
25
|
-
# creates main script
|
26
|
-
m = File.new("#{p_name}/lib/#{p_name}.rb", 'w+')
|
27
|
-
m.puts "require '#{p_name}/base'"
|
28
|
-
m.puts 'class HelloWorld'
|
29
|
-
m.puts "\tdef self.hello"
|
30
|
-
m.puts "\t\treturn 'Hello world!'"
|
31
|
-
m.puts "\tend"
|
32
|
-
m.puts 'end'
|
33
|
-
m.close
|
34
|
-
|
35
|
-
# creates executable
|
36
|
-
e = File.new("#{p_name}/bin/#{p_name}", 'w+')
|
37
|
-
e.puts '#!/usr/bin/env ruby'
|
38
|
-
e.puts 'begin'
|
39
|
-
e.puts "\trequire '#{p_name}'"
|
40
|
-
e.puts 'rescue LoadError'
|
41
|
-
e.puts "\trequire 'rubygems'"
|
42
|
-
e.puts "\trequire '#{p_name}'"
|
43
|
-
e.puts 'end'
|
44
|
-
e.close
|
45
|
-
File.chmod(0755, "#{p_name}/bin/#{p_name}")
|
46
|
-
|
47
|
-
# TODO: WRITE AUTOMATED TESTS
|
48
|
-
t = File.new("#{p_name}/test/test_#{p_name}.rb", 'w+')
|
49
|
-
t.puts "require 'test/unit'"
|
50
|
-
t.puts "require '#{p_name}'"
|
51
|
-
t.puts 'class HelloWorldTest < Test::Unit::TestCase'
|
52
|
-
t.puts "\tdef test_hello_world"
|
53
|
-
t.puts "\t\t\tassert_equal(HelloWorld.hello, 'Hello world!')"
|
54
|
-
t.puts "\tend"
|
55
|
-
t.puts 'end'
|
56
|
-
t.close
|
57
|
-
|
58
|
-
# writes Rakefile
|
59
|
-
r = File.new("#{p_name}/Rakefile", 'w+')
|
60
|
-
r.puts 'require \'rake/testtask\''
|
61
|
-
r.puts 'Rake::TestTask.new do |t|'
|
62
|
-
r.puts "\tt.libs << 'test'"
|
63
|
-
r.puts 'end'
|
64
|
-
r.puts 'desc \'Run tests\''
|
65
|
-
r.puts 'task :default => :test'
|
66
|
-
r.close
|
67
|
-
|
68
|
-
# writes gemspec
|
69
|
-
gemspec = File.new("#{p_name}/#{p_name}.gemspec", 'w+')
|
70
|
-
gemspec.puts '# -*- encoding: utf-8 -*-'
|
71
|
-
gemspec.puts "lib = File.expand_path('../lib', __FILE__)"
|
72
|
-
gemspec.puts "$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)\n\n"
|
73
|
-
gemspec.puts 'Gem::Specification.new do |s|'
|
74
|
-
gemspec.puts "\ts.name = '#{p_name}'"
|
75
|
-
gemspec.puts "\ts.version = '#{version}'"
|
76
|
-
gemspec.puts "\ts.platform = Gem::Platform::RUBY"
|
77
|
-
gemspec.puts "\ts.authors = #{authors}"
|
78
|
-
gemspec.puts "\ts.email = '#{email}'"
|
79
|
-
gemspec.puts "\ts.homepage = '#{site}'"
|
80
|
-
gemspec.puts "\ts.summary = '#{summary}'"
|
81
|
-
gemspec.puts "\ts.description = <<-EOF\n\t\t#{description}\nEOF"
|
82
|
-
gemspec.puts "\ts.license = '#{license}'"
|
83
|
-
gemspec.puts "\ts.files = Dir['lib/**/*.rb']"
|
84
|
-
gemspec.puts "\ts.executables = ['#{p_name}']"
|
85
|
-
gemspec.puts "\ts.test_files = Dir['test/**/*.rb']"
|
86
|
-
gemspec.puts "\ts.require_path = ['lib']"
|
87
|
-
gemspec.puts 'end'
|
88
|
-
|
89
|
-
# runs automated tests
|
90
|
-
#system 'cd '
|
91
|
-
#system 'rake'
|
data/lib/gbud/getinfo.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
# extracts required information for project
|
2
|
-
class GetInfo
|
3
|
-
def initialize(prompt)
|
4
|
-
@prompt = prompt
|
5
|
-
@info = ''
|
6
|
-
@u_verify = ''
|
7
|
-
end
|
8
|
-
|
9
|
-
def user_prompt
|
10
|
-
loop do
|
11
|
-
print @prompt
|
12
|
-
take_input
|
13
|
-
break if verify_input
|
14
|
-
end
|
15
|
-
@info
|
16
|
-
end
|
17
|
-
|
18
|
-
def take_input
|
19
|
-
@info = gets.chomp.to_s
|
20
|
-
end
|
21
|
-
|
22
|
-
def verify_input
|
23
|
-
puts "You have entered: #{@info}"
|
24
|
-
print 'Is this correct? (Y/N) => '
|
25
|
-
@u_verify = gets.chomp.to_s.upcase
|
26
|
-
return false unless @u_verify == 'Y'
|
27
|
-
true
|
28
|
-
end
|
29
|
-
end
|
data/test/test_getinfo.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'gbud'
|
3
|
-
|
4
|
-
# test methods in getinfo module
|
5
|
-
class GetInfoTest < Test::Unit::TestCase
|
6
|
-
def test_take_input
|
7
|
-
with_stdin do |user|
|
8
|
-
user.puts 'test'
|
9
|
-
assert_equal(
|
10
|
-
GetInfo.new('').take_input, 'test')
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def test_verify_input_one
|
15
|
-
with_stdin do |user|
|
16
|
-
user.puts 'Y'
|
17
|
-
assert_equal(
|
18
|
-
GetInfo.new('').verify_input, true)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_verify_input_two
|
23
|
-
with_stdin do |user|
|
24
|
-
user.puts 'Y'
|
25
|
-
assert_equal(
|
26
|
-
GetInfo.new('').verify_input, true)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def test_verify_input_fail
|
31
|
-
with_stdin do |user|
|
32
|
-
user.puts 'N'
|
33
|
-
assert_equal(
|
34
|
-
GetInfo.new('').verify_input, false)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def test_user_prompt
|
39
|
-
with_stdin do |user|
|
40
|
-
user.puts 'test'
|
41
|
-
user.puts 'Y'
|
42
|
-
assert_equal(GetInfo.new('').user_prompt, 'test')
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def with_stdin
|
47
|
-
stdin = $stdin # remember $stdin
|
48
|
-
$stdin, write = IO.pipe # create pipe assigning its "read end" to $stdin
|
49
|
-
yield write # pass pipe's "write end" to block
|
50
|
-
ensure
|
51
|
-
write.close # close pipe
|
52
|
-
$stdin = stdin # restore $stdin
|
53
|
-
end
|
54
|
-
end
|