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 +2 -8
- data/README.md +10 -7
- data/lib/tapp.rb +7 -3
- data/lib/tapp/object_extension.rb +2 -8
- data/lib/tapp/printer.rb +8 -13
- data/lib/tapp/printer/pretty_print.rb +13 -2
- data/lib/tapp/printer/puts.rb +2 -0
- data/lib/tapp/turnip.rb +34 -0
- data/lib/tapp/util.rb +3 -1
- data/lib/tapp/version.rb +1 -1
- data/spec/acceptance/custom_printer.feature +24 -0
- data/spec/acceptance/default_printer.feature +3 -3
- data/spec/acceptance/taputs.feature +0 -16
- data/spec/spec_helper.rb +3 -2
- data/tapp.gemspec +0 -1
- metadata +24 -33
- checksums.yaml +0 -7
- data/lib/tapp/printer/awesome_print.rb +0 -10
- data/spec/steps/global_steps.rb +0 -28
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# tapp
|
1
|
+
# tapp 
|
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
|
-
|
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
|
15
|
-
config
|
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
|
15
|
-
tapp :puts
|
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
|
-
|
6
|
-
autoload :PrettyPrint, 'tapp/printer/pretty_print'
|
7
|
-
autoload :Puts, 'tapp/printer/puts'
|
5
|
+
@printers = {}
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
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
|
data/lib/tapp/printer/puts.rb
CHANGED
data/lib/tapp/turnip.rb
ADDED
@@ -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
data/lib/tapp/version.rb
CHANGED
@@ -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 :
|
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 = :
|
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
|
-
|
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
data/tapp.gemspec
CHANGED
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
|
+
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:
|
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
|
-
-
|
64
|
-
-
|
65
|
-
-
|
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:
|
98
|
+
version: 1.3.1
|
107
99
|
requirements: []
|
108
100
|
rubyforge_project:
|
109
|
-
rubygems_version:
|
101
|
+
rubygems_version: 1.8.23
|
110
102
|
signing_key:
|
111
|
-
specification_version:
|
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
|
data/spec/steps/global_steps.rb
DELETED
@@ -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
|