Class: Stubby::Extensions::Default
- Inherits:
-
Object
- Object
- Stubby::Extensions::Default
- Defined in:
- lib/stubby/extensions/default.rb
Instance Method Summary collapse
- #expand_bare(trigger, instruction) ⇒ Object
- #expand_rule(trigger, instruction) ⇒ Object
- #expand_with_protocol(trigger, instruction) ⇒ Object
-
#initialize ⇒ Default
constructor
A new instance of Default.
- #restore!(*args) ⇒ Object
- #run!(*args) ⇒ Object
- #stop!(*args) ⇒ Object
Constructor Details
#initialize ⇒ Default
Returns a new instance of Default.
4 5 6 |
# File 'lib/stubby/extensions/default.rb', line 4 def initialize end |
Instance Method Details
#expand_bare(trigger, instruction) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/stubby/extensions/default.rb', line 61 def (trigger, instruction) { "dns://#{trigger}/a" => "dns-a://#{STUBBY_MASTER}", "http://#{trigger}" => "http-redirect://blank?to=https://#{trigger}&code=302", "https://#{trigger}" => "http-proxy://#{instruction}" } end |
#expand_rule(trigger, instruction) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/stubby/extensions/default.rb', line 20 def (trigger, instruction) # Default expansion: # "example.com": "localhost:3000" # # => # "dns://example.com": "@" # "http://example.com": "http-redirect://blank?to=https://example.com&code=302" # "https://example.com": "http-proxy://localhost:3000" # # "example.com:4000": "localhost:3000" # # => # ERROR: port in trigger unsupported # # "dns://example.com": "@" # "http://example.com:4000" # # "example.com": "http-redirect://localhost:3000" # # => # "dns://example.com": "@" # "http://example.com": "http-redirect://?blank?to=http://localhost:3000&code=302" # ===================================== # # ".*\\.stubby.dev": "file:///var/www/tmp # # => # # "dns://.*\\.stubby.dev": "@", # "http://.*\\.stubby.dev": "file:///var/www/tmp", # "https://.*\\.stubby.dev": "file:///var/www/tmp", scheme, remains = instruction.split("://") scheme, remains = remains, scheme if remains.nil? if scheme.nil? (trigger, instruction) else (trigger, instruction) end end |
#expand_with_protocol(trigger, instruction) ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/stubby/extensions/default.rb', line 69 def (trigger, instruction) { "dns://#{trigger}/a" => "dns-a://#{STUBBY_MASTER}", "http://#{trigger}" => instruction, "https://#{trigger}" => instruction } end |
#restore!(*args) ⇒ Object
16 17 18 |
# File 'lib/stubby/extensions/default.rb', line 16 def restore!(*args) end |
#run!(*args) ⇒ Object
8 9 10 |
# File 'lib/stubby/extensions/default.rb', line 8 def run!(*args) end |
#stop!(*args) ⇒ Object
12 13 14 |
# File 'lib/stubby/extensions/default.rb', line 12 def stop!(*args) end |