super_awesome_print 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f84886051b6aba93025590a9edc35324d9ad38a
4
- data.tar.gz: cdb50d0419bc64e2a0a6f4c07dacda2fa7586782
3
+ metadata.gz: 667f9bfc6e6c7e713cbd16c6a99190cd3acfe1da
4
+ data.tar.gz: 097f500d7cb59370abfa15b206ac7436dca6e65d
5
5
  SHA512:
6
- metadata.gz: 76c20608db1acef613f68cb0697f82386bbfb9cbaa7973b482befc71b323132c60fc8ef1dc47b37758e0f1b0d2067dfa4d9749b24f7453fff76245db9755d142
7
- data.tar.gz: 8ad18ba1535449e97c2f9df07105b80695b09a050a8282b569e56b42c4228bee10833f8c0c564a773d843abb7d25586a7e6804254f0226bca07e7e884909aa03
6
+ metadata.gz: ffb09a964fab8ea80effd4cf5c8d900898c9526cc24e572dfbf8279599c0a11fe3df6895ee318eaedf4ada191001678249e2cfda24f765452169b0b53f1f3e8b
7
+ data.tar.gz: 6dfc352ac908041b84a7c2b7df338be300bf3a6da8f38ed9edad27c81908012f1ed16c38ada01cecd9e7bc6d9ed6c989f8a7723e91978ae4f9831f44ef374d18
data/README.md CHANGED
@@ -35,6 +35,7 @@ SuperAwesomePrint.configure do |config|
35
35
  config.blank_lines_top = 2 # defaults to 0
36
36
  config.blank_lines_bottom = 2 # defaults to 0
37
37
  config.root_path = Rails.root.to_s # this path will be removed from caller's files path, defaults to Rails.root.to_s
38
+ config.log_file_path = '/some/path/to/log/file' # override default log file for `sapf`
38
39
  end
39
40
  ```
40
41
 
@@ -42,6 +43,14 @@ end
42
43
 
43
44
  Just use `sap` global function to print any variable.
44
45
 
46
+ You can also print to a file
47
+
48
+ ```ruby
49
+ sapf 'hello world'
50
+ ```
51
+
52
+ By default it will print everything to `sapf.log` file in current directory or to `log/sapf.log` if you're on Rails. See `log_file_path` config option to override this.
53
+
45
54
  ## Development
46
55
 
47
56
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,10 +1,11 @@
1
1
  class Configuration
2
- attr_accessor :caller_lines, :blank_lines_top, :blank_lines_bottom, :root_path
2
+ attr_accessor :caller_lines, :blank_lines_top, :blank_lines_bottom, :root_path, :log_file_path
3
3
 
4
4
  def initialize
5
5
  @caller_lines = 1
6
6
  @blank_lines_top = 0
7
7
  @blank_lines_bottom = 0
8
8
  @root_path = defined?(Rails) ? Rails.root.to_s : ''
9
+ @log_file_path = @root_path.empty? ? Dir.pwd + '/sapf.log' : @root_path + '/log/sapf.log'
9
10
  end
10
11
  end
@@ -1,3 +1,3 @@
1
1
  module SuperAwesomePrint
2
- VERSION = '0.2.3'.freeze
2
+ VERSION = '0.2.4'.freeze
3
3
  end
@@ -12,6 +12,24 @@ module Kernel
12
12
  ap '*** END ***', :color => { :string => :green }
13
13
  SuperAwesomePrint.blank_lines_bottom
14
14
  end
15
+
16
+ def sapf(msg)
17
+ File.open(SuperAwesomePrint.config.log_file_path , 'a') do |file|
18
+ file.puts("*** #{Time.now} ***")
19
+ file.puts(" class: #{msg.class}") if msg.respond_to?(:class)
20
+ lines = caller[0...SuperAwesomePrint.config.caller_lines].map do |line|
21
+ root_path = SuperAwesomePrint.config.root_path
22
+ if root_path.empty?
23
+ line
24
+ else
25
+ line.gsub(root_path + '/', '')
26
+ end
27
+ end
28
+ lines.each { |l| file.puts(' trace: ' + l) }
29
+ file.puts(msg.inspect)
30
+ file.puts('*** END ***')
31
+ end
32
+ end
15
33
  end
16
34
 
17
35
  module SuperAwesomePrint
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.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Antonyan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-07 00:00:00.000000000 Z
11
+ date: 2017-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.5.1
96
+ rubygems_version: 2.2.5
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Simple wrapper around awesome_print for easier look in long log