bopeep 0.1.6

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.
Files changed (6) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +1 -0
  3. data/bin/bopeep +7 -0
  4. data/bin/console-playground +123 -0
  5. data/lib/bopeep.rb +2294 -0
  6. metadata +200 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0c6ba8791b9e8e28d2650fcbed8846c95b86d210758362119e6ebaf67ae79644
4
+ data.tar.gz: 74d7390521096432e82a3e5aca5eb8ce70ed090f46136aa64bc2adaa758e739c
5
+ SHA512:
6
+ metadata.gz: 57bb72361cf6ebbee6602ba7988cd2760b519b16c5feccf05d1ff6074bdc069fb036320182871664bc9a3720085d4a0a4955ed65133866edb7e731db0a384df4
7
+ data.tar.gz: 3ceb06f5ffdc5c10643a21eee61623081736165c211b2bf16dbf53e2fee0df90d14879b6434bada1b5c0b46129d2310ca39489bac5f17195d1b68bfbfea5d7ed
data/README.md ADDED
@@ -0,0 +1 @@
1
+ # bopeep
data/bin/bopeep ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.expand_path(File.join("..", "..", "lib"), __FILE__))
4
+
5
+ require "bopeep"
6
+
7
+ BoPeep::Runner.new(ARGV).run
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "simplecov"
4
+ SimpleCov.start do
5
+ add_filter %r{^/(?:bopeep|test)/}
6
+ # For running on ruby 2.3 on CI. Latest simplecov requires ruby 2.4+ and `enable_coverage`
7
+ # only exists on the latest versions
8
+ respond_to?(:enable_coverage) and enable_coverage(:branch)
9
+
10
+ # Combine coverage results generated here to what's generated by the test suite
11
+ command_name "Unit Tests"
12
+ end
13
+
14
+ $:.unshift(File.expand_path(File.join("..", "..", "lib"), __FILE__))
15
+
16
+ if ENV["BYEBUG_REMOTE"] == "1"
17
+ require "byebug"
18
+ require "byebug/core"
19
+ Byebug.wait_connection = true
20
+ Byebug.start_server("localhost", 5000)
21
+ end
22
+
23
+ require "pry"
24
+
25
+ # NOTE: Unsure why `"set"` needs to be loaded here
26
+ require "bopeep"
27
+
28
+ console = BoPeep::Console.new
29
+
30
+ ctpa_town = BoPeep::Host.from("randy@ctpa-town.com")
31
+ sodo_sopa = BoPeep::Host.from("loo@sodo-sopa.com")
32
+ nomo_auchi = BoPeep::Host.from("pc@nomo-auchi.com")
33
+ lomo_robo = BoPeep::Host.from("luke@lomo-robo.com")
34
+
35
+ BoPeep::Console.hostname_width = [ctpa_town, sodo_sopa, nomo_auchi].map { |host| host.address.length }.max
36
+
37
+ console.redirecting_stdout_and_stderr do
38
+ # `mirame` is an example of content spanning multiple lines with its last line being longer
39
+ # than 0.
40
+ mirame = console.print_content "mirame!\n ahora! "
41
+
42
+ # We follow `mirame` with content on the same line; when we reset `mirame` to empty text later,
43
+ # this ensures content is correctly reflowed
44
+ console.print BoPeep::Console::SGR("buscame?").with(text_color: :green, effect: :underline)
45
+
46
+ sleep 2
47
+
48
+ # Add a `HostStatus` to check that changing host status after multi-line and single-line content
49
+ # works as expected
50
+ host_line_1 = BoPeep::Console::HostStatus.new(ctpa_town, console)
51
+
52
+ sleep 2
53
+
54
+ # Start a line with single-line content
55
+ que_tal = console.print_content "que tal "
56
+
57
+ sleep 2
58
+
59
+ # Add a `HostStatus`
60
+ host_line_2 = BoPeep::Console::HostStatus.new(sodo_sopa, console)
61
+
62
+ sleep 2
63
+
64
+ # Reset `mirame` to an empty string with SGR effects to check SGR sequences don't affect the
65
+ # `last_line_length` of the content
66
+ mirame.text = BoPeep::Console::SGR("").with(text_color: :cyan, effect: :strikethrough)
67
+
68
+ sleep 2
69
+
70
+ # Update the status of `host_line_1` to check that content after it is re-printed correctly
71
+ host_line_1.started!
72
+
73
+ sleep 2
74
+
75
+ # Add content using `Kernel#print` and `IOProxy#print` to test `IOProxy`
76
+ print "no me cambies! "
77
+ $stdout.print BoPeep::Console::SGR("dejame aqui! ").with(text_color: :red, effect: :blink_slow)
78
+
79
+ # Add more inline content
80
+ que_haces = console.print_content "que haces? "
81
+
82
+ sleep 2
83
+
84
+ # Add two host statuses
85
+ host_line_3 = BoPeep::Console::HostStatus.new(nomo_auchi, console)
86
+
87
+ sleep 2
88
+
89
+ host_line_4 = BoPeep::Console::HostStatus.new(lomo_robo, console)
90
+
91
+ $stdout.puts "me quedo aqui abajo"
92
+
93
+ sleep 2
94
+
95
+ # Change text so it is longer to check that content after it is reflowed correctly
96
+ que_tal.text = "que fue mijo?! "
97
+
98
+ sleep 2
99
+
100
+ host_line_4.started!
101
+
102
+ sleep 2
103
+
104
+ host_line_2.failed! <<~CONTENT
105
+ STDOUT: (none)
106
+ STDERR: unbound variable `$der'
107
+ CONTENT
108
+
109
+ sleep 2
110
+
111
+ que_haces.text = BoPeep::Console::SGR("cuanto quieres? ").with(text_color: :magenta)
112
+
113
+ sleep 2
114
+
115
+ host_line_3.failed! <<~CONTENT
116
+ STDOUT: (none)
117
+ STDERR: whoopsie!
118
+ CONTENT
119
+
120
+ sleep 2
121
+
122
+ host_line_4.success!
123
+ end