1
0
Fork 0
mirror of https://github.com/awesome-print/awesome_print synced 2023-03-27 23:22:34 -04:00

Use assignments consistent with our style guide

This is so that people do not get warnings about problems in existing
code when we turn on Hound style checks.

---

If git-blame brought you here you may want to read this, the
problem is with git-blame, not this change.

Try running these two lines just once:
```
git config --global alias.praise 'log -p -M --follow --stat --'
git config --global alias.praise-line 'log -p -M --pretty=format:"%h (%an %ai)" -L'
```

Now in future you can use

`git praise <path/to/your/file>`

or if you want to see the evolution of a specific line or range of lines

`git praise-line <start-line>:<end-line>:<path/to/your/file>`

Some examples you should try:
```
git praise lib/awesome_print/version.rb
git praise-line 8:8:lib/awesome_print/version.rb
```

Inspiration for these aliases:

http://blog.andrewray.me/a-better-git-blame/
This commit is contained in:
Gerard Caulfield 2016-11-09 17:04:02 +11:00
parent abff97e812
commit a65ba3ff38
No known key found for this signature in database
GPG key ID: 623B327128A9BEC3
10 changed files with 56 additions and 35 deletions

View file

@ -73,10 +73,10 @@ module AwesomePrint
# Add in associations
if @options[:mongo_mapper][:show_associations]
object.associations.each do |name, assoc|
if @options[:mongo_mapper][:inline_embedded] and assoc.embeddable?
data[name.to_s] = object.send(name)
data[name.to_s] = if @options[:mongo_mapper][:inline_embedded] and assoc.embeddable?
object.send(name)
else
data[name.to_s] = assoc
assoc
end
end
end

View file

@ -44,7 +44,7 @@ module AwesomePrint
def awesome_self(object, type)
if @options[:raw] && object.instance_variables.any?
awesome_object(object)
elsif hash = convert_to_hash(object)
elsif (hash = convert_to_hash(object))
awesome_hash(hash)
else
awesome_simple(object.inspect.to_s, type, @inspector)

View file

@ -52,10 +52,10 @@ module AwesomePrint
# Add the proper elements to the temp array and format the separator.
temp = data[0, head] + [nil] + data[-tail, tail]
if is_hash
temp[head] = "#{indent}#{data[head].strip} .. #{data[data.length - tail - 1].strip}"
temp[head] = if is_hash
"#{indent}#{data[head].strip} .. #{data[data.length - tail - 1].strip}"
else
temp[head] = "#{indent}[#{head.to_s.rjust(width)}] .. [#{data.length - tail - 1}]"
"#{indent}[#{head.to_s.rjust(width)}] .. [#{data.length - tail - 1}]"
end
temp
@ -90,7 +90,8 @@ module AwesomePrint
# #<UnboundMethod: Hello#world>
#
if method.to_s =~ /(Unbound)*Method: (.*)[#\.]/
unbound, klass = $1 && '(unbound)', $2
unbound = $1 && '(unbound)'
klass = $2
if klass && klass =~ /(\(\w+:\s.*?\))/ # Is this ActiveRecord-style class?
klass.sub!($1, '') # Yes, strip the fields leaving class name only.
end

View file

@ -13,7 +13,8 @@ module AwesomePrint
end
def format
if superclass = klass.superclass # <-- Assign and test if nil.
superclass = klass.superclass
if superclass
colorize("#{klass.inspect} < #{superclass}", :class)
else
colorize(klass.inspect, :class)

View file

@ -60,11 +60,14 @@ module AwesomePrint
end
def plain_single_line
plain, multiline = options[:plain], options[:multiline]
options[:plain], options[:multiline] = true, false
plain = options[:plain]
multiline = options[:multiline]
options[:plain] = true
options[:multiline] = false
yield
ensure
options[:plain], options[:multiline] = plain, multiline
options[:plain] = plain
options[:multiline] = multiline
end
end
end

View file

@ -64,7 +64,8 @@ module AwesomePrint
end
def left_aligned
current, options[:indent] = options[:indent], 0
current = options[:indent]
options[:indent] = 0
yield
ensure
options[:indent] = current

View file

@ -60,7 +60,8 @@ module AwesomePrint
end
def left_aligned
current, options[:indent] = options[:indent], 0
current = options[:indent]
options[:indent] = 0
yield
ensure
options[:indent] = current

View file

@ -32,7 +32,8 @@ RSpec.describe 'AwesomePrint' do
it "colorizes processes with ENV['ANSICON'] by default" do
begin
stub_tty!
term, ENV['ANSICON'] = ENV['ANSICON'], '1'
term = ENV['ANSICON']
ENV['ANSICON'] = '1'
expect(@arr.ai(multiline: false)).to eq(COLORIZED)
ensure
ENV['ANSICON'] = term
@ -42,7 +43,8 @@ RSpec.describe 'AwesomePrint' do
it 'does not colorize tty processes running in dumb terminals by default' do
begin
stub_tty!
term, ENV['TERM'] = ENV['TERM'], 'dumb'
term = ENV['TERM']
ENV['TERM'] = 'dumb'
expect(@arr.ai(multiline: false)).to eq(PLAIN)
ensure
ENV['TERM'] = term
@ -72,7 +74,8 @@ RSpec.describe 'AwesomePrint' do
it "colorizes processes with ENV['ANSICON'] set to 0" do
begin
stub_tty!
term, ENV['ANSICON'] = ENV['ANSICON'], '1'
term = ENV['ANSICON']
ENV['ANSICON'] = '1'
expect(@arr.ai(multiline: false)).to eq(COLORIZED)
ensure
ENV['ANSICON'] = term
@ -82,7 +85,8 @@ RSpec.describe 'AwesomePrint' do
it 'colorizes dumb terminals' do
begin
stub_tty!
term, ENV['TERM'] = ENV['TERM'], 'dumb'
term = ENV['TERM']
ENV['TERM'] = 'dumb'
expect(@arr.ai(multiline: false)).to eq(COLORIZED)
ensure
ENV['TERM'] = term

View file

@ -32,8 +32,8 @@ RSpec.describe 'AwesomePrint/MongoMapper', skip: -> { !ExtVerifier.has_mongo_map
out.gsub!(/#\<Proc:.+?\>/, 'AWESOME_PRINT_PROC_STUB')
out.gsub!(/BSON::ObjectId\('[\da-f]+?'\)/, "BSON::ObjectId('123456789')")
if MongoMapper::Version >= '0.13'
str = <<-EOS.strip
str = if MongoMapper::Version >= '0.13'
<<-EOS.strip
#<MongoUser:placeholder_id
@__mm_default_keys = [
[0] #<MongoMapper::Plugins::Keys::Key:placeholder_id
@ -110,7 +110,7 @@ RSpec.describe 'AwesomePrint/MongoMapper', skip: -> { !ExtVerifier.has_mongo_map
>
EOS
else
str = <<-EOS.strip
<<-EOS.strip
#<MongoUser:placeholder_id
@_new = true,
attr_accessor :first_name = "Al",

View file

@ -13,7 +13,9 @@ RSpec.describe 'Objects' do
attr_accessor :dabra
def initialize
@abra, @ca, @dabra = 1, 2, 3
@abra = 1
@ca = 2
@dabra = 3
end
end
@ -33,7 +35,9 @@ EOS
it 'instance variables' do
class Hello
def initialize
@abra, @ca, @dabra = 1, 2, 3
@abra = 1
@ca = 2
@dabra = 3
end
end
@ -57,8 +61,12 @@ EOS
attr_accessor :dabra
def initialize
@abra, @ca, @dabra = 1, 2, 3
@scooby, @dooby, @doo = 3, 2, 1
@abra = 1
@ca = 2
@dabra = 3
@scooby = 3
@dooby = 2
@doo = 1
end
end
@ -84,7 +92,8 @@ EOS
attr_writer :ca
def initialize
@abra, @ca = 1, 2
@abra = 1
@ca = 2
@dabra = 3
end
end
@ -108,7 +117,8 @@ EOS
attr_writer :ca
def initialize
@abra, @ca = 1, 2
@abra = 1
@ca = 2
@dabra = 3
end
end