perception 0.1.5

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,20 @@
1
+
2
+
3
+ @ECHO OFF
4
+
5
+ rem CODEPAGE �NDERN
6
+ @cmd /C chcp 1252 > NUL
7
+
8
+
9
+
10
+ echo.
11
+
12
+
13
+ ruby test/_start_all.rb
14
+
15
+ echo.
16
+ echo.
17
+ echo.
18
+ pause
19
+
20
+
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2008-08-01
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,21 @@
1
+ LICENSE: GNU General Public License (GPL)
2
+ Autor: Bjoern Klippstein
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,29 @@
1
+ lib/perception.rb
2
+ lib/perception/const.rb
3
+ lib/perception/date_and_time.rb
4
+ lib/perception/logging.rb
5
+ lib/perception/numeric.rb
6
+ lib/perception/perception_main.rb
7
+ lib/perception/perception_private.rb
8
+ lib/perception/ppp.rb
9
+ lib/perception/string_spread.rb
10
+ lib/perception/test.rb
11
+ 0 start all Tests.bat
12
+ History.txt
13
+ init.rb
14
+ License.txt
15
+ Manifest.txt
16
+ PostInstall.txt
17
+ Rakefile.rb
18
+ README.txt
19
+ website/index.html
20
+ website/index.txt
21
+ website/javascripts/rounded_corners_lite.inc.js
22
+ website/stylesheets/screen.css
23
+ website/template.html.erb
24
+ demo/demo_pp.rb
25
+ demo/demo_zz.rb
26
+ test/_start_all.rb
27
+ test/test_date_and_time.rb
28
+ test/test_numeric.rb
29
+ test/test_ppp.rb
data/PostInstall.txt ADDED
@@ -0,0 +1,6 @@
1
+
2
+ Perception - Beautiful printouts for humans
3
+ For more information on perception, see http://perception.rubyforge.org
4
+
5
+
6
+
data/README.txt ADDED
@@ -0,0 +1,55 @@
1
+ = perception
2
+
3
+ http://perception.rubyforge.org/
4
+
5
+ == DESCRIPTION:
6
+
7
+ Perception - Beautiful printouts for humans
8
+ Perception is a intuitive toolkit for simple everyday debugging.
9
+ It offers a powerfull replacement for print, puts and pp.
10
+
11
+ You get auto-intended and structured output on your console without any configuration.
12
+ Perception also offers temporary printouts (overwritten by the next print),
13
+ printing two informations in one line without destroying the structure
14
+ and optionally slows down printing to readable speed, depending on the complexity of the output.
15
+
16
+
17
+ == FEATURES/PROBLEMS:
18
+
19
+ * FIX (list of features or problems)
20
+
21
+ == SYNOPSIS:
22
+
23
+ FIX (code sample of usage)
24
+
25
+ == REQUIREMENTS:
26
+
27
+ * FIX (list of requirements)
28
+
29
+ == INSTALL:
30
+
31
+ * FIX (sudo gem install, anything else)
32
+
33
+ == LICENSE:
34
+
35
+ GNU General Public License (GPL)
36
+
37
+
38
+ Permission is hereby granted, free of charge, to any person obtaining
39
+ a copy of this software and associated documentation files (the
40
+ 'Software'), to deal in the Software without restriction, including
41
+ without limitation the rights to use, copy, modify, merge, publish,
42
+ distribute, sublicense, and/or sell copies of the Software, and to
43
+ permit persons to whom the Software is furnished to do so, subject to
44
+ the following conditions:
45
+
46
+ The above copyright notice and this permission notice shall be
47
+ included in all copies or substantial portions of the Software.
48
+
49
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
50
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
51
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
52
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
53
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
54
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
55
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile.rb ADDED
@@ -0,0 +1,127 @@
1
+
2
+ # ----------------------------------------------------------------------------------------------
3
+ # NewGem
4
+ #
5
+
6
+ %w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
7
+ require File.dirname(__FILE__) + '/lib/perception'
8
+
9
+ # Generate all the Rake tasks
10
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
11
+ $hoe = Hoe.new('perception', Perception::VERSION) do |p|
12
+ p.developer('Bjoern Klippstein', 'bjoernklippstein@gmail.com')
13
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
14
+ p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
15
+ p.rubyforge_name = p.name # TODO this is default value
16
+ p.extra_deps = [
17
+ ['kyanite', '>= 0.3.1'],
18
+ ]
19
+ p.extra_dev_deps = [
20
+ ['newgem', ">= #{::Newgem::VERSION}"]
21
+ ]
22
+
23
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
24
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
25
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
26
+ p.rsync_args = '-av --delete --ignore-errors'
27
+ end
28
+
29
+ require 'newgem/tasks' # load /tasks/*.rake
30
+ Dir['tasks/**/*.rake'].each { |t| load t }
31
+
32
+ # TODO - want other tests/tasks run by default? Add them to the list
33
+ # task :default => [:spec, :features]
34
+
35
+
36
+
37
+ # ----------------------------------------------------------------------------------------------
38
+ # Kyanite
39
+ #
40
+
41
+ $rake_tasks_ausblenden = %w{ bundles:tm deps:email deps:fetch deps:list manifest manifest:refresh
42
+ announce check_manifest debug_gem email install_gem install_gem_no_doc
43
+ local_deploy package post_blog post_news ridocs test_deps}
44
+ require 'kyanite/rake'
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+ # ----------------------------------------------------------------------------------------------
53
+ # Documentation
54
+ #
55
+ # http://github.com/mislav/hanna/tree/master
56
+
57
+ # instead of 'rake/rdoctask':
58
+ require 'hanna/rdoctask'
59
+
60
+ desc 'Generate RDoc documentation for Perception'
61
+ Rake::RDocTask.new do |rdoc|
62
+ rdoc.rdoc_dir = 'doc'
63
+ rdoc.title = "Perception - Beautiful printouts for humans"
64
+ rdoc.rdoc_files.include('README.txt', 'License.txt')
65
+ rdoc.rdoc_files.include('lib/**/*.rb')
66
+ rdoc.rdoc_files.include('test/**/test_*.rb')
67
+ #rdoc.rdoc_files.exclude('lib/perception/array/array2')
68
+
69
+ rdoc.options += [
70
+ '-SNap',
71
+ '-w4',
72
+ '--charset=utf8',
73
+ ]
74
+ end
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+ # Gem::Specification.new do |s|
83
+ # s.name = %q{perception}
84
+ # s.version = "0.0.1"
85
+ # s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
86
+ # s.authors = ["Bjoern Klippstein"]
87
+ # s.date = %q{2008-08-01}
88
+ # s.description = %q{Beautiful printouts for humans}
89
+ # s.email = ["b-klippstein@gmx.de"]
90
+ # s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "website/index.txt"]
91
+ # s.files = ["", "demo/demo.rb", "demo/demo_pp.rb", "lib/perception/const.rb", "lib/perception/date_and_time.rb", "lib/perception/logging.rb", "lib/perception/n
92
+ # umeric.rb", "lib/perception/perception_main.rb", "lib/perception/perception_private.rb", "lib/perception/ppp.rb", "lib/perception/string_nested.rb", "lib/percep
93
+ # tion/string_spread.rb", "log/see.log", "test/#_start_all_TESTS.bat", "test/_start_all.rb", "test/_testhelper.rb", "test/date_and_time_test.rb", "test/numeric_te
94
+ # st.rb", "test/ppp_test.rb", "test/string_nested_test.rb", "History.txt", "License.txt", "Manifest.txt", "PostInstall.txt", "README.txt", "Rakefile", "config/hoe
95
+ # .rb", "config/requirements.rb", "lib/perception.rb", "lib/perception/version.rb", "script/console", "script/console.cmd", "script/destroy", "script/destroy.cmd"
96
+ # , "script/generate", "script/generate.cmd", "script/txt2html", "script/txt2html.cmd", "setup.rb", "tasks/deployment.rake", "tasks/environment.rake", "tasks/webs
97
+ # ite.rake", "test/test_helper.rb", "test/test_perception.rb", "website/index.html", "website/index.txt", "website/javascripts/rounded_corners_lite.inc.js", "webs
98
+ # ite/stylesheets/screen.css", "website/template.html.erb"]
99
+ # s.has_rdoc = true
100
+ # s.homepage = %q{http://perception.rubyforge.org}
101
+ # s.post_install_message = %q{
102
+ # For more information on perception, see http://perception.rubyforge.org
103
+
104
+ # NOTE: Change this information in PostInstall.txt
105
+ # You can also delete it if you don't want it.
106
+
107
+
108
+ # }
109
+ # s.rdoc_options = ["--main", "README.txt"]
110
+ # s.require_paths = ["lib"]
111
+ # s.rubyforge_project = %q{perception}
112
+ # s.rubygems_version = %q{1.2.0}
113
+ # s.summary = %q{Beautiful printouts for humans}
114
+
115
+ # if s.respond_to? :specification_version then
116
+ # current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
117
+ # s.specification_version = 2
118
+
119
+ # if current_version >= 3 then
120
+ # s.add_development_dependency(%q<hoe>, [">= 1.7.0"])
121
+ # else
122
+ # s.add_dependency(%q<hoe>, [">= 1.7.0"])
123
+ # end
124
+ # else
125
+ # s.add_dependency(%q<hoe>, [">= 1.7.0"])
126
+ # end
127
+ # end
data/demo/demo_pp.rb ADDED
@@ -0,0 +1,163 @@
1
+
2
+ if $0 == __FILE__
3
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'perception' )
4
+ else
5
+ require 'perception'
6
+ end
7
+
8
+
9
+
10
+ module Perception #:nodoc
11
+
12
+ class DemoSee
13
+ @@initialized_count = 0
14
+
15
+ def initialize( announce_first=true )
16
+ #seee.out << :log
17
+ @@initialized_count += 1
18
+ return if (@@initialized_count == 1 && !announce_first)
19
+ #seee.slow!(0.5)
20
+ seee.left!
21
+ #seee.indent!
22
+ see ("\n" * 5) if @@initialized_count > 1
23
+
24
+ if announce_first.kind_of?(String)
25
+ see announce_first
26
+ see '='*announce_first.size
27
+ else
28
+ see "Perception Demo ##{@@initialized_count}"
29
+ see "=================="
30
+ end
31
+ see
32
+ #wait_for_key('Press any key to start')
33
+
34
+
35
+ end # def
36
+
37
+
38
+
39
+ # Printing basic types
40
+ def demo_see_basic_types
41
+ see '1dim Arrays:'
42
+ seee.indent!
43
+ see
44
+ see
45
+ see 'Other Objects:'
46
+ see []
47
+ see 'ordinary string (without "")'
48
+ see '(next one is empty)'
49
+ see ''
50
+ see 1
51
+ see 2
52
+ see 3.0
53
+ see nil
54
+ see true
55
+ see false
56
+ see :a_symbol
57
+
58
+ see ['complex array', [1,2,3], {:key => :value, :love => :baby}, 3.0 , '']
59
+ end # def
60
+
61
+
62
+ def demo_see_pp_object
63
+ seee.logger
64
+ see seee
65
+ end
66
+
67
+
68
+ def demo_see_pp_array
69
+ @array1 = []
70
+ @array1 << ['this','is','an','array','1']
71
+ @array1 << ['this','is','another','array','2']
72
+ @array1 << ['and','this','is','another', :tree]
73
+ @array1 << ['no',{:key => :value},'just','another', 'array']
74
+ see @array1
75
+ see
76
+ see
77
+ @text1 = 'long_longlong_long_long'
78
+ @text2 = 'also_long, also_long, also_long_also'
79
+ @text3 = 'hallo'
80
+ @array2 = []
81
+ @array2 << %W{one a b c}
82
+ @array2 << ['two', @text1, @text2, @text3]
83
+ @array2 << ['three', @text2, @text2, @text1]
84
+ see @array2
85
+ end
86
+
87
+
88
+ def demo_see_pp_hash
89
+ see({:this => :hash, :in => :one, :see => 'short hash in one line'})
90
+ see
91
+ see
92
+ see({:this => :hash, :size => '> 3', :see => 'longer hash in multiple lines', :another_key => 'another value'})
93
+ see
94
+ see
95
+ @hash = { :hash => true,
96
+ :init => true,
97
+ :nil => nil,
98
+ :symbol => :symbol,
99
+ :text => 'text',
100
+ :array => [1,2,3],
101
+ :integer => 1,
102
+ :string => 'hallo',
103
+ :nochn_hash => {:key => :value, :bla => :blubb, :array => [:a,:b,:c], :another_key => 'another value'}
104
+ }
105
+ see @hash
106
+ end
107
+
108
+
109
+ def demo_see_pp_dictionary
110
+ require 'facets/dictionary'
111
+
112
+ @dictionary = Dictionary.new
113
+ @dictionary[:a_dictionary] = true
114
+ @dictionary[:b_init] = true
115
+ @dictionary[:c_symbol] = :symbol
116
+ @dictionary[:d_array] = [1,2,3]
117
+ @dictionary[:e_integer] = 1
118
+ @dictionary[:f_string] = 'hallo'
119
+ @subdictionary = Dictionary.new
120
+ @subdictionary[:a] = :value
121
+ @subdictionary[:b] = 'blubb'
122
+ @subdictionary[:c] = 2
123
+ @subdictionary[:d] = [:a,:b,:c]
124
+ @subdictionary[:e] = { :key => :value}
125
+ @subdictionary[:f] = 'hallo'
126
+ @dictionary[:g_subdictionary] = @subdictionary
127
+ see @dictionary
128
+ end
129
+
130
+
131
+ def self.see_all_demos
132
+ Perception::DemoSee.new('PrettyPrint Array').demo_see_pp_array
133
+ Perception::DemoSee.new('PrettyPrint Object').demo_see_pp_object
134
+ Perception::DemoSee.new('PrettyPrint Hash').demo_see_pp_hash
135
+ #Perception::DemoSee.new('PrettyPrint Dictionary').demo_see_pp_dictionary
136
+
137
+
138
+ #Perception::DemoSee.new('PrettyPrint div').demo_see_basic_types
139
+
140
+ end
141
+
142
+
143
+
144
+ end # class
145
+ end # class
146
+
147
+
148
+ if $0 == __FILE__ then
149
+
150
+ Perception::DemoSee.see_all_demos
151
+
152
+
153
+ end
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+