lib/pry-theme/helper.rb in pry-theme-0.0.10 vs lib/pry-theme/helper.rb in pry-theme-0.1.0
- old
+ new
@@ -34,15 +34,54 @@
def local_theme(name)
File.join(THEME_DIR, name)
end
+ def pathify_theme(name)
+ File.join(THEME_DIR, "#{ name }.prytheme")
+ end
+
def fetch_collection(path, &block)
uri = URI.parse(COLLECTION + path)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
yield(http, uri)
+ end
+
+ def ansi?(color)
+ if color.to_s =~ /\A(\d{1,3})\z/
+ (0..255).include?(color.to_i)
+ else
+ false
+ end
+ end
+
+ def rgb?(color)
+ rgb_pattern = /
+ \A
+
+ ([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])
+ ,
+ ([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])
+ ,
+ ([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])
+
+ \z
+ /x
+ color =~ rgb_pattern ? true : false
+ end
+
+ def hex?(color)
+ color =~ /\A#?[A-F\d]{6}\z/i ? true : false
+ end
+
+ def display_header(text, out)
+ safe_width = 80
+
+ out.puts "-" * safe_width
+ out.puts make_bold(text.center(safe_width))
+ out.puts "-" * safe_width
end
end
end