mingle_event_changes 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +20 -0
- data/lib/mingle_event_changes/change.rb +89 -0
- data/lib/mingle_event_changes.rb +10 -0
- metadata +66 -0
data/README
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
= Mingle Event Changes
|
3
|
+
|
4
|
+
Parse out Mingle Event Feed content element of the entry. Better and simpler API for accessing event changes.
|
5
|
+
|
6
|
+
== How to use
|
7
|
+
|
8
|
+
require 'mingle_event_changes'
|
9
|
+
|
10
|
+
xml = <<-XML
|
11
|
+
<changes>
|
12
|
+
<change type="card-creation" >
|
13
|
+
</change>
|
14
|
+
<change type="card-copied-to" >
|
15
|
+
<source url="http://your.mingle.server:8080/api/v2/projects/one/cards/2.xml"/>
|
16
|
+
<destination url="http://your.mingle.server:8080/api/v2/projects/two/cards/3.xml"></destination>
|
17
|
+
</change>
|
18
|
+
</changes>
|
19
|
+
XML
|
20
|
+
changes = MingleEventChanges.parse(xml)
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module MingleEventChanges
|
2
|
+
class PropertyDefinition
|
3
|
+
include SAXMachine
|
4
|
+
element :name
|
5
|
+
element :position
|
6
|
+
element :data_type
|
7
|
+
element :is_numeric
|
8
|
+
attribute :url
|
9
|
+
|
10
|
+
def is_numeric?
|
11
|
+
is_numeric == 'true'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class CardTypeValue
|
16
|
+
include SAXMachine
|
17
|
+
element :name
|
18
|
+
element :card_type, :value => :url, :as => :url
|
19
|
+
end
|
20
|
+
|
21
|
+
class Change
|
22
|
+
include SAXMachine
|
23
|
+
attribute :type
|
24
|
+
end
|
25
|
+
|
26
|
+
class CardCopyChange < Change
|
27
|
+
element :source, :value => :url, :as => :source_url
|
28
|
+
element :destination, :value => :url, :as => :destination_url
|
29
|
+
end
|
30
|
+
|
31
|
+
class NameChange < Change
|
32
|
+
element :old_value
|
33
|
+
element :new_value
|
34
|
+
end
|
35
|
+
|
36
|
+
class PropertyChange < Change
|
37
|
+
element :property_definition, :class => PropertyDefinition
|
38
|
+
element :old_value
|
39
|
+
element :new_value
|
40
|
+
end
|
41
|
+
|
42
|
+
class CardTypeChange < Change
|
43
|
+
element :old_value, :class => CardTypeValue
|
44
|
+
element :new_value, :class => CardTypeValue
|
45
|
+
end
|
46
|
+
|
47
|
+
class TagChange < Change
|
48
|
+
element :tag
|
49
|
+
end
|
50
|
+
|
51
|
+
class AttachmentChange < Change
|
52
|
+
element :url
|
53
|
+
element :file_name
|
54
|
+
end
|
55
|
+
|
56
|
+
class CommentChange < Change
|
57
|
+
element :comment
|
58
|
+
end
|
59
|
+
|
60
|
+
class Changes
|
61
|
+
include SAXMachine
|
62
|
+
TYPES = {
|
63
|
+
'card-copied-to' => CardCopyChange,
|
64
|
+
'card-copied-from' => CardCopyChange,
|
65
|
+
'card-creation' => Change,
|
66
|
+
'card-deletion' => Change,
|
67
|
+
'card-type-change' => CardTypeChange,
|
68
|
+
'description-change' => Change,
|
69
|
+
'property-change' => PropertyChange,
|
70
|
+
'name-change' => NameChange,
|
71
|
+
'tag-addition' => TagChange,
|
72
|
+
'tag-removal' => TagChange,
|
73
|
+
'attachment-addition' => AttachmentChange,
|
74
|
+
'attachment-removal' => AttachmentChange,
|
75
|
+
'attachment-replacement' => AttachmentChange,
|
76
|
+
'comment-addition' => CommentChange,
|
77
|
+
'system-comment-addition' => CommentChange,
|
78
|
+
'page-creation' => Change
|
79
|
+
}.each do |type, clazz|
|
80
|
+
elements :change, :as => "#{type.gsub(/-/, '_')}_changes", :class => clazz, :with => {:type => type}
|
81
|
+
end
|
82
|
+
|
83
|
+
def changes
|
84
|
+
TYPES.keys.map do |k|
|
85
|
+
send("#{k.gsub(/-/, '_')}_changes")
|
86
|
+
end.flatten
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mingle_event_changes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Xiao Li
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sax-machine
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description:
|
31
|
+
email: swing1979@gmail.com
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- README
|
37
|
+
- lib/mingle_event_changes/change.rb
|
38
|
+
- lib/mingle_event_changes.rb
|
39
|
+
homepage: http://github.com/xli/mingle_event_changes
|
40
|
+
licenses:
|
41
|
+
- MIT
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.8.25
|
61
|
+
signing_key:
|
62
|
+
specification_version: 3
|
63
|
+
summary: Parse out Mingle Event Feed content element of the entry. Better and simpler
|
64
|
+
API for accessing event changes.
|
65
|
+
test_files: []
|
66
|
+
has_rdoc:
|