attractor 2.0.5 → 2.4.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.
@@ -1,48 +0,0 @@
1
- module Attractor
2
- # HTML reporter
3
- class HtmlReporter < BaseReporter
4
- def report
5
- super
6
-
7
- puts 'Generating an HTML report'
8
- @serve_static = true
9
-
10
- FileUtils.mkdir_p './attractor_output'
11
- FileUtils.mkdir_p './attractor_output/stylesheets'
12
- FileUtils.mkdir_p './attractor_output/images'
13
- FileUtils.mkdir_p './attractor_output/javascripts'
14
-
15
- File.open('./attractor_output/images/attractor_logo.svg', 'w') { |file| file.write(logo) }
16
- File.open('./attractor_output/stylesheets/main.css', 'w') { |file| file.write(css) }
17
- File.open('./attractor_output/javascripts/index.js', 'w') { |file| file.write(javascript) }
18
- File.open('./attractor_output/javascripts/index.pack.js', 'w') { |file| file.write(javascript_pack) }
19
-
20
- File.open('./attractor_output/index.html', 'w') { |file| file.write(render) }
21
- puts "Generated HTML report at #{File.expand_path './attractor_output/index.html'}"
22
-
23
- Launchy.open(File.expand_path('./attractor_output/index.html'))
24
- end
25
-
26
- def logo
27
- File.read(File.expand_path('../../../app/assets/images/attractor_logo.svg', __dir__))
28
- end
29
-
30
- def css
31
- File.read(File.expand_path('../../../app/assets/stylesheets/main.css', __dir__))
32
- end
33
-
34
- def javascript_pack
35
- File.read(File.expand_path('../../../app/assets/javascripts/index.pack.js', __dir__))
36
- end
37
-
38
- def javascript
39
- template = Tilt.new(File.expand_path('../../../app/assets/javascripts/index.js.erb', __dir__))
40
- template.render self
41
- end
42
-
43
- def render
44
- template = Tilt.new(File.expand_path('../../../app/views/index.html.erb', __dir__))
45
- template.render self
46
- end
47
- end
48
- end
@@ -1 +0,0 @@
1
- {"churn":{"changes":[{"file_path":"app/assets/javascripts/index.pack.js","times_changed":21},{"file_path":"src/javascript/functions.js","times_changed":16},{"file_path":"src/javascript/index.js","times_changed":4}],"class_churn":[],"method_churn":[],"changed_files":[".gitignore","Rakefile","attractor.gemspec","lib/attractor.rb","lib/attractor/calculators/js_calculator.rb","lib/attractor/cli.rb","src/javascript/calculator/index.js","src/javascript/calculator/package-lock.json","src/javascript/calculator/package.json","src/javascript/calculator/webpack.config.js"],"changed_classes":[],"changed_methods":[]}}
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Attractor
4
- # functionality for watching file system changes
5
- class Watcher
6
- def initialize(file_prefix, callback)
7
- @file_prefix = file_prefix
8
- @callback = callback
9
- end
10
-
11
- def watch
12
- @callback.call
13
-
14
- listener = Listen.to(@file_prefix, ignore: /^attractor_output/) do |modified, _added, _removed|
15
- if modified
16
- puts "#{modified.map(&:to_s).join(', ')} modified, recalculating..."
17
- @callback.call
18
- end
19
- end
20
- listener.start
21
- sleep
22
- end
23
- end
24
- end
data/lib/attractor.rb~ DELETED
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'attractor/version'
4
- require 'attractor/gem_names'
5
- require 'attractor/duration_parser'
6
- require 'attractor/calculators/base_calculator'
7
- require 'attractor/detectors/base_detector'
8
- require 'attractor/reporters/base_reporter'
9
- require 'attractor/suggester'
10
- require 'attractor/watcher'
11
-
12
- Dir[File.join(__dir__, 'attractor', 'reporters', '*.rb')].each do |file|
13
- next if file.start_with?('base')
14
-
15
- require file
16
- end
17
-
18
- module Attractor
19
- class Error < StandardError; end
20
-
21
- @registry_entries = {}
22
-
23
- def register(registry_entry)
24
- @registry_entries[registry_entry.type] = registry_entry
25
- end
26
-
27
- def calculators_for_type(type, **options)
28
- registry_entry_for_type = @registry_entries[type]
29
-
30
- return { type => registry_entry_for_type.calculator_class.new(**options) } if type
31
-
32
-
33
- Hash[@registry_entries.map do |type, entry|
34
- [type, entry.calculator_class.new(**options)] if entry.detector_class.new.detect
35
- end.compact]
36
- end
37
-
38
- module_function :calculators_for_type
39
- module_function :register
40
- end
41
-
42
- Attractor::GemNames.new.to_a.each do |gem_name|
43
- require "attractor/#{gem_name}"
44
- end