tapp 1.4.1 → 1.5.0.rc

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.
data/.travis.yml CHANGED
@@ -1,13 +1,7 @@
1
1
  language: ruby
2
-
3
2
  rvm:
4
3
  - 1.9.3
5
- - 2.0.0
6
- - 2.1.0
7
4
  - ruby-head
8
-
9
- matrix:
10
- allow_failures:
11
- rvm: ruby-head
12
-
5
+ - rbx-18mode
6
+ - rbx-19mode
13
7
  script: bundle exec rspec
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # tapp [![Build Status](https://secure.travis-ci.org/esminc/tapp.png?branch=master)](http://travis-ci.org/#!/esminc/tapp) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/esminc/tapp)
1
+ # tapp ![Build Status](https://secure.travis-ci.org/esminc/tapp.png?branch=master)
2
2
 
3
3
  ## Install
4
4
 
@@ -21,8 +21,8 @@ See more examples in [spec/acceptance](https://github.com/esminc/tapp/tree/maste
21
21
 
22
22
  ``` ruby
23
23
  Tapp.configure do |config|
24
- config.default_printer = :awesome_print
25
24
  config.report_caller = true
25
+ config.default_printer = :puts
26
26
  end
27
27
  ```
28
28
 
@@ -32,18 +32,21 @@ end
32
32
  <th>Default</th>
33
33
  <th>Description</th>
34
34
  </tr>
35
- <tr>
36
- <td><code>default_printer</code></td>
37
- <td><code>:pretty_print</code></td>
38
- <td><a href="https://github.com/esminc/tapp/blob/master/spec/acceptance/default_printer.feature">default_printer.feature</a></td>
39
- </tr>
40
35
  <tr>
41
36
  <td><code>report_caller</code></td>
42
37
  <td><code>false</code></td>
43
38
  <td><a href="https://github.com/esminc/tapp/blob/master/spec/acceptance/report_caller.feature">report_caller.feature</a></td>
44
39
  </tr>
40
+ <tr>
41
+ <td><code>default_printer</code></td>
42
+ <td><code>:pretty_print</code></td>
43
+ <td><a href="https://github.com/esminc/tapp/blob/master/spec/acceptance/default_printer.feature">default_printer.feature</a></td>
44
+ </tr>
45
45
  </table>
46
46
 
47
+ ## Custom Printer
48
+ You can define a custom printer. See [custom_printer.feature](https://github.com/esminc/tapp/blob/master/spec/acceptance/custom_printer.feature).
49
+
47
50
  ## Note on Patches/Pull Requests
48
51
 
49
52
  * Fork the project.
data/lib/tapp.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  require 'tapp/configuration'
2
2
  require 'tapp/deprecated'
3
3
  require 'tapp/object_extension'
4
- require 'tapp/printer'
4
+
5
+ require 'tapp/printer/pretty_print'
6
+ require 'tapp/printer/puts'
5
7
 
6
8
  module Tapp
7
9
  extend Deprecated
@@ -11,8 +13,10 @@ module Tapp
11
13
  @config ||= Tapp::Configuration.new
12
14
  end
13
15
 
14
- def configure(&block)
15
- config.tap(&block)
16
+ def configure
17
+ yield config
18
+
19
+ config
16
20
  end
17
21
  end
18
22
  end
@@ -11,14 +11,8 @@ module Tapp
11
11
  }
12
12
  end
13
13
 
14
- def taputs(&block)
15
- tapp :puts, &block
16
- end
17
-
18
- def taap
19
- warn 'DEPRECATION WARNING: `taap` is deprecated. Set `Tapp.config.default_printer = :awesome_print` and use `tapp` instead.'
20
-
21
- tapp :awesome_print
14
+ def taputs
15
+ tapp :puts
22
16
  end
23
17
  end
24
18
  end
data/lib/tapp/printer.rb CHANGED
@@ -2,20 +2,15 @@ require 'singleton'
2
2
 
3
3
  module Tapp
4
4
  module Printer
5
- autoload :AwesomePrint, 'tapp/printer/awesome_print'
6
- autoload :PrettyPrint, 'tapp/printer/pretty_print'
7
- autoload :Puts, 'tapp/printer/puts'
5
+ @printers = {}
8
6
 
9
- def self.instance(name)
10
- case name
11
- when :pretty_print
12
- PrettyPrint.instance
13
- when :puts
14
- Puts.instance
15
- when :awesome_print
16
- AwesomePrint.instance
17
- else
18
- raise ArgumentError, "Unknown printer: #{name.inspect}"
7
+ class << self
8
+ def register(name, printer)
9
+ @printers[name] = printer
10
+ end
11
+
12
+ def instance(name)
13
+ @printers.fetch(name).instance
19
14
  end
20
15
  end
21
16
 
@@ -1,10 +1,21 @@
1
1
  require 'tapp/printer'
2
- require 'pp'
3
2
 
4
3
  module Tapp::Printer
5
4
  class PrettyPrint < Base
6
5
  def print(*args)
7
- pp *args
6
+ require 'pp'
7
+
8
+ self.class.class_eval do
9
+ remove_method :print
10
+
11
+ def print(*args)
12
+ pp *args
13
+ end
14
+ end
15
+
16
+ print *args
8
17
  end
9
18
  end
19
+
20
+ register :pretty_print, PrettyPrint
10
21
  end
@@ -6,4 +6,6 @@ module Tapp::Printer
6
6
  puts *args
7
7
  end
8
8
  end
9
+
10
+ register :puts, Puts
9
11
  end
@@ -0,0 +1,34 @@
1
+ module Tapp
2
+ module Turnip
3
+ module Steps
4
+ step 'I have the following code:' do |code|
5
+ @code = code
6
+ end
7
+
8
+ step 'a file named :filename with:' do |filename, code|
9
+ @filename, @code = filename, code
10
+ end
11
+
12
+ step 'Ruby it' do
13
+ stdout = StringIO.new
14
+ $stdout = stdout
15
+
16
+ begin
17
+ if @filename
18
+ eval @code, binding, @filename, 1
19
+ else
20
+ eval @code
21
+ end
22
+ ensure
23
+ $stdout = STDOUT
24
+ end
25
+
26
+ @output = stdout.string.gsub(/\e\[0.*?m/, '').chop
27
+ end
28
+
29
+ step 'I should see:' do |output|
30
+ @output.should == output
31
+ end
32
+ end
33
+ end
34
+ end
data/lib/tapp/util.rb CHANGED
@@ -1,10 +1,12 @@
1
+ require 'tapp'
2
+
1
3
  module Tapp
2
4
  module Util
3
5
  module_function
4
6
 
5
7
  def report_called
6
8
  inner, outer = caller.partition {|line|
7
- line.include?('/lib/tapp')
9
+ line =~ %r(/lib/tapp/(?!turnip))
8
10
  }
9
11
 
10
12
  method_quoted = inner.last.split(':in').last.strip
data/lib/tapp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tapp
2
- VERSION = '1.4.1'
2
+ VERSION = '1.5.0.rc'
3
3
  end
@@ -0,0 +1,24 @@
1
+ Feature: Custom printer
2
+ Scenario: define a custom printer and use it
3
+ Given I have the following code:
4
+ """
5
+ require 'tapp/printer'
6
+
7
+ module Tapp::Printer
8
+ class MyPrinter < Base
9
+ def print(*args)
10
+ puts "*** #{args.join(' ')} ***"
11
+ end
12
+ end
13
+
14
+ register :my_printer, MyPrinter
15
+ end
16
+
17
+ %w(foo bar).tapp(:my_printer)
18
+ """
19
+
20
+ When Ruby it
21
+ Then I should see:
22
+ """
23
+ *** foo bar ***
24
+ """
@@ -1,8 +1,8 @@
1
1
  Feature: config.default_printer
2
- Scenario: set config.default_printer to :awesome_print and call tapp
2
+ Scenario: set config.default_printer to :puts and call tapp
3
3
  Given I have the following code:
4
4
  """
5
- Tapp.config.default_printer = :awesome_print
5
+ Tapp.config.default_printer = :puts
6
6
 
7
7
  'hoge'.tapp
8
8
  """
@@ -10,5 +10,5 @@ Feature: config.default_printer
10
10
  When Ruby it
11
11
  Then I should see:
12
12
  """
13
- "hoge"
13
+ hoge
14
14
  """
@@ -14,19 +14,3 @@ Feature: Object#taputs
14
14
  3
15
15
  5
16
16
  """
17
-
18
- Scenario: Call taputs with block
19
- Given I have the following code:
20
- """
21
- (1..5).taputs(&:count).select(&:odd?).taputs
22
- """
23
-
24
- When Ruby it
25
-
26
- Then I should see:
27
- """
28
- 5
29
- 1
30
- 3
31
- 5
32
- """
data/spec/spec_helper.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'tapp'
2
-
3
- Dir[File.expand_path('../steps/**/*.rb', __FILE__)].each {|f| require f }
2
+ require 'tapp/turnip'
4
3
 
5
4
  RSpec.configure do |config|
5
+ config.include Tapp::Turnip::Steps
6
+
6
7
  config.before do
7
8
  Tapp.config.reset
8
9
  end
data/tapp.gemspec CHANGED
@@ -19,5 +19,4 @@ Gem::Specification.new do |s|
19
19
  s.add_runtime_dependency 'thor'
20
20
 
21
21
  s.add_development_dependency 'turnip'
22
- s.add_development_dependency 'awesome_print'
23
22
  end
metadata CHANGED
@@ -1,55 +1,46 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tapp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0.rc
5
+ prerelease: 6
5
6
  platform: ruby
6
7
  authors:
7
8
  - Keita Urashima
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-07-07 00:00:00.000000000 Z
12
+ date: 2012-07-08 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: thor
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - ">="
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0'
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - ">="
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0'
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: turnip
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - ">="
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: '0'
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: awesome_print
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
43
+ - - ! '>='
53
44
  - !ruby/object:Gem::Version
54
45
  version: '0'
55
46
  description: tap { pp self }
@@ -60,9 +51,9 @@ executables:
60
51
  extensions: []
61
52
  extra_rdoc_files: []
62
53
  files:
63
- - ".gitignore"
64
- - ".rspec"
65
- - ".travis.yml"
54
+ - .gitignore
55
+ - .rspec
56
+ - .travis.yml
66
57
  - CHANGELOG.md
67
58
  - Gemfile
68
59
  - LICENSE
@@ -75,46 +66,46 @@ files:
75
66
  - lib/tapp/deprecated.rb
76
67
  - lib/tapp/object_extension.rb
77
68
  - lib/tapp/printer.rb
78
- - lib/tapp/printer/awesome_print.rb
79
69
  - lib/tapp/printer/pretty_print.rb
80
70
  - lib/tapp/printer/puts.rb
71
+ - lib/tapp/turnip.rb
81
72
  - lib/tapp/util.rb
82
73
  - lib/tapp/version.rb
74
+ - spec/acceptance/custom_printer.feature
83
75
  - spec/acceptance/default_printer.feature
84
76
  - spec/acceptance/report_caller.feature
85
77
  - spec/acceptance/tapp.feature
86
78
  - spec/acceptance/taputs.feature
87
79
  - spec/spec_helper.rb
88
- - spec/steps/global_steps.rb
89
80
  - tapp.gemspec
90
81
  homepage: http://github.com/esminc/tapp
91
82
  licenses: []
92
- metadata: {}
93
83
  post_install_message:
94
84
  rdoc_options: []
95
85
  require_paths:
96
86
  - lib
97
87
  required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
98
89
  requirements:
99
- - - ">="
90
+ - - ! '>='
100
91
  - !ruby/object:Gem::Version
101
92
  version: '0'
102
93
  required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
103
95
  requirements:
104
- - - ">="
96
+ - - ! '>'
105
97
  - !ruby/object:Gem::Version
106
- version: '0'
98
+ version: 1.3.1
107
99
  requirements: []
108
100
  rubyforge_project:
109
- rubygems_version: 2.2.2
101
+ rubygems_version: 1.8.23
110
102
  signing_key:
111
- specification_version: 4
103
+ specification_version: 3
112
104
  summary: tap { pp self }
113
105
  test_files:
106
+ - spec/acceptance/custom_printer.feature
114
107
  - spec/acceptance/default_printer.feature
115
108
  - spec/acceptance/report_caller.feature
116
109
  - spec/acceptance/tapp.feature
117
110
  - spec/acceptance/taputs.feature
118
111
  - spec/spec_helper.rb
119
- - spec/steps/global_steps.rb
120
- has_rdoc:
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 38e02e650a387df7aa6a8428fa0f4acd62354045
4
- data.tar.gz: f12d94f1754403691baca4c058cb9730a0e40926
5
- SHA512:
6
- metadata.gz: 64308928255176b3ca811a4344ed9c4e4492198a4c655c3e97609e1272f7e345e0d449cfab482eafd29148896515938ebc0ebda843de3e30ff522d91d320eb09
7
- data.tar.gz: 8ba1f379c3316ac277b0c90fffa39eeba5faa3ac6ffa28232bf8f349bdc1ca27ae1905ace2cccefea4e3a9ff33b91bc5b689c9d040d0d2d2a157e1ab24b2265c
@@ -1,10 +0,0 @@
1
- require 'tapp/printer'
2
- require 'ap'
3
-
4
- module Tapp::Printer
5
- class AwesomePrint < Base
6
- def print(*args)
7
- ap *args
8
- end
9
- end
10
- end
@@ -1,28 +0,0 @@
1
- step 'I have the following code:' do |code|
2
- @code = code
3
- end
4
-
5
- step 'a file named :filename with:' do |filename, code|
6
- @filename, @code = filename, code
7
- end
8
-
9
- step 'Ruby it' do
10
- stdout = StringIO.new
11
- $stdout = stdout
12
-
13
- begin
14
- if @filename
15
- eval @code, binding, @filename, 1
16
- else
17
- eval @code
18
- end
19
- ensure
20
- $stdout = STDOUT
21
- end
22
-
23
- @output = stdout.string.gsub(/\e\[0.*?m/, '').chop
24
- end
25
-
26
- step 'I should see:' do |output|
27
- @output.should == output
28
- end