Class: MrMurano::Mock
- Inherits:
-
Object
- Object
- MrMurano::Mock
- Defined in:
- lib/MrMurano/Mock.rb
Instance Attribute Summary collapse
-
#testpoint_file ⇒ Object
Returns the value of attribute testpoint_file.
-
#uuid ⇒ Object
Returns the value of attribute uuid.
Instance Method Summary collapse
- #create_testpoint ⇒ Object
-
#initialize ⇒ Mock
constructor
A new instance of Mock.
- #mock_template ⇒ Object
- #mock_template_path ⇒ Object
- #remove_testpoint ⇒ Object
- #show ⇒ Object
- #testpoint_path ⇒ Object
Constructor Details
#initialize ⇒ Mock
Returns a new instance of Mock.
16 17 |
# File 'lib/MrMurano/Mock.rb', line 16 def initialize end |
Instance Attribute Details
#testpoint_file ⇒ Object
Returns the value of attribute testpoint_file.
14 15 16 |
# File 'lib/MrMurano/Mock.rb', line 14 def testpoint_file @testpoint_file end |
#uuid ⇒ Object
Returns the value of attribute uuid.
14 15 16 |
# File 'lib/MrMurano/Mock.rb', line 14 def uuid @uuid end |
Instance Method Details
#create_testpoint ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/MrMurano/Mock.rb', line 51 def create_testpoint uuid = SecureRandom.uuid template = ERB.new(mock_template) endpoint = template.result(binding) Pathname.new(testpoint_path).open('wb') do |io| io << endpoint end uuid end |
#mock_template ⇒ Object
36 37 38 39 |
# File 'lib/MrMurano/Mock.rb', line 36 def mock_template path = mock_template_path ::File.read(path) end |
#mock_template_path ⇒ Object
47 48 49 |
# File 'lib/MrMurano/Mock.rb', line 47 def mock_template_path ::File.join(::File.dirname(__FILE__), 'template', 'mock.erb') end |
#remove_testpoint ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/MrMurano/Mock.rb', line 62 def remove_testpoint file = Pathname.new(testpoint_path) if file.exist? file.unlink return true end false end |
#show ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/MrMurano/Mock.rb', line 19 def show file = Pathname.new(testpoint_path) if file.exist? = %(if request.headers["authorization"] == ") file.open('rb') do |io| io.each_line do |line| auth_line = line.include?() if auth_line capture = /\=\= "(.*)"/.match(line) return capture.captures[0] end end end end false end |
#testpoint_path ⇒ Object
41 42 43 44 45 |
# File 'lib/MrMurano/Mock.rb', line 41 def testpoint_path file_name = 'testpoint.post.lua' path = %(#{$cfg['location.endpoints']}/#{file_name}) path end |