super_awesome_print 0.2.3 → 0.2.6

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
- SHA1:
3
- metadata.gz: 9f84886051b6aba93025590a9edc35324d9ad38a
4
- data.tar.gz: cdb50d0419bc64e2a0a6f4c07dacda2fa7586782
2
+ SHA256:
3
+ metadata.gz: e89420aaef1029a21847fffeb95477b60723a8db6e7761b808de8b5ee9e78974
4
+ data.tar.gz: 2c6637522c60f7782f51f41162b22f639296dfde4b13eaf2831449100b9fee72
5
5
  SHA512:
6
- metadata.gz: 76c20608db1acef613f68cb0697f82386bbfb9cbaa7973b482befc71b323132c60fc8ef1dc47b37758e0f1b0d2067dfa4d9749b24f7453fff76245db9755d142
7
- data.tar.gz: 8ad18ba1535449e97c2f9df07105b80695b09a050a8282b569e56b42c4228bee10833f8c0c564a773d843abb7d25586a7e6804254f0226bca07e7e884909aa03
6
+ metadata.gz: e4d7e795ac179d1b9c0d289b8690e00e5df00c36cac5db18e7071c96dd7c3b2d801924d401f903f8b3973021a4fba00a562a354f966e198203d460a29fa85d31
7
+ data.tar.gz: 676fb0021bff46767b692551a18aaaa88183c5740bcd9b75649e54544385c4097a4d9a067ef2ee022500f4919daf148b8dc28bd07866c5d029d06e49878a27ee
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,16 @@ 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
+
54
+ Also, take a look at [cop for RuboCop](https://github.com/olegantonyan/super_awesome_print_rubocop) to make `sap` didn't leak into production.
55
+
45
56
  ## Development
46
57
 
47
58
  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.6'.freeze
3
3
  end
@@ -11,6 +11,26 @@ module Kernel
11
11
  ap msg
12
12
  ap '*** END ***', :color => { :string => :green }
13
13
  SuperAwesomePrint.blank_lines_bottom
14
+ msg
15
+ end
16
+
17
+ def sapf(msg)
18
+ file = File.open(SuperAwesomePrint.config.log_file_path , 'a')
19
+ file.puts("*** #{Time.now} ***")
20
+ file.puts(" class: #{msg.class}") if msg.respond_to?(:class)
21
+ lines = caller[0...SuperAwesomePrint.config.caller_lines].map do |line|
22
+ root_path = SuperAwesomePrint.config.root_path
23
+ if root_path.empty?
24
+ line
25
+ else
26
+ line.gsub(root_path + '/', '')
27
+ end
28
+ end
29
+ lines.each { |l| file.puts(' trace: ' + l) }
30
+ file.puts(msg.inspect)
31
+ file.puts('*** END ***')
32
+ ensure
33
+ file.close
14
34
  end
15
35
  end
16
36
 
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ['lib']
21
21
 
22
- spec.add_development_dependency 'bundler', '~> 1.10'
23
- spec.add_development_dependency 'rake', '~> 10.0'
22
+ spec.add_development_dependency 'bundler'
23
+ spec.add_development_dependency 'rake'
24
24
 
25
25
  if RUBY_VERSION < '1.9.3'
26
26
  spec.add_runtime_dependency 'awesome_print', '1.2.0'
metadata CHANGED
@@ -1,43 +1,43 @@
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.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Antonyan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-07 00:00:00.000000000 Z
11
+ date: 2022-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.10'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.10'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: awesome_print
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -77,7 +77,7 @@ homepage: http://github.com/olegantonyan/super_awesome_print
77
77
  licenses:
78
78
  - MIT
79
79
  metadata: {}
80
- post_install_message:
80
+ post_install_message:
81
81
  rdoc_options: []
82
82
  require_paths:
83
83
  - lib
@@ -92,9 +92,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  requirements: []
95
- rubyforge_project:
96
- rubygems_version: 2.5.1
97
- signing_key:
95
+ rubygems_version: 3.3.7
96
+ signing_key:
98
97
  specification_version: 4
99
98
  summary: Simple wrapper around awesome_print for easier look in long log
100
99
  test_files: []