tanj 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 255ee8e98b1b37bbc2436d5c702c69e7d25e337128aa12b6a897e602e1e3b031
4
+ data.tar.gz: e0705fa204d03ae2a8e170a6b0f9496bfa52acc440f0ad7f4516ca7d4f053ccf
5
+ SHA512:
6
+ metadata.gz: 298a5df19268ae778a4b7f54a80d3bde47e630a3bc4f1903a5a5102ec6077c41c60e5f0269216cf120c0d6c02cd01e906d1da5ee1b157745065ba2170ce6ad59
7
+ data.tar.gz: d000311e5370b6d05d1eebce2e6f708604d45336228bd84f8b1ea9de060972a30d3a37670f82cfe5855f3b3597ea05e3f3ae7b9f001ce5bcb3a411589818ffed
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at paileyq@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in tanj.gemspec
6
+ gemspec
@@ -0,0 +1,28 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tanj (0.0.1)
5
+ binding_of_caller (~> 0.8)
6
+ paint (~> 2.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ binding_of_caller (0.8.0)
12
+ debug_inspector (>= 0.0.1)
13
+ debug_inspector (0.0.3)
14
+ minitest (5.11.3)
15
+ paint (2.0.1)
16
+ rake (10.5.0)
17
+
18
+ PLATFORMS
19
+ ruby
20
+
21
+ DEPENDENCIES
22
+ bundler (~> 1.16)
23
+ minitest (~> 5.0)
24
+ rake (~> 10.0)
25
+ tanj!
26
+
27
+ BUNDLED WITH
28
+ 1.16.1
@@ -0,0 +1,43 @@
1
+ # Tanj
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/tanj`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'tanj'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install tanj
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tanj. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Tanj project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/tanj/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tanj"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'tanj'
4
+
5
+ status = Tanj::CLI.new.run(ARGV)
6
+ exit! if status == false
@@ -0,0 +1,67 @@
1
+ require 'binding_of_caller'
2
+ require 'json'
3
+ require 'paint'
4
+
5
+ require 'tanj/cli'
6
+ require 'tanj/frontend'
7
+ require 'tanj/logger'
8
+ require "tanj/version"
9
+
10
+ module Tanj
11
+ @@logger = Logger::Stderr.new
12
+
13
+ def self.config(options)
14
+ @@logger = options[:logger] unless options[:logger].nil?
15
+ end
16
+
17
+ def self.array(name, options = {})
18
+ b = binding.of_caller(1)
19
+
20
+ if options[:index]
21
+ options[:index].map! do |idx|
22
+ if idx.is_a? Symbol
23
+ { name: idx, value: b.eval(idx.to_s) }
24
+ elsif idx.is_a? Range
25
+ [
26
+ idx.begin.is_a?(Symbol) ?
27
+ { name: idx.begin, value: b.eval(idx.begin.to_s) } : { value: idx.begin },
28
+ idx.end.is_a?(Symbol) ?
29
+ { name: idx.end, value: b.eval(idx.end.to_s) } : { value: idx.end }
30
+ ]
31
+ else
32
+ idx
33
+ end
34
+ end
35
+ end
36
+
37
+ log(caller_locations[0], {
38
+ type: "array",
39
+ value: b.eval(name.to_s),
40
+ name: name,
41
+ options: options
42
+ })
43
+ end
44
+
45
+ def self.var(name)
46
+ log(caller_locations[0], {
47
+ type: "variable",
48
+ value: binding.of_caller(1).eval(name.to_s),
49
+ name: name
50
+ })
51
+ end
52
+
53
+ def self.message(msg)
54
+ log(caller_locations[0], type: "message", message: msg)
55
+ end
56
+
57
+ def self.here
58
+ log(caller_locations[0], type: "here")
59
+ end
60
+
61
+ private
62
+
63
+ def self.log(location, hash)
64
+ hash[:where] = {line_num: location.lineno, path: location.absolute_path, label: location.label}
65
+ @@logger.log "tanj| #{hash.to_json}"
66
+ end
67
+ end
@@ -0,0 +1,10 @@
1
+ module Tanj
2
+ class CLI
3
+ def run(args)
4
+ frontend = Tanj::Frontend.new
5
+ while line = gets
6
+ frontend.receive(line)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,50 @@
1
+ module Tanj
2
+ class Frontend
3
+ def initialize
4
+ @events = []
5
+ end
6
+
7
+ def receive(line)
8
+ return unless line.start_with? "tanj| "
9
+
10
+ event = JSON.parse(line[6..-1], symbolize_names: true)
11
+ @events.push event
12
+ if event[:type] == 'array'
13
+ ary = event[:value]
14
+ if ary.empty?
15
+ puts Paint['<empty array>', 'dark gray']
16
+ else
17
+ print Paint["#{event[:name]}", :underline, :bright, 'deep sky blue'], ': '
18
+ ary.each.with_index do |val, idx|
19
+ idx_layer = 0
20
+ Array(event[:options][:index]).each.sort_by do |target_idx|
21
+ target_idx.is_a?(Array) ? target_idx[1][:value] - target_idx[0][:value] + 2 : 1
22
+ end.each.with_index do |target_idx, target_layer|
23
+ if target_idx.is_a?(Array)
24
+ target_idx = Range.new(*target_idx.map { |v| v[:value] })
25
+ else
26
+ target_idx = target_idx[:value]
27
+ end
28
+ if target_idx === idx
29
+ idx_layer = target_layer + 1
30
+ break
31
+ end
32
+ end
33
+ cell_color = ['white', 'green', 'yellow', 'orange'][idx_layer]
34
+ print Paint['[ ', cell_color]
35
+ print Paint[val.inspect, :bright, cell_color]
36
+ print Paint[' ] ', cell_color]
37
+ end
38
+ puts
39
+ end
40
+ elsif event[:type] == 'message'
41
+ puts Paint[event[:message], :bright, 'orange']
42
+ elsif event[:type] == 'variable'
43
+ print Paint["#{event[:name]}", :underline, :bright, 'deep sky blue'], ': '
44
+ puts Paint[event[:value].inspect, :bright, 'white']
45
+ else
46
+ p event
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,4 @@
1
+ require 'tanj/logger/base_logger'
2
+
3
+ require 'tanj/logger/self'
4
+ require 'tanj/logger/stderr'
@@ -0,0 +1,9 @@
1
+ module Tanj
2
+ module Logger
3
+ class BaseLogger
4
+ def log(line)
5
+ raise NotImplementedError
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ module Tanj
2
+ module Logger
3
+ class Self < BaseLogger
4
+ def initialize
5
+ @frontend = Tanj::Frontend.new
6
+ end
7
+
8
+ def log(line)
9
+ @frontend.receive line
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ module Tanj
2
+ module Logger
3
+ class Stderr < BaseLogger
4
+ def log(line)
5
+ $stderr.puts line
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Tanj
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "tanj/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "tanj"
7
+ spec.version = Tanj::VERSION
8
+ spec.authors = ["Pailey Quilts"]
9
+ spec.email = ["paileyq@gmail.com"]
10
+
11
+ spec.summary = %q{tools for print statement debugging}
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
15
+ f.match(%r{^(test|spec|features)/})
16
+ end
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_runtime_dependency 'binding_of_caller', '~> 0.8'
22
+ spec.add_runtime_dependency 'paint', '~> 2.0'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "minitest", "~> 5.0"
27
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tanj
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Pailey Quilts
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-08-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: binding_of_caller
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.8'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: paint
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ description:
84
+ email:
85
+ - paileyq@gmail.com
86
+ executables:
87
+ - tanj
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - CODE_OF_CONDUCT.md
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - exe/tanj
100
+ - lib/tanj.rb
101
+ - lib/tanj/cli.rb
102
+ - lib/tanj/frontend.rb
103
+ - lib/tanj/logger.rb
104
+ - lib/tanj/logger/base_logger.rb
105
+ - lib/tanj/logger/self.rb
106
+ - lib/tanj/logger/stderr.rb
107
+ - lib/tanj/version.rb
108
+ - tanj.gemspec
109
+ homepage:
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.7.6
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: tools for print statement debugging
133
+ test_files: []