pry-theme 0.0.10 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,7 +43,7 @@ module PryTheme
43
43
  # @param [Integer] colors The number of colors to be used in the palette.
44
44
  def initialize(colors=8)
45
45
  @color_depth = colors.to_i
46
- @notation = "38;5;" if color_depth == 256
46
+ @notation = TermNotation::COLOR256 if color_depth == 256
47
47
 
48
48
  init_palette = "init_#{@color_depth}_colors"
49
49
 
@@ -74,7 +74,7 @@ module PryTheme
74
74
  def init_256_colors
75
75
  {
76
76
  :term => (0...256).to_a,
77
- :human => [ :black, :maroon, :toad_in_love, :olive, :navy_blue, :violet_eggplant, :teal, :silver, :gray, :red, :green, :yellow, :blue, :magenta, :cyan, :white, :black, :dark_indigo, :ultramarine01, :ultramarine02, :persian_blue01, :blue, :dark_spring_green, :dark_turquoise, :cerulean_grey01, :denim01, :royal_blue01, :royal_blue02, :toad_in_love01, :sea_green01, :teal01, :cerulean_grey02, :klein_blue, :azure01, :vert_de_pomme01, :jade01, :jade02, :robin_egg_blue01, :bondi_blue, :light_blue01, :vert_de_pomme02, :malachite01, :emerald01, :turquoise, :robin_egg_blue02, :electric01, :green, :spring_green01, :spring_green02, :mint_green01, :aquamarine01, :cyan, :flea_belly, :plum, :indigo, :purple01, :violet01, :persian_blue02, :khaki01, :wet_asphalt01, :seroburomalinovyj01, :denim02, :royal_blue03, :royal_blue04, :olive_drab, :fern_green, :slate_gray, :steel_blue, :cornflower_blue01, :azure02, :grass01, :emerald02, :sea_green02, :robin_egg_blue03, :bluish01, :light_blue02, :vert_de_pomme03, :pale_green01, :emerald03, :aquamarine02, :robin_egg_blue04, :sky01, :bright_green, :malachite02, :spring_green03, :chartreuse01, :aquamarine03, :cyan01, :maroon01, :eggplant01, :violet_eggplant01, :purple02, :violet02, :violet03, :khaki02, :pale_mauve01, :seroburomalinovyj02, :amethyst01, :amethyst02, :heliotrope01, :olive01, :dark_tan, :gray01, :bluish02, :cornflower_blue02, :royal_blue05, :grass02, :asparagus, :swamp_green01, :light_grey01, :bluish03, :cornflower_blue03, :green_yellow01, :pale_green02, :emerald04, :celadon, :pale_blue01, :sky02, :viridian, :vert_de_pomme04, :mint_green02, :chartreuse02, :aquamarine03, :electric02, :bismarck_furious, :eggplant02, :red_violet01, :violet_eggplant02, :bright_violet, :violet04, :ochre, :pale_mauve02, :pale_red_violet01, :orchid01, :amethyst03, :heliotrope02, :dark_goldenrod, :pale_brown, :mountbatten_pink, :lilac01, :wisteria01, :amethyst04, :old_gold, :brass01, :swamp_green02, :light_grey02, :niagara, :wisteria02, :lime01, :pistachio01, :moss_green, :dark_tea_green, :pale_blue02, :pale_cornflower_blue, :green_yellow02, :green_yellow03, :pistachio02, :chartreuse03, :aquamarine04, :pale_blue03, :titian, :cerise01, :red_violet02, :hot_pink01, :bright_violet, :magenta01, :tenne, :chestnut01, :pale_red_violet02, :orchid02, :orchid03, :heliotrope03, :siena, :dark_salmon, :puce01, :puce2, :violaceous01, :violaceous02, :dark_pear, :brass02, :tan, :pale_chestnut, :lilac02, :wisteria03, :childs_surprise, :vert_de_peche, :flax, :gray_tea_green, :abdel_kerims_beard01, :periwinkle, :lime02, :pistachio03, :pistachio04, :tea_green01, :tea_green02, :pang, :red, :crimson, :cerise02, :hot_pink02, :hot_pink03, :magenta, :international_orange, :alizarin, :dark_pink01, :dark_pink02, :shocked_star, :fuchsia, :tangerine, :salmon, :chestnut02, :pale_red_violet03, :pale_magenta, :violaceous03, :orange, :pink_orange, :saumon, :pink01, :pink02, :violaceous04, :gold, :mustard01, :mustard02, :dark_peach, :pale_pink, :thistle, :yellow, :corn01, :corn02, :perhydor, :lemon_cream, :white, :black01, :black02, :black03, :bistre, :anthracite, :wet_asphalt02, :wet_asphalt03, :wet_asphalt04, :wet_asphalt05, :wet_asphalt06, :wet_asphalt07, :gray01, :gray, :gray02, :gray03, :gray04, :gray05, :light_grey03, :light_grey04, :silver01, :abdel_kerims_beard02, :abdel_kerims_beard03, :abdel_kerims_beard04, :seashell ]
77
+ :human => [ :black, :maroon, :toad_in_love, :olive, :navy_blue, :violet_eggplant, :teal, :silver, :gray, :red, :green, :yellow, :blue, :magenta, :cyan, :white, :black, :dark_indigo, :ultramarine01, :ultramarine02, :persian_blue01, :blue, :dark_spring_green, :dark_turquoise, :cerulean_grey01, :denim01, :royal_blue01, :royal_blue02, :toad_in_love01, :sea_green01, :teal01, :cerulean_grey02, :klein_blue, :azure01, :vert_de_pomme01, :jade01, :jade02, :robin_egg_blue01, :bondi_blue, :light_blue01, :vert_de_pomme02, :malachite01, :emerald01, :turquoise, :robin_egg_blue02, :electric01, :green, :spring_green01, :spring_green02, :mint_green01, :aquamarine01, :cyan, :flea_belly, :plum, :indigo, :purple01, :violet01, :persian_blue02, :khaki01, :wet_asphalt01, :seroburomalinovyj01, :denim02, :royal_blue03, :royal_blue04, :olive_drab, :fern_green, :slate_gray, :steel_blue, :cornflower_blue01, :azure02, :grass01, :emerald02, :sea_green02, :robin_egg_blue03, :bluish01, :light_blue02, :vert_de_pomme03, :pale_green01, :emerald03, :aquamarine02, :robin_egg_blue04, :sky01, :bright_green, :malachite02, :spring_green03, :chartreuse01, :aquamarine03, :cyan01, :maroon01, :eggplant01, :violet_eggplant01, :purple02, :violet02, :violet03, :khaki02, :pale_mauve01, :seroburomalinovyj02, :amethyst01, :amethyst02, :heliotrope01, :olive01, :dark_tan, :gray01, :bluish02, :cornflower_blue02, :royal_blue05, :grass02, :asparagus, :swamp_green01, :light_grey01, :bluish03, :cornflower_blue03, :green_yellow01, :pale_green02, :emerald04, :celadon, :pale_blue01, :sky02, :viridian, :vert_de_pomme04, :mint_green02, :chartreuse02, :aquamarine04, :electric02, :bismarck_furious, :eggplant02, :red_violet01, :violet_eggplant02, :bright_violet, :violet04, :ochre, :pale_mauve02, :pale_red_violet01, :orchid01, :amethyst03, :heliotrope02, :dark_goldenrod, :pale_brown, :mountbatten_pink, :lilac01, :wisteria01, :amethyst04, :old_gold, :brass01, :swamp_green02, :light_grey02, :niagara, :wisteria02, :lime01, :pistachio01, :moss_green, :dark_tea_green, :pale_blue02, :pale_cornflower_blue, :green_yellow02, :green_yellow03, :pistachio02, :chartreuse03, :aquamarine05, :pale_blue03, :titian, :cerise01, :red_violet02, :hot_pink01, :bright_violet, :magenta01, :tenne, :chestnut01, :pale_red_violet02, :orchid02, :orchid03, :heliotrope03, :siena, :dark_salmon, :puce01, :puce2, :violaceous01, :violaceous02, :dark_pear, :brass02, :tan, :pale_chestnut, :lilac02, :wisteria03, :childs_surprise, :vert_de_peche, :flax, :gray_tea_green, :abdel_kerims_beard01, :periwinkle, :lime02, :pistachio03, :pistachio04, :tea_green01, :tea_green02, :pang, :red, :crimson, :cerise02, :hot_pink02, :hot_pink03, :magenta, :international_orange, :alizarin, :dark_pink01, :dark_pink02, :shocked_star, :fuchsia, :tangerine, :salmon, :chestnut02, :pale_red_violet03, :pale_magenta, :violaceous03, :orange, :pink_orange, :saumon, :pink01, :pink02, :violaceous04, :gold, :mustard01, :mustard02, :dark_peach, :pale_pink, :thistle, :yellow, :corn01, :corn02, :perhydor, :lemon_cream, :white, :black01, :black02, :black03, :bistre, :anthracite, :wet_asphalt02, :wet_asphalt03, :wet_asphalt04, :wet_asphalt05, :wet_asphalt06, :wet_asphalt07, :gray01, :gray, :gray02, :gray03, :gray04, :gray05, :light_grey03, :light_grey04, :silver01, :abdel_kerims_beard02, :abdel_kerims_beard03, :abdel_kerims_beard04, :seashell ]
78
78
  }
79
79
  end
80
80
 
@@ -0,0 +1,24 @@
1
+ module PryTheme
2
+ module RGB
3
+
4
+ SYSTEM = [
5
+ [0x00, 0x00, 0x00], [0x80, 0x00, 0x00], [0x00, 0x80, 0x00],
6
+ [0x80, 0x80, 0x00], [0x00, 0x00, 0x80], [0x80, 0x00, 0x80],
7
+ [0x00, 0x80, 0x80], [0xc0, 0xc0, 0xc0], [0x80, 0x80, 0x80],
8
+ [0xff, 0x00, 0x00], [0x00, 0xff, 0x00], [0xff, 0xff, 0x00],
9
+ [0x00, 0x00, 0xff], [0xff, 0x00, 0xff], [0x00, 0xff, 0xff],
10
+ [0xff, 0xff, 0xff]
11
+ ]
12
+
13
+ COLORS = [
14
+ [0, 0, 0], [0, 0, 95], [0, 0, 135], [0, 0, 175], [0, 0, 215], [0, 0, 255], [0, 95, 0], [0, 95, 95], [0, 95, 135], [0, 95, 175], [0, 95, 215], [0, 95, 255], [0, 135, 0], [0, 135, 95], [0, 135, 135], [0, 135, 175], [0, 135, 215], [0, 135, 255], [0, 175, 0], [0, 175, 95], [0, 175, 135], [0, 175, 175], [0, 175, 215], [0, 175, 255], [0, 215, 0], [0, 215, 95], [0, 215, 135], [0, 215, 175], [0, 215, 215], [0, 215, 255], [0, 255, 0], [0, 255, 95], [0, 255, 135], [0, 255, 175], [0, 255, 215], [0, 255, 255], [95, 0, 0], [95, 0, 95], [95, 0, 135], [95, 0, 175], [95, 0, 215], [95, 0, 255], [95, 95, 0], [95, 95, 95], [95, 95, 135], [95, 95, 175], [95, 95, 215], [95, 95, 255], [95, 135, 0], [95, 135, 95], [95, 135, 135], [95, 135, 175], [95, 135, 215], [95, 135, 255], [95, 175, 0], [95, 175, 95], [95, 175, 135], [95, 175, 175], [95, 175, 215], [95, 175, 255], [95, 215, 0], [95, 215, 95], [95, 215, 135], [95, 215, 175], [95, 215, 215], [95, 215, 255], [95, 255, 0], [95, 255, 95], [95, 255, 135], [95, 255, 175], [95, 255, 215], [95, 255, 255], [135, 0, 0], [135, 0, 95], [135, 0, 135], [135, 0, 175], [135, 0, 215], [135, 0, 255], [135, 95, 0], [135, 95, 95], [135, 95, 135], [135, 95, 175], [135, 95, 215], [135, 95, 255], [135, 135, 0], [135, 135, 95], [135, 135, 135], [135, 135, 175], [135, 135, 215], [135, 135, 255], [135, 175, 0], [135, 175, 95], [135, 175, 135], [135, 175, 175], [135, 175, 215], [135, 175, 255], [135, 215, 0], [135, 215, 95], [135, 215, 135], [135, 215, 175], [135, 215, 215], [135, 215, 255], [135, 255, 0], [135, 255, 95], [135, 255, 135], [135, 255, 175], [135, 255, 215], [135, 255, 255], [175, 0, 0], [175, 0, 95], [175, 0, 135], [175, 0, 175], [175, 0, 215], [175, 0, 255], [175, 95, 0], [175, 95, 95], [175, 95, 135], [175, 95, 175], [175, 95, 215], [175, 95, 255], [175, 135, 0], [175, 135, 95], [175, 135, 135], [175, 135, 175], [175, 135, 215], [175, 135, 255], [175, 175, 0], [175, 175, 95], [175, 175, 135], [175, 175, 175], [175, 175, 215], [175, 175, 255], [175, 215, 0], [175, 215, 95], [175, 215, 135], [175, 215, 175], [175, 215, 215], [175, 215, 255], [175, 255, 0], [175, 255, 95], [175, 255, 135], [175, 255, 175], [175, 255, 215], [175, 255, 255], [215, 0, 0], [215, 0, 95], [215, 0, 135], [215, 0, 175], [215, 0, 215], [215, 0, 255], [215, 95, 0], [215, 95, 95], [215, 95, 135], [215, 95, 175], [215, 95, 215], [215, 95, 255], [215, 135, 0], [215, 135, 95], [215, 135, 135], [215, 135, 175], [215, 135, 215], [215, 135, 255], [215, 175, 0], [215, 175, 95], [215, 175, 135], [215, 175, 175], [215, 175, 175], [215, 175, 215], [215, 175, 255], [215, 215, 0], [215, 215, 95], [215, 215, 135], [215, 215, 175], [215, 215, 215], [215, 215, 255], [215, 255, 0], [215, 255, 95], [215, 255, 135], [215, 255, 175], [215, 255, 215], [215, 255, 255], [255, 0, 0], [255, 0, 95], [255, 0, 135], [255, 0, 175], [255, 0, 215], [255, 0, 255], [255, 95, 0], [255, 95, 95], [255, 95, 135], [255, 95, 175], [255, 95, 215], [255, 95, 255], [255, 135, 0], [255, 135, 95], [255, 135, 135], [255, 135, 175], [255, 135, 215], [255, 135, 255], [255, 175, 0], [255, 175, 95], [255, 175, 135], [255, 175, 175], [255, 175, 215], [255, 175, 255], [255, 215, 0], [255, 215, 95], [255, 215, 135], [255, 215, 175], [255, 215, 215], [255, 215, 255], [255, 255, 0], [255, 255, 95], [255, 255, 135], [255, 255, 175], [255, 255, 215]
15
+ ]
16
+
17
+ GREYSCALE = (0x08..0xee).step(0x0a).map { |v| [v] * 3 }
18
+
19
+ def self.table
20
+ SYSTEM + COLORS + GREYSCALE
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,17 @@
1
+ module PryTheme
2
+ module TermNotation
3
+
4
+ # The prefix for 256-color ANSI foreground codes.
5
+ COLOR256 = "38;5;"
6
+
7
+ # The prefix for 256-color ANSI background codes.
8
+ BACKGROUND256 = "48;5;"
9
+
10
+ # The prefix for displaying a text only with a background color.
11
+ NO_FOREGROUND = "38;0"
12
+
13
+ # The prefix represents an empty ANSI code (used to please CodeRay).
14
+ EMPTY = "38;0;0"
15
+
16
+ end
17
+ end
@@ -4,7 +4,7 @@ module PryTheme
4
4
  attr_reader :scheme, :author, :description, :color_depth, :version, :name
5
5
 
6
6
  def initialize(theme_filename)
7
- theme_file = File.join(THEME_DIR, "#{theme_filename}.prytheme")
7
+ theme_file = Helper.pathify_theme(theme_filename)
8
8
 
9
9
  if File.exists?(theme_file)
10
10
  theme = YAML.load_file(theme_file)
@@ -1,3 +1,3 @@
1
1
  module PryTheme
2
- VERSION = "0.0.10"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -27,11 +27,12 @@ module PryTheme
27
27
  if Helper.installed?(Pry.config.theme)
28
28
  PryTheme.set_theme(Pry.config.theme)
29
29
  else
30
- _pry_.output.puts %{Can't find "#{Pry.config.theme}" theme. Using "#{DEFAULT_THEME_NAME}"}
30
+ _pry_.output.puts %{Can't find "#{ Pry.config.theme }" theme. Using "#{ DEFAULT_THEME_NAME }"}
31
31
  PryTheme.set_theme(DEFAULT_THEME_NAME)
32
32
  end
33
33
  else
34
- _pry_.output.puts %{Can't find `Pry.config.theme` definition in your `~/.pryrc`.\nUsing "pry-classic" theme now.}
34
+ _pry_.output.puts %{Can't find `Pry.config.theme` definition in your `~/.pryrc`.\nUsing "#{ DEFAULT_THEME_NAME }" theme now.}
35
+ PryTheme.set_theme(DEFAULT_THEME_NAME)
35
36
  end
36
37
  end
37
38
 
data/lib/pry-theme.rb CHANGED
@@ -1,10 +1,13 @@
1
1
  require 'pry-theme/version'
2
+ require 'pry-theme/uninstaller'
2
3
  require 'pry-theme/helper'
3
- require 'pry-theme/commands'
4
4
  require 'pry-theme/palette'
5
+ require 'pry-theme/term_notation'
5
6
  require 'pry-theme/theme'
7
+ require 'pry-theme/rgb'
8
+ require 'pry-theme/color_converter'
9
+ require 'pry-theme/commands'
6
10
  require 'pry-theme/when_started_hook'
7
- require 'pry-theme/uninstaller'
8
11
 
9
12
  require 'yaml'
10
13
 
@@ -123,7 +126,7 @@ module PryTheme
123
126
 
124
127
  color_bg = find_color($7, palette) do |c|
125
128
  if palette.color_depth == 256
126
- "48;5;#{c.term}"
129
+ "#{ TermNotation::BACKGROUND256 }#{c.term}"
127
130
  else
128
131
  Formatting::BACKGROUNDS[c.human.to_s]
129
132
  end
@@ -131,7 +134,7 @@ module PryTheme
131
134
 
132
135
  # Uh oh :(
133
136
  notation = if !color_fg
134
- "38;0"
137
+ TermNotation::NO_FOREGROUND
135
138
  elsif palette.notation
136
139
  palette.notation[0..-2]
137
140
  else
@@ -143,7 +146,7 @@ module PryTheme
143
146
  # In cases when a user decided not to provide an argument value in theme,
144
147
  # use default color. Not handling this situation results in CodeRay's
145
148
  # error ("can't convert nil into String" stuff).
146
- "38;0;0"
149
+ TermNotation::EMPTY
147
150
  end
148
151
  rescue NoColorError => e
149
152
  Pry.output.puts "#{e}: wrong color value: `#{color}`. Typo?"
@@ -4,6 +4,5 @@ begin
4
4
 
5
5
  PryTheme.install_gem_hooks
6
6
  rescue LoadError
7
- # Be silent, when we can't load Pry (when it's uninstalled).
7
+ # Be silent when we can't load Pry (when it's uninstalled).
8
8
  end
9
-
data/pry-theme.gemspec CHANGED
@@ -1,4 +1,7 @@
1
- require './lib/pry-theme/version'
1
+ unless defined? PryTheme::VERSION
2
+ require File.expand_path('../lib/pry-theme/version', __FILE__)
3
+ end
4
+
2
5
  Gem::Specification.new do |s|
3
6
  s.name = "pry-theme"
4
7
  s.version = PryTheme::VERSION
@@ -13,6 +16,9 @@ Gem::Specification.new do |s|
13
16
  s.require_path = "lib"
14
17
  s.files = `git ls-files`.split "\n"
15
18
 
16
- s.add_runtime_dependency "pry", "~> 0.9"
17
19
  s.add_runtime_dependency "json"
20
+
21
+ s.add_development_dependency "bacon"
22
+ s.add_development_dependency "rake"
23
+ s.add_development_dependency "pry"
18
24
  end
@@ -0,0 +1,38 @@
1
+ ---
2
+ meta:
3
+ theme-name : pry-classic
4
+ version : 4
5
+ color-depth : 8
6
+ description : Default Pry theme
7
+ author : Kyrylo Silin <kyrylosilin@gmail.com>, Kornelius Kalnbach
8
+
9
+ theme:
10
+ class : magenta (b)
11
+ class_variable : cyan
12
+ comment : blue
13
+ constant : blue (bu)
14
+ error : yellow (b) on red
15
+ float : magenta (b)
16
+ global_variable : on green
17
+ instance_variable : (d)
18
+ integer : blue (b)
19
+ keyword : red (b)
20
+ method : blue (b)
21
+ predefined_constant : cyan (b)
22
+ regexp:
23
+ self : red
24
+ content : red
25
+ delimiter : red (db)
26
+ modifier : magenta (b)
27
+ function : (db)
28
+ shell:
29
+ self : on green
30
+ content : (db)
31
+ delimiter : white
32
+ string:
33
+ self : green
34
+ content : green
35
+ modifier : green (b)
36
+ escape : cyan (b)
37
+ delimiter : green (b)
38
+ symbol : green (b)
data/test/helper.rb ADDED
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'pry'
3
+
4
+ # Brute force or otherwise it won't work for all platforms.
5
+ begin
6
+ $:.unshift File.expand_path("../../lib", __FILE__)
7
+ require 'pry-theme'
8
+ rescue
9
+ end
10
+
11
+ require 'bacon'
12
+
13
+ puts "Ruby version: #{RUBY_VERSION}; Pry Theme version: #{PryTheme::VERSION}"
14
+
15
+ class InputTester
16
+ def initialize(*actions)
17
+ @orig_actions = actions.dup
18
+ @actions = actions
19
+ end
20
+
21
+ def readline(*)
22
+ @actions.shift
23
+ end
24
+
25
+ def rewind
26
+ @actions = @orig_actions.dup
27
+ end
28
+ end
29
+
30
+ def mock_pry(*args)
31
+ args.flatten!
32
+ binding = args.first.is_a?(Binding) ? args.shift : binding()
33
+
34
+ input = InputTester.new(*args)
35
+ output = StringIO.new
36
+
37
+ redirect_pry_io(input, output) do
38
+ binding.pry
39
+ end
40
+
41
+ output.string
42
+ end
43
+
44
+ def redirect_pry_io(new_in, new_out = StringIO.new)
45
+ old_in = Pry.input
46
+ old_out = Pry.output
47
+
48
+ Pry.input = new_in
49
+ Pry.output = new_out
50
+ begin
51
+ yield
52
+ ensure
53
+ Pry.input = old_in
54
+ Pry.output = old_out
55
+ end
56
+ end
@@ -0,0 +1,38 @@
1
+ require 'helper'
2
+
3
+ describe PryTheme::ColorConverter do
4
+
5
+ before do
6
+ @converter = PryTheme::ColorConverter
7
+ end
8
+
9
+ describe PryTheme::ColorConverter::COLORS do
10
+ it 'should have 256 colors' do
11
+ @converter::COLORS.size.should == 256
12
+ end
13
+ end
14
+
15
+ it "should convert from rgb to hex" do
16
+ @converter.rgb_to_hex("55,55,55").should == "#373737"
17
+ end
18
+
19
+ it "should convert from rgb to ansi" do
20
+ @converter.rgb_to_ansi("55,55,55").should == 59
21
+ end
22
+
23
+ it "should convert from hex to rgb with an octothorp sign" do
24
+ @converter.hex_to_rgb("#373737").should == [55, 55, 55]
25
+ end
26
+
27
+ it "should convert from hex to rgb without an octothorp sign" do
28
+ @converter.hex_to_rgb("373737").should == [55, 55, 55]
29
+ end
30
+
31
+ it "should convert from hex to ansi with an octothorp sign" do
32
+ @converter.hex_to_ansi("#373737").should == 59
33
+ end
34
+
35
+ it "should convert from ansi to rgb without an octothorp sign" do
36
+ @converter.hex_to_ansi("373737").should == 59
37
+ end
38
+ end
@@ -0,0 +1,55 @@
1
+ require 'helper'
2
+
3
+ describe "PryTheme::Commands" do
4
+ describe "color option" do
5
+ it "should display a color when given a numeric argument" do
6
+ mock_pry(binding, "pry-theme -c 23").should =~ /dark_turquoise/
7
+ end
8
+
9
+ it "should display warning when invalid color number given" do
10
+ out = mock_pry("pry-theme -c 1000")
11
+ out.should =~ /Invalid color: 1000/
12
+ end
13
+
14
+ it "should display warning when random symbols given" do
15
+ out = mock_pry("pry-theme -c $_dopey+")
16
+ out.should =~ /Invalid color: \$_dopey\+/
17
+ end
18
+
19
+ it "should display a color when a hex given" do
20
+ mock_pry("pry-theme -c #625a2d").should =~ /khaki01/
21
+ end
22
+
23
+ it "should display a color when an rgb given" do
24
+ mock_pry("pry-theme -c 95,196,60").should =~ /pale_green01/
25
+ end
26
+
27
+ it "should display a color when a human-readable name given" do
28
+ mock_pry("pry-theme -c steel_blue").should =~ /steel_blue/
29
+ end
30
+
31
+ it "should display multiple colors when a substring given" do
32
+ out = mock_pry("pry-theme -c dark_t")
33
+
34
+ out.should =~ /dark_turquoise/
35
+ out.should =~ /dark_tan/
36
+ out.should =~ /dark_tea_green/
37
+ end
38
+ end
39
+
40
+ describe "all-colors option" do
41
+ it "should display all colors for 8-color palette" do
42
+ out = mock_pry("pry-theme -a 8")
43
+
44
+ out.should =~ /black/
45
+ out.should =~ /magenta/
46
+ end
47
+
48
+ #it "should display all colors for 256-color palette" do
49
+ #out = mock_pry("pry-theme -a 256")
50
+
51
+ #out.should =~ /black/
52
+ #out.should =~ /seashell/
53
+ #end
54
+ end
55
+ end
@@ -0,0 +1,45 @@
1
+ require 'helper'
2
+
3
+ describe PryTheme::Helper do
4
+ before do
5
+ @h = PryTheme::Helper
6
+ end
7
+
8
+ it "should show correctly default themes" do
9
+ themes = %w{
10
+ zenburn solarized vim-default railscasts pry-cold saturday twilight
11
+ github monokai pry-modern tomorrow pry-classic vim-detailed
12
+ }
13
+ themes.map! { |theme| theme + ".prytheme" }
14
+
15
+ (@h.example_themes - themes).should == []
16
+ end
17
+
18
+ it "should show correct theme file_version" do
19
+ path = File.join(File.dirname(__FILE__), "fixtures", "pry-classic.prytheme")
20
+ @h.theme_file_version(path).should == 4
21
+ end
22
+
23
+ it "should detect ansi color" do
24
+ @h.ansi?(0).should == true
25
+ @h.ansi?(-1).should == false
26
+ @h.ansi?(256).should == false
27
+ @h.ansi?("bashful").should == false
28
+ end
29
+
30
+ it "should detect rgb color" do
31
+ @h.rgb?("55,55,55").should == true
32
+ @h.rgb?("0,0,0").should == true
33
+ @h.rgb?("256,255,255").should == false
34
+ @h.rgb?("1").should == false
35
+ @h.rgb?("55,55,55,").should == false
36
+ @h.rgb?("sneezy").should == false
37
+ end
38
+
39
+ it "should detect hex color" do
40
+ @h.hex?("#373737").should == true
41
+ @h.hex?("3A3F3E").should == true
42
+ @h.hex?("dopey").should == false
43
+ @h.hex?(373737).should == false
44
+ end
45
+ end
@@ -0,0 +1,11 @@
1
+ require 'helper'
2
+
3
+ describe "A PryTheme::Color instance" do
4
+ before do
5
+ @c = PryTheme::Color.new("111", "dopey")
6
+ end
7
+
8
+ it "should represent itself in terminal form" do
9
+ @c.to_term("38;5;").should == "\e[38;5;111;7m111\e[0m:\e[38;5;111mdopey\e[0m"
10
+ end
11
+ end
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  meta:
3
3
  theme-name : github
4
- version : 3
4
+ version : 4
5
5
  color-depth : 256
6
6
  description : Based on github theme
7
7
  author : John Mair
@@ -24,7 +24,6 @@ theme:
24
24
  content : toad_in_love01
25
25
  delimiter : toad_in_love01
26
26
  modifier : toad_in_love01
27
- function : toad_in_love01
28
27
  shell:
29
28
  self : puce01
30
29
  content : puce01
@@ -32,7 +31,5 @@ theme:
32
31
  string:
33
32
  self : alizarin
34
33
  content : alizarin
35
- modifier : alizarin
36
- escape : alizarin
37
34
  delimiter : alizarin
38
35
  symbol : pale_magenta