attractor 1.0.1 → 1.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3f38396b22816a7fb22cf0c142cfbc88f719627fe817eb800a9ad0112198bbe4
4
- data.tar.gz: e3195fbb97ca495deaea5fc3de7a2e4bf9e54429e66a657e38c59b6c409ca217
3
+ metadata.gz: 11835b70ba787d947df52990eb130dd226a33dca6081905d3d8358e87d8425fa
4
+ data.tar.gz: 5d6908e051be5d673b98d331d6e7549df112652b133918621ba4ed7d022f1e1b
5
5
  SHA512:
6
- metadata.gz: 68267925faaa4210932f3c5bc5eb50199630ea693b616294bbcd30afb6df47b968bf0d6b7bcc5968279f96b95eed27f35d5d6bf218b67baeb72109f2572976f4
7
- data.tar.gz: 352aed4e99d5b864274915b842493d3b984f1f59836b3f076f248c33809b90c5609b6b449a92f00117cff26393175ed1e8f40eca7e7458633a70f5d1e04fdc11
6
+ metadata.gz: 7aa8164fb88a2addaf36f180cfca2e58701c5700fc5a61111fd4cf11a6b3506f4b2d19645befc3f7f9dd39604e4339de2fc28b4d97d41997a549f02ed318c331
7
+ data.tar.gz: 5cccb6fa1fbf7b55d01a1473b3d6303cb509ae7914b97d55b08899661983112c041cfd35d125dbea2393defe0a83fea21c2a49423f60a2f1745bc973dab5b996
@@ -1,3 +1,7 @@
1
+ ## RELEASE 1.0.2
2
+
3
+ * ENHANCEMENT: make launching of browser optional
4
+
1
5
  ## RELEASE 1.0.1
2
6
 
3
7
  * FIX: fix sinatra reporter
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
 
@@ -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
- Launchy.open(File.expand_path('./attractor_output/index.html'))
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
- Launchy.open('http://localhost:7890')
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
- Launchy.open('http://localhost:7890')
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
@@ -1,3 +1,3 @@
1
1
  module Attractor
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Rubisch