snoop_dogg 0.1.3

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 85a3f5cac3e538489dbe4378b1335319aa016cb4
4
+ data.tar.gz: c262d1c5e449c7fb6ecd6f90e7861438d8e0d2df
5
+ SHA512:
6
+ metadata.gz: 661394e639d0dd17c603ae1441e719b46793d54abda55891e3ef7af8ed0be0d86f08544b7b745fc313658dbf14fda760df482cac000242296b9ac9230a309619
7
+ data.tar.gz: ac6784af3bd12b62d3b6f838972ec5228a8d8b883c67551f6e883bc440b7e1e55605cf680df857f9dd38a0021e5c106a6913092ed004e0701f5658fe2a7dc3f8
@@ -0,0 +1,20 @@
1
+ Copyright 2018 Kevin J. Storberg
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,62 @@
1
+ # Name
2
+ SnoopDogg
3
+
4
+
5
+
6
+ # Description
7
+ SnoopDogg version '0.1.3' adds a powerful inspect-type method to Rails applications (i.e. 'snoop'). The 'snoop' method formats and
8
+ displays Model data in ways that human eyes can more easily digest. Simply put, SnoopDogg version '0.1.3' is a nicer way to see Models.
9
+
10
+
11
+
12
+ # Usage
13
+ SnoopDogg is a nicer way to see Models
14
+
15
+ ## Simply call 'snoop' on a Model
16
+ - Call 'snoop' on any Model to view the Model's attributes printed out to the console
17
+ - The Model's attributes will be sorted, color coded, and printed to the console one line at a time
18
+ - The 'snoop' method can be called directly on the Model's class, this will print empty attributes to the console
19
+
20
+ ## Feed 'snoop' arguments to view a Model's associations too
21
+ - 'snoop' can take arguments in the form of keys matching a Model's associations
22
+ - If the association is one-to-one, 'snoop' will find the associated record and print it below it's parent
23
+ - If the association is one-to-many, 'snoop' will print every associated record matching that relationship
24
+ - 'snoop' is powerful, it can print out multiple associations at once | e.g. User.first.snoop(:address, :comments)
25
+
26
+
27
+
28
+ # Installation
29
+ Add this line to your application's Gemfile:
30
+
31
+ ```ruby
32
+ gem 'snoop_dogg'
33
+ ```
34
+
35
+ And then execute:
36
+ ```bash
37
+ $ bundle
38
+ ```
39
+
40
+ Or install it yourself as:
41
+ ```bash
42
+ $ gem install snoop_dogg
43
+ ```
44
+
45
+
46
+ # Authors
47
+ - Kevin J. Storberg, Ooftypop Inc.
48
+
49
+
50
+
51
+ # Contributing
52
+ We welcome collaboration on all of our open source projects.
53
+
54
+ When contributing to SnoopDogg, we ask that you:
55
+ - notify us of your intended contribution so we may provide feedback
56
+ - make a PR on Github with a short description of your changes
57
+ - update any relevant documentation
58
+
59
+
60
+
61
+ # License
62
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,27 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'SnoopDogg'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ require 'bundler/gem_tasks'
18
+
19
+ require 'rake/testtask'
20
+
21
+ Rake::TestTask.new(:test) do |t|
22
+ t.libs << 'test'
23
+ t.pattern = 'test/**/*_test.rb'
24
+ t.verbose = false
25
+ end
26
+
27
+ task default: :test
@@ -0,0 +1,47 @@
1
+ require "snoop_dogg/railtie"
2
+
3
+ module SnoopDogg
4
+ extend ActiveSupport::Concern
5
+ private
6
+
7
+ included do
8
+ def snoop *args
9
+ puts "=" * 89,
10
+ "#{self.class.name} #{self.id}",
11
+ "=" * 89
12
+ self.attributes.sort.each do |k,v|
13
+ puts "#{k}: #{paint(v)}"
14
+ end
15
+ if args.any?
16
+ args.each do |arg|
17
+ self.send(arg).each {|child| child.snoop } rescue self.send(arg).snoop
18
+ end
19
+ else
20
+ puts "=" * 89
21
+ end
22
+ end
23
+
24
+ def self.snoop
25
+ self.new.snoop
26
+ end
27
+ end
28
+
29
+ def paint(v)
30
+ case v.class.to_s
31
+ when "ActiveSupport::TimeWithZone", "Date", "Time", "DateTime"
32
+ "\e[#{32}m#{v}\e[0m"
33
+ when "Fixnum"
34
+ "\e[#{34}m#{v}\e[0m"
35
+ when "NilClass"
36
+ "\e[#{31}m#{'nil'}\e[0m"
37
+ when "String"
38
+ "\e[#{33}m#{v}\e[0m"
39
+ when "FalseClass", "TrueClass"
40
+ "\e[#{32}m#{v}\e[0m"
41
+ else
42
+ "\e[#{35}m#{v}\e[0m"
43
+ end
44
+ end
45
+ end
46
+
47
+ ActiveRecord::Base.send(:include, SnoopDogg)
@@ -0,0 +1,4 @@
1
+ module SnoopDogg
2
+ class Railtie < ::Rails::Railtie
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module SnoopDogg
2
+ VERSION = '0.1.3'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :snoop_dogg do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: snoop_dogg
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ platform: ruby
6
+ authors:
7
+ - Kevin J. Storberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-01-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.2.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.2.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: A nicer way to see models
42
+ email:
43
+ - kevin@storberg.net
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - lib/snoop_dogg.rb
52
+ - lib/snoop_dogg/railtie.rb
53
+ - lib/snoop_dogg/version.rb
54
+ - lib/tasks/snoop_dogg_tasks.rake
55
+ homepage: https://github.com/ooftypop/snoop_dogg
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 2.6.10
76
+ signing_key:
77
+ specification_version: 4
78
+ summary: A nicer way to see models
79
+ test_files: []