gbud 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gbud.rb +1 -1
- data/lib/gbud/base.rb +91 -0
- data/lib/gbud/getinfo.rb +29 -0
- data/test/test_getinfo.rb +54 -0
- metadata +6 -4
- data/test/test_gbud.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e175e224bba7fbd99773788d3d92488600c7291f
|
4
|
+
data.tar.gz: 5271c490f76ee9f8d487ba13208cd63122177c07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3581b02760b91904e9d8515871fabd288f106512828a620eb8a10967d555123582fd87e12d0c911131936d192452078f3bda8f59a5185a3f7b608f121bc85e11
|
7
|
+
data.tar.gz: 6fb3d65f1c076fa1b29b9b2f563ddabd6dc4f712af35b04c6289bb7e6b67acf175951d3d984ee8f9c376d61d81fafce7de62dd0b8c13ac4acd734f511f7ba577
|
data/lib/gbud.rb
CHANGED
data/lib/gbud/base.rb
ADDED
@@ -0,0 +1,91 @@
|
|
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 = ['lib/#{p_name}.rb']"
|
84
|
+
gemspec.puts "\ts.executables = ['#{p_name}']"
|
85
|
+
gemspec.puts "\ts.test_files = ['test/test_#{p_name}.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
ADDED
@@ -0,0 +1,29 @@
|
|
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
|
@@ -0,0 +1,54 @@
|
|
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
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Davis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-13 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
|
@@ -21,7 +21,9 @@ extra_rdoc_files: []
|
|
21
21
|
files:
|
22
22
|
- bin/gbud
|
23
23
|
- lib/gbud.rb
|
24
|
-
-
|
24
|
+
- lib/gbud/base.rb
|
25
|
+
- lib/gbud/getinfo.rb
|
26
|
+
- test/test_getinfo.rb
|
25
27
|
homepage: http://www.github.com/d3d1rty/gbud
|
26
28
|
licenses:
|
27
29
|
- GPL v3
|
@@ -47,4 +49,4 @@ signing_key:
|
|
47
49
|
specification_version: 4
|
48
50
|
summary: Initializes the basic structure of a gem
|
49
51
|
test_files:
|
50
|
-
- test/
|
52
|
+
- test/test_getinfo.rb
|
data/test/test_gbud.rb
DELETED
File without changes
|