Class: Insta::Configuration
- Inherits:
-
Object
- Object
- Insta::Configuration
- Defined in:
- lib/insta/configuration.rb,
sig/insta/configuration.rbs
Instance Attribute Summary collapse
-
#ci_mode ⇒ Symbol
: Symbol.
-
#default_serializer ⇒ Symbol
: Symbol.
-
#diff_color ⇒ Symbol
: Symbol.
-
#diff_display ⇒ Symbol
: Symbol.
-
#diff_width ⇒ Integer?
: Integer?.
-
#heredoc_identifier ⇒ String
: String.
-
#new_snapshot ⇒ Symbol
: Symbol.
-
#snapshot_directory ⇒ ^(test_class: String) -> String?
: (^(test_class: String) -> String)?.
-
#snapshot_extension ⇒ String
: String.
-
#snapshot_filename ⇒ snapshot_filename_resolver?
: snapshot_filename_resolver?.
-
#snapshot_path ⇒ String
@rbs! type snapshot_filename_resolver = ^(test_name: String, counter: Integer, options: Hash[Symbol, untyped]) -> String.
-
#snapshot_sanitizer ⇒ ^(String) -> String?
: (^(String) -> String)?.
-
#update_mode ⇒ Symbol
: Symbol.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
: () -> void.
-
#resolved_ci_mode? ⇒ Boolean
: () -> bool.
-
#resolved_diff_color ⇒ String
: () -> String.
-
#resolved_diff_display ⇒ String
: () -> String.
-
#resolved_update_mode ⇒ Symbol
: () -> Symbol.
Constructor Details
#initialize ⇒ Configuration
: () -> void
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/insta/configuration.rb', line 24 def initialize @snapshot_path = "test/snapshots" @diff_display = :side_by_side @diff_width = nil @diff_color = :auto @update_mode = :auto @default_serializer = :to_s @heredoc_identifier = "SNAP" @ci_mode = :auto @snapshot_extension = ".snap" @snapshot_sanitizer = nil @snapshot_filename = nil @snapshot_directory = nil @new_snapshot = :review end |
Instance Attribute Details
#ci_mode ⇒ Symbol
: Symbol
16 17 18 |
# File 'lib/insta/configuration.rb', line 16 def ci_mode @ci_mode end |
#default_serializer ⇒ Symbol
: Symbol
14 15 16 |
# File 'lib/insta/configuration.rb', line 14 def default_serializer @default_serializer end |
#diff_color ⇒ Symbol
: Symbol
12 13 14 |
# File 'lib/insta/configuration.rb', line 12 def diff_color @diff_color end |
#diff_display ⇒ Symbol
: Symbol
10 11 12 |
# File 'lib/insta/configuration.rb', line 10 def diff_display @diff_display end |
#diff_width ⇒ Integer?
: Integer?
11 12 13 |
# File 'lib/insta/configuration.rb', line 11 def diff_width @diff_width end |
#heredoc_identifier ⇒ String
: String
15 16 17 |
# File 'lib/insta/configuration.rb', line 15 def heredoc_identifier @heredoc_identifier end |
#new_snapshot ⇒ Symbol
: Symbol
21 22 23 |
# File 'lib/insta/configuration.rb', line 21 def new_snapshot @new_snapshot end |
#snapshot_directory ⇒ ^(test_class: String) -> String?
: (^(test_class: String) -> String)?
20 21 22 |
# File 'lib/insta/configuration.rb', line 20 def snapshot_directory @snapshot_directory end |
#snapshot_extension ⇒ String
: String
17 18 19 |
# File 'lib/insta/configuration.rb', line 17 def snapshot_extension @snapshot_extension end |
#snapshot_filename ⇒ snapshot_filename_resolver?
: snapshot_filename_resolver?
19 20 21 |
# File 'lib/insta/configuration.rb', line 19 def snapshot_filename @snapshot_filename end |
#snapshot_path ⇒ String
@rbs! type snapshot_filename_resolver = ^(test_name: String, counter: Integer, options: Hash[Symbol, untyped]) -> String
9 10 11 |
# File 'lib/insta/configuration.rb', line 9 def snapshot_path @snapshot_path end |
#snapshot_sanitizer ⇒ ^(String) -> String?
: (^(String) -> String)?
18 19 20 |
# File 'lib/insta/configuration.rb', line 18 def snapshot_sanitizer @snapshot_sanitizer end |
#update_mode ⇒ Symbol
: Symbol
13 14 15 |
# File 'lib/insta/configuration.rb', line 13 def update_mode @update_mode end |
Instance Method Details
#resolved_ci_mode? ⇒ Boolean
: () -> bool
59 60 61 62 63 64 65 |
# File 'lib/insta/configuration.rb', line 59 def resolved_ci_mode? case @ci_mode when :auto then CI.ci? when true then true else false end end |
#resolved_diff_color ⇒ String
: () -> String
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/insta/configuration.rb', line 68 def resolved_diff_color return "never" if ENV.key?("NO_COLOR") case @diff_color when :always then "always" when :never then "never" when :auto $stdout.tty? ? "always" : "never" else "auto" end end |
#resolved_diff_display ⇒ String
: () -> String
82 83 84 85 86 87 |
# File 'lib/insta/configuration.rb', line 82 def resolved_diff_display case @diff_display when :inline then "inline" else "side-by-side-show-both" end end |
#resolved_update_mode ⇒ Symbol
: () -> Symbol
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/insta/configuration.rb', line 41 def resolved_update_mode if ENV["INSTA_UPDATE"] case ENV.fetch("INSTA_UPDATE", nil) when "always", "force" then :force when "new" then :new when "no" then :no else :auto end elsif ENV["INSTA_FORCE_PASS"] :pending elsif resolved_ci_mode? :no else @update_mode end end |