probedock-ruby 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/probe_dock_ruby.rb +1 -1
- data/lib/probe_dock_ruby/annotation.rb +86 -0
- data/lib/probe_dock_ruby/config.rb +0 -9
- data/lib/probe_dock_ruby/test_result.rb +25 -5
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30bec889e68d731bcf7b79db7770994cb1fa3778
|
4
|
+
data.tar.gz: ee91a1b9033170aaccfe37c4eb94dd97e004ef51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d34a3fc3b26926bf1d13849b066b49f24bd817210b7bc98de5180d304a27597448e6705d486d7c59be59822083b94f5859c8c2f7836bbc496a6fa6281fe78153
|
7
|
+
data.tar.gz: 1a4a2a778672e65fd8349a0cc45928b8d3fc755f0ac87077cc1b52c002b379de39f7f7d1d4cb84bf8313ab1f004173a3528e40906e7274da97f5e2e1e2d6c1ab
|
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/lib/probe_dock_ruby.rb
CHANGED
@@ -0,0 +1,86 @@
|
|
1
|
+
module ProbeDockProbe
|
2
|
+
class Annotation
|
3
|
+
BASE_REGEXP_STRING = '@probedock\(([^\(\)]*)\)'
|
4
|
+
ANNOTATION_REGEXP = /#{BASE_REGEXP_STRING}/
|
5
|
+
STRIP_ANNOTATION_REGEXP = /\s*#{BASE_REGEXP_STRING}/
|
6
|
+
|
7
|
+
attr_reader :key, :category, :tags, :tickets, :active
|
8
|
+
|
9
|
+
def initialize(str)
|
10
|
+
parse(str)
|
11
|
+
end
|
12
|
+
|
13
|
+
def merge!(annotation)
|
14
|
+
@key = annotation.key if annotation.key
|
15
|
+
@category = annotation.category if annotation.category
|
16
|
+
@active = annotation.active unless annotation.active.nil?
|
17
|
+
@tags = (@tags + annotation.tags).compact.collect(&:to_s).uniq
|
18
|
+
@tickets = (@tickets + annotation.tickets).compact.collect(&:to_s).uniq
|
19
|
+
self
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.strip_annotations(test_name)
|
23
|
+
test_name.gsub(STRIP_ANNOTATION_REGEXP, '')
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def parse(str)
|
29
|
+
@key = nil
|
30
|
+
@category = nil
|
31
|
+
@tags = []
|
32
|
+
@tickets = []
|
33
|
+
@active = nil
|
34
|
+
|
35
|
+
loop do
|
36
|
+
match = str.match(ANNOTATION_REGEXP)
|
37
|
+
|
38
|
+
if match
|
39
|
+
text = match[1]
|
40
|
+
|
41
|
+
if text.match(/^[a-z0-9]+$/)
|
42
|
+
@key = text
|
43
|
+
else
|
44
|
+
@key = parse_annotation_value(text, 'key')
|
45
|
+
@category = parse_annotation_value(text, 'category')
|
46
|
+
parse_annotation_list(text, 'tag', @tags)
|
47
|
+
parse_annotation_list(text, 'ticket', @tickets)
|
48
|
+
|
49
|
+
active = text.match(/active=["']?(1|0|true|false|yes|no|t|f|y|n)["']?/i)
|
50
|
+
if active
|
51
|
+
@active = !active[1].match(/^(1|y|yes|t|true)$/i).nil?
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
str = str.sub(ANNOTATION_REGEXP, '')
|
56
|
+
else
|
57
|
+
break
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def keyword_regexp(keyword)
|
63
|
+
/#{keyword}=(?:(?<#{keyword}>[^"'\s]+)|["']?(?<#{keyword}>[^"']+)["']?)/
|
64
|
+
end
|
65
|
+
|
66
|
+
def parse_annotation_value(text, keyword)
|
67
|
+
match = text.match(keyword_regexp(keyword))
|
68
|
+
match ? match[keyword] : nil
|
69
|
+
end
|
70
|
+
|
71
|
+
def parse_annotation_list(text, keyword, values)
|
72
|
+
regexp = keyword_regexp(keyword)
|
73
|
+
|
74
|
+
loop do
|
75
|
+
match = text.match(regexp)
|
76
|
+
|
77
|
+
if match
|
78
|
+
values.push(match[keyword]) unless values.include?(match[keyword])
|
79
|
+
text = text.sub(regexp, '')
|
80
|
+
end
|
81
|
+
|
82
|
+
break unless match
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ProbeDockProbe
|
2
2
|
class TestResult
|
3
|
-
attr_reader :key, :fingerprint, :name, :category, :tags, :tickets, :data, :duration, :message
|
3
|
+
attr_reader :key, :fingerprint, :name, :category, :active, :tags, :tickets, :data, :duration, :message
|
4
4
|
|
5
5
|
def initialize project, options = {}
|
6
6
|
|
@@ -14,15 +14,34 @@ module ProbeDockProbe
|
|
14
14
|
raise Error, "The :duration options is required (indicates how long it took to run the test)"
|
15
15
|
end
|
16
16
|
|
17
|
-
@key = options[:key]
|
18
17
|
@fingerprint = options[:fingerprint]
|
18
|
+
|
19
19
|
@name = options[:name].to_s
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
@
|
21
|
+
annotation = Annotation.new('')
|
22
|
+
|
23
|
+
if @name.match(Annotation::ANNOTATION_REGEXP)
|
24
|
+
annotation.merge!(Annotation.new(@name))
|
25
|
+
@name = Annotation.strip_annotations(@name)
|
26
|
+
end
|
27
|
+
|
28
|
+
options_annotation = options[:annotation]
|
29
|
+
options_annotation = Annotation.new(options_annotation) if options_annotation.kind_of?(String)
|
30
|
+
annotation.merge!(options_annotation) if options_annotation
|
31
|
+
|
32
|
+
@key = options[:key] || annotation.key
|
33
|
+
@category = options[:category] || annotation.category || project.category
|
34
|
+
@tags = (wrap(options[:tags]) + wrap(annotation.tags) + wrap(project.tags)).compact.collect(&:to_s).uniq
|
35
|
+
@tickets = (wrap(options[:tickets]) + wrap(annotation.tickets) + wrap(project.tickets)).compact.collect(&:to_s).uniq
|
24
36
|
|
25
37
|
@passed = !!options[:passed]
|
38
|
+
|
39
|
+
if !options[:active].nil?
|
40
|
+
@active = options[:active]
|
41
|
+
elsif !annotation.active.nil?
|
42
|
+
@active = annotation.active
|
43
|
+
end
|
44
|
+
|
26
45
|
@duration = options[:duration]
|
27
46
|
@message = options[:message]
|
28
47
|
|
@@ -44,6 +63,7 @@ module ProbeDockProbe
|
|
44
63
|
h['m'] = @message if @message
|
45
64
|
h['n'] = @name.length > 255 ? "#{@name[0, 252]}..." : @name
|
46
65
|
h['c'] = @category
|
66
|
+
h['v'] = @active unless @active.nil?
|
47
67
|
h['g'] = @tags
|
48
68
|
h['t'] = @tickets
|
49
69
|
h['a'] = @data
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: probedock-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Oulevay (Alpha Hydrae)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -193,6 +193,7 @@ files:
|
|
193
193
|
- README.md
|
194
194
|
- VERSION
|
195
195
|
- lib/probe_dock_ruby.rb
|
196
|
+
- lib/probe_dock_ruby/annotation.rb
|
196
197
|
- lib/probe_dock_ruby/client.rb
|
197
198
|
- lib/probe_dock_ruby/config.rb
|
198
199
|
- lib/probe_dock_ruby/project.rb
|
@@ -222,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
223
|
version: '0'
|
223
224
|
requirements: []
|
224
225
|
rubyforge_project:
|
225
|
-
rubygems_version: 2.4.
|
226
|
+
rubygems_version: 2.4.6
|
226
227
|
signing_key:
|
227
228
|
specification_version: 4
|
228
229
|
summary: Ruby library to develop new probes for Probe Dock.
|