cool_debug 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 [Ignacy Moryc]
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.
data/README ADDED
@@ -0,0 +1,19 @@
1
+ Cool_debug
2
+ ====
3
+
4
+ I was always unsatisfied with the way Rails view's debug method worked.
5
+ What I wanted was a way to present objects data for debug purposes in clean and readable way.
6
+ This is why I created this plugin.
7
+
8
+ Example
9
+ =======
10
+
11
+ In views:
12
+
13
+ cool_debug(@object)
14
+
15
+ For each object that we call cool_debug returns nice formatted table, see example here: http://i43.tinypic.com/2dr6ihj.jpg
16
+
17
+
18
+
19
+ Copyright (c) 2010 [Ignacy Moryc], released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,41 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ PKG_FILES = FileList[ '[a-zA-Z]*', 'lib/**/*', 'rails/**/*', 'tasks/**/*', 'test/**/*' ]
6
+
7
+ desc 'Default: run unit tests.'
8
+ task :default => :test
9
+
10
+ desc 'Test the cool_debug plugin.'
11
+ Rake::TestTask.new(:test) do |t|
12
+ t.libs << 'lib'
13
+ t.libs << 'test'
14
+ t.pattern = 'test/**/*_test.rb'
15
+ t.verbose = true
16
+ end
17
+
18
+ desc 'Generate documentation for the cool_debug plugin.'
19
+ Rake::RDocTask.new(:rdoc) do |rdoc|
20
+ rdoc.rdoc_dir = 'rdoc'
21
+ rdoc.title = 'Prrp'
22
+ rdoc.options << '--line-numbers' << '--inline-source'
23
+ rdoc.rdoc_files.include('README')
24
+ rdoc.rdoc_files.include('lib/**/*.rb')
25
+ end
26
+
27
+
28
+
29
+ begin
30
+ require 'jeweler'
31
+ Jeweler::Tasks.new do |gemspec|
32
+ gemspec.name = "cool_debug"
33
+ gemspec.summary = "Nicer debug in rails views"
34
+ gemspec.email = "imoryc@gmail.com"
35
+ gemspec.homepage = "http://github.com/ignacy/cool_debug"
36
+ gemspec.authors = ["Ignacy Moryc"]
37
+ end
38
+ Jeweler::GemcutterTasks.new
39
+ rescue LoadError
40
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
41
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,56 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{cool_debug}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ignacy Moryc"]
12
+ s.date = %q{2010-04-18}
13
+ s.email = %q{imoryc@gmail.com}
14
+ s.extra_rdoc_files = [
15
+ "README"
16
+ ]
17
+ s.files = [
18
+ "MIT-LICENSE",
19
+ "README",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "cool_debug.gemspec",
23
+ "install.rb",
24
+ "lib/cool_debug.rb",
25
+ "lib/cool_debug_helper.rb",
26
+ "rails/init.rb",
27
+ "tasks/cool_debug_tasks.rake",
28
+ "test/cool_debug_test.rb",
29
+ "test/database.yml",
30
+ "test/debug.log",
31
+ "test/schema.rb",
32
+ "test/test_helper.rb",
33
+ "uninstall.rb"
34
+ ]
35
+ s.homepage = %q{http://github.com/ignacy/cool_debug}
36
+ s.rdoc_options = ["--charset=UTF-8"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = %q{1.3.6}
39
+ s.summary = %q{Nicer debug in rails views}
40
+ s.test_files = [
41
+ "test/test_helper.rb",
42
+ "test/cool_debug_test.rb",
43
+ "test/schema.rb"
44
+ ]
45
+
46
+ if s.respond_to? :specification_version then
47
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
51
+ else
52
+ end
53
+ else
54
+ end
55
+ end
56
+
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ # Install hook code here
data/lib/cool_debug.rb ADDED
@@ -0,0 +1 @@
1
+ require 'cool_debug_helper'
@@ -0,0 +1,26 @@
1
+ module CoolDebugHelper
2
+
3
+ def cool_debug(obj)
4
+ front = <<-eos
5
+
6
+ <table style="background:white; border:1px solid black;">
7
+ <tr>
8
+ <th colspan="3" style="text-shadow: 2px 2px 2px #ddccb5; font-size: 16px; color:#04376C; background:#689CD2; text-align: center;"> #{obj.type } </th>
9
+ </tr>
10
+ eos
11
+ middle = ""
12
+ obj.class.column_names.each do |name|
13
+ middle << print_row_for_cool_debug(obj, name)
14
+ end
15
+
16
+ return front + middle + "</table><br/>"
17
+ end
18
+
19
+ private
20
+ def print_row_for_cool_debug(obj, name)
21
+ "<tr><td style='font-weight: bold;'>#{name}</td> <td> => </td> <td style='text-align: right;'>#{obj.send(name.to_sym)}</td></tr>"
22
+ end
23
+
24
+
25
+ end
26
+
data/rails/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'cool_debug'
2
+ ActionView::Base.send :include, CoolDebugHelper
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :cool_debug do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class CoolDebugTest < Test::Unit::TestCase
4
+ load_schema
5
+ class Bike < ActiveRecord::Base
6
+ end
7
+
8
+ def test_schema_has_loaded_correctly
9
+ assert_equal [], Bike.all
10
+ end
11
+ end
data/test/database.yml ADDED
@@ -0,0 +1,22 @@
1
+ sqlite:
2
+ :adapter: sqlite
3
+ :dbfile: vendor/plugins/prrp/test/prrp_plugin.sqlite.db
4
+
5
+ sqlite3:
6
+ :adapter: sqlite3
7
+ :dbfile: vendor/plugins/prrp/test/prrp_plugin.sqlite3.db
8
+
9
+ postgresql:
10
+ :adapter: postgresql
11
+ :username: postgres
12
+ :password: postgres
13
+ :database: prrp_plugin_test
14
+ :min_messages: ERROR
15
+
16
+ mysql:
17
+ :adapter: mysql
18
+ :host: localhost
19
+ :username: root
20
+ :password: password
21
+ :database: prrp_plugin_test
22
+
data/test/debug.log ADDED
@@ -0,0 +1,13 @@
1
+ # Logfile created on Sun Apr 18 10:30:04 +0200 2010 by logger.rb/22285
2
+ SQL (0.4ms) select sqlite_version(*)
3
+ SQL (0.8ms)  SELECT name
4
+ FROM sqlite_master
5
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
6
+ 
7
+ SQL (105.6ms) CREATE TABLE "bikes" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255), "mark" varchar(255), "produced" datetime, "age" integer, "price" integer) 
8
+ SQL (1.0ms)  SELECT name
9
+ FROM sqlite_master
10
+ WHERE type = 'table' AND NOT name = 'sqlite_sequence'
11
+ 
12
+ SQL (0.5ms) SELECT version FROM "schema_migrations"
13
+ CoolDebugTest::Bike Load (0.3ms) SELECT * FROM "bikes" 
data/test/schema.rb ADDED
@@ -0,0 +1,9 @@
1
+ ActiveRecord::Schema.define(:version => 0) do
2
+ create_table :bikes, :force => true do |t|
3
+ t.string :name
4
+ t.string :mark
5
+ t.datetime :produced
6
+ t.integer :age
7
+ t.integer :price
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ ENV['RAILS_ENV'] = 'test'
2
+ ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) + '/../../../..'
3
+ require 'test/unit'
4
+ require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config/environment.rb'))
5
+ def load_schema
6
+ config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml'))
7
+ ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
8
+ db_adapter = 'sqlite3'
9
+
10
+ if db_adapter.nil?
11
+ raise "No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite or Sqlite3."
12
+ end
13
+ ActiveRecord::Base.establish_connection(config[db_adapter])
14
+ load(File.dirname(__FILE__) + "/schema.rb")
15
+ require File.dirname(__FILE__) + '/../rails/init.rb'
16
+ end
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cool_debug
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Ignacy Moryc
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-04-18 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description:
22
+ email: imoryc@gmail.com
23
+ executables: []
24
+
25
+ extensions: []
26
+
27
+ extra_rdoc_files:
28
+ - README
29
+ files:
30
+ - MIT-LICENSE
31
+ - README
32
+ - Rakefile
33
+ - VERSION
34
+ - cool_debug.gemspec
35
+ - install.rb
36
+ - lib/cool_debug.rb
37
+ - lib/cool_debug_helper.rb
38
+ - rails/init.rb
39
+ - tasks/cool_debug_tasks.rake
40
+ - test/cool_debug_test.rb
41
+ - test/database.yml
42
+ - test/debug.log
43
+ - test/schema.rb
44
+ - test/test_helper.rb
45
+ - uninstall.rb
46
+ has_rdoc: true
47
+ homepage: http://github.com/ignacy/cool_debug
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options:
52
+ - --charset=UTF-8
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ requirements: []
70
+
71
+ rubyforge_project:
72
+ rubygems_version: 1.3.6
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: Nicer debug in rails views
76
+ test_files:
77
+ - test/test_helper.rb
78
+ - test/cool_debug_test.rb
79
+ - test/schema.rb