copperegg-revealmetrics 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -19
- data/lib/copperegg/revealmetrics.rb +17 -0
- data/lib/copperegg/revealmetrics/api.rb +28 -0
- data/lib/copperegg/revealmetrics/custom_dashboard.rb +142 -0
- data/lib/copperegg/revealmetrics/metric_group.rb +127 -0
- data/lib/copperegg/revealmetrics/metric_sample.rb +26 -0
- data/lib/copperegg/revealmetrics/mixins/persistence.rb +124 -0
- data/lib/copperegg/revealmetrics/tag.rb +97 -0
- data/lib/copperegg/revealmetrics/ver.rb +7 -0
- data/test/custom_dashboard_test.rb +28 -28
- data/test/metric_group_test.rb +11 -11
- data/test/metric_sample_test.rb +2 -2
- data/test/tag_test.rb +12 -12
- metadata +9 -9
- data/lib/copperegg.rb +0 -13
- data/lib/copperegg/api.rb +0 -24
- data/lib/copperegg/custom_dashboard.rb +0 -138
- data/lib/copperegg/metric_group.rb +0 -123
- data/lib/copperegg/metric_sample.rb +0 -22
- data/lib/copperegg/mixins/persistence.rb +0 -118
- data/lib/copperegg/tag.rb +0 -94
- data/lib/copperegg/ver.rb +0 -3
data/lib/copperegg/tag.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
module CopperEgg
|
2
|
-
class Tag
|
3
|
-
include CopperEgg::Mixins::Persistence
|
4
|
-
|
5
|
-
resource "tags"
|
6
|
-
|
7
|
-
attr_accessor :name, :objects
|
8
|
-
|
9
|
-
def load_attributes(attributes)
|
10
|
-
@objects_original = []
|
11
|
-
|
12
|
-
attributes.each do |name, value|
|
13
|
-
if name.to_s == "id"
|
14
|
-
@id = value
|
15
|
-
elsif !respond_to?("#{name}=")
|
16
|
-
next
|
17
|
-
elsif name.to_s == "objects"
|
18
|
-
@objects = value.map { |object| object["idv"].to_s.gsub(/\|$/, "") }
|
19
|
-
@objects_original = @objects.clone
|
20
|
-
else
|
21
|
-
send "#{name}=", value
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def name
|
27
|
-
@name || @id
|
28
|
-
end
|
29
|
-
|
30
|
-
def valid?
|
31
|
-
@error = nil
|
32
|
-
|
33
|
-
if self.name.nil? || self.name.to_s.strip.empty?
|
34
|
-
@error = "Name can't be blank."
|
35
|
-
return false
|
36
|
-
end
|
37
|
-
|
38
|
-
if self.name.to_s.match(/[^\w-]/)
|
39
|
-
@error = "Name contains invalid characters."
|
40
|
-
return false
|
41
|
-
end
|
42
|
-
|
43
|
-
if self.objects.nil? || self.objects.empty?
|
44
|
-
@error = "You must define at least one object."
|
45
|
-
return false
|
46
|
-
end
|
47
|
-
|
48
|
-
unless self.objects.kind_of?(Array)
|
49
|
-
@error = "Invalid objects field."
|
50
|
-
return false
|
51
|
-
end
|
52
|
-
|
53
|
-
if self.objects.any? { |object| !object.kind_of?(String) }
|
54
|
-
@error = "Invalid object identifier."
|
55
|
-
return false
|
56
|
-
end
|
57
|
-
|
58
|
-
true
|
59
|
-
end
|
60
|
-
|
61
|
-
def delete
|
62
|
-
self.class.request_200({:id => name, :request_type => "delete"})
|
63
|
-
end
|
64
|
-
|
65
|
-
def save
|
66
|
-
unless valid?
|
67
|
-
raise ValidationError.new(@error)
|
68
|
-
end
|
69
|
-
|
70
|
-
remove_objects(@objects_original - @objects)
|
71
|
-
add_objects(@objects - @objects_original)
|
72
|
-
@objects_original = @objects
|
73
|
-
end
|
74
|
-
|
75
|
-
def update
|
76
|
-
save
|
77
|
-
end
|
78
|
-
|
79
|
-
def to_hash
|
80
|
-
{"tag" => name, "ids" => objects}
|
81
|
-
end
|
82
|
-
|
83
|
-
private
|
84
|
-
|
85
|
-
def remove_objects(ids)
|
86
|
-
self.class.request_200({:id => name, :ids => ids, :request_type => "delete"}) unless ids.empty?
|
87
|
-
end
|
88
|
-
|
89
|
-
def add_objects(ids)
|
90
|
-
self.class.request_200({:tag => name, :ids => ids, :request_type => "post"}) unless ids.empty?
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
end
|
data/lib/copperegg/ver.rb
DELETED