qtapp 1.4.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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eb49f3f791e401242a20209c648607c9d6e2e989
4
+ data.tar.gz: 3c639259ca1bcd71ba4a889552ef1d8cd98c2246
5
+ SHA512:
6
+ metadata.gz: e70586f7d074bcd5d413bbc0e42cc12a4860c2cc60229c4a59e3788f938b52aa58a0f270a54b11b9b224c0376f0ae45f7737166bb89f14f2863d6309957b77d6
7
+ data.tar.gz: 43a21669ba13817e5405ac4748b82e30680ff77da7f6065ec0af366671c4299bd4f8d3d21ac7fc4b3dab32fbfc44e26a160fb3b9d585df4c8acad0a1ed8dab5a
@@ -0,0 +1,22 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
22
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ -r turnip/rspec
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1
7
+ - 2.2
8
+ - ruby-head
9
+
10
+ matrix:
11
+ allow_failures:
12
+ rvm: ruby-head
13
+
14
+ script: bundle exec rspec
@@ -0,0 +1,29 @@
1
+ # ChangeLog
2
+
3
+ ## 1.4.0 (2012-07-08)
4
+
5
+ Some API changes for future enhancements.
6
+
7
+ * Added `Tapp.config` and `Tapp.configure`. See README.md for details.
8
+ * `Tapp.verbose` moved to `Tapp.config.report_caller`.
9
+ * `Object#taap` is deprecated. Set `Tapp.config.default_printer = :awesome_print` and use `#tapp` instead.
10
+
11
+ ## 1.3.1 (2012-03-13)
12
+
13
+ * `tapp grep` finds "taputs" and "taap". (@kei-s)
14
+
15
+ ## 1.3.0 (2011-11-01)
16
+
17
+ * Add `tapp` command-line tool. (@ursm)
18
+
19
+ ## 1.2.0 (2011-10-27)
20
+
21
+ * Add `Tapp.verbose` option. (@moro)
22
+
23
+ ## 1.1.0 (2011-07-06)
24
+
25
+ * `Object#taap` support `awesome_print`. (Thanks @ryopeko!)
26
+
27
+ ## 1.0.0 (2010-07-07)
28
+
29
+ initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in qtapp.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,30 @@
1
+ qtapp
2
+
3
+ Copyright (c) 2015 Hirofumi Wakasugi
4
+
5
+ ---------------------------------------------------------------------
6
+
7
+ tapp
8
+
9
+ Copyright (c) 2010-2012 Keita Urashima
10
+
11
+ ---------------------------------------------------------------------
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining
14
+ a copy of this software and associated documentation files (the
15
+ "Software"), to deal in the Software without restriction, including
16
+ without limitation the rights to use, copy, modify, merge, publish,
17
+ distribute, sublicense, and/or sell copies of the Software, and to
18
+ permit persons to whom the Software is furnished to do so, subject to
19
+ the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be
22
+ included in all copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,46 @@
1
+ # qtapp [![Build Status](https://travis-ci.org/5t111111/qtapp.svg)](https://travis-ci.org/5t111111/qtapp) [![Code Climate](https://codeclimate.com/github/5t111111/qtapp/badges/gpa.svg)](https://codeclimate.com/github/5t111111/qtapp)
2
+
3
+ qtapp adds `Object#qtapp` for outputting debug logs with ease, forked from [tapp](https://github.com/esminc/tapp).
4
+ The difference between the original `tapp` and `qtapp` is only one thing, `qtapp` decorates logs with CRAZY HANKAKU KANAs.
5
+
6
+ ## Install
7
+
8
+ ```
9
+ $ gem install qtapp
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ``` ruby
15
+ require 'qtapp'
16
+
17
+ 'foo'.qtapp
18
+ 'foo'.taputs
19
+ ```
20
+
21
+ ## Configuration
22
+
23
+ ``` ruby
24
+ Qtapp.configure do |config|
25
+ config.default_printer = :awesome_print
26
+ config.report_caller = true
27
+ end
28
+ ```
29
+
30
+ ## Note on Patches/Pull Requests
31
+
32
+ * Fork the project.
33
+ * Make your feature addition or bug fix.
34
+ * Add tests for it. This is important so I don't break it in a
35
+ future version unintentionally.
36
+ * Commit, do not mess with rakefile, version, or history.
37
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
38
+ * Send me a pull request. Bonus points for topic branches.
39
+
40
+ ## Copyright
41
+
42
+ Copyright © 2015 Hirofumi Wakasugi. See LICENSE for details.
43
+
44
+ ### tapp
45
+
46
+ Copyright © 2010-2012 Keita Urashima.
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'qtapp/command'
4
+
5
+ Qtapp::Command.start
@@ -0,0 +1,20 @@
1
+ require 'qtapp/configuration'
2
+ require 'qtapp/deprecated'
3
+ require 'qtapp/object_extension'
4
+ require 'qtapp/printer'
5
+
6
+ module Qtapp
7
+ extend Deprecated
8
+
9
+ class << self
10
+ def config
11
+ @config ||= Qtapp::Configuration.new
12
+ end
13
+
14
+ def configure(&block)
15
+ config.tap(&block)
16
+ end
17
+ end
18
+ end
19
+
20
+ Object.__send__ :include, Qtapp::ObjectExtension
@@ -0,0 +1,12 @@
1
+ require 'thor'
2
+
3
+ module Qtapp
4
+ class Command < Thor
5
+ desc 'grep [<git-grep-options>]', 'Print lines using qtapp'
6
+ def grep(*)
7
+ opts = ['--word-regexp', '-e', 'qtapp', '-e', 'qtaputs', '-e', 'qtaap', *ARGV.drop(1)]
8
+ git_grep = ['git', 'grep', opts].flatten.join(' ')
9
+ puts `#{git_grep}`.gsub(/^Gemfile(\.lock)?:.+?\n/, '')
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ module Qtapp
2
+ class Configuration
3
+ attr_accessor :default_printer, :report_caller
4
+
5
+ def initialize
6
+ reset
7
+ end
8
+
9
+ def reset
10
+ self.default_printer = :pretty_print
11
+ self.report_caller = false
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,33 @@
1
+ require 'highline'
2
+
3
+ module Qtapp
4
+ module Crazy
5
+ @colors = %i{red green yellow blue magenta cyan white}
6
+ @crazy_samples = [
7
+ "アララララーイ",
8
+ "アーラララララァ",
9
+ "ムニョ",
10
+ "ズキューン",
11
+ "ブロロロロ",
12
+ "トルチョック",
13
+ "バキューン",
14
+ "ビヨンセ",
15
+ "ビヨーク",
16
+ "トムヨーク",
17
+ "ゾワゾワゾワ",
18
+ "キキーッ",
19
+ "ヌッヘッホー",
20
+ "ミョルニル",
21
+ "ドーンハンマー"
22
+ ]
23
+
24
+ @high_line = HighLine.new
25
+
26
+ module_function
27
+
28
+ def crazy_line
29
+ 20.times { print @high_line.color(@crazy_samples.sample, @colors.sample) }
30
+ print "\n"
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,15 @@
1
+ module Qtapp
2
+ module Deprecated
3
+ def verbose=(bool)
4
+ warn 'DEPRECATION WARNING: Qtapp.verbose= is deprecated. Use Qtapp.config.report_caller= instead.'
5
+
6
+ config.report_caller = bool
7
+ end
8
+
9
+ def verbose
10
+ warn 'DEPRECATION WARNING: Qtapp.verbose is deprecated. Use Qtapp.config.report_caller instead.'
11
+
12
+ config.report_caller
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,24 @@
1
+ require 'qtapp/printer'
2
+ require 'qtapp/util'
3
+
4
+ module Qtapp
5
+ module ObjectExtension
6
+ def qtapp(printer = Qtapp.config.default_printer)
7
+ Qtapp::Util.report_called if Qtapp.config.report_caller
8
+
9
+ tap {
10
+ Qtapp::Printer.instance(printer).print block_given? ? yield(self) : self
11
+ }
12
+ end
13
+
14
+ def taputs(&block)
15
+ qtapp :puts, &block
16
+ end
17
+
18
+ def taap
19
+ warn 'DEPRECATION WARNING: `taap` is deprecated. Set `Qtapp.config.default_printer = :awesome_print` and use `qtapp` instead.'
20
+
21
+ qtapp :awesome_print
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+ require 'singleton'
2
+ require 'qtapp/crazy'
3
+
4
+ module Qtapp
5
+ module Printer
6
+ autoload :AwesomePrint, 'qtapp/printer/awesome_print'
7
+ autoload :PrettyPrint, 'qtapp/printer/pretty_print'
8
+ autoload :Puts, 'qtapp/printer/puts'
9
+
10
+ def self.instance(name)
11
+ case name
12
+ when :pretty_print
13
+ PrettyPrint.instance
14
+ when :puts
15
+ Puts.instance
16
+ when :awesome_print
17
+ AwesomePrint.instance
18
+ else
19
+ raise ArgumentError, "Unknown printer: #{name.inspect}"
20
+ end
21
+ end
22
+
23
+ class Base
24
+ include Singleton
25
+
26
+ def print(*args)
27
+ raise NotImplementedError
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,12 @@
1
+ require 'qtapp/printer'
2
+ require 'ap'
3
+
4
+ module Qtapp::Printer
5
+ class AwesomePrint < Base
6
+ def print(*args)
7
+ Qtapp::Crazy.crazy_line
8
+ ap *args
9
+ Qtapp::Crazy.crazy_line
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'qtapp/printer'
2
+ require 'pp'
3
+
4
+ module Qtapp::Printer
5
+ class PrettyPrint < Base
6
+ def print(*args)
7
+ Qtapp::Crazy.crazy_line
8
+ pp *args
9
+ Qtapp::Crazy.crazy_line
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ require 'qtapp/printer'
2
+
3
+ module Qtapp::Printer
4
+ class Puts < Base
5
+ def print(*args)
6
+ Qtapp::Crazy.crazy_line
7
+ puts *args
8
+ Qtapp::Crazy.crazy_line
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ module Qtapp
2
+ module Util
3
+ module_function
4
+
5
+ def report_called
6
+ inner, outer = caller.partition {|line|
7
+ line.include?('/lib/qtapp')
8
+ }
9
+
10
+ method_quoted = inner.last.split(':in').last.strip
11
+
12
+ puts "#{method_quoted} in #{outer.first}"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Qtapp
2
+ VERSION = '1.4.1'
3
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "qtapp/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "qtapp"
7
+ s.version = Qtapp::VERSION
8
+ s.authors = ["Hirofumi Wakasugi"]
9
+ s.email = ["baenej@gmail.com"]
10
+ s.homepage = "http://github.com/5t111111/qtapp"
11
+ s.summary = %q{tap { pp self } decorated with CRAZY HANKAKU KANAs around }
12
+ s.description = %q{tap { pp self } decorated with CRAZY HANKAKU KANAs around }
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_runtime_dependency 'thor'
20
+ s.add_runtime_dependency 'highline'
21
+
22
+ s.add_development_dependency 'turnip'
23
+ s.add_development_dependency 'awesome_print'
24
+
25
+ s.add_development_dependency 'rake'
26
+ end
@@ -0,0 +1,14 @@
1
+ Feature: config.default_printer
2
+ Scenario: set config.default_printer to :awesome_print and call qtapp
3
+ Given I have the following code:
4
+ """
5
+ Qtapp.config.default_printer = :awesome_print
6
+
7
+ 'hoge'.qtapp
8
+ """
9
+
10
+ When Ruby it
11
+ Then I should see:
12
+ """
13
+ "hoge"
14
+ """
@@ -0,0 +1,13 @@
1
+ Feature: Object#qtapp
2
+ Scenario: Call qtapp within methods chain
3
+ Given I have the following code:
4
+ """
5
+ (1..5).qtapp.select(&:odd?).qtapp.inject(&:+)
6
+ """
7
+
8
+ When Ruby it
9
+ Then I should see:
10
+ """
11
+ 1..5
12
+ [1, 3, 5]
13
+ """
@@ -0,0 +1,32 @@
1
+ Feature: Object#taputs
2
+ Scenario: Call taputs within methods chain
3
+ Given I have the following code:
4
+ """
5
+ (1..5).taputs.select(&:odd?).taputs.inject(&:+)
6
+ """
7
+
8
+ When Ruby it
9
+
10
+ Then I should see:
11
+ """
12
+ 1..5
13
+ 1
14
+ 3
15
+ 5
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
+ """
@@ -0,0 +1,21 @@
1
+ Feature: config.report_caller
2
+ Scenario: set config.report_caller to true and call qtapp
3
+ Given a file named "hello.rb" with:
4
+ """
5
+ Qtapp.config.report_caller = true
6
+
7
+ class Hello
8
+ def say
9
+ 'hello'.qtapp
10
+ end
11
+ end
12
+
13
+ Hello.new.say
14
+ """
15
+
16
+ When Ruby it
17
+ Then I should see:
18
+ """
19
+ `qtapp' in hello.rb:5:in `say'
20
+ "hello"
21
+ """
@@ -0,0 +1,9 @@
1
+ require 'qtapp'
2
+
3
+ Dir[File.expand_path('../steps/**/*.rb', __FILE__)].each {|f| require f }
4
+
5
+ RSpec.configure do |config|
6
+ config.before do
7
+ Qtapp.config.reset
8
+ end
9
+ end
@@ -0,0 +1,28 @@
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
+ expect(@output).to eq output
28
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qtapp
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.4.1
5
+ platform: ruby
6
+ authors:
7
+ - Hirofumi Wakasugi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: highline
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: turnip
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
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: awesome_print
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: 'tap { pp self } decorated with CRAZY HANKAKU KANAs around '
84
+ email:
85
+ - baenej@gmail.com
86
+ executables:
87
+ - qtapp
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - CHANGELOG.md
95
+ - Gemfile
96
+ - LICENSE
97
+ - README.md
98
+ - Rakefile
99
+ - bin/qtapp
100
+ - lib/qtapp.rb
101
+ - lib/qtapp/command.rb
102
+ - lib/qtapp/configuration.rb
103
+ - lib/qtapp/crazy.rb
104
+ - lib/qtapp/deprecated.rb
105
+ - lib/qtapp/object_extension.rb
106
+ - lib/qtapp/printer.rb
107
+ - lib/qtapp/printer/awesome_print.rb
108
+ - lib/qtapp/printer/pretty_print.rb
109
+ - lib/qtapp/printer/puts.rb
110
+ - lib/qtapp/util.rb
111
+ - lib/qtapp/version.rb
112
+ - qtapp.gemspec
113
+ - spec/acceptance/default_printer.feature
114
+ - spec/acceptance/qtapp.feature
115
+ - spec/acceptance/qtaputs.feature
116
+ - spec/acceptance/report_caller.feature
117
+ - spec/spec_helper.rb
118
+ - spec/steps/global_steps.rb
119
+ homepage: http://github.com/5t111111/qtapp
120
+ licenses: []
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.4.5
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: tap { pp self } decorated with CRAZY HANKAKU KANAs around
142
+ test_files:
143
+ - spec/acceptance/default_printer.feature
144
+ - spec/acceptance/qtapp.feature
145
+ - spec/acceptance/qtaputs.feature
146
+ - spec/acceptance/report_caller.feature
147
+ - spec/spec_helper.rb
148
+ - spec/steps/global_steps.rb