pd 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
- *~
2
- /.yardoc
1
+ /rfrom/
2
+ /*.gem
3
+ /Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source :rubygems
2
+
3
+ gem "awesome_print"
4
+
5
+ group :development do
6
+ gem "rspec"
7
+ end
data/README.md CHANGED
@@ -1,47 +1,18 @@
1
- pd, a print helper method for debug to Kernel
1
+ pd, some helper methods to help debuging
2
2
  ==========================================
3
3
 
4
- **Homepage**: [https://github.com/GutenYe/pd](https://github.com/GutenYe/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/GutenYe/pd/issues](https://github.com/GutenYe/pd/issues) <br/>
4
+ | Homepage: | https://github.com/GutenYe/pd |
5
+ |----------------|------------------------------------------------------ |
6
+ | Author: | Guten |
7
+ | License: | MIT-LICENSE |
8
+ | Documentation: | http://rubydoc.info/gems/pd/frames |
9
+ | Issue Tracker: | https://github.com/GutenYe/pd/issues |
9
10
 
10
11
  Overview
11
12
  --------
12
- sometimes, I need debug other people's code, and I'd like to use `pd`, so add this lib to environment variable `RUBYOPT="-r pd"` make this happen.
13
13
 
14
- pd(print debug), for debug only, like p, but use ", " between each argument as separator instead of "\n".
15
-
16
- * search 'pd' is much easier than 'p' in source file.
17
- * sometimes use pd is much convient than p
18
-
19
- For example:
20
-
21
- pd :Person, name, age
22
- #=>
23
- Person: "Alice", 12
24
-
25
- p name, age
26
- #=>
27
- "Alice"
28
- 12
29
-
30
- Usage
31
- -----
32
-
33
- add RUBYOPT as Environment Variable
34
- RUBYOPT="-r pd" # for ruby1.9
35
- RUBYOPT="-r/absolute/path/to/pd" # for ruby1.8
36
- pd "a","b"
37
-
38
- Contributing
39
- -------------
40
-
41
- * report bugs/featues to issue tracker.
42
- * fork it and pull a request.
43
- * improve documentation.
44
- * feel free to post any ideas.
14
+ 1. add 'pd' method to Kernel, 'pd' is much easy to search than orignal 'p' method.
15
+ 2. include 'awesome_print' gem
45
16
 
46
17
  Install
47
18
  ----------
@@ -50,4 +21,13 @@ Install
50
21
 
51
22
  Copyright
52
23
  ---------
53
- Copyright &copy; 2011 by Guten. this library released under MIT-License, See {file:LICENSE} for futher details.
24
+
25
+ (the MIT License)
26
+
27
+ Copyright (c) 2011 Guten
28
+
29
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
30
+
31
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
32
+
33
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -1,24 +1,43 @@
1
- desc "release to rubygems"
1
+ sudo = Process.pid==0 ? "" : "sudo"
2
+
3
+ desc "build a gem file"
2
4
  task :release do
3
- sh "gem build pd.gemspec"
4
- sh "gem push pd-*.gem"
5
- sh "rm pd-*.gem"
5
+ run "gem build pd.gemspec"
6
+ run "gem push *.gem"
7
+ run "#{sudo} gem install *.gem"
8
+ run "rm *.gem"
6
9
  end
7
10
 
8
- desc "install to local"
11
+ desc "install a gem file"
9
12
  task :install do
10
- sh "gem build pd.gemspec"
11
- sh "gem install pd-*.gem"
12
- sh "rm pd-*.gem"
13
+ run "gem build pd.gemspec"
14
+ run "#{sudo} gem install *.gem"
15
+ run "rm *.gem"
13
16
  end
14
17
 
15
-
16
- desc "testing the library"
18
+ desc "autotest with watchr"
17
19
  task :test do
18
- sh "rspec --color spec"
20
+ run "watchr pd.watchr"
21
+ end
22
+
23
+ desc "testing the libraray"
24
+ namespace :test do
25
+ task :all do
26
+ run "rspec spec"
27
+ end
28
+ end
29
+
30
+ desc "run yard server --reload"
31
+ task :doc do
32
+ run "yard server --reload"
33
+ end
34
+
35
+ desc "clean up"
36
+ task :clean do
37
+ run "rm *.gem"
19
38
  end
20
39
 
21
- def sh cmd
40
+ def run cmd
22
41
  puts cmd
23
42
  system cmd
24
43
  end
data/lib/pd.rb CHANGED
@@ -1,3 +1,5 @@
1
+ autoload :Pd_VERSION, "pd/version"
2
+
1
3
  module Kernel
2
4
  # print for debug
3
5
  #
@@ -8,15 +10,18 @@ module Kernel
8
10
  # @overload pd(title, obj, ...)
9
11
  # @param [Symbol] title if first arg is a Captial Symbol, use it as title
10
12
  # @return [nil]
11
- def pd *args
12
- puts args.map{|v|v.inspect}.join(", ")
13
+ def pd(*args)
14
+ puts args.map{|v|v.inspect}.join(" ")
13
15
  end
14
16
 
15
- # *for debug* print hr. puts '='*14 + " #{name}"
17
+ # print hr. puts '='*14 + " #{name}"
16
18
  #
17
19
  # sometime, we just need a horizonal line to separate message for debug.
18
20
  # @param [String] name
19
- def phr name=nil
20
- puts '='*14 + " #{name}"
21
+ def phr(name=nil)
22
+ puts "="*14 + " #{name}"
21
23
  end
22
24
  end
25
+
26
+ require "ap"
27
+
@@ -0,0 +1 @@
1
+ Pd_VERSION = "1.0.5"
data/pd.gemspec CHANGED
@@ -1,10 +1,9 @@
1
- $: << "."
2
- require "version"
1
+ Kernel.load File.expand_path("../lib/pd/version.rb", __FILE__)
3
2
 
4
3
  Gem::Specification.new do |s|
5
4
  s.name = "pd"
6
- s.version = VERSION::IS
7
- s.summary = "a print helper method for debug to Kernel"
5
+ s.version = Pd_VERSION
6
+ s.summary = "some helper methods to help debuging"
8
7
  s.description = <<-EOF
9
8
  a print helper method for debug to Kernel
10
9
  EOF
@@ -15,4 +14,6 @@ a print helper method for debug to Kernel
15
14
  s.rubyforge_project = "xx"
16
15
 
17
16
  s.files = `git ls-files`.split("\n")
17
+
18
+ s.add_dependency "awesome_print"
18
19
  end
data/pd.watchr CHANGED
@@ -14,8 +14,8 @@ Signal.trap('QUIT') do
14
14
  test "spec"
15
15
  end
16
16
 
17
- def test path
18
- cmd = "rspec --color #{path}"
17
+ def test(path)
18
+ cmd = "rspec #{path}"
19
19
  puts cmd
20
20
  system cmd
21
21
  end
@@ -1,5 +1,4 @@
1
1
  require "spec_helper"
2
- require "pd"
3
2
 
4
3
  describe Kernel do
5
4
  describe "#pd" do
@@ -7,7 +6,7 @@ describe Kernel do
7
6
  message = capture :stdout do
8
7
  pd "foo", "bar"
9
8
  end
10
- message.should =~ /"foo" "bar"/
9
+ message.should == %~"foo" "bar"\n~
11
10
  end
12
11
  end
13
12
 
@@ -19,5 +18,4 @@ describe Kernel do
19
18
  message.should =~ /======.*foo/
20
19
  end
21
20
  end
22
-
23
21
  end
@@ -1,15 +1,13 @@
1
1
  require "stringio"
2
+ require "pd"
2
3
 
3
- RSpec.configure do |config|
4
+ $spec_dir = File.expand_path("..", __FILE__)
5
+ $spec_data = File.expand_path("../data", __FILE__)
4
6
 
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
7
+ RSpec.configure do |config|
8
+ def capture(stream)
12
9
  begin
10
+ stream = stream.to_s
13
11
  eval "$#{stream} = StringIO.new"
14
12
  yield
15
13
  result = eval("$#{stream}").string
@@ -19,4 +17,29 @@ RSpec.configure do |config|
19
17
 
20
18
  result
21
19
  end
20
+
21
+ alias :silence :capture
22
22
  end
23
+
24
+ module Kernel
25
+ private
26
+
27
+ def xdescribe(*args, &blk)
28
+ describe *args do
29
+ pending "xxxxxxxxx"
30
+ end
31
+ end
32
+
33
+ def xcontext(*args, &blk)
34
+ context *args do
35
+ pending "xxxxxxxxx"
36
+ end
37
+ end
38
+
39
+ def xit(*args, &blk)
40
+ it *args do
41
+ pending "xxxxxxxx"
42
+ end
43
+ end
44
+ end
45
+
metadata CHANGED
@@ -1,66 +1,70 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pd
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.5
4
5
  prerelease:
5
- version: 1.0.3
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Guten
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
+ date: 2012-02-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: awesome_print
16
+ requirement: &11456500 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *11456500
25
+ description: ! 'a print helper method for debug to Kernel
12
26
 
13
- date: 2011-07-05 00:00:00 Z
14
- dependencies: []
15
-
16
- description: |
17
- a print helper method for debug to Kernel
18
-
27
+ '
19
28
  email: ywzhaifei@gmail.com
20
29
  executables: []
21
-
22
30
  extensions: []
23
-
24
31
  extra_rdoc_files: []
25
-
26
- files:
32
+ files:
27
33
  - .gitignore
34
+ - .rspec
28
35
  - .yardopts
29
- - LICENSE
36
+ - Gemfile
30
37
  - README.md
31
38
  - Rakefile
32
39
  - lib/pd.rb
40
+ - lib/pd/version.rb
33
41
  - pd.gemspec
34
42
  - pd.watchr
35
43
  - spec/pd_spec.rb
36
44
  - spec/spec_helper.rb
37
- - version.rb
38
45
  homepage: http://github.com/GutenYe/pd
39
46
  licenses: []
40
-
41
47
  post_install_message:
42
48
  rdoc_options: []
43
-
44
- require_paths:
49
+ require_paths:
45
50
  - lib
46
- required_ruby_version: !ruby/object:Gem::Requirement
51
+ required_ruby_version: !ruby/object:Gem::Requirement
47
52
  none: false
48
- requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- version: "0"
52
- required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
58
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: "0"
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
58
63
  requirements: []
59
-
60
64
  rubyforge_project: xx
61
- rubygems_version: 1.8.5
65
+ rubygems_version: 1.8.11
62
66
  signing_key:
63
67
  specification_version: 3
64
- summary: a print helper method for debug to Kernel
68
+ summary: some helper methods to help debuging
65
69
  test_files: []
66
-
70
+ has_rdoc:
data/LICENSE DELETED
@@ -1,20 +0,0 @@
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.
data/version.rb DELETED
@@ -1,7 +0,0 @@
1
- module VERSION
2
- MAJOR = 1
3
- MINOR = 0
4
- PATCH = 3
5
-
6
- IS = [MAJOR, MINOR, PATCH].join(".")
7
- end