colorcode_convert_rgb 0.1.0

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 (158) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +23 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +40 -0
  6. data/Rakefile +10 -0
  7. data/bin/console +14 -0
  8. data/bin/setup +8 -0
  9. data/colorcode_convert_rgb.gemspec +30 -0
  10. data/exe/colorcode_convert_rgb +4 -0
  11. data/lib/colorcode_convert_rgb.rb +7 -0
  12. data/lib/colorcode_convert_rgb/cli.rb +13 -0
  13. data/lib/colorcode_convert_rgb/version.rb +3 -0
  14. data/vendor/bundle/ruby/2.5.0/bin/colorcode_convert_rgb +27 -0
  15. data/vendor/bundle/ruby/2.5.0/bin/rake +27 -0
  16. data/vendor/bundle/ruby/2.5.0/bin/thor +27 -0
  17. data/vendor/bundle/ruby/2.5.0/cache/minitest-5.14.2.gem +0 -0
  18. data/vendor/bundle/ruby/2.5.0/cache/rake-12.3.3.gem +0 -0
  19. data/vendor/bundle/ruby/2.5.0/cache/thor-1.0.1.gem +0 -0
  20. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/.autotest +34 -0
  21. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/History.rdoc +1397 -0
  22. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/Manifest.txt +27 -0
  23. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/README.rdoc +764 -0
  24. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/Rakefile +74 -0
  25. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/design_rationale.rb +52 -0
  26. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/hoe/minitest.rb +32 -0
  27. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest.rb +1056 -0
  28. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/assertions.rb +807 -0
  29. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/autorun.rb +13 -0
  30. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/benchmark.rb +455 -0
  31. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/expectations.rb +303 -0
  32. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/hell.rb +11 -0
  33. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/mock.rb +240 -0
  34. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/parallel.rb +70 -0
  35. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/pride.rb +4 -0
  36. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/pride_plugin.rb +142 -0
  37. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/spec.rb +342 -0
  38. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/test.rb +220 -0
  39. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/lib/minitest/unit.rb +45 -0
  40. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/test/minitest/metametameta.rb +136 -0
  41. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/test/minitest/test_minitest_assertions.rb +1575 -0
  42. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/test/minitest/test_minitest_benchmark.rb +137 -0
  43. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/test/minitest/test_minitest_mock.rb +872 -0
  44. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/test/minitest/test_minitest_reporter.rb +299 -0
  45. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/test/minitest/test_minitest_spec.rb +1061 -0
  46. data/vendor/bundle/ruby/2.5.0/gems/minitest-5.14.2/test/minitest/test_minitest_test.rb +1084 -0
  47. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/CONTRIBUTING.rdoc +43 -0
  48. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/Gemfile +3 -0
  49. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/History.rdoc +2344 -0
  50. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/MIT-LICENSE +21 -0
  51. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/README.rdoc +156 -0
  52. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/Rakefile +41 -0
  53. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/azure-pipelines.yml +11 -0
  54. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/bin/bundle +105 -0
  55. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/bin/console +7 -0
  56. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/bin/rake +29 -0
  57. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/bin/rdoc +29 -0
  58. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/bin/rubocop +29 -0
  59. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/bin/setup +6 -0
  60. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/command_line_usage.rdoc +158 -0
  61. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/example/Rakefile1 +38 -0
  62. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/example/Rakefile2 +35 -0
  63. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/example/a.c +6 -0
  64. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/example/b.c +6 -0
  65. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/example/main.c +11 -0
  66. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/glossary.rdoc +42 -0
  67. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/jamis.rb +592 -0
  68. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/proto_rake.rdoc +127 -0
  69. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/rake.1 +156 -0
  70. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/rakefile.rdoc +622 -0
  71. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/doc/rational.rdoc +151 -0
  72. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/exe/rake +27 -0
  73. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake.rb +71 -0
  74. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/application.rb +824 -0
  75. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/backtrace.rb +24 -0
  76. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/clean.rb +78 -0
  77. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/cloneable.rb +17 -0
  78. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/cpu_counter.rb +107 -0
  79. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/default_loader.rb +15 -0
  80. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/dsl_definition.rb +195 -0
  81. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/early_time.rb +22 -0
  82. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/ext/core.rb +26 -0
  83. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/ext/string.rb +176 -0
  84. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/file_creation_task.rb +25 -0
  85. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/file_list.rb +435 -0
  86. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/file_task.rb +54 -0
  87. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/file_utils.rb +137 -0
  88. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/file_utils_ext.rb +145 -0
  89. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/invocation_chain.rb +57 -0
  90. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/invocation_exception_mixin.rb +17 -0
  91. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/late_time.rb +18 -0
  92. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/linked_list.rb +112 -0
  93. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/loaders/makefile.rb +54 -0
  94. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/multi_task.rb +14 -0
  95. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/name_space.rb +38 -0
  96. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/packagetask.rb +207 -0
  97. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/phony.rb +16 -0
  98. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/private_reader.rb +21 -0
  99. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/promise.rb +100 -0
  100. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/pseudo_status.rb +30 -0
  101. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/rake_module.rb +67 -0
  102. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/rake_test_loader.rb +27 -0
  103. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/rule_recursion_overflow_error.rb +20 -0
  104. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/scope.rb +43 -0
  105. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/task.rb +413 -0
  106. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/task_argument_error.rb +8 -0
  107. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/task_arguments.rb +109 -0
  108. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/task_manager.rb +324 -0
  109. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/tasklib.rb +12 -0
  110. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/testtask.rb +224 -0
  111. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/thread_history_display.rb +49 -0
  112. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/thread_pool.rb +163 -0
  113. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/trace_output.rb +23 -0
  114. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/version.rb +10 -0
  115. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/lib/rake/win32.rb +51 -0
  116. data/vendor/bundle/ruby/2.5.0/gems/rake-12.3.3/rake.gemspec +42 -0
  117. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/.document +5 -0
  118. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/CHANGELOG.md +220 -0
  119. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/CONTRIBUTING.md +15 -0
  120. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/LICENSE.md +20 -0
  121. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/README.md +51 -0
  122. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/bin/thor +6 -0
  123. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor.rb +517 -0
  124. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/actions.rb +336 -0
  125. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/actions/create_file.rb +104 -0
  126. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/actions/create_link.rb +61 -0
  127. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/actions/directory.rb +108 -0
  128. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/actions/empty_directory.rb +143 -0
  129. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/actions/file_manipulation.rb +373 -0
  130. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/actions/inject_into_file.rb +120 -0
  131. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/base.rb +699 -0
  132. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/command.rb +142 -0
  133. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/core_ext/hash_with_indifferent_access.rb +97 -0
  134. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/error.rb +110 -0
  135. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/group.rb +281 -0
  136. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/invocation.rb +178 -0
  137. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/line_editor.rb +17 -0
  138. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/line_editor/basic.rb +37 -0
  139. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/line_editor/readline.rb +88 -0
  140. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/nested_context.rb +29 -0
  141. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/parser.rb +4 -0
  142. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/parser/argument.rb +70 -0
  143. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/parser/arguments.rb +175 -0
  144. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/parser/option.rb +159 -0
  145. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/parser/options.rb +236 -0
  146. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/rake_compat.rb +72 -0
  147. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/runner.rb +325 -0
  148. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/shell.rb +81 -0
  149. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/shell/basic.rb +491 -0
  150. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/shell/color.rb +153 -0
  151. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/shell/html.rb +126 -0
  152. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/util.rb +284 -0
  153. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/lib/thor/version.rb +3 -0
  154. data/vendor/bundle/ruby/2.5.0/gems/thor-1.0.1/thor.gemspec +28 -0
  155. data/vendor/bundle/ruby/2.5.0/specifications/minitest-5.14.2.gemspec +38 -0
  156. data/vendor/bundle/ruby/2.5.0/specifications/rake-12.3.3.gemspec +43 -0
  157. data/vendor/bundle/ruby/2.5.0/specifications/thor-1.0.1.gemspec +34 -0
  158. metadata +214 -0
@@ -0,0 +1,70 @@
1
+ module Minitest
2
+ module Parallel #:nodoc:
3
+
4
+ ##
5
+ # The engine used to run multiple tests in parallel.
6
+
7
+ class Executor
8
+
9
+ ##
10
+ # The size of the pool of workers.
11
+
12
+ attr_reader :size
13
+
14
+ ##
15
+ # Create a parallel test executor of with +size+ workers.
16
+
17
+ def initialize size
18
+ @size = size
19
+ @queue = Queue.new
20
+ @pool = nil
21
+ end
22
+
23
+ ##
24
+ # Start the executor
25
+
26
+ def start
27
+ @pool = size.times.map {
28
+ Thread.new(@queue) do |queue|
29
+ Thread.current.abort_on_exception = true
30
+ while (job = queue.pop)
31
+ klass, method, reporter = job
32
+ reporter.synchronize { reporter.prerecord klass, method }
33
+ result = Minitest.run_one_method klass, method
34
+ reporter.synchronize { reporter.record result }
35
+ end
36
+ end
37
+ }
38
+ end
39
+
40
+ ##
41
+ # Add a job to the queue
42
+
43
+ def << work; @queue << work; end
44
+
45
+ ##
46
+ # Shuts down the pool of workers by signalling them to quit and
47
+ # waiting for them all to finish what they're currently working
48
+ # on.
49
+
50
+ def shutdown
51
+ size.times { @queue << nil }
52
+ @pool.each(&:join)
53
+ end
54
+ end
55
+
56
+ module Test # :nodoc:
57
+ def _synchronize; Minitest::Test.io_lock.synchronize { yield }; end # :nodoc:
58
+
59
+ module ClassMethods # :nodoc:
60
+ def run_one_method klass, method_name, reporter
61
+ Minitest.parallel_executor << [klass, method_name, reporter]
62
+ end
63
+
64
+ def test_order
65
+ :parallel
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,4 @@
1
+ require "minitest"
2
+
3
+ Minitest.load_plugins
4
+ Minitest::PrideIO.pride!
@@ -0,0 +1,142 @@
1
+ require "minitest"
2
+
3
+ module Minitest
4
+ def self.plugin_pride_options opts, _options # :nodoc:
5
+ opts.on "-p", "--pride", "Pride. Show your testing pride!" do
6
+ PrideIO.pride!
7
+ end
8
+ end
9
+
10
+ def self.plugin_pride_init options # :nodoc:
11
+ if PrideIO.pride? then
12
+ klass = ENV["TERM"] =~ /^xterm|-256color$/ ? PrideLOL : PrideIO
13
+ io = klass.new options[:io]
14
+
15
+ self.reporter.reporters.grep(Minitest::Reporter).each do |rep|
16
+ rep.io = io if rep.io.tty?
17
+ end
18
+ end
19
+ end
20
+
21
+ ##
22
+ # Show your testing pride!
23
+
24
+ class PrideIO
25
+ ##
26
+ # Activate the pride plugin. Called from both -p option and minitest/pride
27
+
28
+ def self.pride!
29
+ @pride = true
30
+ end
31
+
32
+ ##
33
+ # Are we showing our testing pride?
34
+
35
+ def self.pride?
36
+ @pride ||= false
37
+ end
38
+
39
+ # Start an escape sequence
40
+ ESC = "\e["
41
+
42
+ # End the escape sequence
43
+ NND = "#{ESC}0m"
44
+
45
+ # The IO we're going to pipe through.
46
+ attr_reader :io
47
+
48
+ def initialize io # :nodoc:
49
+ @io = io
50
+ # stolen from /System/Library/Perl/5.10.0/Term/ANSIColor.pm
51
+ # also reference http://en.wikipedia.org/wiki/ANSI_escape_code
52
+ @colors ||= (31..36).to_a
53
+ @size = @colors.size
54
+ @index = 0
55
+ end
56
+
57
+ ##
58
+ # Wrap print to colorize the output.
59
+
60
+ def print o
61
+ case o
62
+ when "." then
63
+ io.print pride o
64
+ when "E", "F" then
65
+ io.print "#{ESC}41m#{ESC}37m#{o}#{NND}"
66
+ when "S" then
67
+ io.print pride o
68
+ else
69
+ io.print o
70
+ end
71
+ end
72
+
73
+ def puts *o # :nodoc:
74
+ o.map! { |s|
75
+ s.to_s.sub(/Finished/) {
76
+ @index = 0
77
+ "Fabulous run".split(//).map { |c|
78
+ pride(c)
79
+ }.join
80
+ }
81
+ }
82
+
83
+ io.puts(*o)
84
+ end
85
+
86
+ ##
87
+ # Color a string.
88
+
89
+ def pride string
90
+ string = "*" if string == "."
91
+ c = @colors[@index % @size]
92
+ @index += 1
93
+ "#{ESC}#{c}m#{string}#{NND}"
94
+ end
95
+
96
+ def method_missing msg, *args # :nodoc:
97
+ io.send(msg, *args)
98
+ end
99
+ end
100
+
101
+ ##
102
+ # If you thought the PrideIO was colorful...
103
+ #
104
+ # (Inspired by lolcat, but with clean math)
105
+
106
+ class PrideLOL < PrideIO
107
+ PI_3 = Math::PI / 3 # :nodoc:
108
+
109
+ def initialize io # :nodoc:
110
+ # walk red, green, and blue around a circle separated by equal thirds.
111
+ #
112
+ # To visualize, type this into wolfram-alpha:
113
+ #
114
+ # plot (3*sin(x)+3), (3*sin(x+2*pi/3)+3), (3*sin(x+4*pi/3)+3)
115
+
116
+ # 6 has wide pretty gradients. 3 == lolcat, about half the width
117
+ @colors = (0...(6 * 7)).map { |n|
118
+ n *= 1.0 / 6
119
+ r = (3 * Math.sin(n ) + 3).to_i
120
+ g = (3 * Math.sin(n + 2 * PI_3) + 3).to_i
121
+ b = (3 * Math.sin(n + 4 * PI_3) + 3).to_i
122
+
123
+ # Then we take rgb and encode them in a single number using base 6.
124
+ # For some mysterious reason, we add 16... to clear the bottom 4 bits?
125
+ # Yes... they're ugly.
126
+
127
+ 36 * r + 6 * g + b + 16
128
+ }
129
+
130
+ super
131
+ end
132
+
133
+ ##
134
+ # Make the string even more colorful. Damnit.
135
+
136
+ def pride string
137
+ c = @colors[@index % @size]
138
+ @index += 1
139
+ "#{ESC}38;5;#{c}m#{string}#{NND}"
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,342 @@
1
+ require "minitest/test"
2
+
3
+ class Module # :nodoc:
4
+ def infect_an_assertion meth, new_name, dont_flip = false # :nodoc:
5
+ block = dont_flip == :block
6
+ dont_flip = false if block
7
+
8
+ # warn "%-22p -> %p %p" % [meth, new_name, dont_flip]
9
+ self.class_eval <<-EOM, __FILE__, __LINE__ + 1
10
+ def #{new_name} *args
11
+ where = Minitest.filter_backtrace(caller).first
12
+ where = where.split(/:in /, 2).first # clean up noise
13
+ warn "DEPRECATED: global use of #{new_name} from #\{where}. Use _(obj).#{new_name} instead. This will fail in Minitest 6."
14
+ Minitest::Expectation.new(self, Minitest::Spec.current).#{new_name}(*args)
15
+ end
16
+ EOM
17
+
18
+ Minitest::Expectation.class_eval <<-EOM, __FILE__, __LINE__ + 1
19
+ def #{new_name} *args
20
+ raise "Calling ##{new_name} outside of test." unless ctx
21
+ case
22
+ when #{!!dont_flip} then
23
+ ctx.#{meth}(target, *args)
24
+ when #{block} && Proc === target then
25
+ ctx.#{meth}(*args, &target)
26
+ else
27
+ ctx.#{meth}(args.first, target, *args[1..-1])
28
+ end
29
+ end
30
+ EOM
31
+ end
32
+ end
33
+
34
+ Minitest::Expectation = Struct.new :target, :ctx # :nodoc:
35
+
36
+ ##
37
+ # Kernel extensions for minitest
38
+
39
+ module Kernel
40
+ ##
41
+ # Describe a series of expectations for a given target +desc+.
42
+ #
43
+ # Defines a test class subclassing from either Minitest::Spec or
44
+ # from the surrounding describe's class. The surrounding class may
45
+ # subclass Minitest::Spec manually in order to easily share code:
46
+ #
47
+ # class MySpec < Minitest::Spec
48
+ # # ... shared code ...
49
+ # end
50
+ #
51
+ # class TestStuff < MySpec
52
+ # it "does stuff" do
53
+ # # shared code available here
54
+ # end
55
+ # describe "inner stuff" do
56
+ # it "still does stuff" do
57
+ # # ...and here
58
+ # end
59
+ # end
60
+ # end
61
+ #
62
+ # For more information on getting started with writing specs, see:
63
+ #
64
+ # http://www.rubyinside.com/a-minitestspec-tutorial-elegant-spec-style-testing-that-comes-with-ruby-5354.html
65
+ #
66
+ # For some suggestions on how to improve your specs, try:
67
+ #
68
+ # http://betterspecs.org
69
+ #
70
+ # but do note that several items there are debatable or specific to
71
+ # rspec.
72
+ #
73
+ # For more information about expectations, see Minitest::Expectations.
74
+
75
+ def describe desc, *additional_desc, &block # :doc:
76
+ stack = Minitest::Spec.describe_stack
77
+ name = [stack.last, desc, *additional_desc].compact.join("::")
78
+ sclas = stack.last || if Class === self && kind_of?(Minitest::Spec::DSL) then
79
+ self
80
+ else
81
+ Minitest::Spec.spec_type desc, *additional_desc
82
+ end
83
+
84
+ cls = sclas.create name, desc
85
+
86
+ stack.push cls
87
+ cls.class_eval(&block)
88
+ stack.pop
89
+ cls
90
+ end
91
+ private :describe
92
+ end
93
+
94
+ ##
95
+ # Minitest::Spec -- The faster, better, less-magical spec framework!
96
+ #
97
+ # For a list of expectations, see Minitest::Expectations.
98
+
99
+ class Minitest::Spec < Minitest::Test
100
+
101
+ def self.current # :nodoc:
102
+ Thread.current[:current_spec]
103
+ end
104
+
105
+ def initialize name # :nodoc:
106
+ super
107
+ Thread.current[:current_spec] = self
108
+ end
109
+
110
+ ##
111
+ # Oh look! A Minitest::Spec::DSL module! Eat your heart out DHH.
112
+
113
+ module DSL
114
+ ##
115
+ # Contains pairs of matchers and Spec classes to be used to
116
+ # calculate the superclass of a top-level describe. This allows for
117
+ # automatically customizable spec types.
118
+ #
119
+ # See: register_spec_type and spec_type
120
+
121
+ TYPES = [[//, Minitest::Spec]]
122
+
123
+ ##
124
+ # Register a new type of spec that matches the spec's description.
125
+ # This method can take either a Regexp and a spec class or a spec
126
+ # class and a block that takes the description and returns true if
127
+ # it matches.
128
+ #
129
+ # Eg:
130
+ #
131
+ # register_spec_type(/Controller$/, Minitest::Spec::Rails)
132
+ #
133
+ # or:
134
+ #
135
+ # register_spec_type(Minitest::Spec::RailsModel) do |desc|
136
+ # desc.superclass == ActiveRecord::Base
137
+ # end
138
+
139
+ def register_spec_type *args, &block
140
+ if block then
141
+ matcher, klass = block, args.first
142
+ else
143
+ matcher, klass = *args
144
+ end
145
+ TYPES.unshift [matcher, klass]
146
+ end
147
+
148
+ ##
149
+ # Figure out the spec class to use based on a spec's description. Eg:
150
+ #
151
+ # spec_type("BlahController") # => Minitest::Spec::Rails
152
+
153
+ def spec_type desc, *additional
154
+ TYPES.find { |matcher, _klass|
155
+ if matcher.respond_to? :call then
156
+ matcher.call desc, *additional
157
+ else
158
+ matcher === desc.to_s
159
+ end
160
+ }.last
161
+ end
162
+
163
+ def describe_stack # :nodoc:
164
+ Thread.current[:describe_stack] ||= []
165
+ end
166
+
167
+ def children # :nodoc:
168
+ @children ||= []
169
+ end
170
+
171
+ def nuke_test_methods! # :nodoc:
172
+ self.public_instance_methods.grep(/^test_/).each do |name|
173
+ self.send :undef_method, name
174
+ end
175
+ end
176
+
177
+ ##
178
+ # Define a 'before' action. Inherits the way normal methods should.
179
+ #
180
+ # NOTE: +type+ is ignored and is only there to make porting easier.
181
+ #
182
+ # Equivalent to Minitest::Test#setup.
183
+
184
+ def before _type = nil, &block
185
+ define_method :setup do
186
+ super()
187
+ self.instance_eval(&block)
188
+ end
189
+ end
190
+
191
+ ##
192
+ # Define an 'after' action. Inherits the way normal methods should.
193
+ #
194
+ # NOTE: +type+ is ignored and is only there to make porting easier.
195
+ #
196
+ # Equivalent to Minitest::Test#teardown.
197
+
198
+ def after _type = nil, &block
199
+ define_method :teardown do
200
+ self.instance_eval(&block)
201
+ super()
202
+ end
203
+ end
204
+
205
+ ##
206
+ # Define an expectation with name +desc+. Name gets morphed to a
207
+ # proper test method name. For some freakish reason, people who
208
+ # write specs don't like class inheritance, so this goes way out of
209
+ # its way to make sure that expectations aren't inherited.
210
+ #
211
+ # This is also aliased to #specify and doesn't require a +desc+ arg.
212
+ #
213
+ # Hint: If you _do_ want inheritance, use minitest/test. You can mix
214
+ # and match between assertions and expectations as much as you want.
215
+
216
+ def it desc = "anonymous", &block
217
+ block ||= proc { skip "(no tests defined)" }
218
+
219
+ @specs ||= 0
220
+ @specs += 1
221
+
222
+ name = "test_%04d_%s" % [ @specs, desc ]
223
+
224
+ undef_klasses = self.children.reject { |c| c.public_method_defined? name }
225
+
226
+ define_method name, &block
227
+
228
+ undef_klasses.each do |undef_klass|
229
+ undef_klass.send :undef_method, name
230
+ end
231
+
232
+ name
233
+ end
234
+
235
+ ##
236
+ # Essentially, define an accessor for +name+ with +block+.
237
+ #
238
+ # Why use let instead of def? I honestly don't know.
239
+
240
+ def let name, &block
241
+ name = name.to_s
242
+ pre, post = "let '#{name}' cannot ", ". Please use another name."
243
+ methods = Minitest::Spec.instance_methods.map(&:to_s) - %w[subject]
244
+ raise ArgumentError, "#{pre}begin with 'test'#{post}" if
245
+ name =~ /\Atest/
246
+ raise ArgumentError, "#{pre}override a method in Minitest::Spec#{post}" if
247
+ methods.include? name
248
+
249
+ define_method name do
250
+ @_memoized ||= {}
251
+ @_memoized.fetch(name) { |k| @_memoized[k] = instance_eval(&block) }
252
+ end
253
+ end
254
+
255
+ ##
256
+ # Another lazy man's accessor generator. Made even more lazy by
257
+ # setting the name for you to +subject+.
258
+
259
+ def subject &block
260
+ let :subject, &block
261
+ end
262
+
263
+ def create name, desc # :nodoc:
264
+ cls = Class.new(self) do
265
+ @name = name
266
+ @desc = desc
267
+
268
+ nuke_test_methods!
269
+ end
270
+
271
+ children << cls
272
+
273
+ cls
274
+ end
275
+
276
+ def name # :nodoc:
277
+ defined?(@name) ? @name : super
278
+ end
279
+
280
+ def to_s # :nodoc:
281
+ name # Can't alias due to 1.8.7, not sure why
282
+ end
283
+
284
+ attr_reader :desc # :nodoc:
285
+ alias :specify :it
286
+
287
+ ##
288
+ # Rdoc... why are you so dumb?
289
+
290
+ module InstanceMethods
291
+ ##
292
+ # Takes a value or a block and returns a value monad that has
293
+ # all of Expectations methods available to it.
294
+ #
295
+ # _(1 + 1).must_equal 2
296
+ #
297
+ # And for blocks:
298
+ #
299
+ # _ { 1 + "1" }.must_raise TypeError
300
+ #
301
+ # This method of expectation-based testing is preferable to
302
+ # straight-expectation methods (on Object) because it stores its
303
+ # test context, bypassing our hacky use of thread-local variables.
304
+ #
305
+ # NOTE: At some point, the methods on Object will be deprecated
306
+ # and then removed.
307
+ #
308
+ # It is also aliased to #value and #expect for your aesthetic
309
+ # pleasure:
310
+ #
311
+ # _(1 + 1).must_equal 2
312
+ # value(1 + 1).must_equal 2
313
+ # expect(1 + 1).must_equal 2
314
+
315
+ def _ value = nil, &block
316
+ Minitest::Expectation.new block || value, self
317
+ end
318
+
319
+ alias value _
320
+ alias expect _
321
+
322
+ def before_setup # :nodoc:
323
+ super
324
+ Thread.current[:current_spec] = self
325
+ end
326
+ end
327
+
328
+ def self.extended obj # :nodoc:
329
+ obj.send :include, InstanceMethods
330
+ end
331
+ end
332
+
333
+ extend DSL
334
+
335
+ TYPES = DSL::TYPES # :nodoc:
336
+ end
337
+
338
+ require "minitest/expectations"
339
+
340
+ class Object # :nodoc:
341
+ include Minitest::Expectations unless ENV["MT_NO_EXPECTATIONS"]
342
+ end