flight-control-tower 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/flight-control-tower +11 -0
- data/lib/flight-control-tower.rb +17 -0
- data/lib/flight-control-tower/parser.rb +66 -0
- metadata +48 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 31757e5119a7e7aa71852e298066e77057562439
|
4
|
+
data.tar.gz: 2bf445545edc584f69fbbda114fc6302e33870ad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 50adacd51473f19a5845e4102f5dafef87fefa1e9b281b3a2508df1a887b90e27a47854ac1e7eebf82d2cfe7121a1a5e6aaffaf3ae764cfcde499d4043fd9cc9
|
7
|
+
data.tar.gz: 0ffc519f9b9ef55d96d4afae2bd9ba5ae61bff0b72f3778fc6a2d77c9b2681d25cf4e35bdab6c33b8856f82bbd7c725f497a52bdeaf820aefb9c0055a1f165a1
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
|
4
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'flight-control-tower'
|
7
|
+
|
8
|
+
control_tower = FlightControlTower::ControlTower.new(ARGV[0])
|
9
|
+
puts control_tower.report_traffic
|
10
|
+
|
11
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'flight-control-tower/parser'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module FlightControlTower
|
5
|
+
class ControlTower
|
6
|
+
def initialize(config_file)
|
7
|
+
@config_file = config_file
|
8
|
+
end
|
9
|
+
|
10
|
+
def report_traffic
|
11
|
+
config = YAML.load_file(@config_file)
|
12
|
+
files_to_parse = Dir[config["include_pattern"]] - Dir[config["exclude_pattern"]]
|
13
|
+
Parser.parse(files_to_parse)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module FlightControlTower
|
4
|
+
class Parser
|
5
|
+
|
6
|
+
def self.parse files_to_parse
|
7
|
+
connections = create_connections(files_to_parse)
|
8
|
+
puts create_graph(connections).to_json
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
def create_connections(files_to_parse)
|
13
|
+
results = {}
|
14
|
+
results['document'] = { outbound: [], inbound: [] }
|
15
|
+
files_to_parse.each do |f|
|
16
|
+
content = File.read(f)
|
17
|
+
next unless content.match(/defineComponent/)
|
18
|
+
|
19
|
+
component_name = File.basename(f)
|
20
|
+
results[component_name] = { outbound: [], inbound: [] }
|
21
|
+
|
22
|
+
inbound = content.scan(/this.on\((.+?)\)/).map{|e| e[0].split(',').map(&:strip) }
|
23
|
+
inbound.each do |args|
|
24
|
+
results[component_name][:inbound] << args[0] if args.length == 2
|
25
|
+
results[component_name][:inbound] << args[1] if args.length == 3
|
26
|
+
end
|
27
|
+
|
28
|
+
outbound = content.scan(/this.trigger\((.+?)\)/).map{|e| e[0].split(',').map(&:strip) }
|
29
|
+
outbound.each do |args|
|
30
|
+
results['document'][:outbound] << args[1] if args[0] == 'document'
|
31
|
+
results[component_name][:outbound] << args[1]
|
32
|
+
end
|
33
|
+
results[component_name][:inbound].uniq!
|
34
|
+
results[component_name][:outbound].uniq!
|
35
|
+
end
|
36
|
+
results
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_grap(results)
|
40
|
+
graph = []
|
41
|
+
results.each_pair do |component_name, component_events|
|
42
|
+
component_events[:inbound].each do |event|
|
43
|
+
results.each_pair do |next_component_name, next_component_events|
|
44
|
+
next if component_name == next_component_name
|
45
|
+
if results[next_component_name][:outbound].include?(event)
|
46
|
+
graph << { source: next_component_name, target: component_name, eventName: event }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
results.each_pair do |component_name, component_events|
|
53
|
+
component_events[:outbound].each do |event|
|
54
|
+
results.each_pair do |next_component_name, next_component_events|
|
55
|
+
next if component_name == next_component_name
|
56
|
+
if results[next_component_name][:inbound].include?(event)
|
57
|
+
graph << { source: component_name, dest: next_component_name, type: event }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
return graph
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
metadata
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flight-control-tower
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Duda Dornelles
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-04 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: This gem parses your flight components and stores their event interactions
|
14
|
+
to later plot it using d3
|
15
|
+
email:
|
16
|
+
- duda@thoughtworks.com
|
17
|
+
executables:
|
18
|
+
- flight-control-tower
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- bin/flight-control-tower
|
23
|
+
- lib/flight-control-tower.rb
|
24
|
+
- lib/flight-control-tower/parser.rb
|
25
|
+
homepage:
|
26
|
+
licenses: []
|
27
|
+
metadata: {}
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
requirements: []
|
43
|
+
rubyforge_project:
|
44
|
+
rubygems_version: 2.2.2
|
45
|
+
signing_key:
|
46
|
+
specification_version: 4
|
47
|
+
summary: Plot your flightjs components and its events interactions
|
48
|
+
test_files: []
|