Class: Phantasma::Helpers
- Inherits:
-
Object
- Object
- Phantasma::Helpers
- Defined in:
- lib/phantasma/helpers.rb
Class Method Summary collapse
- .camel_to_snake(str) ⇒ Object
-
.test_api_endpoints ⇒ Object
this is for linux system to check if any new endpoints vs ALLOWED_ENDPOINTS.
Class Method Details
.camel_to_snake(str) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/phantasma/helpers.rb', line 3 def self.camel_to_snake(str) if str.to_s.match(/NFT/) return str.to_s.gsub(/^([A-Z]{1}[a-z]+)([A-Z]+[a-z]?)$/, '\1_\2') .tr('-', '_') .downcase end str.to_s.gsub(/::/, '/') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase end |
.test_api_endpoints ⇒ Object
this is for linux system to check if any new endpoints vs ALLOWED_ENDPOINTS
17 18 19 20 21 |
# File 'lib/phantasma/helpers.rb', line 17 def self.test_api_endpoints cmd = `curl -v --silent https://testnet.phantasma.info/swagger/v1/swagger.json 2>&1 | grep -oP '(?<=\/api\/v1/)(.+)(?=\".+$)'` endpoints = cmd&.gsub(/\n/, ' ').strip.split(' ') endpoints&.push('rpc') end |