summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTom Black <[email protected]>2018-10-16 23:24:18 -0700
committerTom Black <[email protected]>2018-10-16 23:24:18 -0700
commit1b646f82c67e7c38df08113bcc3323c7aaf4639f (patch)
treed932a3d054ceba5ce5be69e42453998787cf4d9f
parenta4a7e23038e26ecc63d94b5e815c36dff2ffb433 (diff)
downloadruby2d-1b646f82c67e7c38df08113bcc3323c7aaf4639f.tar.gz
ruby2d-1b646f82c67e7c38df08113bcc3323c7aaf4639f.zip
Move `String#colorize` to a separate file to require
-rw-r--r--Rakefile14
-rwxr-xr-xbin/ruby2d9
-rw-r--r--ext/ruby2d/extconf.rb9
-rw-r--r--lib/ruby2d.rb3
-rw-r--r--lib/ruby2d/colorize.rb10
5 files changed, 18 insertions, 27 deletions
diff --git a/Rakefile b/Rakefile
index b91fa6a..99382e5 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,18 +1,10 @@
require 'rspec/core/rake_task'
+require_relative 'lib/ruby2d/colorize'
require_relative 'lib/ruby2d/version'
-# Helpers
-
-class String
- def colorize(c); "\e[#{c}m#{self}\e[0m" end
- def bold; colorize('1') end
- def blue; colorize('1;34') end
- def red; colorize('1;31') end
-end
-
# Simple 2D is required for these tasks
if `which simple2d`.empty?
- puts "Simple 2D not found!".red
+ puts "Simple 2D not found!".error
puts "Install before running Rake tasks."
exit
end
@@ -22,7 +14,7 @@ def get_args
end
def print_task(task)
- print "\n", "==> ".blue, task.bold, "\n\n"
+ print "\n", "==> ".info, task.bold, "\n\n"
end
def run_cmd(cmd)
diff --git a/bin/ruby2d b/bin/ruby2d
index 9fe9714..9a819d9 100755
--- a/bin/ruby2d
+++ b/bin/ruby2d
@@ -1,15 +1,8 @@
#!/usr/bin/env ruby
+require 'ruby2d/colorize'
require 'ruby2d/version'
require 'fileutils'
-# Extending `String` to include some fancy colors
-class String
- def colorize(c); "\e[#{c}m#{self}\e[0m" end
- def bold; colorize('1') end
- def warn; colorize('1;33') end
- def error; colorize('1;31') end
-end
-
# The installed gem directory
@gem_dir = "#{Gem::Specification.find_by_name('ruby2d').gem_dir}"
diff --git a/ext/ruby2d/extconf.rb b/ext/ruby2d/extconf.rb
index d3ddac0..3cd2302 100644
--- a/ext/ruby2d/extconf.rb
+++ b/ext/ruby2d/extconf.rb
@@ -1,17 +1,12 @@
require 'mkmf'
+require_relative '../../lib/ruby2d/colorize'
S2D_VERSION = '1.0.1' # Simple 2D minimum version required
$errors = []
-class String
- def colorize(c); "\e[#{c}m#{self}\e[0m" end
- def bold; colorize('1') end
- def red; colorize('1;31') end
-end
-
def print_errors
puts "
-#{"== #{"Ruby 2D Installation Errors".red} =======================================\n"}
+#{"== #{"Ruby 2D Installation Errors".error} =======================================\n"}
#{$errors.join("\n ")}\n
#{"======================================================================="}"
end
diff --git a/lib/ruby2d.rb b/lib/ruby2d.rb
index 58a69da..2471888 100644
--- a/lib/ruby2d.rb
+++ b/lib/ruby2d.rb
@@ -1,7 +1,8 @@
# Ruby2D module and native extension loader, adds DSL
-require 'ruby2d/renderable'
+require 'ruby2d/colorize'
require 'ruby2d/exceptions'
+require 'ruby2d/renderable'
require 'ruby2d/color'
require 'ruby2d/window'
require 'ruby2d/dsl'
diff --git a/lib/ruby2d/colorize.rb b/lib/ruby2d/colorize.rb
new file mode 100644
index 0000000..856ecb8
--- /dev/null
+++ b/lib/ruby2d/colorize.rb
@@ -0,0 +1,10 @@
+# String#colorize
+
+# Extend `String` to include some fancy colors
+class String
+ def colorize(c); "\e[#{c}m#{self}\e[0m" end
+ def bold; colorize('1') end
+ def info; colorize('1;34') end
+ def warn; colorize('1;33') end
+ def error; colorize('1;31') end
+end