Class: Generator::Path
- Inherits:
- 
      Object
      
        - Object
- Generator::Path
 
- Defined in:
- lib/generator/parsers/path.rb
Constant Summary collapse
- HTTP_METHODS =
- ["delete", "get", "patch", "post", "put"].freeze 
Instance Attribute Summary collapse
- 
  
    
      #methods  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute methods. 
Instance Method Summary collapse
- #has_dynamic_sandbox? ⇒ Boolean
- 
  
    
      #initialize(path, methods)  ⇒ Path 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Path. 
- #operations(api_name_with_version) ⇒ Object
- #parameters ⇒ Object
- #path ⇒ Object
- #sandbox_only? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(path, methods) ⇒ Path
Returns a new instance of Path.
| 11 12 13 14 | # File 'lib/generator/parsers/path.rb', line 11 def initialize(path, methods) @path = path @methods = methods end | 
Instance Attribute Details
#methods ⇒ Object (readonly)
Returns the value of attribute methods.
| 9 10 11 | # File 'lib/generator/parsers/path.rb', line 9 def methods @methods end | 
Instance Method Details
#has_dynamic_sandbox? ⇒ Boolean
| 38 39 40 | # File 'lib/generator/parsers/path.rb', line 38 def has_dynamic_sandbox? !!methods.dig("x-amzn-api-sandbox", "dynamic") end | 
#operations(api_name_with_version) ⇒ Object
| 16 17 18 19 20 | # File 'lib/generator/parsers/path.rb', line 16 def operations(api_name_with_version) methods.select { |k, _| HTTP_METHODS.include?(k) }.map do |method, operation| Operation.new(self, method, operation, api_name_with_version) end end | 
#parameters ⇒ Object
| 34 35 36 | # File 'lib/generator/parsers/path.rb', line 34 def parameters methods.fetch("parameters", []) end | 
#path ⇒ Object
| 26 27 28 29 30 31 32 | # File 'lib/generator/parsers/path.rb', line 26 def path # Use atomic grouping (?>...) to prevent ReDoS @path.gsub(/\{(?>([^}]+))\}/) do match = Regexp.last_match(1) or raise("No match found") "\#{percent_encode(#{match.underscore})}" end end | 
#sandbox_only? ⇒ Boolean
| 42 43 44 | # File 'lib/generator/parsers/path.rb', line 42 def sandbox_only? methods.key?("x-amzn-api-sandbox-only") end | 
#to_s ⇒ Object
| 22 23 24 | # File 'lib/generator/parsers/path.rb', line 22 def to_s path end |