tk_inspect 0.1.0

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
+ SHA256:
3
+ metadata.gz: 7f7377cade733dd797288129ec45fcb1481c05096df88cf18a42fefa0ae6329f
4
+ data.tar.gz: 52aa4aa14cd64cdfd27034a436da29341fec08b00969cd6e9be280248f666c6a
5
+ SHA512:
6
+ metadata.gz: 419d81b4705568549fc788e1c34a7732cde280e6fb074cfb929128352201d6909f94106e14cefca2a6c05e6c945f486ec3a4fbd954d575a4305c2a54fe25496e
7
+ data.tar.gz: b1ac46a63e8ddc81fc30ef535e4dfb50a4bf47454cf16a27f90076104837d49555582a5ae3ed2abcebaa73540da0fa4b2124bef0a9d9f9486de67cea26c148b4
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.3
7
+ before_install: gem install bundler -v 1.16.6
@@ -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 jes@josepegea.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,11 @@
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 tk_inspect.gemspec
6
+ gemspec
7
+
8
+ group :development, :test do
9
+ gem 'pry'
10
+ gem 'pry-byebug'
11
+ end
@@ -0,0 +1,67 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tk_inspect (0.1.0)
5
+ rouge (~> 3.26)
6
+ tk_component (~> 0.1.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (6.0.3.4)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 0.7, < 2)
14
+ minitest (~> 5.1)
15
+ tzinfo (~> 1.1)
16
+ zeitwerk (~> 2.2, >= 2.2.2)
17
+ byebug (11.1.3)
18
+ coderay (1.1.3)
19
+ concurrent-ruby (1.1.8)
20
+ diff-lcs (1.4.4)
21
+ i18n (1.8.7)
22
+ concurrent-ruby (~> 1.0)
23
+ method_source (1.0.0)
24
+ minitest (5.14.3)
25
+ pry (0.13.1)
26
+ coderay (~> 1.1)
27
+ method_source (~> 1.0)
28
+ pry-byebug (3.9.0)
29
+ byebug (~> 11.0)
30
+ pry (~> 0.13.0)
31
+ rake (10.5.0)
32
+ rouge (3.26.0)
33
+ rspec (3.10.0)
34
+ rspec-core (~> 3.10.0)
35
+ rspec-expectations (~> 3.10.0)
36
+ rspec-mocks (~> 3.10.0)
37
+ rspec-core (3.10.0)
38
+ rspec-support (~> 3.10.0)
39
+ rspec-expectations (3.10.0)
40
+ diff-lcs (>= 1.2.0, < 2.0)
41
+ rspec-support (~> 3.10.0)
42
+ rspec-mocks (3.10.0)
43
+ diff-lcs (>= 1.2.0, < 2.0)
44
+ rspec-support (~> 3.10.0)
45
+ rspec-support (3.10.0)
46
+ thread_safe (0.3.6)
47
+ tk (0.3.0)
48
+ tk_component (0.1.2)
49
+ activesupport (~> 6.0.3)
50
+ tk (~> 0.3.0)
51
+ tzinfo (1.2.9)
52
+ thread_safe (~> 0.1)
53
+ zeitwerk (2.4.2)
54
+
55
+ PLATFORMS
56
+ ruby
57
+
58
+ DEPENDENCIES
59
+ bundler (~> 1.16)
60
+ pry
61
+ pry-byebug
62
+ rake (~> 10.0)
63
+ rspec (~> 3.0)
64
+ tk_inspect!
65
+
66
+ BUNDLED WITH
67
+ 1.16.6
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ # TkInspect
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/tk_inspect`. 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 'tk_inspect'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install tk_inspect
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 spec` 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]/tk_inspect. 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 TkInspect project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/tk_inspect/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tk_inspect"
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
+ require "pry"
10
+ Pry.start
11
+
12
+ # require "irb"
13
+ # 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,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "tk_inspect"
5
+ require "pry"
6
+
7
+ console = TkInspect::Console::Base.new(root: true)
8
+ console.make_main
9
+ console.focus
10
+ console.execute(ARGV.join(' ')) if ARGV.any?
11
+ console.focus
12
+
13
+ Tk.mainloop
14
+
@@ -0,0 +1,65 @@
1
+ class Object
2
+ def id_for_tk_inspect
3
+ object_id.to_s
4
+ end
5
+
6
+ def value_for_tk_inspect
7
+ to_s
8
+ end
9
+
10
+ def number_of_children_for_tk_inspect
11
+ instance_variables.size
12
+ end
13
+
14
+ def children_for_tk_inspect
15
+ instance_variables.map { |v| [v, instance_variable_get(v)] }.to_h
16
+ end
17
+ end
18
+
19
+ class String
20
+ def value_for_tk_inspect
21
+ frozen? ? dup : self
22
+ end
23
+ end
24
+
25
+ class Array
26
+ def value_for_tk_inspect
27
+ "#{size} elements"
28
+ end
29
+
30
+ def number_of_children_for_tk_inspect
31
+ size + super
32
+ end
33
+
34
+ def children_for_tk_inspect
35
+ map.with_index { |obj, idx| [ idx.to_s, obj ] }.to_h.merge(super)
36
+ end
37
+ end
38
+
39
+ class Hash
40
+ def value_for_tk_inspect
41
+ "#{size} elements"
42
+ end
43
+
44
+ def number_of_children_for_tk_inspect
45
+ size + super
46
+ end
47
+
48
+ def children_for_tk_inspect
49
+ merge(super)
50
+ end
51
+ end
52
+
53
+ class Struct
54
+ def value_for_tk_inspect
55
+ "#{size} elements"
56
+ end
57
+
58
+ def number_of_children_for_tk_inspect
59
+ size + super
60
+ end
61
+
62
+ def children_for_tk_inspect
63
+ to_h.merge(super)
64
+ end
65
+ end
@@ -0,0 +1,9 @@
1
+ class Object
2
+ def open_tk_console(b = binding, modal = true)
3
+ @@main_console ||= TkInspect::Console::Base.new(modal: modal)
4
+ @@main_console.eval_binding = b
5
+ @@main_console.focus
6
+ modal ? @@main_console.modal_loop : Tk.mainloop
7
+ end
8
+ alias otkc open_tk_console
9
+ end
@@ -0,0 +1,12 @@
1
+ require 'tk_component'
2
+ require "tk_inspect/version"
3
+ require 'tk_inspect/inspector'
4
+ require 'tk_inspect/class_browser'
5
+ require 'tk_inspect/canvas_window'
6
+ require 'tk_inspect/console'
7
+ require 'base_inspectors'
8
+ require 'cli_support'
9
+
10
+ module TkInspect
11
+ # Your code goes here...
12
+ end
@@ -0,0 +1,2 @@
1
+ require_relative './canvas_window/base'
2
+ require_relative './canvas_window/root_component'
@@ -0,0 +1,39 @@
1
+ module TkInspect
2
+ module CanvasWindow
3
+ class Base
4
+ attr_accessor :tk_root
5
+ attr_accessor :main_component
6
+
7
+ delegate :canvas, to: :main_component
8
+
9
+ def initialize
10
+ @tk_root = nil
11
+ @main_component = nil
12
+ end
13
+
14
+ def refresh
15
+ @main_component.nil? ? create_root : @main_component.regenerate
16
+ self
17
+ end
18
+
19
+ def create_root
20
+ @tk_root = TkComponent::Window.new(title: "Canvas Window")
21
+ @main_component = RootComponent.new
22
+ @main_component.canvas_window = self
23
+ @tk_root.place_root_component(@main_component)
24
+ end
25
+
26
+ def new_turtle
27
+ TkComponent::Turtle.new(canvas: main_component.canvas)
28
+ end
29
+ end
30
+ end
31
+
32
+ module Console
33
+ class Base
34
+ def new_canvas_window
35
+ TkInspect::CanvasWindow::Base.new.refresh
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,17 @@
1
+ module TkInspect
2
+ module CanvasWindow
3
+ class RootComponent < TkComponent::Base
4
+ attr_accessor :canvas_window
5
+
6
+ def generate(parent_component, options = {})
7
+ parse_component(parent_component, options) do |p|
8
+ @canvas = p.canvas(sticky: 'nwes', x_flex: 1, y_flex: 1)
9
+ end
10
+ end
11
+
12
+ def canvas
13
+ @canvas.native_item
14
+ end
15
+ end
16
+ end
17
+ end