mirror of
https://github.com/awesome-print/awesome_print
synced 2023-03-27 23:22:34 -04:00
Make option name more meaningful
I just noticed a code review which suggested against the name we are currently using and gave some good reasoning: "Naming things "new" is always a problem (since time passes and it's no longer new). Maybe colonize_symbol_keys? ("colonize" sounds kind of gross though...) https://git.io/vKIiX The ruby19_syntax name was suggested later in the conversation. As we have not yet released with the previous option name, it's now or never for this change.
This commit is contained in:
parent
9ad80f0309
commit
cf18904915
4 changed files with 25 additions and 25 deletions
|
@ -41,7 +41,7 @@ plain: false, # Use colors.
|
||||||
raw: false, # Do not recursively format instance variables.
|
raw: false, # Do not recursively format instance variables.
|
||||||
sort_keys: false, # Do not sort hash keys.
|
sort_keys: false, # Do not sort hash keys.
|
||||||
limit: false, # Limit arrays & hashes. Accepts bool or int.
|
limit: false, # Limit arrays & hashes. Accepts bool or int.
|
||||||
new_hash_syntax: false, # Use Ruby 1.9 hash syntax in output.
|
ruby19_syntax: false, # Use Ruby 1.9 hash syntax in output.
|
||||||
color: {
|
color: {
|
||||||
args: :pale,
|
args: :pale,
|
||||||
array: :white,
|
array: :white,
|
||||||
|
|
|
@ -28,10 +28,10 @@ module AwesomePrint
|
||||||
|
|
||||||
data = data.map do |key, value|
|
data = data.map do |key, value|
|
||||||
indented do
|
indented do
|
||||||
if options[:new_hash_syntax] && symbol?(key)
|
if options[:ruby19_syntax] && symbol?(key)
|
||||||
new_hash_syntax(key, value, width)
|
ruby19_syntax(key, value, width)
|
||||||
else
|
else
|
||||||
old_hash_syntax(key, value, width)
|
pre_ruby19_syntax(key, value, width)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -50,12 +50,12 @@ module AwesomePrint
|
||||||
k.first == ':'
|
k.first == ':'
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_hash_syntax(k, v, width)
|
def ruby19_syntax(k, v, width)
|
||||||
k[0] = ''
|
k[0] = ''
|
||||||
align(k, width - 1) << colorize(": ", :hash) << inspector.awesome(v)
|
align(k, width - 1) << colorize(": ", :hash) << inspector.awesome(v)
|
||||||
end
|
end
|
||||||
|
|
||||||
def old_hash_syntax(k, v, width)
|
def pre_ruby19_syntax(k, v, width)
|
||||||
align(k, width) << colorize(" => ", :hash) << inspector.awesome(v)
|
align(k, width) << colorize(" => ", :hash) << inspector.awesome(v)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ module AwesomePrint
|
||||||
raw: false, # Do not recursively format instance variables.
|
raw: false, # Do not recursively format instance variables.
|
||||||
sort_keys: false, # Do not sort hash keys.
|
sort_keys: false, # Do not sort hash keys.
|
||||||
limit: false, # Limit arrays & hashes. Accepts bool or int.
|
limit: false, # Limit arrays & hashes. Accepts bool or int.
|
||||||
new_hash_syntax: false, # Use Ruby 1.9 hash syntax in output.
|
ruby19_syntax: false, # Use Ruby 1.9 hash syntax in output.
|
||||||
color: {
|
color: {
|
||||||
args: :pale,
|
args: :pale,
|
||||||
array: :white,
|
array: :white,
|
||||||
|
|
|
@ -276,7 +276,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "new hash syntax" do
|
it "new hash syntax" do
|
||||||
expect(@hash.ai(:plain => true, :new_hash_syntax => true)).to eq <<-EOS.strip
|
expect(@hash.ai(:plain => true, :ruby19_syntax => true)).to eq <<-EOS.strip
|
||||||
{
|
{
|
||||||
1 => {
|
1 => {
|
||||||
sym: {
|
sym: {
|
||||||
|
@ -328,7 +328,7 @@ EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
it "colored with new hash syntax" do
|
it "colored with new hash syntax" do
|
||||||
expect(@hash.ai(:new_hash_syntax => true)).to eq <<-EOS.strip
|
expect(@hash.ai(:ruby19_syntax => true)).to eq <<-EOS.strip
|
||||||
{
|
{
|
||||||
1\e[0;37m => \e[0m{
|
1\e[0;37m => \e[0m{
|
||||||
sym\e[0;37m: \e[0m{
|
sym\e[0;37m: \e[0m{
|
||||||
|
|
Loading…
Reference in a new issue