Class: Poke::CurlParser
- Inherits:
-
Object
- Object
- Poke::CurlParser
- Defined in:
- lib/poke/curl_parser.rb
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
Returns the value of attribute arguments.
-
#comments ⇒ Object
readonly
Returns the value of attribute comments.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #add_argument(arg) ⇒ Object
-
#initialize(content) ⇒ CurlParser
constructor
A new instance of CurlParser.
- #remove_argument(pattern) ⇒ Object
- #replace_argument(pattern, replacement) ⇒ Object
- #to_command ⇒ Object
- #to_command_with_line_continuation ⇒ Object
Constructor Details
#initialize(content) ⇒ CurlParser
Returns a new instance of CurlParser.
9 10 11 12 13 14 15 |
# File 'lib/poke/curl_parser.rb', line 9 def initialize(content) @content = content @comments = [] @arguments = [] @url = nil parse end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
Returns the value of attribute arguments.
7 8 9 |
# File 'lib/poke/curl_parser.rb', line 7 def arguments @arguments end |
#comments ⇒ Object (readonly)
Returns the value of attribute comments.
7 8 9 |
# File 'lib/poke/curl_parser.rb', line 7 def comments @comments end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/poke/curl_parser.rb', line 7 def url @url end |
Instance Method Details
#add_argument(arg) ⇒ Object
33 34 35 |
# File 'lib/poke/curl_parser.rb', line 33 def add_argument(arg) @arguments << arg end |
#remove_argument(pattern) ⇒ Object
37 38 39 |
# File 'lib/poke/curl_parser.rb', line 37 def remove_argument(pattern) @arguments.reject! { |arg| arg.match?(pattern) } end |
#replace_argument(pattern, replacement) ⇒ Object
41 42 43 44 45 |
# File 'lib/poke/curl_parser.rb', line 41 def replace_argument(pattern, replacement) @arguments.map! do |arg| arg.match?(pattern) ? replacement : arg end end |
#to_command ⇒ Object
17 18 19 20 21 22 |
# File 'lib/poke/curl_parser.rb', line 17 def to_command parts = ['curl'] parts.concat(@arguments) parts << @url if @url parts.join(' ') end |
#to_command_with_line_continuation ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/poke/curl_parser.rb', line 24 def to_command_with_line_continuation parts = ['curl'] parts.concat(@arguments) parts << @url if @url # Join with line continuation for better readability parts.join(" \\\n ") end |