pry-theme 1.0.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/Gemfile +13 -1
- data/VERSION +1 -1
- data/lib/pry-theme.rb +1 -0
- data/lib/pry-theme/commands.rb +7 -7
- data/lib/pry-theme/config.rb +35 -0
- data/lib/pry-theme/when_started_hook.rb +6 -0
- data/pry-theme.gemspec +3 -5
- data/spec/commands_spec.rb +3 -0
- data/spec/config_spec.rb +35 -0
- data/spec/helper.rb +8 -11
- metadata +7 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 915606c125b12d2db78eb2fbcc80a733abb5d97e
|
4
|
+
data.tar.gz: c74ffb434932c0e71a84d9892e677b88398ac169
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b85ec4855ee1e104b5c0df4ab64d470e8678112ca6b5ceef3087befed492010bb7b6f117c20cf93b9ccfcb8e35e4eeef8b7e55d2301893cdf7499a405d67360
|
7
|
+
data.tar.gz: b7b7f6c96befaeb1ffc5ad4d642b45fc204bd0cf76033075b2976e2c168465ddc31dcf0030fd7f3cbfe76324729d8e71573ddef57a46d27923eaf1368b417383
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,26 @@
|
|
1
1
|
Pry Theme changelog
|
2
2
|
===================
|
3
3
|
|
4
|
+
### v1.1.0 (June 13, 2014)
|
5
|
+
|
6
|
+
* Added `theme_options` config hash. It is a general config for Pry Theme
|
7
|
+
* Added option that enables painting hash keys as symbols.
|
8
|
+
[→](https://github.com/kyrylo/pry-theme/issues/30)
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
{foo: 1, :bar => 2}
|
12
|
+
# ^ ^
|
13
|
+
# | |
|
14
|
+
# key symbol
|
15
|
+
```
|
16
|
+
|
17
|
+
By default `foo` and `bar` have different colours. If you put this inside your
|
18
|
+
`.pryrc`, then the key will have the same colour as the symbol.
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
Pry.config.theme_options = {:paint_key_as_symbol => true}
|
22
|
+
```
|
23
|
+
|
4
24
|
### v1.0.3 (May 12, 2014)
|
5
25
|
|
6
26
|
* Fixed error when Pry.config.theme is set to a theme that doesn't exist
|
data/Gemfile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/lib/pry-theme.rb
CHANGED
data/lib/pry-theme/commands.rb
CHANGED
@@ -142,7 +142,7 @@ module PryTheme
|
|
142
142
|
opt.run do |opts, args|
|
143
143
|
|
144
144
|
if opts.present?(:c)
|
145
|
-
|
145
|
+
_pry_.pager.page Preview.new(ThemeList.current_theme).long
|
146
146
|
elsif args.empty?
|
147
147
|
output.puts ThemeList.current_theme.name
|
148
148
|
end
|
@@ -166,7 +166,7 @@ module PryTheme
|
|
166
166
|
].each { |m| __send__(m, cmd) }
|
167
167
|
|
168
168
|
cmd.add_callback(:empty) do
|
169
|
-
|
169
|
+
_pry_.pager.page opts.help
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
@@ -183,15 +183,15 @@ module PryTheme
|
|
183
183
|
|
184
184
|
def display_colors(color_model)
|
185
185
|
case color_model
|
186
|
-
when 256 then (
|
187
|
-
when 16 then (
|
188
|
-
when 8 then (
|
186
|
+
when 256 then _pry_.pager.page(ColorTable.t256)
|
187
|
+
when 16 then _pry_.pager.page(ColorTable.t16)
|
188
|
+
when 8 then _pry_.pager.page(ColorTable.t8)
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
192
192
|
def show_local_list
|
193
193
|
previews = ThemeList.themes.map { |theme| Preview.new(theme).short }
|
194
|
-
|
194
|
+
_pry_.pager.page(previews.join("\n"))
|
195
195
|
end
|
196
196
|
|
197
197
|
def show_remote_list
|
@@ -216,7 +216,7 @@ module PryTheme
|
|
216
216
|
|
217
217
|
out += response.body + "\n\n"
|
218
218
|
}
|
219
|
-
|
219
|
+
_pry_.pager.page(out.chomp)
|
220
220
|
end
|
221
221
|
|
222
222
|
def json_body(address)
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module PryTheme
|
2
|
+
class Config
|
3
|
+
class Executor
|
4
|
+
# @note The method amends the default behaviour of CodeRay.
|
5
|
+
#
|
6
|
+
# Sets the colour of the key token to the colour of the symbol token (akin to
|
7
|
+
# Pygments).
|
8
|
+
# @example
|
9
|
+
# {foo: 1, :bar => 2}
|
10
|
+
# # ^ ^
|
11
|
+
# # | |
|
12
|
+
# # key symbol
|
13
|
+
# Without this patch keys and symbols have generally different colours. It's
|
14
|
+
# impossible to set the colour of the key token, but with help of this method
|
15
|
+
# you can make it look like a symbol.
|
16
|
+
# @return [void]
|
17
|
+
# @see https://github.com/kyrylo/pry-theme/issues/30
|
18
|
+
def paint_key_as_symbol
|
19
|
+
token_colors = CodeRay::Encoders::Terminal::TOKEN_COLORS
|
20
|
+
token_colors[:key] = token_colors[:symbol]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(options)
|
25
|
+
@executor = Executor.new
|
26
|
+
@options = options
|
27
|
+
end
|
28
|
+
|
29
|
+
def apply
|
30
|
+
@options.each do |key, value|
|
31
|
+
@executor.__send__(key) if value
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -10,10 +10,16 @@ module PryTheme
|
|
10
10
|
display_warning(_pry_) if Pry.config.theme
|
11
11
|
ThemeList.activate_theme_intelligently
|
12
12
|
end
|
13
|
+
|
14
|
+
apply_config
|
13
15
|
end
|
14
16
|
|
15
17
|
private
|
16
18
|
|
19
|
+
def apply_config
|
20
|
+
PryTheme::Config.new(Pry.config.theme_options).apply
|
21
|
+
end
|
22
|
+
|
17
23
|
# Copy a default theme to theme directory, but only if it isn't there yet.
|
18
24
|
def recreate_user_themes_from_default_ones
|
19
25
|
FileUtils.mkdir_p(USER_THEMES_DIR) unless File.exist?(USER_THEMES_DIR)
|
data/pry-theme.gemspec
CHANGED
@@ -12,10 +12,8 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.require_path = 'lib'
|
13
13
|
s.files = `git ls-files`.split("\n")
|
14
14
|
|
15
|
-
s.
|
16
|
-
s.
|
15
|
+
s.add_dependency 'json', '~> 1.8'
|
16
|
+
s.add_dependency 'coderay', '~> 1.1'
|
17
17
|
|
18
|
-
s.add_development_dependency '
|
19
|
-
s.add_development_dependency 'rake', '~> 10.1'
|
20
|
-
s.add_development_dependency 'pry', '~> 0.9'
|
18
|
+
s.add_development_dependency 'bundler', '~> 1.0'
|
21
19
|
end
|
data/spec/commands_spec.rb
CHANGED
@@ -82,6 +82,9 @@ describe PryTheme::Command::PryTheme do
|
|
82
82
|
end
|
83
83
|
|
84
84
|
describe "'colors' subcommand" do
|
85
|
+
before { Pry.config.color = true }
|
86
|
+
after { Pry.config.color = false }
|
87
|
+
|
85
88
|
if ENV['TERM'] =~ /256color/
|
86
89
|
it "displays colours accordingly to the terminal color support" do
|
87
90
|
table = pry_eval('pry-theme colors')
|
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe PryTheme::Config do
|
4
|
+
before do
|
5
|
+
@token_colors = CodeRay::Encoders::Terminal::TOKEN_COLORS
|
6
|
+
@old_key_token = @token_colors[:key]
|
7
|
+
@token_colors[:key].should != @token_colors[:symbol]
|
8
|
+
end
|
9
|
+
|
10
|
+
after do
|
11
|
+
CodeRay::Encoders::Terminal::TOKEN_COLORS[:key] = @old_key_token
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#apply" do
|
15
|
+
describe ":paint_key_as_symbol is true" do
|
16
|
+
before do
|
17
|
+
PryTheme::Config.new(paint_key_as_symbol: true).apply
|
18
|
+
end
|
19
|
+
|
20
|
+
it "sets the key token to the value of the symbol token" do
|
21
|
+
@token_colors[:key].should == @token_colors[:symbol]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe ":paint_key_as symbol is false" do
|
26
|
+
before do
|
27
|
+
PryTheme::Config.new(paint_key_as_symbol: false).apply
|
28
|
+
end
|
29
|
+
|
30
|
+
it "doesn't set the key token to the value of the symbol token" do
|
31
|
+
@token_colors[:key].should != @token_colors[:symbol]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/spec/helper.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
|
-
require '
|
2
|
-
require 'pry'
|
1
|
+
require 'bundler/setup'
|
3
2
|
require 'pry/test/helper'
|
4
3
|
|
4
|
+
Bundler.require :default, :test
|
5
|
+
|
5
6
|
Pry.config.theme = nil
|
6
7
|
Pry.config.pager = false
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
require 'bacon'
|
14
|
-
|
15
|
-
puts "Ruby: #{ RUBY_VERSION }; Ruby Engine: #{ defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby' }; " \
|
16
|
-
"Pry Theme: #{ PryTheme::VERSION }"
|
9
|
+
puts(
|
10
|
+
"Ruby: #{RUBY_VERSION}; " +
|
11
|
+
"Ruby Engine: #{defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'}; " +
|
12
|
+
"Pry Theme: #{PryTheme::VERSION}"
|
13
|
+
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-theme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyrylo Silin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -39,47 +39,19 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rake
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '10.1'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '10.1'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0.9'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0.9'
|
54
|
+
version: '1.0'
|
83
55
|
description: The plugin enables color theme support for Pry.
|
84
56
|
email: kyrylosilin@gmail.com
|
85
57
|
executables: []
|
@@ -103,6 +75,7 @@ files:
|
|
103
75
|
- lib/pry-theme/colors/color256.rb
|
104
76
|
- lib/pry-theme/colors/color8.rb
|
105
77
|
- lib/pry-theme/commands.rb
|
78
|
+
- lib/pry-theme/config.rb
|
106
79
|
- lib/pry-theme/declaration.rb
|
107
80
|
- lib/pry-theme/definition.rb
|
108
81
|
- lib/pry-theme/formattable.rb
|
@@ -123,6 +96,7 @@ files:
|
|
123
96
|
- spec/colors/color256_spec.rb
|
124
97
|
- spec/colors/color8_spec.rb
|
125
98
|
- spec/commands_spec.rb
|
99
|
+
- spec/config_spec.rb
|
126
100
|
- spec/helper.rb
|
127
101
|
- spec/hex_spec.rb
|
128
102
|
- spec/rgb_spec.rb
|