super_awesome_print 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb39c2290ca2b6ed6ab2436a82d16b47a8edab7e
4
- data.tar.gz: 0976a049b8d00556c682d9a008c05d5b7466d181
3
+ metadata.gz: f278fe4412a4ff7d18230b15cd8d5a36780ce476
4
+ data.tar.gz: 814ec19746437935d831a4ffcc1748ec4cf0b26a
5
5
  SHA512:
6
- metadata.gz: 560ca36e08e3947a95d700d3f0c034757745c0a924b2c53338ef47d408436ccd49712b2a11c5dffce29de88200ccede2f703633a1887116712836744ccd50de5
7
- data.tar.gz: 8d2ce3c8324a820d1bc9f0c85c9647c1eb7e344f3f01d778b65792d83717ad6829c5c946b9f84e545684a9ef9ab25e1a7e6915092e7a7c454dac0428b657b96f
6
+ metadata.gz: 88d59f52d0c7aa9e9bf3213fe13c038ddae55c4df0fe76e69171cc90355678423b8d71d0f34086af5af2d43e1f8e0427ffaf09b69234f877d9d981e87ed3320a
7
+ data.tar.gz: ac5cc4430a541b092e4eaa3d161ad9a14af26c59955566c581281c44abe580cc54020cd0c2506447ccef24099f63aded79c825fcc98fd5a5d984e33e85568d83
data/README.md CHANGED
@@ -15,7 +15,7 @@ end
15
15
  Add this line to your application's Gemfile:
16
16
 
17
17
  ```ruby
18
- gem 'super_awesome_print', github: 'olegantonyan/super_awesome_print'
18
+ gem 'super_awesome_print'
19
19
  ```
20
20
 
21
21
  And then execute:
@@ -26,6 +26,17 @@ Or install it yourself as:
26
26
 
27
27
  $ gem install super_awesome_print
28
28
 
29
+ You can optionally customize configuration in an initializer.<br/>
30
+ In Rails, you can add the following to `config/initializers/super_awesome_print.rb`:
31
+
32
+ ```ruby
33
+ SuperAwesomePrint.configure do |config|
34
+ config.caller_lines = 3 # defaults to 1
35
+ config.blank_lines_top = 2 # defaults to 0
36
+ config.blank_lines_bottom = 2 # defaults to 0
37
+ end
38
+ ```
39
+
29
40
  ## Usage
30
41
 
31
42
  Just use `sap` global function to print any variable.
@@ -38,7 +49,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
38
49
 
39
50
  ## Contributing
40
51
 
41
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/super_awesome_print. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/olegantonyan/super_awesome_print. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://www.contributor-covenant.org) code of conduct.
42
53
 
43
54
 
44
55
  ## License
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "super_awesome_print"
3
+ require 'bundler/setup'
4
+ require 'super_awesome_print'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require "super_awesome_print"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
13
+ require 'irb'
14
14
  IRB.start
@@ -1,13 +1,50 @@
1
- require "super_awesome_print/version"
2
- require "awesome_print"
1
+ require 'super_awesome_print/version'
2
+ require 'super_awesome_print/configuration'
3
+ require 'awesome_print'
3
4
 
4
- def sap msg
5
- ap "*** #{Time.now} ***", color: {string: :green}
6
- src = caller.first.gsub(Rails.root.to_s + '/', '')
7
- ap src, color: {string: :purpleish}
5
+ def sap(msg)
6
+ SuperAwesomePrint.blank_lines_top
7
+ ap "*** #{Time.now} ***", color: { string: :green }
8
+ ap msg.class if msg.respond_to?(:class)
9
+ SuperAwesomePrint.print_caller_lines(caller)
8
10
  ap msg
9
- ap '*** END ***', color: {string: :green}
11
+ ap '*** END ***', color: { string: :green }
12
+ SuperAwesomePrint.blank_lines_bottom
10
13
  end
11
14
 
12
15
  module SuperAwesomePrint
16
+ class << self
17
+ attr_writer :configuration
18
+ end
19
+
20
+ def self.print_caller_lines(caller_array)
21
+ number_of_lines = config.caller_lines
22
+ lines = caller_array[0...number_of_lines].map do |line|
23
+ line.gsub(Rails.root.to_s + '/', '')
24
+ end
25
+ lines.each { |line| ap line, color: { string: :purpleish } }
26
+ end
27
+
28
+ def self.blank_lines_top
29
+ # The first puts has no visible effect
30
+ # So we want to puts once regardless of config
31
+ puts
32
+ config.blank_lines_top.times { puts }
33
+ end
34
+
35
+ def self.blank_lines_bottom
36
+ config.blank_lines_bottom.times { puts }
37
+ end
38
+
39
+ def self.config
40
+ SuperAwesomePrint.configuration
41
+ end
42
+
43
+ def self.configuration
44
+ @configuration ||= Configuration.new
45
+ end
46
+
47
+ def self.configure
48
+ yield configuration
49
+ end
13
50
  end
@@ -0,0 +1,9 @@
1
+ class Configuration
2
+ attr_accessor :caller_lines, :blank_lines_top, :blank_lines_bottom
3
+
4
+ def initialize
5
+ @caller_lines = 1
6
+ @blank_lines_top = 0
7
+ @blank_lines_bottom = 0
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module SuperAwesomePrint
2
- VERSION = "0.1.1"
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -4,22 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'super_awesome_print/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "super_awesome_print"
7
+ spec.name = 'super_awesome_print'
8
8
  spec.version = SuperAwesomePrint::VERSION
9
- spec.authors = ["Oleg Antonyan"]
10
- spec.email = ["oleg.b.antonyan@gmail.com"]
9
+ spec.authors = ['Oleg Antonyan']
10
+ spec.email = ['oleg.b.antonyan@gmail.com']
11
11
 
12
- spec.summary = %q{Simple wrapper around awesome_print for easier look in long log}
13
- spec.description = %q{Add colored '*********', time and line number around printed value}
14
- spec.homepage = "http://github.com/olegantonyan/super_awesome_printsuper_awesome_print"
15
- spec.license = "MIT"
12
+ spec.summary = 'Simple wrapper around awesome_print for easier look in long log'
13
+ spec.description = "Add colored '*********', time and line number around printed value"
14
+ spec.homepage = 'http://github.com/olegantonyan/super_awesome_print'
15
+ spec.license = 'MIT'
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
18
+ spec.bindir = 'exe'
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
20
+ spec.require_paths = ['lib']
21
21
 
22
- spec.add_development_dependency "bundler", "~> 1.10"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_runtime_dependency "awesome_print"
22
+ spec.add_development_dependency 'bundler', '~> 1.10'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_runtime_dependency 'awesome_print'
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_awesome_print
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Antonyan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-25 00:00:00.000000000 Z
11
+ date: 2016-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -70,9 +70,10 @@ files:
70
70
  - bin/console
71
71
  - bin/setup
72
72
  - lib/super_awesome_print.rb
73
+ - lib/super_awesome_print/configuration.rb
73
74
  - lib/super_awesome_print/version.rb
74
75
  - super_awesome_print.gemspec
75
- homepage: http://github.com/olegantonyan/super_awesome_printsuper_awesome_print
76
+ homepage: http://github.com/olegantonyan/super_awesome_print
76
77
  licenses:
77
78
  - MIT
78
79
  metadata: {}