tagcrumbs 0.3.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.
Files changed (178) hide show
  1. data/History.txt +9 -0
  2. data/License.txt +22 -0
  3. data/Manifest.txt +177 -0
  4. data/PostInstall.txt +2 -0
  5. data/README.rdoc +45 -0
  6. data/Rakefile +35 -0
  7. data/TODO.txt +17 -0
  8. data/bin/tagcrumbs +5 -0
  9. data/examples/address_update.rb +15 -0
  10. data/examples/comment_new.rb +19 -0
  11. data/examples/favorite_new.rb +17 -0
  12. data/examples/filter_new.rb +15 -0
  13. data/examples/friendship_create.rb +19 -0
  14. data/examples/link_new.rb +16 -0
  15. data/examples/location_update.rb +16 -0
  16. data/examples/picture_update.rb +16 -0
  17. data/examples/placemark_new_simple.rb +24 -0
  18. data/examples/placemark_new_suggestions.rb +24 -0
  19. data/examples/profile_link_new.rb +14 -0
  20. data/examples/profile_update.rb +12 -0
  21. data/examples/request_authorization.rb +25 -0
  22. data/examples/settings_update.rb +12 -0
  23. data/examples/subscription_new.rb +15 -0
  24. data/examples/tagcrumbs_find.rb +25 -0
  25. data/examples/tagcrumbs_search.rb +7 -0
  26. data/examples/user.rb +28 -0
  27. data/examples/user_recommendation_new.rb +15 -0
  28. data/lib/tagcrumbs/builders/builder.rb +45 -0
  29. data/lib/tagcrumbs/builders/json_builder.rb +38 -0
  30. data/lib/tagcrumbs/builders/xml_builder.rb +30 -0
  31. data/lib/tagcrumbs/cli.rb +268 -0
  32. data/lib/tagcrumbs/config_store.rb +35 -0
  33. data/lib/tagcrumbs/exceptions.rb +13 -0
  34. data/lib/tagcrumbs/node.rb +43 -0
  35. data/lib/tagcrumbs/parsers/json_parser.rb +79 -0
  36. data/lib/tagcrumbs/parsers/parser.rb +24 -0
  37. data/lib/tagcrumbs/parsers/xml_parser.rb +54 -0
  38. data/lib/tagcrumbs/proxy.rb +32 -0
  39. data/lib/tagcrumbs/requestor.rb +140 -0
  40. data/lib/tagcrumbs/resources/array.rb +108 -0
  41. data/lib/tagcrumbs/resources/models/accessors.rb +252 -0
  42. data/lib/tagcrumbs/resources/models/activity.rb +19 -0
  43. data/lib/tagcrumbs/resources/models/address.rb +16 -0
  44. data/lib/tagcrumbs/resources/models/city.rb +13 -0
  45. data/lib/tagcrumbs/resources/models/comment.rb +12 -0
  46. data/lib/tagcrumbs/resources/models/country.rb +15 -0
  47. data/lib/tagcrumbs/resources/models/fanship.rb +12 -0
  48. data/lib/tagcrumbs/resources/models/favorite.rb +22 -0
  49. data/lib/tagcrumbs/resources/models/filter.rb +32 -0
  50. data/lib/tagcrumbs/resources/models/flag.rb +10 -0
  51. data/lib/tagcrumbs/resources/models/friendship.rb +12 -0
  52. data/lib/tagcrumbs/resources/models/geoname.rb +8 -0
  53. data/lib/tagcrumbs/resources/models/link.rb +13 -0
  54. data/lib/tagcrumbs/resources/models/location.rb +13 -0
  55. data/lib/tagcrumbs/resources/models/model.rb +148 -0
  56. data/lib/tagcrumbs/resources/models/picture.rb +28 -0
  57. data/lib/tagcrumbs/resources/models/place.rb +17 -0
  58. data/lib/tagcrumbs/resources/models/placemark.rb +30 -0
  59. data/lib/tagcrumbs/resources/models/profile.rb +16 -0
  60. data/lib/tagcrumbs/resources/models/profile_link.rb +12 -0
  61. data/lib/tagcrumbs/resources/models/root.rb +19 -0
  62. data/lib/tagcrumbs/resources/models/settings.rb +14 -0
  63. data/lib/tagcrumbs/resources/models/state.rb +14 -0
  64. data/lib/tagcrumbs/resources/models/subscription.rb +13 -0
  65. data/lib/tagcrumbs/resources/models/suggestions.rb +11 -0
  66. data/lib/tagcrumbs/resources/models/tag.rb +6 -0
  67. data/lib/tagcrumbs/resources/models/tagcrumb.rb +58 -0
  68. data/lib/tagcrumbs/resources/models/user.rb +101 -0
  69. data/lib/tagcrumbs/resources/models/user_recommendation.rb +18 -0
  70. data/lib/tagcrumbs/resources/resource.rb +76 -0
  71. data/lib/tagcrumbs/validations.rb +301 -0
  72. data/lib/tagcrumbs.rb +232 -0
  73. data/script/console +10 -0
  74. data/script/destroy +14 -0
  75. data/script/generate +14 -0
  76. data/spec/fixtures/activity.json +210 -0
  77. data/spec/fixtures/activity.xml +66 -0
  78. data/spec/fixtures/address.json +183 -0
  79. data/spec/fixtures/address.xml +58 -0
  80. data/spec/fixtures/city.json +88 -0
  81. data/spec/fixtures/city.xml +34 -0
  82. data/spec/fixtures/comment.json +286 -0
  83. data/spec/fixtures/comment.xml +87 -0
  84. data/spec/fixtures/country.json +32 -0
  85. data/spec/fixtures/country.xml +13 -0
  86. data/spec/fixtures/fanship.json +180 -0
  87. data/spec/fixtures/fanship.xml +54 -0
  88. data/spec/fixtures/favorite.json +332 -0
  89. data/spec/fixtures/favorite.xml +109 -0
  90. data/spec/fixtures/filter.json +243 -0
  91. data/spec/fixtures/filter.xml +80 -0
  92. data/spec/fixtures/friendship.json +180 -0
  93. data/spec/fixtures/friendship.xml +54 -0
  94. data/spec/fixtures/geoname.json +18 -0
  95. data/spec/fixtures/geoname.xml +6 -0
  96. data/spec/fixtures/json_parser.json +25 -0
  97. data/spec/fixtures/link.json +288 -0
  98. data/spec/fixtures/link.xml +88 -0
  99. data/spec/fixtures/location.json +204 -0
  100. data/spec/fixtures/location.xml +71 -0
  101. data/spec/fixtures/picture.json +154 -0
  102. data/spec/fixtures/picture.png +0 -0
  103. data/spec/fixtures/picture.xml +49 -0
  104. data/spec/fixtures/placemark.json +357 -0
  105. data/spec/fixtures/placemark.xml +58 -0
  106. data/spec/fixtures/placemarks.json +887 -0
  107. data/spec/fixtures/placemarks.xml +348 -0
  108. data/spec/fixtures/profile.json +282 -0
  109. data/spec/fixtures/profile.xml +100 -0
  110. data/spec/fixtures/profile_link.json +156 -0
  111. data/spec/fixtures/profile_link.xml +49 -0
  112. data/spec/fixtures/root.json +46 -0
  113. data/spec/fixtures/root.xml +14 -0
  114. data/spec/fixtures/settings.json +147 -0
  115. data/spec/fixtures/settings.xml +45 -0
  116. data/spec/fixtures/state.json +62 -0
  117. data/spec/fixtures/state.xml +23 -0
  118. data/spec/fixtures/subscription.json +283 -0
  119. data/spec/fixtures/subscription.xml +86 -0
  120. data/spec/fixtures/suggestions.json +1877 -0
  121. data/spec/fixtures/suggestions.xml +724 -0
  122. data/spec/fixtures/tag.json +9 -0
  123. data/spec/fixtures/tag.xml +4 -0
  124. data/spec/fixtures/user.json +105 -0
  125. data/spec/fixtures/user.xml +31 -0
  126. data/spec/fixtures/user_recommendation.json +349 -0
  127. data/spec/fixtures/user_recommendation.xml +106 -0
  128. data/spec/fixtures/validation_errors.json +5 -0
  129. data/spec/fixtures/validation_errors.xml +5 -0
  130. data/spec/fixtures/xml_parser.xml +13 -0
  131. data/spec/spec.opts +1 -0
  132. data/spec/spec_helper.rb +75 -0
  133. data/spec/tagcrumbs/builders/builder_spec.rb +57 -0
  134. data/spec/tagcrumbs/builders/json_builder_spec.rb +47 -0
  135. data/spec/tagcrumbs/builders/xml_builder_spec.rb +34 -0
  136. data/spec/tagcrumbs/exceptions_spec.rb +16 -0
  137. data/spec/tagcrumbs/node_spec.rb +42 -0
  138. data/spec/tagcrumbs/parsers/json_parser_spec.rb +117 -0
  139. data/spec/tagcrumbs/parsers/parser_spec.rb +25 -0
  140. data/spec/tagcrumbs/parsers/xml_parser_spec.rb +117 -0
  141. data/spec/tagcrumbs/proxy_spec.rb +48 -0
  142. data/spec/tagcrumbs/requestor_spec.rb +62 -0
  143. data/spec/tagcrumbs/resources/array_spec.rb +62 -0
  144. data/spec/tagcrumbs/resources/models/accessors_spec.rb +123 -0
  145. data/spec/tagcrumbs/resources/models/activity_spec.rb +33 -0
  146. data/spec/tagcrumbs/resources/models/address_spec.rb +24 -0
  147. data/spec/tagcrumbs/resources/models/city_spec.rb +33 -0
  148. data/spec/tagcrumbs/resources/models/comment_spec.rb +23 -0
  149. data/spec/tagcrumbs/resources/models/country_spec.rb +26 -0
  150. data/spec/tagcrumbs/resources/models/fanship_spec.rb +28 -0
  151. data/spec/tagcrumbs/resources/models/favorite_spec.rb +28 -0
  152. data/spec/tagcrumbs/resources/models/filter_spec.rb +43 -0
  153. data/spec/tagcrumbs/resources/models/flag_spec.rb +5 -0
  154. data/spec/tagcrumbs/resources/models/friendship_spec.rb +28 -0
  155. data/spec/tagcrumbs/resources/models/geoname_spec.rb +18 -0
  156. data/spec/tagcrumbs/resources/models/link_spec.rb +24 -0
  157. data/spec/tagcrumbs/resources/models/location_spec.rb +28 -0
  158. data/spec/tagcrumbs/resources/models/model_spec.rb +27 -0
  159. data/spec/tagcrumbs/resources/models/picture_spec.rb +42 -0
  160. data/spec/tagcrumbs/resources/models/place_spec.rb +12 -0
  161. data/spec/tagcrumbs/resources/models/placemark_spec.rb +61 -0
  162. data/spec/tagcrumbs/resources/models/profile_link_spec.rb +29 -0
  163. data/spec/tagcrumbs/resources/models/profile_spec.rb +43 -0
  164. data/spec/tagcrumbs/resources/models/root_spec.rb +57 -0
  165. data/spec/tagcrumbs/resources/models/settings_spec.rb +32 -0
  166. data/spec/tagcrumbs/resources/models/state_spec.rb +30 -0
  167. data/spec/tagcrumbs/resources/models/subscription_spec.rb +28 -0
  168. data/spec/tagcrumbs/resources/models/suggestions_spec.rb +33 -0
  169. data/spec/tagcrumbs/resources/models/tag_spec.rb +16 -0
  170. data/spec/tagcrumbs/resources/models/tagcrumb_spec.rb +21 -0
  171. data/spec/tagcrumbs/resources/models/user_recommendation_spec.rb +35 -0
  172. data/spec/tagcrumbs/resources/models/user_spec.rb +128 -0
  173. data/spec/tagcrumbs/resources/resource_spec.rb +62 -0
  174. data/spec/tagcrumbs/validations_spec.rb +27 -0
  175. data/spec/tagcrumbs_spec.rb +103 -0
  176. data/tagcrumbs.gemspec +59 -0
  177. data/tasks/rspec.rake +21 -0
  178. metadata +327 -0
data/History.txt ADDED
@@ -0,0 +1,9 @@
1
+ == 0.3.1 2009-06-14
2
+
3
+ * 1 major enhancement:
4
+ * Improved documentation
5
+
6
+ == 0.3.0 2009-06-13
7
+
8
+ * 1 major enhancement:
9
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2009 Tagcrumbs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,177 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ PostInstall.txt
5
+ README.rdoc
6
+ Rakefile
7
+ TODO.txt
8
+ bin/tagcrumbs
9
+ examples/address_update.rb
10
+ examples/comment_new.rb
11
+ examples/favorite_new.rb
12
+ examples/filter_new.rb
13
+ examples/friendship_create.rb
14
+ examples/link_new.rb
15
+ examples/location_update.rb
16
+ examples/picture_update.rb
17
+ examples/placemark_new_simple.rb
18
+ examples/placemark_new_suggestions.rb
19
+ examples/profile_link_new.rb
20
+ examples/profile_update.rb
21
+ examples/request_authorization.rb
22
+ examples/settings_update.rb
23
+ examples/subscription_new.rb
24
+ examples/tagcrumbs_find.rb
25
+ examples/tagcrumbs_search.rb
26
+ examples/user.rb
27
+ examples/user_recommendation_new.rb
28
+ lib/tagcrumbs.rb
29
+ lib/tagcrumbs/builders/builder.rb
30
+ lib/tagcrumbs/builders/json_builder.rb
31
+ lib/tagcrumbs/builders/xml_builder.rb
32
+ lib/tagcrumbs/cli.rb
33
+ lib/tagcrumbs/config_store.rb
34
+ lib/tagcrumbs/exceptions.rb
35
+ lib/tagcrumbs/node.rb
36
+ lib/tagcrumbs/parsers/json_parser.rb
37
+ lib/tagcrumbs/parsers/parser.rb
38
+ lib/tagcrumbs/parsers/xml_parser.rb
39
+ lib/tagcrumbs/proxy.rb
40
+ lib/tagcrumbs/requestor.rb
41
+ lib/tagcrumbs/resources/array.rb
42
+ lib/tagcrumbs/resources/models/accessors.rb
43
+ lib/tagcrumbs/resources/models/activity.rb
44
+ lib/tagcrumbs/resources/models/address.rb
45
+ lib/tagcrumbs/resources/models/city.rb
46
+ lib/tagcrumbs/resources/models/comment.rb
47
+ lib/tagcrumbs/resources/models/country.rb
48
+ lib/tagcrumbs/resources/models/fanship.rb
49
+ lib/tagcrumbs/resources/models/favorite.rb
50
+ lib/tagcrumbs/resources/models/filter.rb
51
+ lib/tagcrumbs/resources/models/flag.rb
52
+ lib/tagcrumbs/resources/models/friendship.rb
53
+ lib/tagcrumbs/resources/models/geoname.rb
54
+ lib/tagcrumbs/resources/models/link.rb
55
+ lib/tagcrumbs/resources/models/location.rb
56
+ lib/tagcrumbs/resources/models/model.rb
57
+ lib/tagcrumbs/resources/models/picture.rb
58
+ lib/tagcrumbs/resources/models/place.rb
59
+ lib/tagcrumbs/resources/models/placemark.rb
60
+ lib/tagcrumbs/resources/models/profile.rb
61
+ lib/tagcrumbs/resources/models/profile_link.rb
62
+ lib/tagcrumbs/resources/models/root.rb
63
+ lib/tagcrumbs/resources/models/settings.rb
64
+ lib/tagcrumbs/resources/models/state.rb
65
+ lib/tagcrumbs/resources/models/subscription.rb
66
+ lib/tagcrumbs/resources/models/suggestions.rb
67
+ lib/tagcrumbs/resources/models/tag.rb
68
+ lib/tagcrumbs/resources/models/tagcrumb.rb
69
+ lib/tagcrumbs/resources/models/user.rb
70
+ lib/tagcrumbs/resources/models/user_recommendation.rb
71
+ lib/tagcrumbs/resources/resource.rb
72
+ lib/tagcrumbs/validations.rb
73
+ script/console
74
+ script/destroy
75
+ script/generate
76
+ spec/fixtures/activity.json
77
+ spec/fixtures/activity.xml
78
+ spec/fixtures/address.json
79
+ spec/fixtures/address.xml
80
+ spec/fixtures/city.json
81
+ spec/fixtures/city.xml
82
+ spec/fixtures/comment.json
83
+ spec/fixtures/comment.xml
84
+ spec/fixtures/country.json
85
+ spec/fixtures/country.xml
86
+ spec/fixtures/fanship.json
87
+ spec/fixtures/fanship.xml
88
+ spec/fixtures/favorite.json
89
+ spec/fixtures/favorite.xml
90
+ spec/fixtures/filter.json
91
+ spec/fixtures/filter.xml
92
+ spec/fixtures/friendship.json
93
+ spec/fixtures/friendship.xml
94
+ spec/fixtures/geoname.json
95
+ spec/fixtures/geoname.xml
96
+ spec/fixtures/json_parser.json
97
+ spec/fixtures/link.json
98
+ spec/fixtures/link.xml
99
+ spec/fixtures/location.json
100
+ spec/fixtures/location.xml
101
+ spec/fixtures/picture.json
102
+ spec/fixtures/picture.png
103
+ spec/fixtures/picture.xml
104
+ spec/fixtures/placemark.json
105
+ spec/fixtures/placemark.xml
106
+ spec/fixtures/placemarks.json
107
+ spec/fixtures/placemarks.xml
108
+ spec/fixtures/profile.json
109
+ spec/fixtures/profile.xml
110
+ spec/fixtures/profile_link.json
111
+ spec/fixtures/profile_link.xml
112
+ spec/fixtures/root.json
113
+ spec/fixtures/root.xml
114
+ spec/fixtures/settings.json
115
+ spec/fixtures/settings.xml
116
+ spec/fixtures/state.json
117
+ spec/fixtures/state.xml
118
+ spec/fixtures/subscription.json
119
+ spec/fixtures/subscription.xml
120
+ spec/fixtures/suggestions.json
121
+ spec/fixtures/suggestions.xml
122
+ spec/fixtures/tag.json
123
+ spec/fixtures/tag.xml
124
+ spec/fixtures/user.json
125
+ spec/fixtures/user.xml
126
+ spec/fixtures/user_recommendation.json
127
+ spec/fixtures/user_recommendation.xml
128
+ spec/fixtures/validation_errors.json
129
+ spec/fixtures/validation_errors.xml
130
+ spec/fixtures/xml_parser.xml
131
+ spec/spec.opts
132
+ spec/spec_helper.rb
133
+ spec/tagcrumbs/builders/builder_spec.rb
134
+ spec/tagcrumbs/builders/json_builder_spec.rb
135
+ spec/tagcrumbs/builders/xml_builder_spec.rb
136
+ spec/tagcrumbs/exceptions_spec.rb
137
+ spec/tagcrumbs/node_spec.rb
138
+ spec/tagcrumbs/parsers/json_parser_spec.rb
139
+ spec/tagcrumbs/parsers/parser_spec.rb
140
+ spec/tagcrumbs/parsers/xml_parser_spec.rb
141
+ spec/tagcrumbs/proxy_spec.rb
142
+ spec/tagcrumbs/requestor_spec.rb
143
+ spec/tagcrumbs/resources/array_spec.rb
144
+ spec/tagcrumbs/resources/models/accessors_spec.rb
145
+ spec/tagcrumbs/resources/models/activity_spec.rb
146
+ spec/tagcrumbs/resources/models/address_spec.rb
147
+ spec/tagcrumbs/resources/models/city_spec.rb
148
+ spec/tagcrumbs/resources/models/comment_spec.rb
149
+ spec/tagcrumbs/resources/models/country_spec.rb
150
+ spec/tagcrumbs/resources/models/fanship_spec.rb
151
+ spec/tagcrumbs/resources/models/favorite_spec.rb
152
+ spec/tagcrumbs/resources/models/filter_spec.rb
153
+ spec/tagcrumbs/resources/models/flag_spec.rb
154
+ spec/tagcrumbs/resources/models/friendship_spec.rb
155
+ spec/tagcrumbs/resources/models/geoname_spec.rb
156
+ spec/tagcrumbs/resources/models/link_spec.rb
157
+ spec/tagcrumbs/resources/models/location_spec.rb
158
+ spec/tagcrumbs/resources/models/model_spec.rb
159
+ spec/tagcrumbs/resources/models/picture_spec.rb
160
+ spec/tagcrumbs/resources/models/place_spec.rb
161
+ spec/tagcrumbs/resources/models/placemark_spec.rb
162
+ spec/tagcrumbs/resources/models/profile_link_spec.rb
163
+ spec/tagcrumbs/resources/models/profile_spec.rb
164
+ spec/tagcrumbs/resources/models/root_spec.rb
165
+ spec/tagcrumbs/resources/models/settings_spec.rb
166
+ spec/tagcrumbs/resources/models/state_spec.rb
167
+ spec/tagcrumbs/resources/models/subscription_spec.rb
168
+ spec/tagcrumbs/resources/models/suggestions_spec.rb
169
+ spec/tagcrumbs/resources/models/tag_spec.rb
170
+ spec/tagcrumbs/resources/models/tagcrumb_spec.rb
171
+ spec/tagcrumbs/resources/models/user_recommendation_spec.rb
172
+ spec/tagcrumbs/resources/models/user_spec.rb
173
+ spec/tagcrumbs/resources/resource_spec.rb
174
+ spec/tagcrumbs/validations_spec.rb
175
+ spec/tagcrumbs_spec.rb
176
+ tagcrumbs.gemspec
177
+ tasks/rspec.rake
data/PostInstall.txt ADDED
@@ -0,0 +1,2 @@
1
+ For more information on tagcrumbs, see http://tagcrumbs.rubyforge.org
2
+
data/README.rdoc ADDED
@@ -0,0 +1,45 @@
1
+ = Tagcrumbs Gem
2
+
3
+ == DESCRIPTION:
4
+
5
+ This is a RubyGem that provides an ActiveRecord-like interface to the www.tagcrumbs.com web service.
6
+
7
+ == WEBSITES:
8
+
9
+ * http://www.tagcrumbs.com/
10
+ * http://developers.tagcrumbs.com/
11
+ * http://github.com/tagcrumbs/tagcrumbs_gem
12
+ * http://tagcrumbs.rubyforge.org/
13
+
14
+ == FEATURES:
15
+
16
+ * ActiveRecord and ActiveResource-like interface
17
+ * Support for OAuth authorization (3-legged and 2-legged)
18
+ * Automatic loading of associated Models when they are accessed (just like ActiveRecord associations)
19
+ * JSON and XML support
20
+ * URLs are loaded from the web service and are not build manually to automatically adapt to smaller changes
21
+ * A console program to interactively create new Placemarks or to create a Placemark by passing command line arguments (scripting support)
22
+ * Validation error messages are read from the server and loaded into the objects
23
+ * Find Tagcrumbs by many filter criteria
24
+ * Load name, tag and city suggestions to help a user create a new placemark
25
+
26
+ == SYNOPSIS:
27
+
28
+ * see the examples directory for some usage examples
29
+
30
+ == REQUIREMENTS:
31
+
32
+ * activesupport
33
+ * hpricot
34
+ * htmlentities
35
+ * json
36
+ * oauth
37
+ * mime-types
38
+ * builder
39
+
40
+ == INSTALL:
41
+
42
+ * sudo gem install tagcrumbs
43
+
44
+ == LICENSE:
45
+ * see License.txt for more information
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
2
+ %w[rake rake/clean fileutils newgem rubigen].each { |f| require f }
3
+ require File.dirname(__FILE__) + '/lib/tagcrumbs'
4
+
5
+ # Generate all the Rake tasks
6
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
7
+ $hoe = Hoe.new('tagcrumbs', Tagcrumbs::VERSION) do |p|
8
+ p.developer('Sascha Konietzke', 'sascha@tagcrumbs.com')
9
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
10
+ p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
11
+ p.rubyforge_name = p.name # TODO this is default value
12
+ p.extra_deps = [
13
+ ['activesupport','= 2.3.2'],
14
+ ['hpricot', '= 0.8.1'],
15
+ ['htmlentities', '= 4.0.0'],
16
+ ['json', '= 1.1.6'],
17
+ ['oauth', '= 0.3.4'],
18
+ ['mime-types', '= 1.16'],
19
+ ['builder', '= 2.1.2']
20
+ ]
21
+ p.extra_dev_deps = [
22
+ ['newgem', ">= #{::Newgem::VERSION}"]
23
+ ]
24
+
25
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
26
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
27
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
28
+ p.rsync_args = '-av --delete --ignore-errors'
29
+ end
30
+
31
+ require 'newgem/tasks' # load /tasks/*.rake
32
+ Dir['tasks/**/*.rake'].each { |t| load t }
33
+
34
+ # TODO - want other tests/tasks run by default? Add them to the list
35
+ task :default => [:spec]
data/TODO.txt ADDED
@@ -0,0 +1,17 @@
1
+ - push to rubyforge
2
+
3
+ - have more examples in rdoc
4
+ - test on windows
5
+ - filter activities by location
6
+ - direct access to total_entries in proxy if present in document
7
+
8
+ == next steps
9
+ - implement http-basic to oauth proxy
10
+ - migrate to ruby 1.9
11
+
12
+ == future version
13
+ - add distances with georuby?
14
+ - email recommendations?
15
+ - client_application?
16
+
17
+
data/bin/tagcrumbs ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/../lib/tagcrumbs/cli'
4
+
5
+ Tagcrumbs::CLI.execute(STDOUT, STDIN, STDERR, ARGV)
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/request_authorization'
4
+
5
+
6
+ placemark = Tagcrumbs.current_user.placemarks.first # get your last placemark
7
+
8
+ placemark.address.street_address += '- modified by webservice'
9
+
10
+ if placemark.address.save
11
+ puts "Updated the address of #{placemark.name}"
12
+ else
13
+ puts "Could not update the address of #{placemark.name}"
14
+ end
15
+
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/request_authorization'
4
+
5
+ # Find a Placemark to put the comment first
6
+ placemark = Tagcrumbs.current_user.placemarks.first
7
+ raise "You don't have any Placemarks" unless placemark # of course you can also add comments to other user's placemarks, but we don't want to spam them here
8
+
9
+ comment = Tagcrumbs::Comment.new(:text => 'My comment text', :placemark => placemark)
10
+
11
+
12
+ if comment.save
13
+ puts "Saved Comment successfully at #{comment.created_at}. URL: #{comment.resource_url}"
14
+ else
15
+ puts "There were errors when saving the Comment:"
16
+ puts comment.errors.full_messages.join("\n")
17
+ end
18
+
19
+ # comment.destroy # would destroy the comment
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/request_authorization'
4
+
5
+
6
+ placemark = Tagcrumbs::Placemark.find(:from => :friends, :per_page => 1).first # get the last placemark of your friends
7
+
8
+ favorite = Tagcrumbs::Favorite.new(:tag_list => 'tag1, tag2', :private => false, :subscribe => false, :placemark => placemark)
9
+
10
+ if favorite.save
11
+ puts "Saved Favorite successfully at #{favorite.created_at}. URL: #{favorite.resource_url}"
12
+ else
13
+ puts "There were errors when saving the Favorite:"
14
+ puts favorite.errors.full_messages.join("\n")
15
+ end
16
+
17
+ # favorite.destroy # would destroy the favorite
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/request_authorization'
4
+
5
+ filter = Tagcrumbs::Filter.new(:name => 'Friends Favs in Germany', :from => 'friends', :tagcrumb_type => 'Favorite',
6
+ :country => Tagcrumbs::Country.search('germany').first)
7
+
8
+ if filter.save
9
+ puts "Saved Filter successfully at #{filter.created_at}. URL: #{filter.resource_url}"
10
+ else
11
+ puts "There were errors when saving the Filter:"
12
+ puts filter.errors.full_messages.join("\n")
13
+ end
14
+
15
+ puts "First Favorite: #{filter.tagcrumbs.first.name}"
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/request_authorization'
4
+
5
+ sascha = Tagcrumbs::User.find_by_username 'sascha'
6
+
7
+ if Tagcrumbs.current_user.friend_with?(sascha)
8
+ puts "You are already a friend with sascha"
9
+ Tagcrumbs.current_user.friendship_with(sascha).destroy
10
+ else
11
+ puts "Making you a friend of sascha..."
12
+ friendship = Tagcrumbs::Friendship.new(:friend => sascha)
13
+
14
+ if friendship.save
15
+ puts "You are now friend with sascha"
16
+ else
17
+ puts "Could not become friend of sascha"
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/request_authorization'
4
+
5
+ placemark = Tagcrumbs.current_user.placemarks.first
6
+
7
+ link = Tagcrumbs::Link.new(:url => 'http://www.tagcrumbs.com', :placemark => placemark)
8
+
9
+ if link.save
10
+ puts "Saved Link successfully at #{link.created_at}. URL: #{link.resource_url}"
11
+ else
12
+ puts "There were errors when saving the Link:"
13
+ puts link.errors.full_messages.join("\n")
14
+ end
15
+
16
+ # link.destroy # would destroy the link
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/request_authorization'
4
+
5
+
6
+ location = Tagcrumbs.current_user.location
7
+ puts "Your are currently at #{location.latitude}, #{location.longitude}."
8
+
9
+ location.latitude = 0.0
10
+ location.longitude = 0.0
11
+
12
+ if location.save
13
+ puts "Updated your current location"
14
+ else
15
+ puts "Could not update your current location."
16
+ end
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/request_authorization'
4
+
5
+ pic = Tagcrumbs.current_user.picture
6
+
7
+ pic.get_file(ENV['HOME'] + '/Pictures/ich/ich.jpg')
8
+
9
+ if pic.save
10
+ puts "Uploaded a new Picture!"
11
+ else
12
+ puts "There were errors when saving the Picture:"
13
+ puts pic.errors.full_messages.join("\n")
14
+ end
15
+
16
+ # pic.destroy
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/request_authorization'
4
+
5
+
6
+ # Just create a Placemark without any suggestions
7
+ placemark = Tagcrumbs::Placemark.new(:name => "Tagcrumbs Gem Test", :notes => "My Notes", :tag_list => 'tag1, tag2',
8
+ :private => true, :latitude => 49.12, :longitude => 9.01, :guess_city => true,
9
+ :address_attributes => {
10
+ :street_address => 'Street Name',
11
+ :postal_code => '1234',
12
+ :city => 'City Name',
13
+ :state => 'State Name',
14
+ :country => 'Country Name'
15
+ })
16
+
17
+ if placemark.save
18
+ puts "Saved Placemark successfully at #{placemark.created_at}. URL: #{placemark.resource_url}"
19
+ else
20
+ puts "There were errors when saving the Placemark:"
21
+ puts placemark.errors.full_messages.join("\n")
22
+ end
23
+
24
+ # placemark.destroy # would destroy the placemark
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/request_authorization'
4
+
5
+ # Create a Placemark with Suggestions
6
+ placemark = Tagcrumbs::Placemark.new
7
+
8
+ # Latitude and Longitude must be set first to get suggestions
9
+ placemark.latitude = 49
10
+ placemark.longitude = 9
11
+
12
+ suggestions = placemark.suggestions # load suggestions from the webservice
13
+
14
+ # Of course you would let the user pick from the suggestions
15
+ placemark.name = suggestions.names.first || 'no suggestions found'
16
+ placemark.city = suggestions.cities.first
17
+ placemark.tag_list = suggestions.popular_tags.first.name
18
+
19
+ if placemark.save
20
+ puts "Saved Placemark successfully at #{placemark.created_at}. URL: #{placemark.resource_url}"
21
+ else
22
+ puts "There were errors when saving the Placemark:"
23
+ puts placemark.errors.full_messages.join("\n")
24
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/request_authorization'
4
+
5
+ profile_link = Tagcrumbs::ProfileLink.new(:url => 'http://www.tagcrumbs.com', :link_type => 'Homepage')
6
+
7
+ if profile_link.save
8
+ puts "Saved profile link. URL: #{profile_link.resource_url}"
9
+ else
10
+ puts "Could not save profile link."
11
+ puts profile_link.errors.full_messages.join("\n")
12
+ end
13
+
14
+ # profile_link.destroy
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/request_authorization'
4
+
5
+ Tagcrumbs.current_user.profile.fullname = 'Testing Webservice'
6
+ Tagcrumbs.current_user.profile.city = Tagcrumbs::City.search('stuttgart').first
7
+
8
+ if Tagcrumbs.current_user.profile.save
9
+ puts "Updated Fullname"
10
+ else
11
+ puts "Could not update Fullname."
12
+ end
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/../lib/tagcrumbs'
4
+
5
+ config_store = Tagcrumbs::ConfigStore.load(ENV['HOME'] + '/.tagcrumbs')
6
+ Tagcrumbs.configure(config_store.options) # you can also set up your own consumer credentials at this point
7
+
8
+ unless Tagcrumbs.valid_credentials?
9
+ puts "Please authorize the Gem to have access to your Tagcrumbs account on: #{Tagcrumbs.authorize_url}"
10
+
11
+ %x(open #{Tagcrumbs.authorize_url}) # open browser
12
+
13
+ print "Press Enter to continue..."
14
+ gets
15
+
16
+ if Tagcrumbs.exchange_request_token!
17
+ puts "Authorization succeeded."
18
+
19
+ config_store.update(Tagcrumbs.options.slice(:access_token, :access_secret))
20
+
21
+ else
22
+ puts "Authorization failed."
23
+ end
24
+
25
+ end
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/request_authorization'
4
+
5
+ Tagcrumbs.current_user.settings.locale = 'en-US'
6
+
7
+ if Tagcrumbs.current_user.settings.save
8
+ puts "Updated settings successfully"
9
+ else
10
+ puts "Could not update settings"
11
+ puts Tagcrumbs.current_user.settings.errors.full_messages.join("\n")
12
+ end
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/request_authorization'
4
+
5
+ placemark = Tagcrumbs::Placemark.find(:from => :friends, :per_page => 1).first # get the last placemark of your friends
6
+ subscription = Tagcrumbs::Subscription.new(:placemark => placemark)
7
+
8
+ if subscription.save
9
+ puts "Saved subscription. URL: #{subscription.resource_url}"
10
+ else
11
+ puts "Could not save subscription."
12
+ puts subscription.errors.full_messages.join("\n")
13
+ end
14
+
15
+ # profile_link.destroy
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/../lib/tagcrumbs' # this would not be needed if we only search for public Tagcrumbs
4
+
5
+ # Find the latest Tagcrumbs in Stuttgart, Germany
6
+ stuttgart = Tagcrumbs::City.search('stuttgart').first
7
+ in_stuttgart = Tagcrumbs::Tagcrumb.find(:from => :everybody, :city => stuttgart)
8
+
9
+ puts "Total Tagcrumbs in Stuttgart: #{in_stuttgart.total_entries}"
10
+
11
+ # Find Favorites of one user in the last two weeks
12
+ from_cornelius = Tagcrumbs::Tagcrumb.find(:username => 'cornelius', :from => :user, :since => 2.weeks.ago)
13
+ puts "Total Favorites of Cornelius in the last two weeks: #{from_cornelius.total_entries}"
14
+
15
+ # Find all Placemarks near the current location
16
+ nearby = Tagcrumbs::Tagcrumb.find(:from => :everybody, :within => 0.55)
17
+ puts "A total of #{nearby.total_entries} Tagcrumbs near your current location"
18
+
19
+ # Find all Placemarks near any other location
20
+ nearby_other = Tagcrumbs::Tagcrumb.find(:from => :everybody, :within => 0.55, :latitude => 49, :longitude => 9, :sort => :distance, :order => :asc, :per_page => 50)
21
+ puts "A total of #{nearby_other.total_entries} Tagcrumbs nearby (49, 9)"
22
+
23
+ # Find Placemarks with certain tags
24
+ tagged = Tagcrumbs::Tagcrumb.find(:from => :friends, :tags => 'bar, beer')
25
+ puts "Your friends have #{tagged.total_entries} Tagcrumbs tagged bar and beer."
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/../lib/tagcrumbs' # this would not be needed if we only search for public Tagcrumbs
4
+
5
+ # This is doing a fulltext search, searching name, tags, description, etc.
6
+ restaurants = Tagcrumbs::Tagcrumb.search(:q => 'restaurant', :l => 'berlin', :w => 'city')
7
+ puts "#{restaurants.total_entries} Placemarks that contain the word 'restaurant' in Berlin."
data/examples/user.rb ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby -rubygems
2
+
3
+ require File.dirname(__FILE__) + '/request_authorization'
4
+
5
+ user = Tagcrumbs.current_user
6
+
7
+ puts "== Current active user: #{user}, Fullname: #{user.profile.fullname}"
8
+
9
+ puts "== You have #{user.tagcrumbs.total_entries} Tagcrumbs."
10
+
11
+ puts "== Your friends:"
12
+
13
+ user.friends.each do |friend|
14
+ puts friend.username
15
+ end
16
+
17
+ puts "== Your last comments:"
18
+
19
+ user.comments.each do |comment|
20
+ puts comment.text
21
+ end
22
+
23
+ puts "== Your last activities:"
24
+
25
+ user.activities.each do |activity|
26
+ puts "Type: #{activity.event_type}, Subject: #{activity.subject.resource_url} Secondary Subject: #{activity.secondary_subject ? activity.secondary_subject.resource_url : 'none'}"
27
+ end
28
+