bash_help 0.0.6 → 0.0.7

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
2
  SHA256:
3
- metadata.gz: 7d5ea3c23f7cfe859565d88a1b5e1cc6ea5ad45b0ba88113e0674bd68a9a7480
4
- data.tar.gz: 01146b54892d107d977fe8f4b88197242c6d2c644e68b258afb6f77594fa3696
3
+ metadata.gz: 5ba51a95971f3b6ec99e21420faa25c89035028aee10cc4ce50914a983a326af
4
+ data.tar.gz: 253f33b13708c8bb6b963b61d238763799e8597a70e1f8ab6cf46f6a07c050e0
5
5
  SHA512:
6
- metadata.gz: d914a3d9ba07446fe3192cea18f24c0e3859630c94af472f1267c26bcd56673a1fdd5995db5a8735f2a1374fe97e5179aa19e517f813f0a00fc6abf72cace132
7
- data.tar.gz: 0d86f7249d67720f2893f4a671c93bfa50d24396fe26a9676ed9d92abfd7676287047b259a96037ddae8cf3da98a1d86d111e1fcc5a548f13e3c82a91e4262b1
6
+ metadata.gz: 2292d7a6d5a61723f63bd4ce3e4a36905ef7e7f5d54e36645f5bbccf42b5ed8dc7b050fd221845810701ed918ead3599b6dacda6d0cabcaab3cadd7657300954
7
+ data.tar.gz: c4719b8257130483286d0a048eab33e063ffbd2dad6edb5d35d890cd98e6f358b13d61a0e7861fc157f69671ccff5589022c83de8e9a3066bc09bce0570db7cb
data/lib/bash_help.rb CHANGED
@@ -7,3 +7,5 @@
7
7
  require_relative 'hello_module.rb'
8
8
  require_relative 'bash_standins.rb'
9
9
  require_relative 'general_helpers.rb'
10
+ require_relative 'drawing.rb'
11
+ require_relative 'compile.rb'
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,116 @@
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
114
+
115
+ # Run the testing function
116
+ test_all_drawing_methods
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.6
4
+ version: 0.0.7
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