active_interaction_mapper 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9d0ed67fcfda4a6fff4d58994183112c5106a9c5c3088e605e085d69142ed5a3
4
+ data.tar.gz: cbcd25da9413a1a4c300e905282dbd0bdc36e6f93d64d23b0769fd536d7e5343
5
+ SHA512:
6
+ metadata.gz: 1cc73cb54b61f0298b248629705d967947c4f8441bcbd71b1f071364090e1a1f08060afabb4e2a754b8ebf60d039a061dafe8af9db1dd9fba25c456b95a61fae
7
+ data.tar.gz: f53aa74b4c31f922f95539af5cbcb8bfbab01fc15875f18ecdb29c1411720d5e8c3e512d7f8b1f821bc863ed4bba5e7c74d6e704fa30914908eb41d264f81733
data/.gitignore ADDED
@@ -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/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Datasource local storage ignored files
5
+ /dataSources/
6
+ /dataSources.local.xml
7
+ # Editor-based HTTP Client requests
8
+ /httpRequests/
@@ -0,0 +1,82 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
+ </content>
12
+ <orderEntry type="jdk" jdkName="ruby-3.0.1-p64" jdkType="RUBY_SDK" />
13
+ <orderEntry type="sourceFolder" forTests="false" />
14
+ <orderEntry type="library" scope="PROVIDED" name="active_interaction (v4.0.0, ruby-3.0.1-p64) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="activemodel (v6.1.3.2, ruby-3.0.1-p64) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v6.1.3.2, ruby-3.0.1-p64) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, ruby-3.0.1-p64) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.16, ruby-3.0.1-p64) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.8, ruby-3.0.1-p64) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.4.4, ruby-3.0.1-p64) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="i18n (v1.8.10, ruby-3.0.1-p64) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.14.4, ruby-3.0.1-p64) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v1.20.1, ruby-3.0.1-p64) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="parser (v3.0.1.1, ruby-3.0.1-p64) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, ruby-3.0.1-p64) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.3, ruby-3.0.1-p64) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="rbs (v1.0.4, ruby-3.0.1-p64) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.1.1, ruby-3.0.1-p64) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, ruby-3.0.1-p64) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.10.0, ruby-3.0.1-p64) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.10.1, ruby-3.0.1-p64) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.10.1, ruby-3.0.1-p64) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.10.2, ruby-3.0.1-p64) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.10.2, ruby-3.0.1-p64) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.14.0, ruby-3.0.1-p64) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.5.0, ruby-3.0.1-p64) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="ruby-graphviz (v1.2.5, ruby-3.0.1-p64) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, ruby-3.0.1-p64) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.4, ruby-3.0.1-p64) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.0.0, ruby-3.0.1-p64) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.4.2, ruby-3.0.1-p64) [gem]" level="application" />
42
+ </component>
43
+ <component name="RakeTasksCache">
44
+ <option name="myRootTask">
45
+ <RakeTaskImpl id="rake">
46
+ <subtasks>
47
+ <RakeTaskImpl description="Build active_interaction_mapper-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
48
+ <RakeTaskImpl id="build">
49
+ <subtasks>
50
+ <RakeTaskImpl description="Generate SHA512 checksum if active_interaction_mapper-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
51
+ </subtasks>
52
+ </RakeTaskImpl>
53
+ <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
54
+ <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
55
+ <RakeTaskImpl description="Build and install active_interaction_mapper-0.1.0.gem into system gems" fullCommand="install" id="install" />
56
+ <RakeTaskImpl id="install">
57
+ <subtasks>
58
+ <RakeTaskImpl description="Build and install active_interaction_mapper-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
59
+ </subtasks>
60
+ </RakeTaskImpl>
61
+ <RakeTaskImpl description="Create tag v0.1.0 and build and push active_interaction_mapper-0.1.0.gem to https://github.com/charbel-elhajj/active_interaction_mapper" fullCommand="release[remote]" id="release[remote]" />
62
+ <RakeTaskImpl description="Run RuboCop" fullCommand="rubocop" id="rubocop" />
63
+ <RakeTaskImpl id="rubocop">
64
+ <subtasks>
65
+ <RakeTaskImpl description="Auto-correct RuboCop offenses" fullCommand="rubocop:auto_correct" id="auto_correct" />
66
+ </subtasks>
67
+ </RakeTaskImpl>
68
+ <RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
69
+ <RakeTaskImpl description="" fullCommand="default" id="default" />
70
+ <RakeTaskImpl description="" fullCommand="release" id="release" />
71
+ <RakeTaskImpl id="release">
72
+ <subtasks>
73
+ <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
74
+ <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
75
+ <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
76
+ </subtasks>
77
+ </RakeTaskImpl>
78
+ </subtasks>
79
+ </RakeTaskImpl>
80
+ </option>
81
+ </component>
82
+ </module>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/active_interaction_mapper.iml" filepath="$PROJECT_DIR$/.idea/active_interaction_mapper.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2021-05-06
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at charbelelhajj99@hotmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in active_interaction_mapper.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.7"
13
+
14
+ gem "active_interaction", "~> 4.0"
15
+
16
+ gem 'ruby-graphviz'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 charbel-elhajj
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.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # ActiveInteractionMapper
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/active_interaction_mapper`. 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 'active_interaction_mapper'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install active_interaction_mapper
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 the created tag, 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]/active_interaction_mapper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/active_interaction_mapper/blob/master/CODE_OF_CONDUCT.md).
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 ActiveInteractionMapper project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/active_interaction_mapper/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/active_interaction_mapper/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "active_interaction_mapper"
7
+ spec.version = ActiveInteractionMapper::VERSION
8
+ spec.authors = ["charbel-elhajj"]
9
+ spec.email = ["charbelelhajj99@hotmail.com"]
10
+
11
+ spec.summary = "Allows to track the interactions between ActiveInteraction"
12
+ spec.description = "This gem allows the tracking of ActiveInteractions interactions.\n
13
+ This is done by tracking the .execute methode that is overridden in each class inheriting from ActiveInteraction.\n
14
+ To be able to trace function calls, I used Ruby's TracePoint class and to draw the graphs I used the 'ruby-graphviz' gem.\n
15
+ Note that you need to install GraphViz in your environment and have its path in your path environment variable to be able to draw graphs.\n"
16
+ spec.homepage = "https://rubygems.org/gems/active_interaction_mapper"
17
+ spec.license = "MIT"
18
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
19
+
20
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
+
22
+ spec.metadata["homepage_uri"] = 'https://github.com/charbel-elhajj/active_interaction_mapper'
23
+ spec.metadata["source_code_uri"] = "https://github.com/charbel-elhajj/active_interaction_mapper"
24
+ spec.metadata["changelog_uri"] = "https://github.com/charbel-elhajj/active_interaction_mapper"
25
+
26
+ # Specify which files should be added to the gem when it is released.
27
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
29
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
30
+ end
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ # Uncomment to register a new dependency of your gem
36
+ # spec.add_dependency "example-gem", "~> 1.0"
37
+
38
+ # For more information and examples about making a new gem, checkout our
39
+ # guide at: https://bundler.io/guides/creating_gem.html
40
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "active_interaction_mapper"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -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,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "active_interaction_mapper/version"
4
+
5
+
6
+ require "active_interaction_mapper/version"
7
+ require "active_interaction_mapper/tracer"
8
+ require "active_interaction_mapper/filter/start_at"
9
+ require "active_interaction_mapper/filter/active_interaction_filter"
10
+ require "active_interaction_mapper/output/text"
11
+ require "active_interaction_mapper/output/dot"
12
+
13
+ module ActiveInteractionMapper
14
+ class Error < StandardError; end
15
+
16
+ def self.trace(start_at: nil, output_image: true, folder_name:'', file_name:'', &block)
17
+ filters = []
18
+ filters << Filter::StartAt.new(start_at) if start_at
19
+ filters << Filter::ActiveInteractionFilter.new
20
+
21
+ if output_image
22
+ output = ActiveInteractionMapper::Output::Dot.new(folder_name: folder_name, file_name: file_name)
23
+ else
24
+ output = ActiveInteractionMapper::Output::Text.new($stdout)
25
+ end
26
+ tracer = Tracer.new(filters: filters, output: output)
27
+ tracer.enable
28
+
29
+ begin
30
+ yield
31
+ ensure
32
+ tracer.disable
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,5 @@
1
+ module ActiveInteractionMapper
2
+ module Filter
3
+
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ module ActiveInteractionMapper
2
+ module Filter
3
+ class ActiveInteractionFilter
4
+ def initialize
5
+ end
6
+
7
+ def keep?(tp, normalized_class_name)
8
+ class_and_method = "#{normalized_class_name}.#{tp.method_id}"
9
+ (class_and_method.end_with? '.execute')
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,53 @@
1
+ module ActiveInteractionMapper
2
+ module Filter
3
+ class StartAt
4
+ def initialize(start_matcher)
5
+ @start_matcher = start_matcher
6
+ @started = false
7
+ @stack = []
8
+ end
9
+
10
+ def keep?(tp, normalized_class_name)
11
+
12
+
13
+ if !@started && call_event?(tp) && matches?(normalized_class_name)
14
+ @started = true
15
+ end
16
+
17
+ if @started && call_event?(tp)
18
+ @stack << normalized_class_name
19
+ return true
20
+ end
21
+
22
+ if @started && return_event?(tp)
23
+ @stack.pop
24
+
25
+ if @stack.empty?
26
+ @started = false
27
+ end
28
+ end
29
+
30
+ @started
31
+ end
32
+
33
+ private
34
+
35
+ def call_event?(tp)
36
+ tp.event == :call || tp.event == :c_call
37
+ end
38
+
39
+ def return_event?(tp)
40
+ tp.event == :return || tp.event == :c_return
41
+ end
42
+
43
+ def matches?(normalized_class_name)
44
+ case @start_matcher
45
+ when Regexp
46
+ (@start_matcher =~ normalized_class_name) != nil
47
+ when String
48
+ @start_matcher == normalized_class_name
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,4 @@
1
+ module ActiveInteractionMapper
2
+ module Output
3
+ end
4
+ end
@@ -0,0 +1,52 @@
1
+ require 'ruby-graphviz'
2
+ require 'fileutils'
3
+ require 'date'
4
+
5
+
6
+ module ActiveInteractionMapper
7
+ module Output
8
+ class Dot
9
+ def initialize(folder_name:'', file_name:'')
10
+ d = DateTime.now
11
+ d_string = d.strftime("%d%m%Y_%H%M%S")
12
+ if folder_name.empty?
13
+ @folder_name = "dir_#{d_string}"
14
+ else
15
+ @folder_name = "#{folder_name}"
16
+ end
17
+ if file_name.empty?
18
+ @file_name = "img_#{d_string}.png"
19
+ else
20
+ @file_name = "#{file_name}_#{d_string}.png"
21
+ end
22
+ @stack = []
23
+ @graph = GraphViz.new('CodeMapper')
24
+
25
+ end
26
+
27
+ def push(tp, normalized_class_name)
28
+ node = @graph.add_node("#{normalized_class_name}")
29
+
30
+
31
+ if @stack != []
32
+ @graph.add_edge(@stack.last,node)
33
+ end
34
+
35
+ @stack << node
36
+ end
37
+
38
+ def pop(tp, normalized_class_name)
39
+ @stack.pop
40
+ end
41
+
42
+ def done
43
+ full_path = "./tmp/#{@folder_name}/#{@file_name}"
44
+ dirname = File.dirname(full_path)
45
+ unless File.directory?(dirname)
46
+ FileUtils.mkdir_p(dirname)
47
+ end
48
+ @graph.output( :png => full_path)
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,22 @@
1
+ module ActiveInteractionMapper
2
+ module Output
3
+ class Text
4
+ def initialize(io)
5
+ @io = io
6
+ @indent = ''
7
+ end
8
+
9
+ def push(tp, normalized_class_name)
10
+ @io.puts "#{@indent}#{normalized_class_name}\n"
11
+ @indent << ' '
12
+ end
13
+
14
+ def pop(tp, normalized_class_name)
15
+ @indent = @indent[0...-2]
16
+ end
17
+
18
+ def done
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,45 @@
1
+ # require_relative './filter/active_interaction_filter'
2
+ module ActiveInteractionMapper
3
+ class Tracer
4
+ def initialize(filters: [], output:)
5
+ @filters = filters
6
+ @output = output
7
+ end
8
+
9
+ def enable
10
+ tracer.enable
11
+ end
12
+
13
+ def disable
14
+ tracer.disable
15
+ @output.done
16
+ end
17
+
18
+ private
19
+ def keep?(tp, normalized_class_name)
20
+ class_and_method = "#{normalized_class_name}.#{tp.method_id}"
21
+ val = (class_and_method.end_with? '.execute')
22
+ return val
23
+ end
24
+ def tracer
25
+ indent = ''
26
+
27
+ @tracer ||= TracePoint.new(:call, :c_call, :return, :c_return) do |tp|
28
+
29
+ normalized_class_name = tp.defined_class.to_s
30
+ .sub(/\#<Class\:(.*)\>/, '\1')
31
+ .sub(/\#<(.*)\:0x[0-f]+\>/, '\1')
32
+
33
+
34
+ next if @filters.any?{ |filter| !filter.keep?(tp, normalized_class_name) }
35
+
36
+ if tp.event == :call || tp.event == :c_call
37
+ @output.push(tp, normalized_class_name)
38
+ elsif tp.event == :return || tp.event == :c_return
39
+ @output.pop(tp, normalized_class_name)
40
+ end
41
+
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveInteractionMapper
4
+ VERSION = "0.1.0"
5
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_interaction_mapper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - charbel-elhajj
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-05-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |
14
+ This gem allows the tracking of ActiveInteractions interactions.
15
+
16
+ This is done by tracking the .execute methode that is overridden in each class inheriting from ActiveInteraction.
17
+
18
+ To be able to trace function calls, I used Ruby's TracePoint class and to draw the graphs I used the 'ruby-graphviz' gem.
19
+
20
+ Note that you need to install GraphViz in your environment and have its path in your path environment variable to be able to draw graphs.
21
+ email:
22
+ - charbelelhajj99@hotmail.com
23
+ executables: []
24
+ extensions: []
25
+ extra_rdoc_files: []
26
+ files:
27
+ - ".gitignore"
28
+ - ".idea/.gitignore"
29
+ - ".idea/active_interaction_mapper.iml"
30
+ - ".idea/modules.xml"
31
+ - ".rspec"
32
+ - ".rubocop.yml"
33
+ - CHANGELOG.md
34
+ - CODE_OF_CONDUCT.md
35
+ - Gemfile
36
+ - LICENSE.txt
37
+ - README.md
38
+ - Rakefile
39
+ - active_interaction_mapper.gemspec
40
+ - bin/console
41
+ - bin/setup
42
+ - lib/active_interaction_mapper.rb
43
+ - lib/active_interaction_mapper/filter.rb
44
+ - lib/active_interaction_mapper/filter/active_interaction_filter.rb
45
+ - lib/active_interaction_mapper/filter/start_at.rb
46
+ - lib/active_interaction_mapper/output.rb
47
+ - lib/active_interaction_mapper/output/dot.rb
48
+ - lib/active_interaction_mapper/output/text.rb
49
+ - lib/active_interaction_mapper/tracer.rb
50
+ - lib/active_interaction_mapper/version.rb
51
+ homepage: https://rubygems.org/gems/active_interaction_mapper
52
+ licenses:
53
+ - MIT
54
+ metadata:
55
+ allowed_push_host: https://rubygems.org
56
+ homepage_uri: https://github.com/charbel-elhajj/active_interaction_mapper
57
+ source_code_uri: https://github.com/charbel-elhajj/active_interaction_mapper
58
+ changelog_uri: https://github.com/charbel-elhajj/active_interaction_mapper
59
+ post_install_message:
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 2.4.0
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.2.15
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Allows to track the interactions between ActiveInteraction
78
+ test_files: []