flow_project_manager 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b84dd9485ad5a477ab7519cf99d4ea2c0cbb6ea0
4
- data.tar.gz: 80e2f08b2e4ffdd0bf70dbc1cd2d6e73a5dfbb4a
3
+ metadata.gz: 6876dc1a9d216bb1919af8276961a339b08f6af9
4
+ data.tar.gz: c9d68542959a28d28041f5623c2cb855ace7e4eb
5
5
  SHA512:
6
- metadata.gz: 2d72ad62232fd9211aec317b7e033c98d19384c6aeacba5ce61df31fd9a35b43df2170afc7ab22de3fa6e3cdc03f18917e8ff9f3252e00b9da1f93b69adbe743
7
- data.tar.gz: 5a34be628b4b1db36159be69646498e8cc63ddb155d65f2909256a340339bda3ec0d8867850e5c7e265bae89e284eb68a2dc0bb47c00ead41be3a7330c6bf242
6
+ metadata.gz: 1058e0504dc6153c1c7c17946bb953248fa7b9ffada72415e3c93c94cb4007d638edc413a523587f9f4c5b2db8966626aae114689a35ec9fd0090fb2a2cc7981
7
+ data.tar.gz: 5572132b27dacd8abb6b07f550c68973c105694806832edad7da3cf4f39deca50ed1f6bae2691a8cd6d055087d3659570589b0a2b7cdcda8e939184df9b41587
@@ -29,5 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "webmock"
30
30
 
31
31
  spec.add_dependency "api_tools"
32
- spec.add_dependency "crack"
32
+ spec.add_dependency "nokogiri"
33
33
  end
@@ -1,6 +1,6 @@
1
1
  require 'api_tools'
2
- require "crack"
3
2
  require "json"
3
+ require_relative "../utils/junit_reader"
4
4
 
5
5
  module FlowApi
6
6
  class Rest < DefaultRest
@@ -11,7 +11,7 @@ module FlowApi
11
11
 
12
12
  def base_params
13
13
  {
14
- api_token: ENV["FLOW_PROJECT_API_TOKEN"]
14
+ project_api_token: ENV["FLOW_PROJECT_API_TOKEN"]
15
15
  }
16
16
  end
17
17
 
@@ -34,7 +34,7 @@ module FlowApi
34
34
  end
35
35
 
36
36
  def send_test_log_json(file_path)
37
- json_str = junit_file_to_hash(file_path).to_json
37
+ json_str = JunitReader.build_json_from_juniter(file_path).to_json
38
38
  FlowApi::Rest.send_log_json ENV["FLOW_PROJECT_ID"], ENV["FLOW_JOB_ID"], json_str
39
39
  end
40
40
  end
@@ -1,5 +1,6 @@
1
1
  require "flow_project_manager/version"
2
2
  require_relative "./flow_api/manager"
3
+ require_relative "./utils/junit_reader"
3
4
 
4
5
  module FlowProjectManager
5
6
  end
@@ -1,3 +1,3 @@
1
1
  module FlowProjectManager
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,59 @@
1
+ require 'nokogiri'
2
+
3
+ class JunitReader
4
+ class << self
5
+ def build_json_from_juniter(file_path)
6
+ answer = {}
7
+ xml = File.read(file_path)
8
+ doc = Nokogiri::XML(xml) do |config|
9
+ config.options = Nokogiri::XML::ParseOptions::NOBLANKS
10
+ end
11
+
12
+ root_element = doc.root
13
+ answer["name"] = root_element["name"]
14
+ answer["tests"] = root_element["tests"]
15
+ answer["failures"] = root_element["failures"]
16
+
17
+ testsuites = root_element.children.map do |element|
18
+ # Read testsuite
19
+ next if element.name != "testsuite"
20
+ read_test_suite( element )
21
+ end
22
+ testsuites.reject! {|m| m == nil}
23
+
24
+ answer["testsuites"] = testsuites
25
+ answer
26
+ end
27
+
28
+ def read_test_suite(element)
29
+ test_suite = {}
30
+ test_suite["name"] = element["name"]
31
+ test_suite["tests"] = element["tests"]
32
+ test_suite["failures"] = element["failures"]
33
+ testcases = element.children.map do |element_testcase|
34
+ # Read testcase
35
+ next if element_testcase.name != "testcase"
36
+ read_test_case(element_testcase)
37
+ end
38
+ testcases.reject! {|m| m == nil}
39
+
40
+ test_suite["testcases"] = testcases
41
+ test_suite
42
+ end
43
+
44
+ def read_test_case(element)
45
+ testcase = {}
46
+ testcase["classname"] = element["classname"]
47
+ testcase["name"] = element["name"]
48
+ testcase["time"] = element["time"]
49
+ failure_node = element.children.first
50
+ if failure_node && failure_node.name == "failure"
51
+ testcase["failure"] = {
52
+ message: failure_node["message"],
53
+ __content__: failure_node.text
54
+ }
55
+ end
56
+ testcase
57
+ end
58
+ end
59
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flow_project_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - atpking
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-23 00:00:00.000000000 Z
11
+ date: 2017-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -109,7 +109,7 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: crack
112
+ name: nokogiri
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
@@ -145,6 +145,7 @@ files:
145
145
  - lib/flow_api/manager.rb
146
146
  - lib/flow_project_manager.rb
147
147
  - lib/flow_project_manager/version.rb
148
+ - lib/utils/junit_reader.rb
148
149
  homepage: http://www.flow.ci
149
150
  licenses:
150
151
  - MIT