active_interaction_mapper 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d0ed67fcfda4a6fff4d58994183112c5106a9c5c3088e605e085d69142ed5a3
4
- data.tar.gz: cbcd25da9413a1a4c300e905282dbd0bdc36e6f93d64d23b0769fd536d7e5343
3
+ metadata.gz: 04df9c268dba3ec70903f55e79c1c2192ea5b48e56c54efe90151236163ba8ec
4
+ data.tar.gz: 0b52c77f0a6f2ad1f8fef6d0110c48019e736a80e4e15f528009dc5250f3444d
5
5
  SHA512:
6
- metadata.gz: 1cc73cb54b61f0298b248629705d967947c4f8441bcbd71b1f071364090e1a1f08060afabb4e2a754b8ebf60d039a061dafe8af9db1dd9fba25c456b95a61fae
7
- data.tar.gz: f53aa74b4c31f922f95539af5cbcb8bfbab01fc15875f18ecdb29c1411720d5e8c3e512d7f8b1f821bc863ed4bba5e7c74d6e704fa30914908eb41d264f81733
6
+ metadata.gz: 1948eb450ee1077ac2ad496d04010dd918ac3061f464258fa535bf103bb28137bc23ac6388d508698ba99095dc8db7590a56541afa135acf93ab72826197dd01
7
+ data.tar.gz: 4cae1c962e177c00f828a0423f2bc254106d013774750b14a3f380aac925396730b2e9192d5bad0a65e5f293ba1034e329a23cacf79262cf0de9aff90a1f1da9
data/Gemfile CHANGED
@@ -13,4 +13,4 @@ gem "rubocop", "~> 1.7"
13
13
 
14
14
  gem "active_interaction", "~> 4.0"
15
15
 
16
- gem 'ruby-graphviz'
16
+ gem 'ruby-graphviz', '~> 1.2.5'
data/README.md CHANGED
@@ -1,8 +1,9 @@
1
1
  # ActiveInteractionMapper
2
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
3
+ This gem allows the tracking of ActiveInteractions interactions.
4
+ This is done by tracking the .execute methode that is overridden in each class inheriting from ActiveInteraction.
5
+ To be able to trace function calls, I used Ruby's TracePoint class and to draw the graphs I used the 'ruby-graphviz' gem.
6
+ 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.
6
7
 
7
8
  ## Installation
8
9
 
@@ -20,9 +21,57 @@ Or install it yourself as:
20
21
 
21
22
  $ gem install active_interaction_mapper
22
23
 
24
+ Note: You also need to install the gem : [ruby-graphviz](https://rubygems.org/gems/ruby-graphviz/) and install [graphviz](https://graphviz.org/download/) in your environment.
25
+
23
26
  ## Usage
24
27
 
25
- TODO: Write usage instructions here
28
+ Generating a graph and outputting as text to STDOUT:
29
+
30
+ ```ruby
31
+ ActiveInteractionMapper.trace(output_image: false) do
32
+ # Code to trace
33
+ end
34
+ ```
35
+
36
+ You can choose to output your result as a png as follows:
37
+
38
+ ```ruby
39
+ ActiveInteractionMapper.trace(output_image: true, folder_name:'', file_name:'') do
40
+ # Code to trace
41
+ end
42
+ ```
43
+ By default, the files are generated in the tmp folder.
44
+ If the folder_name and file_name are left empty, the code will create a directory and a file using the current date and time.
45
+
46
+ You can also choose where the graph should start by using the start_at argument with the full name of the interaction you want to start at.
47
+
48
+ ```ruby
49
+ ActiveInteractionMapper.trace(output_image: true, folder_name:'', file_name:'', start_at: 'ActiveInteractionA') do
50
+ # Code to trace
51
+ end
52
+ ```
53
+
54
+ Here's an example of a code I worked on. It runs an interaction in an Rspec test and puts the graph in the directory 'tmp/spec/.../test_file_name' and in a file with the name of the test running and the date it was run at.
55
+
56
+ ```ruby
57
+ require 'active_interaction_mapper'
58
+
59
+ RSpec.describe Test do
60
+
61
+ around do |example|
62
+ path = example.metadata[:example_group][:file_path]
63
+ ActiveInteractionMapper.trace(folder_name: path.split('.')[1], file_name: example.metadata[:description]) do
64
+ example.call
65
+ end
66
+ end
67
+ it "does something useful" do
68
+ outcome = Test::ActiveInteractionA.run()
69
+ expect(outcome.result).to eq(true)
70
+ end
71
+ end
72
+ ```
73
+
74
+
26
75
 
27
76
  ## Development
28
77
 
@@ -33,7 +33,8 @@ Gem::Specification.new do |spec|
33
33
  spec.require_paths = ["lib"]
34
34
 
35
35
  # Uncomment to register a new dependency of your gem
36
- # spec.add_dependency "example-gem", "~> 1.0"
36
+ spec.add_dependency 'ruby-graphviz', '~> 1.2.5'
37
+
37
38
 
38
39
  # For more information and examples about making a new gem, checkout our
39
40
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveInteractionMapper
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_interaction_mapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - charbel-elhajj
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-07 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2021-05-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby-graphviz
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.2.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.5
13
27
  description: |
14
28
  This gem allows the tracking of ActiveInteractions interactions.
15
29