pry-theme 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,6 +1,22 @@
1
1
  Pry Theme changelog
2
2
  ===================
3
3
 
4
+ ### v0.0.9 (July 05, 2012)
5
+
6
+ * **HOT**: Added `--install` flag. Now, you can easily install Pry themes from
7
+ Pry Theme Collection via command line (`pry-theme -i nifty-theme`);
8
+ * Added pager for long output. Try `pry-theme -a 256` and you will immediately
9
+ notice the difference;
10
+ * Added more informative output for `--list` flag;
11
+ * Added a bunch of new default themes: solarized, zenburn, twilight, tomorrow,
12
+ saturday, railscasts, monokai, github and charcoal-black;
13
+ * Fixed wrong color name in 256-color palette (`pale_conflower_blue` →
14
+ `pale_cornflower_blue`);
15
+ * Fixed bug with respect to unwanted fall back to the `pry-classic` theme,
16
+ when a user tries to switch to nonexistent theme;
17
+ * Added a feature to `pry-theme` command: when a user invokes `pry-theme`
18
+ command without arguments, it returns name of the current theme.
19
+
4
20
  ### v0.0.8 (July 02, 2012)
5
21
 
6
22
  * **IMPORTANT**: Changed directory where to store themes! Themes now live in
data/README.md CHANGED
@@ -41,7 +41,7 @@ That's all! Launch your Pry and you will see the changes.
41
41
 
42
42
  Pry Theme has a command-line interface available via Pry. Just launch Pry and
43
43
  start working with it. For example, you can _temporary_ change themes on the
44
- fly:
44
+ fly (only for the current session):
45
45
 
46
46
  [1] pry(main)> pry-theme pry-classic
47
47
 
@@ -62,7 +62,11 @@ if you want to find some themes other than default ones.
62
62
 
63
63
  Put your theme file in `$HOME/.pry/themes` directory.
64
64
 
65
- And don't forget to adjust your `.pryrc`!
65
+ If you don't want to bother with routine operations, you can install a theme
66
+ from the Collection with help of `pry-theme -i <name>` command. For example, you
67
+ can install tomorrow-night theme: `pry-theme -i tomorrow-night`.
68
+
69
+ Oh, and don't forget to adjust your `.pryrc`!
66
70
 
67
71
  Limitations
68
72
  -----------
@@ -73,7 +77,7 @@ but with a couple of admonishments. They are listed below.
73
77
  ### OS support
74
78
 
75
79
  * GNU/Linux;
76
- * Mac OS (I hope so, leastwise);
80
+ * Mac OS.
77
81
 
78
82
  I hope it runs on Windows too, but I couldn't find any sane terminal, that
79
83
  would support 256 colors. Sorry, Windows guys. Please, file an issue, if you
@@ -93,6 +97,12 @@ Under the hood
93
97
  Basically, Pry Theme is nothing but a CodeRay color scheme with a human-readable
94
98
  syntax.
95
99
 
100
+ Credits
101
+ -------
102
+
103
+ * Thanks to [banister][johndogg] for bringing the plugin in masses and
104
+ contributing a bunch of themes.
105
+
96
106
  License
97
107
  -------
98
108
 
@@ -105,3 +115,4 @@ The project uses Zlib License. See LICENSE file for more information.
105
115
  [cli]: https://github.com/kyrylo/pry-theme/wiki/Pry-Theme-CLI
106
116
  [wiki]: https://github.com/kyrylo/pry-theme/wiki
107
117
  [ptc]: https://github.com/kyrylo/pry-theme-collection
118
+ [johndogg]: https://github.com/banister/ "John Dogg"
@@ -0,0 +1,37 @@
1
+ ---
2
+ meta:
3
+ theme-name : charcoal-black
4
+ version : 3
5
+ color-depth : 256
6
+ description : Based on Charcoalblack theme from Emacs
7
+ author : John Mair
8
+
9
+ theme:
10
+ class : robin_egg_blue02 (b)
11
+ class_variable : pale_blue03 (b)
12
+ comment : light_grey03
13
+ constant : robin_egg_blue02 (b)
14
+ error : tenne (i)
15
+ float : silver01
16
+ global_variable : robin_egg_blue02
17
+ instance_variable : pale_blue03
18
+ integer : seroburomalinovyj01
19
+ keyword : pale_blue03 (b)
20
+ method : royal_blue05
21
+ predefined_constant : robin_egg_blue02 (b)
22
+ regexp:
23
+ self : alizarin
24
+ content : alizarin
25
+ delimiter : alizarin
26
+ modifier : alizarin
27
+ function : alizarin
28
+ shell:
29
+ self : puce01
30
+ content : puce01
31
+ delimiter : gray02
32
+ string:
33
+ self : bluish03
34
+ modifier : bluish03
35
+ escape : bluish03
36
+ delimiter : bluish03
37
+ symbol : bluish03
@@ -0,0 +1,37 @@
1
+ ---
2
+ meta:
3
+ theme-name : github
4
+ version : 2
5
+ color-depth : 256
6
+ description : Based on github theme
7
+ author : John Mair
8
+
9
+ theme:
10
+ class : denim02 (b)
11
+ class_variable : aquamarine02 (b)
12
+ comment : light_grey03
13
+ constant : aquamarine02
14
+ error : tenne (i)
15
+ float : silver01
16
+ global_variable : robin_egg_blue02
17
+ instance_variable : aquamarine02
18
+ integer : aquamarine02
19
+ keyword : seashell (b)
20
+ method : maroon01
21
+ predefined_constant : robin_egg_blue02 (b)
22
+ regexp:
23
+ self : toad_in_love01
24
+ content : toad_in_love01
25
+ delimiter : toad_in_love01
26
+ modifier : toad_in_love01
27
+ function : toad_in_love01
28
+ shell:
29
+ self : puce01
30
+ content : puce01
31
+ delimiter : gray02
32
+ string:
33
+ self : alizarin
34
+ modifier : alizarin
35
+ escape : alizarin
36
+ delimiter : alizarin
37
+ symbol : pale_magenta
@@ -0,0 +1,37 @@
1
+ ---
2
+ meta:
3
+ theme-name : monokai
4
+ version : 1
5
+ color-depth : 256
6
+ description : Based on Wimer Hazenberg's theme
7
+ author : Kyrylo Silin <kyrylosilin@gmail.com>
8
+
9
+ theme:
10
+ class : sky01
11
+ class_variable :
12
+ comment : pale_mauve01
13
+ constant : sky01
14
+ error : crimson (i)
15
+ float : amethyst04
16
+ global_variable :
17
+ instance_variable :
18
+ integer : amethyst01
19
+ keyword : crimson
20
+ method : lime01
21
+ predefined_constant : sky01
22
+ regexp:
23
+ self : flax
24
+ content : flax
25
+ delimiter : flax
26
+ modifier : flax
27
+ function : flax
28
+ shell:
29
+ self : flax
30
+ content : flax
31
+ delimiter : flax
32
+ string:
33
+ self : flax
34
+ modifier : flax
35
+ escape : flax
36
+ delimiter : flax
37
+ symbol : old_gold
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  meta:
3
3
  theme-name : pry-classic
4
- version : 2
4
+ version : 3
5
5
  color-depth : 8
6
- description : Based on Kornelius Kalnbach's default CodeRay's color theme.
7
- author : Kyrylo Silin <kyrylosilin@gmail.com>
6
+ description : Default Pry theme
7
+ author : Kyrylo Silin <kyrylosilin@gmail.com>, Kornelius Kalnbach
8
8
 
9
9
  theme:
10
10
  class : magenta (b)
@@ -1,9 +1,9 @@
1
1
  ---
2
2
  meta:
3
3
  theme-name : pry-modern
4
- version : 1
4
+ version : 2
5
5
  color-depth : 256
6
- description :
6
+ description : Nifty version of pry-classic
7
7
  author : Kyrylo Silin <kyrylosilin@gmail.com>
8
8
 
9
9
  theme:
@@ -0,0 +1,37 @@
1
+ ---
2
+ meta:
3
+ theme-name : railscasts
4
+ version : 5
5
+ color-depth : 256
6
+ description : RailsCasts theme
7
+ author : Ryan Fitzgerald, John Mair
8
+
9
+ theme:
10
+ class : red
11
+ class_variable : periwinkle (b)
12
+ comment : brass02
13
+ constant : red
14
+ error : green (u) on maroon
15
+ float : lilac01
16
+ global_variable : red
17
+ instance_variable : periwinkle
18
+ integer : cornflower_blue03
19
+ keyword : international_orange (b)
20
+ method : mustard02 (b)
21
+ predefined_constant : sky02
22
+ regexp:
23
+ self : green
24
+ content : green
25
+ delimiter : green
26
+ modifier : green
27
+ function : green
28
+ shell:
29
+ self : toad_in_love
30
+ content : green
31
+ delimiter : green
32
+ string:
33
+ self : pistachio04
34
+ modifier : robin_egg_blue01
35
+ escape : old_gold
36
+ delimiter : pistachio04
37
+ symbol : sky02
@@ -0,0 +1,37 @@
1
+ ---
2
+ meta:
3
+ theme-name : saturday-night
4
+ version : 4
5
+ color-depth : 256
6
+ description : A modification of "tommorow night"
7
+ author : John Mair (banisterfiend)
8
+
9
+ theme:
10
+ class : violaceous04
11
+ class_variable : gray05 (b)
12
+ comment : slate_gray
13
+ constant : violaceous04
14
+ error : black (u) on maroon
15
+ float : lilac01
16
+ global_variable : red
17
+ instance_variable : gray05
18
+ integer : cornflower_blue03
19
+ keyword : alizarin
20
+ method : cornflower_blue03
21
+ predefined_constant : cyan
22
+ regexp:
23
+ self : alizarin
24
+ content : alizarin
25
+ delimiter : alizarin
26
+ modifier : lilac01
27
+ function : alizarin
28
+ shell:
29
+ self : toad_in_love
30
+ content : green
31
+ delimiter : green
32
+ string:
33
+ self : old_gold
34
+ modifier : old_gold
35
+ escape : old_gold
36
+ delimiter : old_gold
37
+ symbol : old_gold (b)
@@ -0,0 +1,37 @@
1
+ ---
2
+ meta:
3
+ theme-name : solarized
4
+ version : 3
5
+ color-depth : 256
6
+ description : Precision colors for machines and people
7
+ author : Kyrylo Silin <kyrylosilin@gmail.com>, Ethan Schoonover
8
+
9
+ theme:
10
+ class : dark_goldenrod
11
+ class_variable : azure01
12
+ comment : wet_asphalt05
13
+ constant : dark_goldenrod
14
+ error : abdel_kerims_beard04
15
+ float : robin_egg_blue01
16
+ global_variable : azure01
17
+ instance_variable : azure01
18
+ integer : robin_egg_blue01
19
+ keyword : gray03 (b)
20
+ method : azure01
21
+ predefined_constant : azure01
22
+ regexp:
23
+ self : tenne
24
+ content : olive_drab
25
+ delimiter : titian
26
+ modifier : titian
27
+ function : black
28
+ shell:
29
+ self :
30
+ content : robin_egg_blue01
31
+ delimiter : titian
32
+ string:
33
+ self : robin_egg_blue01
34
+ modifier :
35
+ escape :
36
+ delimiter : titian
37
+ symbol : robin_egg_blue01
@@ -0,0 +1,37 @@
1
+ ---
2
+ meta:
3
+ theme-name : tomorrow
4
+ version : 2
5
+ color-depth : 256
6
+ description : Based on Tomorrow by Chris Kempson
7
+ author : John Mair
8
+
9
+ theme:
10
+ class : gold
11
+ class_variable : flea_belly (b)
12
+ comment : gray03
13
+ constant : gold
14
+ error : tenne (i)
15
+ float : silver01
16
+ global_variable : dark_peach
17
+ instance_variable : alizarin
18
+ integer : tangerine
19
+ keyword : heliotrope03
20
+ method : royal_blue05
21
+ predefined_constant : tangerine
22
+ regexp:
23
+ self : alizarin
24
+ content : old_gold
25
+ delimiter : alizarin
26
+ modifier : old_gold
27
+ function : old_gold
28
+ shell:
29
+ self : puce01
30
+ content : puce01
31
+ delimiter : gray02
32
+ string:
33
+ self : old_gold
34
+ modifier : old_gold
35
+ escape : old_gold
36
+ delimiter : old_gold
37
+ symbol : old_gold
@@ -0,0 +1,37 @@
1
+ ---
2
+ meta:
3
+ theme-name : twilight
4
+ version : 2
5
+ color-depth : 256
6
+ description : Based on Twilight from Emacs color-theme package
7
+ author : John Mair
8
+
9
+ theme:
10
+ class : vert_de_peche
11
+ class_variable : pale_cornflower_blue (b)
12
+ comment : gray03
13
+ constant : vert_de_peche
14
+ error : tenne (i)
15
+ float : silver01
16
+ global_variable : pale_cornflower_blue
17
+ instance_variable : cornflower_blue02
18
+ integer : pale_blue01
19
+ keyword : brass02 (b)
20
+ method : ochre (b)
21
+ predefined_constant : pale_cornflower_blue
22
+ regexp:
23
+ self : moss_green
24
+ content : moss_green
25
+ delimiter : moss_green
26
+ modifier : pale_cornflower_blue
27
+ function : moss_green
28
+ shell:
29
+ self : moss_green
30
+ content : moss_green
31
+ delimiter : moss_green
32
+ string:
33
+ self : moss_green
34
+ modifier : pale_cornflower_blue
35
+ escape : moss_green
36
+ delimiter : moss_green
37
+ symbol : chestnut01
@@ -0,0 +1,37 @@
1
+ ---
2
+ meta:
3
+ theme-name : zenburn
4
+ version : 3
5
+ color-depth : 256
6
+ description : A low-contrast color scheme
7
+ author : Kyrylo Silin <kyrylosilin@gmail.com>, Jani Nurminen
8
+
9
+ theme:
10
+ class : dark_peach (b)
11
+ class_variable : dark_peach
12
+ comment : swamp_green01
13
+ constant : dark_peach (b)
14
+ error : tenne (i)
15
+ float : silver01
16
+ global_variable : dark_peach
17
+ instance_variable : dark_peach
18
+ integer : pale_blue01
19
+ keyword : dark_salmon (b)
20
+ method : corn02
21
+ predefined_constant : dark_peach
22
+ regexp:
23
+ self : abdel_kerims_beard01
24
+ content : puce01
25
+ delimiter : gray02
26
+ modifier : gray02
27
+ function :
28
+ shell:
29
+ self :
30
+ content : puce01
31
+ delimiter : gray02
32
+ string:
33
+ self : puce01
34
+ modifier :
35
+ escape :
36
+ delimiter : gray02
37
+ symbol : puce01 (b)
@@ -1,3 +1,7 @@
1
+ require 'net/https'
2
+ require 'base64'
3
+ require 'json'
4
+
1
5
  module PryTheme
2
6
  Commands = Pry::CommandSet.new do
3
7
 
@@ -7,26 +11,22 @@ module PryTheme
7
11
  banner <<-BANNER
8
12
  Usage: pry-theme [OPTIONS] [--help]
9
13
 
10
- Change your theme on the fly.
14
+ Change your theme on the fly (for one session).
11
15
 
12
16
  pry-theme pry-modern
13
17
 
14
- Display 8-color palette.
18
+ Show all themes from Pry Theme Collection.
15
19
 
16
- pry-theme --all-colors 8
20
+ pry-theme -lr
17
21
 
18
- Display Pry Theme code for terminal color 34.
22
+ Install a theme from Pry Theme Collection.
19
23
 
20
- pry-theme -c 34
24
+ pry-theme -i pry-classic
21
25
 
22
26
  Test your current color theme.
23
27
 
24
28
  pry-theme -t
25
29
 
26
- Show a list with currently installed themes
27
-
28
- pry-theme --list
29
-
30
30
  Wiki: https://github.com/kyrylo/pry-theme/wiki/Pry-Theme-CLI
31
31
  BANNER
32
32
 
@@ -34,7 +34,9 @@ module PryTheme
34
34
  opt.on :a, "all-colors", "Show all available 8/256 colors."
35
35
  opt.on :c, "color", "Show information about a specific color (256)."
36
36
  opt.on :t, "test", "Test your current theme", :argument => false
37
- opt.on :l, "list", "Show a list with all available themes", :argument => false
37
+ opt.on :l, "list", "Show a list of installed themes", :argument => false
38
+ opt.on :r, "remote", "Show a list of themes from Pry Theme Collection", :argument => false
39
+ opt.on :i, "install", "Install a theme from Pry Theme Collection"
38
40
  end
39
41
 
40
42
  def process
@@ -45,9 +47,13 @@ module PryTheme
45
47
  elsif opts.t?
46
48
  test_theme
47
49
  elsif opts.l?
48
- show_list
50
+ opts.r? ? show_remote_list : show_list
51
+ elsif opts.i?
52
+ install_theme
49
53
  elsif args[0] =~ /\A\w+-?\w+\z/
50
54
  switch_to_theme
55
+ elsif args.empty?
56
+ output.puts "Current theme: #{PryTheme.current_theme}"
51
57
  end
52
58
  rescue NoPaletteError => no_palette_error
53
59
  warn no_palette_error
@@ -63,7 +69,7 @@ module PryTheme
63
69
  end
64
70
 
65
71
  def show_palette_colors
66
- output.puts Palette.new(args[0]).to_s
72
+ lputs Palette.new(args[0]).to_a.join("\n")
67
73
  end
68
74
 
69
75
  def show_specific_color
@@ -111,17 +117,18 @@ module PryTheme
111
117
  end
112
118
  end
113
119
  end
114
- # Testing complete.
120
+ # Testing "#{PryTheme.current_theme}" theme complete.
115
121
  TEST
116
122
 
117
- output.puts colorize_code(example)
123
+ lputs colorize_code(example)
118
124
  end
119
125
 
120
126
  def show_list
121
127
  old_theme = PryTheme.current_theme.dup
122
128
 
123
- each_theme_in(THEME_DIR) do |theme, index, all_themes_num|
124
- theme.sub!(/\.prytheme\z/, "")
129
+ all_themes = installed_themes.map do |theme|
130
+ theme = File.basename(theme, ".prytheme")
131
+ meta = Theme.new(theme)
125
132
  PryTheme.set_theme(theme)
126
133
 
127
134
  chunk = <<-CHUNK
@@ -132,14 +139,60 @@ class PickMe
132
139
  end
133
140
  CHUNK
134
141
 
135
- output.puts "\e[038;0;1m[#{theme}]\e[0m#{ " *" if theme == old_theme }"
136
- output.puts "---"
137
- output.puts colorize_code(chunk)
138
- output.puts unless index+1 == all_themes_num
142
+ mark_current = "* " if theme == old_theme
143
+ header = make_bold("#{mark_current}[#{theme}]")
144
+ snippet = colorize_code(chunk)
145
+ [header, meta.description, "---", snippet].compact.join("\n")
139
146
  end
147
+
148
+ lputs all_themes.join("\n")
140
149
  ensure
141
150
  PryTheme.set_theme(old_theme)
142
151
  end
152
+
153
+ def show_remote_list
154
+ body = {}
155
+ fetch_collection("/") do |http, uri|
156
+ output.puts "Fetching list of themes..."
157
+ response = http.request(Net::HTTP::Get.new(uri.request_uri))
158
+ body = JSON.parse(response.body)
159
+ end
160
+
161
+ i = 0
162
+ remote_themes = body.map do |theme|
163
+ if (name = theme["name"]) =~ /\A[[a-z][0-9]-]+\z/
164
+ "#{i+=1}. #{installed?(name) ? make_bold(name) : name}"
165
+ end
166
+ end.compact
167
+
168
+ lputs remote_themes.join("\n")
169
+ end
170
+
171
+ def install_theme
172
+ return unless args[0]
173
+
174
+ body = {}
175
+ fetch_collection("/#{args[0]}/#{args[0]}.prytheme") do |http, uri|
176
+ output.puts "Fetching theme from the collection..."
177
+ response = http.request(Net::HTTP::Get.new(uri.request_uri))
178
+ body = JSON.parse(response.body)
179
+ end
180
+
181
+ if body["message"]
182
+ output.puts "Cannot find theme: #{args[0]}"
183
+ return
184
+ end
185
+
186
+ theme = Base64.decode64(body["content"])
187
+
188
+ File.open(local_theme("#{args[0]}.prytheme"), "w") do |f|
189
+ f.puts theme
190
+ end
191
+
192
+ output.puts "Successfully installed #{args[0]}!"
193
+ rescue
194
+ output.puts "An error occurred!"
195
+ end
143
196
  end
144
197
 
145
198
  end
@@ -1,13 +1,47 @@
1
1
  module PryTheme
2
2
  module Helper
3
3
 
4
- def each_theme_in(dir, &block)
5
- themes = Dir.entries(dir) - %w{ . .. }
6
- n = themes.size
4
+ module_function
7
5
 
8
- themes.each_with_index do |theme, index|
9
- yield(theme, index, n)
10
- end
6
+ def example_themes
7
+ (Dir.entries(EXAMPLES_ROOT) - %w{ . .. })
8
+ end
9
+
10
+ def installed_themes
11
+ (Dir.entries(THEME_DIR) - %w{ . .. })
12
+ end
13
+
14
+ def installed?(theme)
15
+ installed_themes.any? { |t| /\A#{theme}.prytheme\z/ =~ t }
16
+ end
17
+
18
+ def lputs(text, out=nil)
19
+ Pry::Helpers::BaseHelpers.stagger_output(text, out)
20
+ end
21
+
22
+ def make_bold(text)
23
+ Pry::Helpers::Text.bold(text)
24
+ end
25
+
26
+ def theme_file_version(path)
27
+ version = File.foreach(path) { |line| break line if $. == 4 }
28
+ version.scan(/\d+/)[0].to_i
29
+ end
30
+
31
+ def default_theme(name)
32
+ File.join(EXAMPLES_ROOT, name)
33
+ end
34
+
35
+ def local_theme(name)
36
+ File.join(THEME_DIR, name)
37
+ end
38
+
39
+ def fetch_collection(path, &block)
40
+ uri = URI.parse(COLLECTION + path)
41
+ http = Net::HTTP.new(uri.host, uri.port)
42
+ http.use_ssl = true
43
+
44
+ yield(http, uri)
11
45
  end
12
46
 
13
47
  end
@@ -58,7 +58,7 @@ module PryTheme
58
58
  end
59
59
  end
60
60
 
61
- def to_s
61
+ def to_a
62
62
  @colors.map { |c| c.to_term(@notation) }
63
63
  end
64
64
 
@@ -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_conflower_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, :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 ]
78
78
  }
79
79
  end
80
80
 
@@ -1,3 +1,3 @@
1
1
  module PryTheme
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -7,13 +7,28 @@ module PryTheme
7
7
  def call(target, options, _pry_)
8
8
  FileUtils.mkdir_p(THEME_DIR) unless File.exists?(THEME_DIR)
9
9
 
10
- each_theme_in(EXAMPLES_ROOT) do |theme, _, _|
11
- unless File.exists?(File.join(THEME_DIR, theme))
12
- FileUtils.cp(File.join(EXAMPLES_ROOT, theme), THEME_DIR)
10
+ example_themes.each do |theme|
11
+ # Copy a default theme to theme directory if it isn't there yet. Update
12
+ # an installed theme if a theme from the gem has a more recent version
13
+ # (version determines by theme's meta information).
14
+ if File.exists?(local_theme(theme))
15
+ new_version = theme_file_version(default_theme(theme))
16
+ old_version = theme_file_version(local_theme(theme))
17
+
18
+ if new_version > old_version
19
+ FileUtils.cp(default_theme(theme), THEME_DIR)
20
+ end
21
+ else
22
+ FileUtils.cp(default_theme(theme), THEME_DIR)
13
23
  end
14
24
  end
15
25
 
16
- PryTheme.set_theme(Pry.config.theme)
26
+ if Helper.installed?(Pry.config.theme)
27
+ PryTheme.set_theme(Pry.config.theme)
28
+ else
29
+ _pry_.output.puts %{Can't find "#{Pry.config.theme}" theme. Using "#{DEFAULT_THEME_NAME}"}
30
+ PryTheme.set_theme(DEFAULT_THEME_NAME)
31
+ end
17
32
  end
18
33
 
19
34
  end
data/lib/pry-theme.rb CHANGED
@@ -32,12 +32,13 @@ module PryTheme
32
32
  # The name of the default theme of Pry Theme.
33
33
  DEFAULT_THEME_NAME = "pry-classic"
34
34
 
35
+ # The URI for GitHub API link to Pry Theme Collection contents.
36
+ COLLECTION = "https://api.github.com/repos/kyrylo/pry-theme-collection/contents"
37
+
35
38
  def self.set_theme(theme_name)
36
- theme = PryTheme.convert(theme_name)
37
- if theme ||= PryTheme.convert(theme_name = DEFAULT_THEME_NAME)
38
- ::CodeRay::Encoders::Terminal::TOKEN_COLORS.merge!(theme)
39
- @current_theme = theme_name
40
- end
39
+ return unless theme = PryTheme.convert(theme_name)
40
+ ::CodeRay::Encoders::Terminal::TOKEN_COLORS.merge!(theme)
41
+ @current_theme = theme_name
41
42
  end
42
43
 
43
44
  def self.current_theme
data/pry-theme.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- require "./lib/pry-theme/version"
1
+ require './lib/pry-theme/version'
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "pry-theme"
@@ -14,5 +14,6 @@ Gem::Specification.new do |s|
14
14
  s.require_path = "lib"
15
15
  s.files = `git ls-files`.split "\n"
16
16
 
17
- s.add_runtime_dependency "pry", "~> 0.9"
17
+ s.add_runtime_dependency "pry", "~> 0.9"
18
+ s.add_runtime_dependency "json"
18
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-02 00:00:00.000000000 Z
12
+ date: 2012-07-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pry
@@ -27,6 +27,22 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0.9'
30
+ - !ruby/object:Gem::Dependency
31
+ name: json
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
30
46
  description: The plugin enables color theme support for your Pry. No more .pryrc bustling.
31
47
  email: kyrylosilin@gmail.com
32
48
  executables: []
@@ -37,8 +53,17 @@ files:
37
53
  - CHANGELOG.md
38
54
  - LICENSE
39
55
  - README.md
56
+ - examples/charcoal-black.prytheme
57
+ - examples/github.prytheme
58
+ - examples/monokai.prytheme
40
59
  - examples/pry-classic.prytheme
41
60
  - examples/pry-modern.prytheme
61
+ - examples/railscasts.prytheme
62
+ - examples/saturday.prytheme
63
+ - examples/solarized.prytheme
64
+ - examples/tomorrow.prytheme
65
+ - examples/twilight.prytheme
66
+ - examples/zenburn.prytheme
42
67
  - lib/pry-theme.rb
43
68
  - lib/pry-theme/commands.rb
44
69
  - lib/pry-theme/helper.rb