pd 1.0.1

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,2 @@
1
+ *~
2
+ /.yardoc
@@ -0,0 +1,5 @@
1
+ --markup markdown
2
+
3
+ -
4
+ docs/**/*.md
5
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Guten
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 NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ pd, a print helper method for debug to Kernel
2
+ ==========================================
3
+
4
+ **Homepage**: [https://github.com/GutenLinux/pd](https://github.com/GutenLinux/pd) <br/>
5
+ **Author**: Guten <br/>
6
+ **License**: MIT License <br/>
7
+ **Documentation**: [http://rubydoc.info/gems/pd/frames](http://rubydoc.info/gems/pd/frames) <br/>
8
+ **Issue Tracker**: [https://github.com/GutenLinux/pd/issues](https://github.com/GutenLinux/pd/issues) <br/>
9
+
10
+ Overview
11
+ --------
12
+ pd(print debug), for debug only, like p, but use " " between each argument as separator instead of "\n".
13
+
14
+ * search 'pd' is much easier than 'p' in source file.
15
+ * sometimes use pd is much convient than p
16
+
17
+ For example:
18
+
19
+ a="foo"
20
+ p a, a.length
21
+ "foo"
22
+ 3
23
+ pd a, a.length
24
+ "foo" 3
25
+
26
+ Usage
27
+ -----
28
+
29
+ add RUBYOPT="-r pd" as environment variable.
30
+ pd "a","b"
31
+
32
+ Install
33
+ ----------
34
+
35
+ gem install pd
36
+
37
+ Copyright
38
+ ---------
39
+ Copyright &copy; 2011 by Guten. this library released under MIT-License, See {file:LICENSE} for futher details.
@@ -0,0 +1,16 @@
1
+ desc "release to rubygems"
2
+ task :release do
3
+ sh "gem build pd.gemspec"
4
+ sh "gem push pd-*.gem"
5
+ sh "rm pd-*.gem"
6
+ end
7
+
8
+ desc "testing the library"
9
+ task :test do
10
+ sh "rspec --color spec"
11
+ end
12
+
13
+ def sh cmd
14
+ puts cmd
15
+ system cmd
16
+ end
@@ -0,0 +1,30 @@
1
+ module Kernel
2
+ # *for debug* pd(print debug), like p, but use " " in each argument instead of "\n".
3
+ # * search 'pd' is much easier than 'p' in source file.
4
+ # * sometimes use pd is much convient than p
5
+ #
6
+ # @example
7
+ # a="foo"
8
+ # p a, a.length
9
+ # =>
10
+ # "foo"
11
+ # 3
12
+ # pd a, a.length
13
+ # =>
14
+ # "foo" 3
15
+ #
16
+ # @param [Object] *args
17
+ # @return nil
18
+ def pd *args
19
+ args.each do |arg| print arg.inspect," " end
20
+ print "\n"
21
+ end
22
+
23
+ # *for debug* print hr. puts '='*14 + " #{name}"
24
+ #
25
+ # sometime, we just need a horizonal line to separate message for debug.
26
+ # @param [String] name
27
+ def phr name=nil
28
+ puts '='*14 + " #{name}"
29
+ end
30
+ end
@@ -0,0 +1,18 @@
1
+ $: << "."
2
+ require "version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "pd"
6
+ s.version = VERSION::IS
7
+ s.summary = "a print helper method for debug to Kernel"
8
+ s.description = <<-EOF
9
+ a print helper method for debug to Kernel
10
+ EOF
11
+
12
+ s.author = "Guten"
13
+ s.email = "ywzhaifei@gmail.com"
14
+ s.homepage = "http://github.com/GutenLinux/pd"
15
+ s.rubyforge_project = "xx"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ end
@@ -0,0 +1,22 @@
1
+ # lib/**/*.rb
2
+ watch %r~lib/(.*)\.rb~ do |m|
3
+ test "spec/#{m[1]}_spec.rb"
4
+ end
5
+
6
+ # spec/**/*_spec.rb
7
+ watch %r~spec/.*_spec\.rb~ do |m|
8
+ test m[0]
9
+ end
10
+
11
+ # Ctrl-\
12
+ Signal.trap('QUIT') do
13
+ puts "--- Running all tests ---\n\n"
14
+ test "spec"
15
+ end
16
+
17
+ def test path
18
+ cmd = "rspec --color #{path}"
19
+ puts cmd
20
+ system cmd
21
+ end
22
+
@@ -0,0 +1,23 @@
1
+ require "spec_helper"
2
+ require "pd"
3
+
4
+ describe Kernel do
5
+ describe "#pd" do
6
+ it "prints message to stdout" do
7
+ message = capture :stdout do
8
+ pd "foo", "bar"
9
+ end
10
+ message.should =~ /"foo" "bar"/
11
+ end
12
+ end
13
+
14
+ describe "#phr" do
15
+ it "print a horizonal line" do
16
+ message = capture :stdout do
17
+ phr "foo"
18
+ end
19
+ message.should =~ /======.*foo/
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,22 @@
1
+ require "stringio"
2
+
3
+ RSpec.configure do |config|
4
+
5
+ # a helper to capture stream
6
+ #
7
+ # @example
8
+ # capture(:stdout){..}
9
+ # @param [Symbol] stream
10
+ # @return [String] print result in block
11
+ def capture stream
12
+ begin
13
+ eval "$#{stream} = StringIO.new"
14
+ yield
15
+ result = eval("$#{stream}").string
16
+ ensure
17
+ eval("$#{stream} = #{stream.upcase}")
18
+ end
19
+
20
+ result
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ module VERSION
2
+ MAJOR = 1
3
+ MINOR = 0
4
+ PATCH = 1
5
+
6
+ IS = [MAJOR, MINOR, PATCH].join(".")
7
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pd
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Guten
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-06 00:00:00 +08:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: |
18
+ a print helper method for debug to Kernel
19
+
20
+ email: ywzhaifei@gmail.com
21
+ executables: []
22
+
23
+ extensions: []
24
+
25
+ extra_rdoc_files: []
26
+
27
+ files:
28
+ - .gitignore
29
+ - .yardopts
30
+ - LICENSE
31
+ - README.md
32
+ - Rakefile
33
+ - lib/pd.rb
34
+ - pd.gemspec
35
+ - pd.watchr
36
+ - spec/pd_spec.rb
37
+ - spec/spec_helper.rb
38
+ - version.rb
39
+ has_rdoc: true
40
+ homepage: http://github.com/GutenLinux/pd
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ requirements: []
61
+
62
+ rubyforge_project: xx
63
+ rubygems_version: 1.6.1
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: a print helper method for debug to Kernel
67
+ test_files: []
68
+