bash_help 0.0.6 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bash_help.rb +2 -0
- data/lib/compile.rb +42 -0
- data/lib/drawing.rb +113 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e648594a9a813b4519050fbedfe17564d6d34b5fcc09e83d79d78a772da39fcd
|
4
|
+
data.tar.gz: fee9a8244ecccd7ca9ed33907a2b61a92aacd7a285643178c50ce1022ceea9bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c68cc8f705151aeb5c172c230689cff50dfd5ce3d5fc5a46698c10cc555e1ed3449f4d6b3fe8496edbd16e12088f6305d5047d3733ec8915dcdd3d5a94007490
|
7
|
+
data.tar.gz: e578be7bf8192f3c04e31e7c637853e9823ba7770008542682c004d0b4862e598cbc1e7bc2fac375ccda834e758874dbb31284b8e89e661dc79030345fcaa50b
|
data/lib/bash_help.rb
CHANGED
data/lib/compile.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# helper functions for compilation, used primarily for quick ruby build scripts.
|
2
|
+
|
3
|
+
require_relative 'drawing.rb'
|
4
|
+
require_relative 'general_helpers.rb'
|
5
|
+
|
6
|
+
## C compiler helpers:
|
7
|
+
def gcc_compile(files, project_name, extra_flags = '', override_flags = false)
|
8
|
+
line
|
9
|
+
|
10
|
+
if files.empty?
|
11
|
+
puts 'No files to compile'
|
12
|
+
return
|
13
|
+
end
|
14
|
+
|
15
|
+
if project_name.empty?
|
16
|
+
puts 'No project name given'
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
puts "Compiling #{files} into #{project_name}..."
|
21
|
+
|
22
|
+
ignore_header_warnings = '-Wno-builtin-declaration-mismatch -Wno-implicit-function-declaration'
|
23
|
+
|
24
|
+
default_flags = ['-g', ignore_header_warnings].join(' ')
|
25
|
+
flags = [default_flags, extra_flags].join(' ')
|
26
|
+
|
27
|
+
flags = extra_flags if override_flags
|
28
|
+
|
29
|
+
puts "Flags: #{flags}"
|
30
|
+
|
31
|
+
command = "gcc -o #{project_name} #{files} #{flags}"
|
32
|
+
|
33
|
+
# exit if the compilation fails.
|
34
|
+
safe_system command
|
35
|
+
|
36
|
+
puts "Compiled #{project_name}"
|
37
|
+
puts "Running..."
|
38
|
+
|
39
|
+
line
|
40
|
+
|
41
|
+
safe_system "./#{project_name}"
|
42
|
+
end
|
data/lib/drawing.rb
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# text drawing helper functions.
|
2
|
+
|
3
|
+
def line
|
4
|
+
puts '-' * 80
|
5
|
+
end
|
6
|
+
|
7
|
+
def box_text(text)
|
8
|
+
length = text.length + 4
|
9
|
+
puts '+' + '-' * length + '+'
|
10
|
+
puts "| " + text + " |"
|
11
|
+
puts '+' + '-' * length + '+'
|
12
|
+
end
|
13
|
+
|
14
|
+
def double_box_text(text)
|
15
|
+
length = text.length + 6
|
16
|
+
puts '+' + '=' * length + '+'
|
17
|
+
puts "|| " + text + " ||"
|
18
|
+
puts '+' + '=' * length + '+'
|
19
|
+
end
|
20
|
+
|
21
|
+
def center_text(text)
|
22
|
+
total_length = 80
|
23
|
+
text_length = text.length
|
24
|
+
leading_space = (total_length - text_length) / 2
|
25
|
+
puts ' ' * leading_space + text
|
26
|
+
end
|
27
|
+
|
28
|
+
def right_align_text(text)
|
29
|
+
total_length = 80
|
30
|
+
text_length = text.length
|
31
|
+
leading_space = total_length - text_length
|
32
|
+
puts ' ' * leading_space + text
|
33
|
+
end
|
34
|
+
|
35
|
+
def draw_horizontal_line(length)
|
36
|
+
puts '-' * length
|
37
|
+
end
|
38
|
+
|
39
|
+
def draw_vertical_line(length)
|
40
|
+
length.times { puts '|' }
|
41
|
+
end
|
42
|
+
|
43
|
+
def star_text(text)
|
44
|
+
length = text.length + 6
|
45
|
+
puts '*' * length
|
46
|
+
puts "** " + text + " **"
|
47
|
+
puts '*' * length
|
48
|
+
end
|
49
|
+
|
50
|
+
def triangle_text(text)
|
51
|
+
length = text.length + 2
|
52
|
+
length.times { |i| puts ' ' * (length - i) + text[0..i] }
|
53
|
+
end
|
54
|
+
|
55
|
+
def pyramid_text(text)
|
56
|
+
length = text.length
|
57
|
+
(length / 2 + 1).times do |i|
|
58
|
+
puts ' ' * (length - i) + text[0..(2*i)] + ' ' * (length - i)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Testing function
|
63
|
+
def test_all_drawing_methods
|
64
|
+
# Test the line function
|
65
|
+
puts "Testing the line function:"
|
66
|
+
line
|
67
|
+
puts "\n"
|
68
|
+
|
69
|
+
# Test the box_text function
|
70
|
+
puts "Testing the box_text function:"
|
71
|
+
box_text("Test text")
|
72
|
+
puts "\n"
|
73
|
+
|
74
|
+
# Test the double_box_text function
|
75
|
+
puts "Testing the double_box_text function:"
|
76
|
+
double_box_text("Test text")
|
77
|
+
puts "\n"
|
78
|
+
|
79
|
+
# Test the center_text function
|
80
|
+
puts "Testing the center_text function:"
|
81
|
+
center_text("Test text")
|
82
|
+
puts "\n"
|
83
|
+
|
84
|
+
# Test the right_align_text function
|
85
|
+
puts "Testing the right_align_text function:"
|
86
|
+
right_align_text("Test text")
|
87
|
+
puts "\n"
|
88
|
+
|
89
|
+
# Test the draw_horizontal_line function
|
90
|
+
puts "Testing the draw_horizontal_line function:"
|
91
|
+
draw_horizontal_line(10)
|
92
|
+
puts "\n"
|
93
|
+
|
94
|
+
# Test the draw_vertical_line function
|
95
|
+
puts "Testing the draw_vertical_line function:"
|
96
|
+
draw_vertical_line(10)
|
97
|
+
puts "\n"
|
98
|
+
|
99
|
+
# Test the star_text function
|
100
|
+
puts "Testing the star_text function:"
|
101
|
+
star_text("Test text")
|
102
|
+
puts "\n"
|
103
|
+
|
104
|
+
# Test the triangle_text function
|
105
|
+
puts "Testing the triangle_text function:"
|
106
|
+
triangle_text("Test text")
|
107
|
+
puts "\n"
|
108
|
+
|
109
|
+
# Test the pyramid_text function
|
110
|
+
puts "Testing the pyramid_text function:"
|
111
|
+
pyramid_text("Test text")
|
112
|
+
puts "\n"
|
113
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bash_help
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zack Fisher
|
@@ -18,6 +18,8 @@ extra_rdoc_files: []
|
|
18
18
|
files:
|
19
19
|
- lib/bash_help.rb
|
20
20
|
- lib/bash_standins.rb
|
21
|
+
- lib/compile.rb
|
22
|
+
- lib/drawing.rb
|
21
23
|
- lib/general_helpers.rb
|
22
24
|
- lib/hello_module.rb
|
23
25
|
homepage: https://github.com/zack-fisher
|