mingle_events 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/LICENSE.txt +202 -0
- data/README.textile +117 -0
- data/lib/mingle_events.rb +26 -0
- data/lib/mingle_events/feed.rb +5 -0
- data/lib/mingle_events/feed/author.rb +28 -0
- data/lib/mingle_events/feed/category.rb +75 -0
- data/lib/mingle_events/feed/element_support.rb +19 -0
- data/lib/mingle_events/feed/entry.rb +96 -0
- data/lib/mingle_events/feed/page.rb +61 -0
- data/lib/mingle_events/http_error.rb +26 -0
- data/lib/mingle_events/mingle_basic_auth_access.rb +71 -0
- data/lib/mingle_events/mingle_oauth_access.rb +40 -0
- data/lib/mingle_events/poller.rb +32 -0
- data/lib/mingle_events/processors.rb +10 -0
- data/lib/mingle_events/processors/author_filter.rb +62 -0
- data/lib/mingle_events/processors/card_data.rb +102 -0
- data/lib/mingle_events/processors/card_type_filter.rb +28 -0
- data/lib/mingle_events/processors/category_filter.rb +19 -0
- data/lib/mingle_events/processors/custom_property_filter.rb +30 -0
- data/lib/mingle_events/processors/http_post_publisher.rb +20 -0
- data/lib/mingle_events/processors/pipeline.rb +20 -0
- data/lib/mingle_events/processors/puts_publisher.rb +17 -0
- data/lib/mingle_events/project_custom_properties.rb +33 -0
- data/lib/mingle_events/project_event_fetcher.rb +96 -0
- data/test/mingle_events/feed/author_test.rb +39 -0
- data/test/mingle_events/feed/category_test.rb +20 -0
- data/test/mingle_events/feed/entry_test.rb +140 -0
- data/test/mingle_events/feed/page_test.rb +82 -0
- data/test/mingle_events/poller_test.rb +47 -0
- data/test/mingle_events/processors/author_filter_test.rb +80 -0
- data/test/mingle_events/processors/card_data_test.rb +210 -0
- data/test/mingle_events/processors/card_type_filter_test.rb +51 -0
- data/test/mingle_events/processors/category_filter_test.rb +27 -0
- data/test/mingle_events/processors/custom_property_filter_test.rb +51 -0
- data/test/mingle_events/processors/pipeline_test.rb +32 -0
- data/test/mingle_events/project_custom_properties_test.rb +39 -0
- data/test/mingle_events/project_event_fetcher_test.rb +122 -0
- data/test/test_helper.rb +163 -0
- data/test/web_hook_server/web_hook_server.rb +6 -0
- metadata +140 -0
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,202 @@
|
|
1
|
+
|
2
|
+
Apache License
|
3
|
+
Version 2.0, January 2004
|
4
|
+
http://www.apache.org/licenses/
|
5
|
+
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
7
|
+
|
8
|
+
1. Definitions.
|
9
|
+
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
12
|
+
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
14
|
+
the copyright owner that is granting the License.
|
15
|
+
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
17
|
+
other entities that control, are controlled by, or are under common
|
18
|
+
control with that entity. For the purposes of this definition,
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
20
|
+
direction or management of such entity, whether by contract or
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
23
|
+
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
25
|
+
exercising permissions granted by this License.
|
26
|
+
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
28
|
+
including but not limited to software source code, documentation
|
29
|
+
source, and configuration files.
|
30
|
+
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
32
|
+
transformation or translation of a Source form, including but
|
33
|
+
not limited to compiled object code, generated documentation,
|
34
|
+
and conversions to other media types.
|
35
|
+
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
37
|
+
Object form, made available under the License, as indicated by a
|
38
|
+
copyright notice that is included in or attached to the work
|
39
|
+
(an example is provided in the Appendix below).
|
40
|
+
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
47
|
+
the Work and Derivative Works thereof.
|
48
|
+
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
50
|
+
the original version of the Work and any modifications or additions
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
62
|
+
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
65
|
+
subsequently incorporated within the Work.
|
66
|
+
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
73
|
+
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
79
|
+
where such license applies only to those patent claims licensable
|
80
|
+
by such Contributor that are necessarily infringed by their
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
83
|
+
institute patent litigation against any entity (including a
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
86
|
+
or contributory patent infringement, then any patent licenses
|
87
|
+
granted to You under this License for that Work shall terminate
|
88
|
+
as of the date such litigation is filed.
|
89
|
+
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
92
|
+
modifications, and in Source or Object form, provided that You
|
93
|
+
meet the following conditions:
|
94
|
+
|
95
|
+
(a) You must give any other recipients of the Work or
|
96
|
+
Derivative Works a copy of this License; and
|
97
|
+
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
99
|
+
stating that You changed the files; and
|
100
|
+
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
103
|
+
attribution notices from the Source form of the Work,
|
104
|
+
excluding those notices that do not pertain to any part of
|
105
|
+
the Derivative Works; and
|
106
|
+
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
109
|
+
include a readable copy of the attribution notices contained
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
112
|
+
of the following places: within a NOTICE text file distributed
|
113
|
+
as part of the Derivative Works; within the Source form or
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
115
|
+
within a display generated by the Derivative Works, if and
|
116
|
+
wherever such third-party notices normally appear. The contents
|
117
|
+
of the NOTICE file are for informational purposes only and
|
118
|
+
do not modify the License. You may add Your own attribution
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
121
|
+
that such additional attribution notices cannot be construed
|
122
|
+
as modifying the License.
|
123
|
+
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
125
|
+
may provide additional or different license terms and conditions
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
129
|
+
the conditions stated in this License.
|
130
|
+
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
134
|
+
this License, without any additional terms or conditions.
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
136
|
+
the terms of any separate license agreement you may have executed
|
137
|
+
with Licensor regarding such Contributions.
|
138
|
+
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
141
|
+
except as required for reasonable and customary use in describing the
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
143
|
+
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
153
|
+
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
159
|
+
incidental, or consequential damages of any character arising as a
|
160
|
+
result of this License or out of the use or inability to use the
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
163
|
+
other commercial damages or losses), even if such Contributor
|
164
|
+
has been advised of the possibility of such damages.
|
165
|
+
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
169
|
+
or other liability obligations and/or rights consistent with this
|
170
|
+
License. However, in accepting such obligations, You may act only
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
175
|
+
of your accepting any such warranty or additional liability.
|
176
|
+
|
177
|
+
END OF TERMS AND CONDITIONS
|
178
|
+
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
180
|
+
|
181
|
+
To apply the Apache License to your work, attach the following
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
183
|
+
replaced with your own identifying information. (Don't include
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
185
|
+
comment syntax for the file format. We also recommend that a
|
186
|
+
file or class name and description of purpose be included on the
|
187
|
+
same "printed page" as the copyright notice for easier
|
188
|
+
identification within third-party archives.
|
189
|
+
|
190
|
+
Copyright 2011 ThoughtWorks, Inc., authored by David J. Rice (david.rice at gmail dot com)
|
191
|
+
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
193
|
+
you may not use this file except in compliance with the License.
|
194
|
+
You may obtain a copy of the License at
|
195
|
+
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
197
|
+
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
201
|
+
See the License for the specific language governing permissions and
|
202
|
+
limitations under the License.
|
data/README.textile
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
h1. Mingle Events
|
2
|
+
|
3
|
+
h3. Overview
|
4
|
+
|
5
|
+
Mingle 3.3 introduced a new Events API in the form of an "Atom feed":http://www.thoughtworks-studios.com/mingle/3.3/help/mingle_api_events.html. The Mingle team and ThoughtWorks Studios are big believers in the use of Atom for exposing events. Atom is a widely used standard, and this event API style puts the issue of robust event delivery in the hands of the consumer, where it belongs. In fact, we'd argue this is the only feasible means of robust, scalable event delivery, short of spending hundreds of thousands or millions of dollars on enterprise buses and such. Atom-delivered events are cheap, scalable, standards-based, and robust.
|
6
|
+
|
7
|
+
However, we do accept that asking integrators wishing to consume events to implement polling is not ideal. Writing polling consumers can be tedious. And this tedium gets in the way of writing sweet Mingle integrations. We are addressing this by publishing libraries such as this, which if effective, fully hide the mechanics of event polling from the consumer. The consumer only need worry about the processing of events. Said processing is modeled in the style of 'pipes and filters.'
|
8
|
+
|
9
|
+
h3. Installation
|
10
|
+
|
11
|
+
<pre>
|
12
|
+
gem install mingle_events
|
13
|
+
</pre>
|
14
|
+
|
15
|
+
h3. Source
|
16
|
+
|
17
|
+
"Hosted on github":https://github.com/ThoughtWorksStudios/mingle_events
|
18
|
+
|
19
|
+
<pre>
|
20
|
+
git clone git://github.com/ThoughtWorksStudios/mingle_events.git
|
21
|
+
</pre>
|
22
|
+
|
23
|
+
h2. Quick example
|
24
|
+
|
25
|
+
<pre>
|
26
|
+
# configure access to mingle
|
27
|
+
mingle_access = MingleEvents::MingleBasicAuthAccess.new('https://localhost:7071', 'david', 'p')
|
28
|
+
|
29
|
+
# assemble processing pipeline
|
30
|
+
post_comments_to_another_service = MingleEvents::Processors::Pipeline.new([
|
31
|
+
MingleEvents::Processors::CategoryFilter.new([MingleEvents::Feed::Category::COMMENT_ADDITION]),
|
32
|
+
MingleEvents::Processors::HttpPostPublisher.new('http://localhost:4567/')
|
33
|
+
])
|
34
|
+
|
35
|
+
# poll once
|
36
|
+
MingleEvents::Poller.new(mingle_access, {'test_project' => [post_comments_to_another_service]}).run_once
|
37
|
+
</pre>
|
38
|
+
|
39
|
+
h2. High level design
|
40
|
+
|
41
|
+
This library pumps the stream of a Mingle project's events through a pipeline of processors that you specify. The processors can do things such as "filter out any events that are not sourced from a Story" or "post an event to an HTTP end-point."
|
42
|
+
|
43
|
+
!http://thoughtworksstudios.github.com/mingle_events_design.png!
|
44
|
+
|
45
|
+
As stated in the opening paragraph, the aim of this library is to hide the mechanics of event polling, making the user's focus solely the definition of the processing pipeline. This library supplies fundamental event processors, such as card type filters, atom category filters, and http publishers. This library should also make it easy for you to write custom processors.
|
46
|
+
|
47
|
+
h2. Events and entries
|
48
|
+
|
49
|
+
You might get confused looking at the source code as to what's an Atom entry and what's a Mingle event. We're still trying to clean that up a bit, but for all intents and purposes, they are the same thing. The Atom feed represents Mingle events in the form of Atom entries. For the most part we try to use the word 'entry' in the context of the feed and 'event' in the context of processing.
|
50
|
+
|
51
|
+
h2. Processors, filters, and pipelines
|
52
|
+
|
53
|
+
Processors, filters, and pipelines are all processors with the same interface. The fundamental model for pipes and filters, or pipelining, is that there is a single, common interface for processing input and returning output. In this context of Mingle event processing, the interface is basically "events in, events out" where "events in" is the list of unprocessed events and "events out" are the processed events. Processed events might be enriched, filtered, untouched but emailed, etc.
|
54
|
+
|
55
|
+
This library ships the following processors:
|
56
|
+
* MingleEvents::Processors::CardData -- loads data for each card that sourced an event in the current stream. This processor requires some special handling (see next section).
|
57
|
+
* MingleEvents::Processors::CardTypeFilter -- filters events to those sourced by cards of specific card type(s)
|
58
|
+
* MingleEvents::Processors::CategoryFilter -- filters events to those with specified Atom categories. Mingle's Atom Categories are specified in MingleEvents::Category
|
59
|
+
* MingleEvents::Processors::HttpPostPublisher -- posts event's raw XML to an HTTP endpoint
|
60
|
+
* MingleEvents::Processors::Pipeline -- manages to processing of events by a sequence of processors
|
61
|
+
|
62
|
+
h2. Card Data
|
63
|
+
|
64
|
+
CardData is a special processor in that it implements a second interface, beyond event processing. This interface is one that allows the lookup of data for the card that sourced the event (if the event was actually sourced by a card). As looking up card data requires accessing additional Mingle server resources, you want to take special care that you don't make repeated requests for the same resources. If you have multiple processors requiring CardData, be sure to use a single instance of CardData across your entire pipeline.
|
65
|
+
|
66
|
+
<pre>
|
67
|
+
card_data = MingleEvents::Processors::CardData.new(mingle_access, 'test_project')
|
68
|
+
|
69
|
+
post_commenting_on_high_priority_bugs_and_stories = MingleEvents::Processors::Pipeline.new([
|
70
|
+
MingleEvents::Processors::CardTypeFilter.new(['story', 'bug'], card_data),
|
71
|
+
MingleEvents::Processors::CustomPropertyFilter.new('Priority', 'High', card_data),
|
72
|
+
MingleEvents::Processors::CategoryFilter.new([MingleEvents::Category::COMMENT_ADDITION]),
|
73
|
+
MingleEvents::Processors::HttpPostPublisher.new('http://otherissuetracker.example.com/comments')
|
74
|
+
])
|
75
|
+
</pre>
|
76
|
+
|
77
|
+
Note that CardData will provide data for the version of the card that was created by the event you are processing and *not* the current version of the card.
|
78
|
+
|
79
|
+
(For users familiar with earlier versions of this library, you will notice that the bulk loading of card data is currently not being taken advantage of. This is because I needed to change some internals of event broadcasting such that processing a big project's entire history did not cause OOM issues. I will very soon restore the bulk loading optimization for when the poller is simply reading the last handful of events. CardData still works, you just might see your client making a few more calls to Mingle.)
|
80
|
+
|
81
|
+
h2. Writing your own processor
|
82
|
+
|
83
|
+
In ruby code, the processing interface is a single method named 'process_events' that has a single parameter, the list of unprocessed events' and returns a list of the processed events.
|
84
|
+
|
85
|
+
Here's a processor that simply logs events:
|
86
|
+
|
87
|
+
<pre>
|
88
|
+
class MyPutsProcessor
|
89
|
+
def process_events(events)
|
90
|
+
events.each do |event|
|
91
|
+
puts event
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
</pre>
|
96
|
+
|
97
|
+
Here's a filtering processor that removes any event without an Atom category term of 'foo':
|
98
|
+
|
99
|
+
<pre>
|
100
|
+
class MyFooFilter
|
101
|
+
def process_events(events)
|
102
|
+
events.select do |event|
|
103
|
+
event.categories.any?{|category| category.term == 'foo'}
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
</pre>
|
108
|
+
|
109
|
+
Be absolutely sure that any processor you write returns a list of events. If you fail to do this, any pipeline using this processor will not function correctly.
|
110
|
+
|
111
|
+
Each event that is passed to the processor is an instance of type MingleEvents::Entry which is a Ruby wrapper around an Atom event. The Entry class makes it easy to access information such as author, Atom categories, whether the event was sourced by a card, etc. As the model is not yet complete, the Entry class also exposes the raw XML of the entry.
|
112
|
+
|
113
|
+
(If you are wondering why the interface for processing is for a list of events rather than a single event, it is because of the above mentioned bulk loading of card data. This may change in the future. CardData may get its own special interface to perform a pre-processing bulk load, and the event processing interface will move to a single event at a time.)
|
114
|
+
|
115
|
+
h2. Retry & Error handling
|
116
|
+
|
117
|
+
As of now, retry is not implemented. If an error occurs during event processing, the error will be logged and processing will stop. The next run will re-start at the point of the last error.
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'net/https'
|
3
|
+
require 'yaml'
|
4
|
+
require 'time'
|
5
|
+
require 'logger'
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'nokogiri'
|
9
|
+
|
10
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'mingle_events', 'feed'))
|
11
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'mingle_events', 'http_error'))
|
12
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'mingle_events', 'poller'))
|
13
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'mingle_events', 'mingle_basic_auth_access'))
|
14
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'mingle_events', 'mingle_oauth_access'))
|
15
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'mingle_events', 'processors'))
|
16
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'mingle_events', 'project_custom_properties'))
|
17
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'mingle_events', 'project_event_fetcher'))
|
18
|
+
|
19
|
+
module MingleEvents
|
20
|
+
|
21
|
+
attr_accessor :log
|
22
|
+
module_function :log, :log=
|
23
|
+
self.log = Logger.new(STDOUT)
|
24
|
+
self.log.level = Logger::INFO
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'feed', 'element_support'))
|
2
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'feed', 'author'))
|
3
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'feed', 'category'))
|
4
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'feed', 'entry'))
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'feed', 'page'))
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module MingleEvents
|
2
|
+
module Feed
|
3
|
+
|
4
|
+
# The user who's Mingle activity triggered this event
|
5
|
+
class Author
|
6
|
+
|
7
|
+
include ElementSupport
|
8
|
+
|
9
|
+
# The name of the author
|
10
|
+
attr_reader :name
|
11
|
+
# The email address of the author
|
12
|
+
attr_reader :email
|
13
|
+
# The URI identifying the author as well as location of his profile data
|
14
|
+
attr_reader :uri
|
15
|
+
# The URI for the author's icon
|
16
|
+
attr_reader :icon_uri
|
17
|
+
|
18
|
+
def initialize(author_element)
|
19
|
+
@name = element_text(author_element, 'name')
|
20
|
+
@email = element_text(author_element, 'email', true)
|
21
|
+
@uri = element_text(author_element, 'uri', true)
|
22
|
+
@icon_uri = element_text(author_element, 'mingle:icon', true)
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
module MingleEvents
|
2
|
+
module Feed
|
3
|
+
|
4
|
+
# An Atom category, with a term and a scheme. Note that an Atom
|
5
|
+
# event can have any number of categories, including zero.
|
6
|
+
# All current Mingle categories are also defined here, as constants.
|
7
|
+
class Category
|
8
|
+
|
9
|
+
# The category's term
|
10
|
+
attr_reader :term
|
11
|
+
# The category's scheme
|
12
|
+
attr_reader :scheme
|
13
|
+
|
14
|
+
def initialize(term, scheme)
|
15
|
+
@term = term
|
16
|
+
@scheme = scheme
|
17
|
+
end
|
18
|
+
|
19
|
+
def ==(other)
|
20
|
+
other.is_a?(Category) && other.term == self.term && other.scheme == self.scheme
|
21
|
+
end
|
22
|
+
|
23
|
+
def hash
|
24
|
+
term.hash ^ scheme.hash
|
25
|
+
end
|
26
|
+
|
27
|
+
def eql?(other)
|
28
|
+
self == other
|
29
|
+
end
|
30
|
+
|
31
|
+
# The Atom category scheme for all Mingle categories
|
32
|
+
MINGLE_SCHEME = 'http://www.thoughtworks-studios.com/ns/mingle#categories'
|
33
|
+
|
34
|
+
# Category for any event sourced by a card
|
35
|
+
CARD = Category.new('card', MINGLE_SCHEME)
|
36
|
+
# Category for any event that is the creation of a new card
|
37
|
+
CARD_CREATION = Category.new('card-creation', MINGLE_SCHEME)
|
38
|
+
# Category for any event that is the deletion of a card
|
39
|
+
CARD_DELETION = Category.new('card-deletion', MINGLE_SCHEME)
|
40
|
+
# Category for any event that includes the change of a card's property value
|
41
|
+
PROPERTY_CHANGE = Category.new('property-change', MINGLE_SCHEME)
|
42
|
+
# Category for any event that includes the change of a card's type
|
43
|
+
CARD_TYPE_CHANGE = Category.new('card-type-change', MINGLE_SCHEME)
|
44
|
+
# Category for any event that includes the commenting on a card
|
45
|
+
COMMENT_ADDITION = Category.new('comment-addition', MINGLE_SCHEME)
|
46
|
+
# Category for any event that incldues the Mingle server's adding a comment to a card
|
47
|
+
SYSTEM_COMMENT_ADDITION = Category.new('system-comment-addition', MINGLE_SCHEME)
|
48
|
+
|
49
|
+
# Category for any event sourced by a wiki page
|
50
|
+
PAGE = Category.new('page', MINGLE_SCHEME)
|
51
|
+
# Category for any event that is the creation of a new wiki page
|
52
|
+
PAGE_CREATION = Category.new('page-creation', MINGLE_SCHEME)
|
53
|
+
|
54
|
+
# Category for any event that includes a card or page name change
|
55
|
+
NAME_CHANGE = Category.new('name-change', MINGLE_SCHEME)
|
56
|
+
# Category for any event that includes a card or page description/content change
|
57
|
+
DESCRIPTION_CHANGE = Category.new('description-change', MINGLE_SCHEME)
|
58
|
+
# Category for any event that includes the tagging of a card or page
|
59
|
+
TAG_ADDITION = Category.new('tag-addition', MINGLE_SCHEME)
|
60
|
+
# Category for any event that includes the removal of a tag from a card or page
|
61
|
+
TAG_REMOVAL = Category.new('tag-removal', MINGLE_SCHEME)
|
62
|
+
# Category for any event that includes the addition of an attachment to a card or page
|
63
|
+
ATTACHMENT_ADDITION = Category.new('attachment-addition', MINGLE_SCHEME)
|
64
|
+
# Category for any event that includes the removal of an attachment from a card or page
|
65
|
+
ATTACHMENT_REMOVAL = Category.new('attachment-removal', MINGLE_SCHEME)
|
66
|
+
# Category for any event that includes the replacement of an attachment on a card or page
|
67
|
+
ATTACHMENT_REPLACEMENT = Category.new('attachment-replacement', MINGLE_SCHEME)
|
68
|
+
|
69
|
+
# Category for any event that is a revision or changeset commit
|
70
|
+
REVISION_COMMIT = Category.new('revision-commit', MINGLE_SCHEME)
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|