html_inspector 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ group :development do
4
+ gem "bundler", "~> 1.0.0"
5
+ gem "jeweler", "~> 1.5.1"
6
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,16 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.5.1)
6
+ bundler (~> 1.0.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.8.7)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ bundler (~> 1.0.0)
16
+ jeweler (~> 1.5.1)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Rusty Burchfield
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.rdoc ADDED
@@ -0,0 +1,20 @@
1
+ = html_inspector
2
+
3
+ Provides and easy way to dump standard data structures to readable HTML.
4
+
5
+ Great for API responses and other arbitrary bags of data that need to be
6
+ visualized on occasion.
7
+
8
+ == Contributing to html_inspector
9
+
10
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
11
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
12
+ * Fork the project
13
+ * Start a feature/bugfix branch
14
+ * Commit and push until you are happy with your contribution
15
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
16
+
17
+ == Copyright
18
+
19
+ Copyright (c) 2010 Rusty Burchfield. See LICENSE.txt for
20
+ further details.
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ begin
5
+ Bundler.setup(:default, :development)
6
+ rescue Bundler::BundlerError => e
7
+ $stderr.puts e.message
8
+ $stderr.puts "Run `bundle install` to install missing gems"
9
+ exit e.status_code
10
+ end
11
+ require 'rake'
12
+
13
+ require 'jeweler'
14
+ Jeweler::Tasks.new do |gem|
15
+ gem.name = "html_inspector"
16
+ gem.homepage = "http://github.com/GICodeWarrior/html_inspector"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Core extension providing .html_inspect}
19
+ gem.description = %Q{Pretty-print your objects into HTML}
20
+ gem.email = "GICodeWarrior@gmail.com"
21
+ gem.authors = ["Rusty Burchfield"]
22
+ end
23
+ Jeweler::RubygemsDotOrgTasks.new
24
+
25
+ task :default => :build
26
+
27
+ require 'rake/rdoctask'
28
+ Rake::RDocTask.new do |rdoc|
29
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
30
+
31
+ rdoc.rdoc_dir = 'rdoc'
32
+ rdoc.title = "html_inspector #{version}"
33
+ rdoc.rdoc_files.include('README*')
34
+ rdoc.rdoc_files.include('lib/**/*.rb')
35
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,4 @@
1
+ require 'html_inspector/escape'
2
+ require 'html_inspector/load'
3
+
4
+ HtmlInspector.load_core_ext
@@ -0,0 +1,9 @@
1
+ class Array
2
+ def html_inspect
3
+ list = '<ol start="0">'
4
+ self.each do |element|
5
+ list << "<li>#{element.html_inspect}</li>"
6
+ end
7
+ list << '</ol>'
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Enumerable
2
+ def html_inspect
3
+ list = '<ul>'
4
+ self.each do |element|
5
+ list << "<li>#{element.html_inspect}</li>"
6
+ end
7
+ list << '</ul>'
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ class Hash
2
+ def html_inspect
3
+ table = '<table>'
4
+ self.each_pair do |key, value|
5
+ table << "<tr><th>#{key.html_inspect}</th>" \
6
+ "<td>#{value.html_inspect}</td></tr>"
7
+ end
8
+ table << '</table>'
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class Object
2
+ def html_inspect
3
+ HtmlInspector.escape(self.inspect)
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class String
2
+ def html_inspect
3
+ HtmlInspector.escape(self.inspect)
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ class HtmlInspector
2
+ class << self
3
+ ESCAPE_TABLE = { '&'=>'&amp;', '<'=>'&lt;', '>'=>'&gt;', '"'=>'&quot;', "'"=>'&#039;', }
4
+
5
+ def escape(data)
6
+ data.to_s.gsub(/[&<>"]/) {|s| ESCAPE_TABLE[s] }
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class HtmlInspector
2
+ class << self
3
+ def load_core_ext
4
+ core_ext = File.expand_path(File.join(File.dirname(__FILE__), 'core_ext'))
5
+ Dir.glob(File.join(core_ext, '*.rb')) do |file|
6
+ file.match(/^.+\/([^\/]+)\.rb$/)
7
+ require "html_inspector/core_ext/#{$1}"
8
+ end
9
+ end
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: html_inspector
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Rusty Burchfield
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-10 00:00:00 -08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :development
23
+ prerelease: false
24
+ name: bundler
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ hash: 23
31
+ segments:
32
+ - 1
33
+ - 0
34
+ - 0
35
+ version: 1.0.0
36
+ requirement: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ type: :development
39
+ prerelease: false
40
+ name: jeweler
41
+ version_requirements: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ hash: 1
47
+ segments:
48
+ - 1
49
+ - 5
50
+ - 1
51
+ version: 1.5.1
52
+ requirement: *id002
53
+ description: Pretty-print your objects into HTML
54
+ email: GICodeWarrior@gmail.com
55
+ executables: []
56
+
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - LICENSE.txt
61
+ - README.rdoc
62
+ files:
63
+ - .document
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - LICENSE.txt
67
+ - README.rdoc
68
+ - Rakefile
69
+ - VERSION
70
+ - lib/html_inspector.rb
71
+ - lib/html_inspector/core_ext/array.rb
72
+ - lib/html_inspector/core_ext/enumerable.rb
73
+ - lib/html_inspector/core_ext/hash.rb
74
+ - lib/html_inspector/core_ext/object.rb
75
+ - lib/html_inspector/core_ext/string.rb
76
+ - lib/html_inspector/escape.rb
77
+ - lib/html_inspector/load.rb
78
+ has_rdoc: true
79
+ homepage: http://github.com/GICodeWarrior/html_inspector
80
+ licenses:
81
+ - MIT
82
+ post_install_message:
83
+ rdoc_options: []
84
+
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ requirements: []
106
+
107
+ rubyforge_project:
108
+ rubygems_version: 1.3.7
109
+ signing_key:
110
+ specification_version: 3
111
+ summary: Core extension providing .html_inspect
112
+ test_files: []
113
+