moogle 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +35 -0
  4. data/Gemfile.lock +148 -0
  5. data/LICENSE.txt +202 -0
  6. data/NOTICE.txt +4 -0
  7. data/README.md +33 -0
  8. data/Rakefile +44 -0
  9. data/fixtures/vcr_cassettes/push_blog_entry.yml +48 -0
  10. data/fixtures/vcr_cassettes/push_webhook_ping.yml +41 -0
  11. data/lib/moogle/commands/create_link.rb +45 -0
  12. data/lib/moogle/commands/create_target.rb +46 -0
  13. data/lib/moogle/commands/destroy_link.rb +37 -0
  14. data/lib/moogle/commands/destroy_target.rb +37 -0
  15. data/lib/moogle/commands/find_targets.rb +31 -0
  16. data/lib/moogle/commands/push_blog_entry.rb +54 -0
  17. data/lib/moogle/commands/push_email.rb +60 -0
  18. data/lib/moogle/commands/push_webhook_ping.rb +58 -0
  19. data/lib/moogle/commands/update_target.rb +44 -0
  20. data/lib/moogle/commands.rb +9 -0
  21. data/lib/moogle/error.rb +6 -0
  22. data/lib/moogle/events/blog_entry_pushed.rb +34 -0
  23. data/lib/moogle/events/email_pushed.rb +36 -0
  24. data/lib/moogle/events/error.rb +24 -0
  25. data/lib/moogle/events/link_created.rb +21 -0
  26. data/lib/moogle/events/link_destroyed.rb +21 -0
  27. data/lib/moogle/events/target_created.rb +21 -0
  28. data/lib/moogle/events/target_destroyed.rb +21 -0
  29. data/lib/moogle/events/target_updated.rb +21 -0
  30. data/lib/moogle/events/webhook_ping_pushed.rb +34 -0
  31. data/lib/moogle/handlers/accept_notification.rb +96 -0
  32. data/lib/moogle/messages/notification.rb +34 -0
  33. data/lib/moogle/models/blog_target.rb +29 -0
  34. data/lib/moogle/models/email_target.rb +16 -0
  35. data/lib/moogle/models/facebook_target.rb +14 -0
  36. data/lib/moogle/models/link.rb +20 -0
  37. data/lib/moogle/models/post_log.rb +21 -0
  38. data/lib/moogle/models/target.rb +22 -0
  39. data/lib/moogle/models/twitter_target.rb +14 -0
  40. data/lib/moogle/models/webhook_target.rb +18 -0
  41. data/lib/moogle/models.rb +9 -0
  42. data/lib/moogle/representers/link_representer.rb +23 -0
  43. data/lib/moogle/representers/target_representer.rb +34 -0
  44. data/lib/moogle/requests/create_link.rb +24 -0
  45. data/lib/moogle/requests/create_target.rb +40 -0
  46. data/lib/moogle/requests/destroy_link.rb +22 -0
  47. data/lib/moogle/requests/destroy_target.rb +22 -0
  48. data/lib/moogle/requests/find_targets.rb +21 -0
  49. data/lib/moogle/requests/push_blog_entry.rb +67 -0
  50. data/lib/moogle/requests/push_email.rb +46 -0
  51. data/lib/moogle/requests/push_webhook_ping.rb +49 -0
  52. data/lib/moogle/requests/update_target.rb +22 -0
  53. data/lib/moogle/requests.rb +6 -0
  54. data/lib/moogle/version.rb +11 -0
  55. data/lib/moogle.rb +5 -0
  56. data/moogle.gemspec +160 -0
  57. data/spec/commands/find_targets_spec.rb +32 -0
  58. data/spec/commands/links_spec.rb +92 -0
  59. data/spec/commands/push_blog_entry_spec.rb +33 -0
  60. data/spec/commands/push_email_spec.rb +44 -0
  61. data/spec/commands/push_webhook_ping_spec.rb +30 -0
  62. data/spec/commands/targets_spec.rb +165 -0
  63. data/spec/handlers/accept_notification_spec.rb +55 -0
  64. data/spec/moogle_spec.rb +1 -0
  65. data/spec/spec_helper.rb +12 -0
  66. data/spec/support/dependencies.rb +10 -0
  67. data/spec/support/vcr.rb +6 -0
  68. metadata +326 -0
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,35 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem 'addressable', '>= 2.2.7'
7
+ gem 'aequitas', '>= 0.0.2'
8
+ gem 'data_mapper', '>= 1.2.0'
9
+ gem 'mail', '>= 2.4.3'
10
+ gem 'faraday', '>= 0.7.6'
11
+ gem 'rafaday', '>= 0.1.0'
12
+ #gem 'rafaday', git: 'https://github.com/byu/rafaday.git', branch: 'develop'
13
+ #gem 'rafaday', git: '../rafaday'
14
+ gem 'roar', '>= 0.9.2'
15
+ gem 'serf', '>= 0.8.0'
16
+ #gem 'serf', git: 'https://github.com/byu/serf.git', branch: 'develop'
17
+ #gem 'serf', path: '../serf'
18
+ gem 'uuidtools', '>= 2.1.2'
19
+ gem 'virtus', '>= 0.3.0'
20
+
21
+ # Add dependencies to develop your gem here.
22
+ # Include everything needed to run rake, tests, features, etc.
23
+ group :development do
24
+ gem "rspec", "~> 2.8.0"
25
+ gem "yard", "~> 0.7.5"
26
+ gem "bundler", "~> 1.1.3"
27
+ gem "jeweler", "~> 1.8.3"
28
+ gem 'simplecov', '>= 0'
29
+
30
+ gem 'vcr', '~> 2.0.0'
31
+ gem 'webmock', '~> 1.8.1'
32
+
33
+ gem 'dm-sqlite-adapter'
34
+ gem 'dm-mysql-adapter'
35
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,148 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.2.3)
5
+ i18n (~> 0.6)
6
+ multi_json (~> 1.0)
7
+ addressable (2.2.7)
8
+ aequitas (0.0.2)
9
+ bcrypt-ruby (3.0.1)
10
+ crack (0.3.1)
11
+ data_mapper (1.2.0)
12
+ dm-aggregates (~> 1.2.0)
13
+ dm-constraints (~> 1.2.0)
14
+ dm-core (~> 1.2.0)
15
+ dm-migrations (~> 1.2.0)
16
+ dm-serializer (~> 1.2.0)
17
+ dm-timestamps (~> 1.2.0)
18
+ dm-transactions (~> 1.2.0)
19
+ dm-types (~> 1.2.0)
20
+ dm-validations (~> 1.2.0)
21
+ data_objects (0.10.8)
22
+ addressable (~> 2.1)
23
+ diff-lcs (1.1.3)
24
+ dm-aggregates (1.2.0)
25
+ dm-core (~> 1.2.0)
26
+ dm-constraints (1.2.0)
27
+ dm-core (~> 1.2.0)
28
+ dm-core (1.2.0)
29
+ addressable (~> 2.2.6)
30
+ dm-do-adapter (1.2.0)
31
+ data_objects (~> 0.10.6)
32
+ dm-core (~> 1.2.0)
33
+ dm-migrations (1.2.0)
34
+ dm-core (~> 1.2.0)
35
+ dm-mysql-adapter (1.2.0)
36
+ dm-do-adapter (~> 1.2.0)
37
+ do_mysql (~> 0.10.6)
38
+ dm-serializer (1.2.1)
39
+ dm-core (~> 1.2.0)
40
+ fastercsv (~> 1.5.4)
41
+ json (~> 1.6.1)
42
+ json_pure (~> 1.6.1)
43
+ multi_json (~> 1.0.3)
44
+ dm-sqlite-adapter (1.2.0)
45
+ dm-do-adapter (~> 1.2.0)
46
+ do_sqlite3 (~> 0.10.6)
47
+ dm-timestamps (1.2.0)
48
+ dm-core (~> 1.2.0)
49
+ dm-transactions (1.2.0)
50
+ dm-core (~> 1.2.0)
51
+ dm-types (1.2.1)
52
+ bcrypt-ruby (~> 3.0.0)
53
+ dm-core (~> 1.2.0)
54
+ fastercsv (~> 1.5.4)
55
+ json (~> 1.6.1)
56
+ multi_json (~> 1.0.3)
57
+ stringex (~> 1.3.0)
58
+ uuidtools (~> 2.1.2)
59
+ dm-validations (1.2.0)
60
+ dm-core (~> 1.2.0)
61
+ do_mysql (0.10.8)
62
+ data_objects (= 0.10.8)
63
+ do_sqlite3 (0.10.8)
64
+ data_objects (= 0.10.8)
65
+ faraday (0.7.6)
66
+ addressable (~> 2.2)
67
+ multipart-post (~> 1.1)
68
+ rack (~> 1.1)
69
+ fastercsv (1.5.4)
70
+ git (1.2.5)
71
+ i18n (0.6.0)
72
+ jeweler (1.8.3)
73
+ bundler (~> 1.0)
74
+ git (>= 1.2.5)
75
+ rake
76
+ rdoc
77
+ json (1.6.6)
78
+ json_pure (1.6.6)
79
+ mail (2.4.4)
80
+ i18n (>= 0.4.0)
81
+ mime-types (~> 1.16)
82
+ treetop (~> 1.4.8)
83
+ mime-types (1.18)
84
+ multi_json (1.0.4)
85
+ multipart-post (1.1.5)
86
+ nokogiri (1.5.2)
87
+ polyglot (0.3.3)
88
+ rack (1.4.1)
89
+ rafaday (0.1.0)
90
+ rake (0.9.2.2)
91
+ rdoc (3.12)
92
+ json (~> 1.4)
93
+ representable (1.1.5)
94
+ json
95
+ nokogiri
96
+ roar (0.9.2)
97
+ representable (~> 1.1)
98
+ rspec (2.8.0)
99
+ rspec-core (~> 2.8.0)
100
+ rspec-expectations (~> 2.8.0)
101
+ rspec-mocks (~> 2.8.0)
102
+ rspec-core (2.8.0)
103
+ rspec-expectations (2.8.0)
104
+ diff-lcs (~> 1.1.2)
105
+ rspec-mocks (2.8.0)
106
+ serf (0.8.0)
107
+ activesupport (>= 3.2.0)
108
+ i18n (>= 0.6.0)
109
+ uuidtools (>= 2.1.2)
110
+ simplecov (0.6.1)
111
+ multi_json (~> 1.0)
112
+ simplecov-html (~> 0.5.3)
113
+ simplecov-html (0.5.3)
114
+ stringex (1.3.2)
115
+ treetop (1.4.10)
116
+ polyglot
117
+ polyglot (>= 0.3.1)
118
+ uuidtools (2.1.2)
119
+ vcr (2.0.1)
120
+ virtus (0.3.0)
121
+ webmock (1.8.6)
122
+ addressable (>= 2.2.7)
123
+ crack (>= 0.1.7)
124
+ yard (0.7.5)
125
+
126
+ PLATFORMS
127
+ ruby
128
+
129
+ DEPENDENCIES
130
+ addressable (>= 2.2.7)
131
+ aequitas (>= 0.0.2)
132
+ bundler (~> 1.1.3)
133
+ data_mapper (>= 1.2.0)
134
+ dm-mysql-adapter
135
+ dm-sqlite-adapter
136
+ faraday (>= 0.7.6)
137
+ jeweler (~> 1.8.3)
138
+ mail (>= 2.4.3)
139
+ rafaday (>= 0.1.0)
140
+ roar (>= 0.9.2)
141
+ rspec (~> 2.8.0)
142
+ serf (>= 0.8.0)
143
+ simplecov
144
+ uuidtools (>= 2.1.2)
145
+ vcr (~> 2.0.0)
146
+ virtus (>= 0.3.0)
147
+ webmock (~> 1.8.1)
148
+ yard (~> 0.7.5)
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 [yyyy] [name of copyright owner]
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/NOTICE.txt ADDED
@@ -0,0 +1,4 @@
1
+ Moogle
2
+ Copyright 2012 Benjamin Yu
3
+ This software includes code written by Benjamin Yu <http://benjaminyu.org/>
4
+ covered under the Apache License <http://www.apache.org/licenses/LICENSE-2.0>.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ Moogle
2
+ ======
3
+
4
+ Moogle is notification pusher to 3rd parties..
5
+
6
+ There are Five support types of notifications:
7
+
8
+ * Email
9
+ * Facebook
10
+ * Twitter
11
+ * Webhook
12
+ * Wordpress (metaWeblog Api)
13
+
14
+ Contributing to Moogle
15
+ ======================
16
+
17
+ * Check out the latest master to make sure the feature hasn't been
18
+ implemented or the bug hasn't been fixed yet
19
+ * Check out the issue tracker to make sure someone already hasn't
20
+ requested it and/or contributed it
21
+ * Fork the project
22
+ * Start a feature/bugfix branch
23
+ * Commit and push until you are happy with your contribution
24
+ * Make sure to add tests for it. This is important so I don't break it
25
+ in a future version unintentionally.
26
+ * Please try not to mess with the Rakefile, version, or history. If
27
+ you want to have your own version, or is otherwise necessary, that is
28
+ fine, but please isolate to its own commit so I can cherry-pick around it.
29
+
30
+ Copyright
31
+ =========
32
+
33
+ Copyright (c) 2012 Benjamin Yu. See LICENSE.txt for further details.
data/Rakefile ADDED
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ require './lib/moogle/version'
16
+ Jeweler::Tasks.new do |gem|
17
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
18
+ gem.name = "moogle"
19
+ gem.homepage = "http://github.com/byu/moogle"
20
+ gem.license = "Apache 2.0"
21
+ gem.summary = %Q{Notification pushing to 3rd parties}
22
+ gem.description = %Q{Notification pushing to 3rd parties}
23
+ gem.email = "benjaminlyu@gmail.com"
24
+ gem.authors = ["Benjamin Yu"]
25
+ gem.version = Moogle::Version::STRING
26
+ # dependencies defined in Gemfile
27
+ end
28
+ Jeweler::RubygemsDotOrgTasks.new
29
+
30
+ require 'rspec/core'
31
+ require 'rspec/core/rake_task'
32
+ RSpec::Core::RakeTask.new(:spec) do |spec|
33
+ spec.pattern = FileList['spec/**/*_spec.rb']
34
+ end
35
+
36
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
37
+ spec.pattern = 'spec/**/*_spec.rb'
38
+ spec.rcov = true
39
+ end
40
+
41
+ task :default => :spec
42
+
43
+ require 'yard'
44
+ YARD::Rake::YardocTask.new
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://example.wordpress.com/xmlrpc.php
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ! '<?xml version="1.0" ?><methodCall><methodName>metaWeblog.newPost</methodName><params><param><value><string>my_blog_id</string></value></param><param><value><string>user@example.com</string></value></param><param><value><string>password</string></value></param><param><value><struct><member><name>title</name><value><string>My
9
+ Test Title</string></value></member><member><name>link</name><value><string>http://example.wordpress.com/</string></value></member><member><name>description</name><value><string>Body
10
+ of the blog post</string></value></member><member><name>categories</name><value><array><data><value><string>tag1</string></value><value><string>tag2</string></value></data></array></value></member></struct></value></param><param><value><boolean>1</boolean></value></param></params></methodCall>
11
+
12
+ '
13
+ headers:
14
+ User-Agent:
15
+ - XMLRPC::Client (Ruby 1.9.3)
16
+ Content-Type:
17
+ - text/xml; charset=utf-8
18
+ Content-Length:
19
+ - '816'
20
+ Connection:
21
+ - keep-alive
22
+ Accept:
23
+ - ! '*/*'
24
+ response:
25
+ status:
26
+ code: 200
27
+ message: OK
28
+ headers:
29
+ Server:
30
+ - nginx
31
+ Date:
32
+ - Wed, 07 Mar 2012 03:08:51 GMT
33
+ Content-Type:
34
+ - text/xml;charset=utf-8
35
+ Connection:
36
+ - close
37
+ X-Hacker:
38
+ - If you're reading this, you should visit automattic.com/jobs and apply to
39
+ join the fun, mention this header.
40
+ Content-Length:
41
+ - '160'
42
+ body:
43
+ encoding: US-ASCII
44
+ string: ! "<?xml version=\"1.0\"?>\n<methodResponse>\n <params>\n <param>\n
45
+ \ <value>\n <string>61</string>\n </value>\n </param>\n </params>\n</methodResponse>\n"
46
+ http_version:
47
+ recorded_at: Wed, 07 Mar 2012 03:08:51 GMT
48
+ recorded_with: VCR 2.0.0
@@ -0,0 +1,41 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://www.example.com/?sig=1dc41d1c2057247a613e0ca8571015ecc15629ec
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ! '{}'
9
+ headers:
10
+ Accept:
11
+ - ! '*/*'
12
+ User-Agent:
13
+ - Ruby
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Date:
20
+ - Wed, 07 Mar 2012 07:20:36 GMT
21
+ Server:
22
+ - Apache
23
+ Last-Modified:
24
+ - Tue, 28 Feb 2012 20:41:04 GMT
25
+ Etag:
26
+ - ! '"d65c17a-95-4ba0c3edeb800"'
27
+ Accept-Ranges:
28
+ - bytes
29
+ Content-Length:
30
+ - '149'
31
+ Vary:
32
+ - Accept-Encoding
33
+ Content-Type:
34
+ - text/html
35
+ body:
36
+ encoding: US-ASCII
37
+ string: ! "<html>\n <head>\n </head>\n <body>\n A long time ago, we used
38
+ to be friends<br/>\n But I haven't thought of you lately at all<br/>\n </body>\n</html>\n"
39
+ http_version:
40
+ recorded_at: Wed, 07 Mar 2012 07:20:36 GMT
41
+ recorded_with: VCR 2.0.0
@@ -0,0 +1,45 @@
1
+ require 'serf/command'
2
+
3
+ require 'moogle/error'
4
+ require 'moogle/events/link_created'
5
+ require 'moogle/requests/create_link'
6
+ require 'moogle/models'
7
+ require 'moogle/representers/link_representer'
8
+
9
+ module Moogle
10
+ module Commands
11
+
12
+ class CreateLink
13
+ include Serf::Command
14
+
15
+ self.request_factory = Moogle::Requests::CreateLink
16
+
17
+ def call
18
+ link_model = opts :link_model, Moogle::Link
19
+ target_model = opts :target_model, Moogle::Target
20
+ event_class = opts :event_class, Moogle::Events::LinkCreated
21
+ representer = opts :representer, Moogle::LinkRepresenter
22
+
23
+ target = target_model.get request.target_id
24
+
25
+ unless target
26
+ raise '404 Not found target'
27
+ end
28
+
29
+ link = link_model.create(
30
+ target: target,
31
+ receiver_ref: request.receiver_ref,
32
+ message_kind: request.message_kind)
33
+ raise link.errors.full_messages.join('. ') unless link.saved?
34
+
35
+ link_rep = link.dup.extend representer
36
+ return event_class.new request.create_child_uuids.merge(link: link_rep)
37
+ rescue => e
38
+ e.extend Moogle::Error
39
+ raise e
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,46 @@
1
+ require 'active_support/core_ext/string/inflections'
2
+ require 'serf/command'
3
+
4
+ require 'moogle/error'
5
+ require 'moogle/events/target_created'
6
+ require 'moogle/requests/create_target'
7
+ require 'moogle/models'
8
+ require 'moogle/representers/target_representer'
9
+
10
+ module Moogle
11
+ module Commands
12
+
13
+ class CreateTarget
14
+ include Serf::Command
15
+
16
+ self.request_factory = Moogle::Requests::CreateTarget
17
+
18
+ ##
19
+ # @return [Moogle::Target] the created target, properly subclassed by type.
20
+ #
21
+ def call
22
+ event_class = opts :event_class, Moogle::Events::TargetCreated
23
+ representer = opts :representer, Moogle::TargetRepresenter
24
+
25
+ # Determine our model class name, and get the constant.
26
+ model_name = "moogle/#{request.type}_target".classify
27
+ target_model = model_name.constantize rescue Moogle::Target
28
+
29
+ # Now, create the target, and raise on errors.
30
+ target = target_model.create(
31
+ owner_ref: request.owner_ref,
32
+ options: request.options)
33
+ raise target.errors.full_messages.join('. ') unless target.saved?
34
+
35
+ target_rep = target.dup.extend representer
36
+ return event_class.new(
37
+ request.create_child_uuids.merge(target: target_rep))
38
+ rescue => e
39
+ e.extend Moogle::Error
40
+ raise e
41
+ end
42
+
43
+ end
44
+
45
+ end
46
+ end