rocket_fuel 0.0.1 → 0.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
  SHA1:
3
- metadata.gz: b2b732a640edd303e1eb042f58222a07b00c3070
4
- data.tar.gz: cb1593ddd42da275b2d15724d0f4d36ee934f7a3
3
+ metadata.gz: 270c8d2e9833cff50010fcb862b829bc00a12a09
4
+ data.tar.gz: 3e73a408b265179b4ccade761b9c492ff63c783f
5
5
  SHA512:
6
- metadata.gz: 21f0ed99469e6f0ca1b470713b51f1a27588f6dcd9ba257c075e7dd37c7220594ebe826fcc30535f939fccf4406ea23f0b40a82ea513fe700d288897f3350853
7
- data.tar.gz: 6882d0a7211428262167273e4a8b75b542cdfe141c9180d5643f04c4df7995663f2e43d23f10742ea35081b38be9d18c3f989ecdd7066ec3374dc53e085d6f73
6
+ metadata.gz: 9331a7e0b37987c513ca6cb989dfe8be6208f0d4e70cb9c32cd8f05544083a34e1c857ae20c1bf20938b826e856b66f4897ba03dc587c0a927527bd83e782d9f
7
+ data.tar.gz: 475438f7135146553fc8bb75eb1c9792f8b8349360efe5ed0eeab142f8ef914680849b23b8915b758d13a5c81a25be33fcb8587386177388b2858057055c9640
@@ -0,0 +1,16 @@
1
+ module RocketFuel
2
+ class CommandLineIcon
3
+ def initialize(icon, fallback = '')
4
+ @icon, @fallback = icon, fallback
5
+ end
6
+
7
+ def render
8
+ fallback? ? @fallback : @icon
9
+ end
10
+
11
+ #we must handle for ruby 1.8 without iconv
12
+ def fallback?
13
+ !@icon.respond_to?(:encode)
14
+ end
15
+ end
16
+ end
@@ -1,23 +1,33 @@
1
+ require 'rocket_fuel/command_line_icon'
2
+
1
3
  module RocketFuel
2
4
  module Precheck
3
5
  class CommandLineResultPresenter
4
6
  include Thor::Base
5
7
 
6
- SUCCESS_ICON = "\u2713".encode('utf-8')
7
- FAILURE_ICON = "\u00D7".encode('utf-8')
8
+ SUCCESS_ICON = ["\u2713", '[ok] ']
9
+ FAILURE_ICON = ["\u00D7", '[failed]']
8
10
 
9
11
  def initialize(result)
10
12
  @result = result
11
13
  end
12
14
 
13
15
  def present
14
- print_wrapped(set_color([icon, @result.message].join(" "), color),
16
+ print_wrapped(set_color([icon.render, @result.message].join(" "), color),
15
17
  :indent => 2)
16
18
  end
17
19
 
18
20
  protected
19
21
  def icon
20
- @result.ok? ? SUCCESS_ICON : FAILURE_ICON
22
+ @result.ok? ? success_icon : failure_icon
23
+ end
24
+
25
+ def success_icon
26
+ @success_icon ||= RocketFuel::CommandLineIcon.new(*SUCCESS_ICON)
27
+ end
28
+
29
+ def failure_icon
30
+ @failure_icon ||= RocketFuel::CommandLineIcon.new(*FAILURE_ICON)
21
31
  end
22
32
 
23
33
  def color
@@ -1,3 +1,3 @@
1
1
  module RocketFuel
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ require 'rocket_fuel/command_line_icon'
4
+
5
+ describe RocketFuel::CommandLineIcon do
6
+ let(:utf_char) { "\u2713" }
7
+ let(:fallback) { '[ok]' }
8
+
9
+ let(:icon) { RocketFuel::CommandLineIcon.new(utf_char, fallback) }
10
+
11
+ it 'renders the fallback if encoding is not supported' do
12
+ icon.expects(:fallback?).returns(true)
13
+ expect(icon.render).to eq(fallback)
14
+ end
15
+
16
+ it 'renders the icon if encoding is supported' do
17
+ expect(icon.render).to eq(utf_char.encode('utf-8'))
18
+ end
19
+ end
@@ -4,11 +4,11 @@ require 'rocket_fuel/precheck/command_line_result_presenter'
4
4
 
5
5
  describe RocketFuel::Precheck::CommandLineResultPresenter do
6
6
  let(:success_icon) do
7
- RocketFuel::Precheck::CommandLineResultPresenter::SUCCESS_ICON
7
+ RocketFuel::Precheck::CommandLineResultPresenter::SUCCESS_ICON[0]
8
8
  end
9
9
 
10
10
  let(:failure_icon) do
11
- RocketFuel::Precheck::CommandLineResultPresenter::FAILURE_ICON
11
+ RocketFuel::Precheck::CommandLineResultPresenter::FAILURE_ICON[0]
12
12
  end
13
13
 
14
14
  it 'includes the message' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rocket_fuel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Pickett
@@ -110,6 +110,7 @@ files:
110
110
  - Rakefile
111
111
  - bin/rocket_fuel
112
112
  - lib/rocket_fuel.rb
113
+ - lib/rocket_fuel/command_line_icon.rb
113
114
  - lib/rocket_fuel/command_line_interface.rb
114
115
  - lib/rocket_fuel/fix.rb
115
116
  - lib/rocket_fuel/fix/abstract_fix.rb
@@ -136,6 +137,7 @@ files:
136
137
  - lib/rocket_fuel/system_details.rb
137
138
  - lib/rocket_fuel/version.rb
138
139
  - rocket_fuel.gemspec
140
+ - spec/rocket_fuel/command_line_icon_spec.rb
139
141
  - spec/rocket_fuel/fix/command_line_tools/dmg_metadata_spec.rb
140
142
  - spec/rocket_fuel/fix/command_line_tools/download_spec.rb
141
143
  - spec/rocket_fuel/fix/macports_fix_spec.rb
@@ -177,6 +179,7 @@ signing_key:
177
179
  specification_version: 4
178
180
  summary: A ruby client for installing rocket fuel
179
181
  test_files:
182
+ - spec/rocket_fuel/command_line_icon_spec.rb
180
183
  - spec/rocket_fuel/fix/command_line_tools/dmg_metadata_spec.rb
181
184
  - spec/rocket_fuel/fix/command_line_tools/download_spec.rb
182
185
  - spec/rocket_fuel/fix/macports_fix_spec.rb