attractor 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +2 -0
- data/lib/attractor/cli.rb +12 -6
- data/lib/attractor/reporters/base_reporter.rb +2 -1
- data/lib/attractor/reporters/html_reporter.rb +4 -1
- data/lib/attractor/reporters/sinatra_reporter.rb +9 -2
- data/lib/attractor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11835b70ba787d947df52990eb130dd226a33dca6081905d3d8358e87d8425fa
|
4
|
+
data.tar.gz: 5d6908e051be5d673b98d331d6e7549df112652b133918621ba4ed7d022f1e1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7aa8164fb88a2addaf36f180cfca2e58701c5700fc5a61111fd4cf11a6b3506f4b2d19645befc3f7f9dd39604e4339de2fc28b4d97d41997a549f02ed318c331
|
7
|
+
data.tar.gz: 5cccb6fa1fbf7b55d01a1473b3d6303cb509ae7914b97d55b08899661983112c041cfd35d125dbea2393defe0a83fea21c2a49423f60a2f1745bc973dab5b996
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -69,12 +69,14 @@ Generate a full report
|
|
69
69
|
$ --file_prefix|-p app/models
|
70
70
|
$ --type|-t rb|js
|
71
71
|
$ --watch|-w
|
72
|
+
$ --no-open-browser|--ci
|
72
73
|
|
73
74
|
Serve the output on http://localhost:7890
|
74
75
|
|
75
76
|
$ attractor serve
|
76
77
|
$ --file_prefix|-p app/models
|
77
78
|
$ --watch|-w
|
79
|
+
$ --no-open-browser|--ci
|
78
80
|
|
79
81
|
## Development
|
80
82
|
|
data/lib/attractor/cli.rb
CHANGED
@@ -29,18 +29,21 @@ module Attractor
|
|
29
29
|
option :file_prefix, aliases: :p
|
30
30
|
option :watch, aliases: :w, type: :boolean
|
31
31
|
option :type, aliases: :t
|
32
|
+
option :no_open_browser, type: :boolean
|
33
|
+
option :ci, type: :boolean
|
32
34
|
def report
|
33
35
|
file_prefix = options[:file_prefix]
|
34
36
|
calculators = Attractor.calculators_for_type(options[:type], file_prefix)
|
37
|
+
open_browser = !(options[:no_open_browser] || options[:ci])
|
35
38
|
if options[:watch]
|
36
39
|
puts 'Listening for file changes...'
|
37
|
-
Attractor::HtmlReporter.new(file_prefix: file_prefix, calculators: calculators).watch
|
40
|
+
Attractor::HtmlReporter.new(file_prefix: file_prefix, calculators: calculators, open_browser: open_browser).watch
|
38
41
|
else
|
39
42
|
case options[:format]
|
40
43
|
when 'html'
|
41
|
-
Attractor::HtmlReporter.new(file_prefix: file_prefix, calculators: calculators).report
|
44
|
+
Attractor::HtmlReporter.new(file_prefix: file_prefix, calculators: calculators, open_browser: open_browser).report
|
42
45
|
else
|
43
|
-
Attractor::HtmlReporter.new(file_prefix: file_prefix, calculators: calculators).report
|
46
|
+
Attractor::HtmlReporter.new(file_prefix: file_prefix, calculators: calculators, open_browser: open_browser).report
|
44
47
|
end
|
45
48
|
end
|
46
49
|
rescue RuntimeError => e
|
@@ -52,18 +55,21 @@ module Attractor
|
|
52
55
|
option :file_prefix, aliases: :p
|
53
56
|
option :watch, aliases: :w, type: :boolean
|
54
57
|
option :type, aliases: :t
|
58
|
+
option :no_open_browser, type: :boolean
|
59
|
+
option :ci, type: :boolean
|
55
60
|
def serve
|
56
61
|
file_prefix = options[:file_prefix]
|
62
|
+
open_browser = !(options[:no_open_browser] || options[:ci])
|
57
63
|
calculators = Attractor.calculators_for_type(options[:type], file_prefix)
|
58
64
|
if options[:watch]
|
59
65
|
puts 'Listening for file changes...'
|
60
|
-
Attractor::SinatraReporter.new(file_prefix: file_prefix, calculators: calculators).watch
|
66
|
+
Attractor::SinatraReporter.new(file_prefix: file_prefix, calculators: calculators, open_browser: open_browser).watch
|
61
67
|
else
|
62
68
|
case options[:format]
|
63
69
|
when 'html'
|
64
|
-
Attractor::SinatraReporter.new(file_prefix: file_prefix, calculators: calculators).report
|
70
|
+
Attractor::SinatraReporter.new(file_prefix: file_prefix, calculators: calculators, open_browser: open_browser).report
|
65
71
|
else
|
66
|
-
Attractor::SinatraReporter.new(file_prefix: file_prefix, calculators: calculators).report
|
72
|
+
Attractor::SinatraReporter.new(file_prefix: file_prefix, calculators: calculators, open_browser: open_browser).report
|
67
73
|
end
|
68
74
|
end
|
69
75
|
end
|
@@ -12,9 +12,10 @@ module Attractor
|
|
12
12
|
attr_accessor :values, :file_prefix
|
13
13
|
def_delegator :@watcher, :watch
|
14
14
|
|
15
|
-
def initialize(file_prefix: '', calculators:)
|
15
|
+
def initialize(file_prefix: '', calculators:, open_browser: true)
|
16
16
|
@file_prefix = file_prefix
|
17
17
|
@calculators = calculators
|
18
|
+
@open_browser = open_browser
|
18
19
|
@values = @calculators.first.last.calculate
|
19
20
|
@suggester = Suggester.new(values)
|
20
21
|
|
@@ -22,7 +22,10 @@ module Attractor
|
|
22
22
|
File.open('./attractor_output/index.html', 'w') { |file| file.write(render) }
|
23
23
|
puts "Generated HTML report at #{File.expand_path './attractor_output/index.html'}"
|
24
24
|
|
25
|
-
|
25
|
+
if @open_browser
|
26
|
+
Launchy.open(File.expand_path('./attractor_output/index.html'))
|
27
|
+
puts "Opening browser window..."
|
28
|
+
end
|
26
29
|
end
|
27
30
|
|
28
31
|
def logo
|
@@ -47,7 +47,11 @@ module Attractor
|
|
47
47
|
app = AttractorApp.new(self)
|
48
48
|
|
49
49
|
puts 'Serving attractor at http://localhost:7890'
|
50
|
-
|
50
|
+
|
51
|
+
if @open_browser
|
52
|
+
Launchy.open('http://localhost:7890') if @open_browser
|
53
|
+
puts "Opening browser window..."
|
54
|
+
end
|
51
55
|
|
52
56
|
Rack::Handler::WEBrick.run app, Port: 7890
|
53
57
|
end
|
@@ -58,7 +62,10 @@ module Attractor
|
|
58
62
|
app = AttractorApp.new(self)
|
59
63
|
|
60
64
|
puts 'Serving attractor at http://localhost:7890'
|
61
|
-
|
65
|
+
if @open_browser
|
66
|
+
Launchy.open('http://localhost:7890')
|
67
|
+
puts "Opening browser window..."
|
68
|
+
end
|
62
69
|
|
63
70
|
Rack::Handler::WEBrick.run Rack::LiveReload.new(app), Port: 7890
|
64
71
|
end
|
data/lib/attractor/version.rb
CHANGED