Class: PactBroker::Matrix::ParseQuery
- Inherits:
-
Object
- Object
- PactBroker::Matrix::ParseQuery
- Defined in:
- lib/pact_broker/matrix/parse_query.rb
Class Method Summary collapse
-
.call(query) ⇒ Object
rubocop: disable Metrics/CyclomaticComplexity rubocop: disable Metrics/MethodLength.
- .parse_selector(i) ⇒ Object
Class Method Details
.call(query) ⇒ Object
rubocop: disable Metrics/CyclomaticComplexity rubocop: disable Metrics/MethodLength
9 10 11 12 13 14 15 16 17 18 19 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 60 61 62 63 |
# File 'lib/pact_broker/matrix/parse_query.rb', line 9 def self.call query params = Rack::Utils.parse_nested_query(query) selectors = (params["q"] || []).collect do |i| parse_selector(i) end = {} if params.key?("success") && params["success"].is_a?(Array) [:success] = params["success"].collect do | value | value == "" ? nil : value == "true" end end if params.key?("success") && params["success"].is_a?(String) [:success] = [params["success"] == "" ? nil : params["success"] == "true"] end if params.key?("latestby") && params["latestby"] != "" [:latestby] = params["latestby"] end # Don't think this is used anywhere... if params.key?("days") && params["days"] != "" [:days] = params["days"].to_i end if params.key?("limit") && params["limit"] != "" [:limit] = params["limit"] else [:limit] = "100" end if params.key?("latest") && params["latest"] != "" [:latest] = params["latest"] == "true" end if params.key?("tag") && params["tag"] != "" [:tag] = params["tag"] end if params.key?("environment") && params["environment"] != "" [:environment_name] = params["environment"] end if params.key?("mainBranch") && params["mainBranch"] != "" [:main_branch] = params["mainBranch"] == "true" end if params["ignore"].is_a?(Array) [:ignore_selectors] = params["ignore"].collect{ |i| parse_selector(i) } else [:ignore_selectors] = [] end return selectors, end |
.parse_selector(i) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/pact_broker/matrix/parse_query.rb', line 65 def self.parse_selector(i) p = PactBroker::Matrix::UnresolvedSelector.new p.pacticipant_name = i["pacticipant"] if i["pacticipant"] && i["pacticipant"] != "" p.pacticipant_version_number = i["version"] if i["version"] && i["version"] != "" p.latest = true if i["latest"] == "true" p.branch = i["branch"] if i["branch"] && i["branch"] != "" p.tag = i["tag"] if i["tag"] && i["tag"] != "" p.environment_name = i["environment"] if i["environment"] && i["environment"] != "" p.main_branch = true if i["mainBranch"] && i["mainBranch"] == "true" p end |