Class: Simulacrum::Component
- Inherits:
-
Object
- Object
- Simulacrum::Component
- Defined in:
- lib/simulacrum/component.rb
Instance Attribute Summary collapse
-
#browser ⇒ Object
readonly
Returns the value of attribute browser.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #acceptable_delta ⇒ Object
- #candidate? ⇒ Boolean
- #candidate_path ⇒ Object
- #diff? ⇒ Boolean
- #diff_path ⇒ Object
-
#initialize(name, options = {}) ⇒ Component
constructor
A new instance of Component.
- #reference? ⇒ Boolean
- #reference_path ⇒ Object
- #remove_candidate ⇒ Object
- #remove_diff ⇒ Object
-
#render ⇒ Object
Load up the component url and capture an image, returns a File object.
Constructor Details
#initialize(name, options = {}) ⇒ Component
Returns a new instance of Component.
11 12 13 14 15 |
# File 'lib/simulacrum/component.rb', line 11 def initialize(name, = {}) @name = name @options = @renderer = Simulacrum::Renderer.new(.url) end |
Instance Attribute Details
#browser ⇒ Object (readonly)
Returns the value of attribute browser.
8 9 10 |
# File 'lib/simulacrum/component.rb', line 8 def browser @browser end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/simulacrum/component.rb', line 8 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
9 10 11 |
# File 'lib/simulacrum/component.rb', line 9 def @options end |
Instance Method Details
#acceptable_delta ⇒ Object
38 39 40 |
# File 'lib/simulacrum/component.rb', line 38 def acceptable_delta .acceptable_delta || Simulacrum.configuration.acceptable_delta end |
#candidate? ⇒ Boolean
30 31 32 |
# File 'lib/simulacrum/component.rb', line 30 def candidate? File.exists?(candidate_path) end |
#candidate_path ⇒ Object
47 48 49 50 |
# File 'lib/simulacrum/component.rb', line 47 def candidate_path filename = Simulacrum.configuration.candidate_filename File.join(root_path, "#{filename}.png") end |
#diff? ⇒ Boolean
34 35 36 |
# File 'lib/simulacrum/component.rb', line 34 def diff? File.exists?(diff_path) end |
#diff_path ⇒ Object
52 53 54 55 |
# File 'lib/simulacrum/component.rb', line 52 def diff_path filename = Simulacrum.configuration.diff_filename File.join(root_path, "#{filename}.png") end |
#reference? ⇒ Boolean
26 27 28 |
# File 'lib/simulacrum/component.rb', line 26 def reference? File.exists?(reference_path) end |
#reference_path ⇒ Object
42 43 44 45 |
# File 'lib/simulacrum/component.rb', line 42 def reference_path filename = Simulacrum.configuration.reference_filename File.join(root_path, "#{filename}.png") end |
#remove_candidate ⇒ Object
57 58 59 |
# File 'lib/simulacrum/component.rb', line 57 def remove_candidate FileUtils.rm(candidate_path) if candidate? end |
#remove_diff ⇒ Object
61 62 63 |
# File 'lib/simulacrum/component.rb', line 61 def remove_diff FileUtils.rm(diff_path) if diff? end |
#render ⇒ Object
Load up the component url and capture an image, returns a File object
18 19 20 21 22 23 24 |
# File 'lib/simulacrum/component.rb', line 18 def render ensure_example_path save_candidate(@renderer.render) crop_candidate_to_selector ensure cleanup end |