sword2ruby 1.0.0

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 (92) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +30 -0
  4. data/LICENCE +35 -0
  5. data/README.md +43 -0
  6. data/Rakefile +53 -0
  7. data/doc/Atom/Collection.html +837 -0
  8. data/doc/Atom/Element.html +197 -0
  9. data/doc/Atom/Entry.html +1795 -0
  10. data/doc/Atom/Feed.html +297 -0
  11. data/doc/Atom/Service.html +363 -0
  12. data/doc/Atom.html +158 -0
  13. data/doc/Gemfile.html +125 -0
  14. data/doc/Object.html +165 -0
  15. data/doc/REXML/Element.html +493 -0
  16. data/doc/REXML.html +158 -0
  17. data/doc/Rakefile.html +123 -0
  18. data/doc/Sword2Ruby/Atom.html +169 -0
  19. data/doc/Sword2Ruby/AutoDiscover.html +327 -0
  20. data/doc/Sword2Ruby/Connection.html +274 -0
  21. data/doc/Sword2Ruby/DepositReceipt.html +331 -0
  22. data/doc/Sword2Ruby/Exception.html +168 -0
  23. data/doc/Sword2Ruby/SwordAccept.html +169 -0
  24. data/doc/Sword2Ruby/SwordStatementOAIORE.html +277 -0
  25. data/doc/Sword2Ruby/User.html +272 -0
  26. data/doc/Sword2Ruby/Utility.html +1101 -0
  27. data/doc/Sword2Ruby.html +213 -0
  28. data/doc/created.rid +29 -0
  29. data/doc/images/add.png +0 -0
  30. data/doc/images/brick.png +0 -0
  31. data/doc/images/brick_link.png +0 -0
  32. data/doc/images/bug.png +0 -0
  33. data/doc/images/bullet_black.png +0 -0
  34. data/doc/images/bullet_toggle_minus.png +0 -0
  35. data/doc/images/bullet_toggle_plus.png +0 -0
  36. data/doc/images/date.png +0 -0
  37. data/doc/images/delete.png +0 -0
  38. data/doc/images/find.png +0 -0
  39. data/doc/images/loadingAnimation.gif +0 -0
  40. data/doc/images/macFFBgHack.png +0 -0
  41. data/doc/images/package.png +0 -0
  42. data/doc/images/page_green.png +0 -0
  43. data/doc/images/page_white_text.png +0 -0
  44. data/doc/images/page_white_width.png +0 -0
  45. data/doc/images/plugin.png +0 -0
  46. data/doc/images/ruby.png +0 -0
  47. data/doc/images/tag_blue.png +0 -0
  48. data/doc/images/tag_green.png +0 -0
  49. data/doc/images/transparent.png +0 -0
  50. data/doc/images/wrench.png +0 -0
  51. data/doc/images/wrench_orange.png +0 -0
  52. data/doc/images/zoom.png +0 -0
  53. data/doc/index.html +118 -0
  54. data/doc/js/darkfish.js +153 -0
  55. data/doc/js/jquery.js +18 -0
  56. data/doc/js/navigation.js +142 -0
  57. data/doc/js/search.js +94 -0
  58. data/doc/js/search_index.js +1 -0
  59. data/doc/js/searcher.js +228 -0
  60. data/doc/rdoc.css +543 -0
  61. data/doc/spec/fixtures/example_txt.html +125 -0
  62. data/doc/table_of_contents.html +267 -0
  63. data/lib/sword2ruby/auto_discover.rb +71 -0
  64. data/lib/sword2ruby/collection.rb +261 -0
  65. data/lib/sword2ruby/connection.rb +37 -0
  66. data/lib/sword2ruby/constant.rb +35 -0
  67. data/lib/sword2ruby/deposit_receipt.rb +52 -0
  68. data/lib/sword2ruby/element.rb +12 -0
  69. data/lib/sword2ruby/entry.rb +602 -0
  70. data/lib/sword2ruby/exception.rb +7 -0
  71. data/lib/sword2ruby/feed.rb +34 -0
  72. data/lib/sword2ruby/rexml_element.rb +79 -0
  73. data/lib/sword2ruby/service.rb +79 -0
  74. data/lib/sword2ruby/sword_accept.rb +10 -0
  75. data/lib/sword2ruby/sword_statement_oai_ore.rb +38 -0
  76. data/lib/sword2ruby/user.rb +25 -0
  77. data/lib/sword2ruby/utility.rb +232 -0
  78. data/lib/sword2ruby/version.rb +4 -0
  79. data/lib/sword2ruby.rb +32 -0
  80. data/spec/auto_discover_spec.rb +30 -0
  81. data/spec/collection_spec.rb +33 -0
  82. data/spec/connection_spec.rb +21 -0
  83. data/spec/end_to_end_spec.rb +235 -0
  84. data/spec/fixtures/example.txt +3 -0
  85. data/spec/fixtures/snowflake.png +0 -0
  86. data/spec/fixtures/zip-test.zip +0 -0
  87. data/spec/service_spec.rb +38 -0
  88. data/spec/statement_spec.rb +53 -0
  89. data/spec/test_constants.rb +32 -0
  90. data/sword2ruby.gemspec +42 -0
  91. data/sword2ruby.tmproj +27 -0
  92. metadata +197 -0
@@ -0,0 +1,35 @@
1
+ module Sword2Ruby
2
+
3
+ #The Atom Syndication Format namespace: http://www.w3.org/2005/Atom
4
+ ATOM_SYNDICATION_FORMAT_NAMESPACE = "http://www.w3.org/2005/Atom"
5
+
6
+ #Atom Publishing Protocol namespace: http://www.w3.org/2007/app
7
+ ATOM_PUBLISHING_PROTOCOL_NAMESPACE = "http://www.w3.org/2007/app"
8
+
9
+ #An array of valid URL schemes: http://, https:// and file://
10
+ VALID_URI_SCHEMES = [:http, :https, :file]
11
+
12
+ #A special lambda object representing the nil object, used by find() when parsing XML which may or may not contain specific elements and attributes
13
+ NIL_LAMBDA = lambda {
14
+ result = nil;
15
+
16
+ def result.text
17
+ nil
18
+ end
19
+
20
+ def result.href
21
+ nil
22
+ end
23
+
24
+ def result.value
25
+ nil
26
+ end
27
+
28
+ def result.attribute(name)
29
+ nil
30
+ end
31
+
32
+ result;
33
+ }
34
+
35
+ end
@@ -0,0 +1,52 @@
1
+ module Sword2Ruby
2
+ #The DepositReceipt object is returned following Post, Put and Delete operations on the Sword server.
3
+ #In some cases (e.g. Post), an Atom::Entry will usually be returned describing the newly created entry. Operations such as Delete do not return an Atom::Entry.
4
+ #If the Sword server does not automatically return the Atom::Entry but instead provides a link to it, the DepositReceipt object will automatically fetch it.
5
+ #
6
+ #For more information, see the Sword2 specification: {section 10 "Deposit Receipt"}[http://sword-app.svn.sourceforge.net/viewvc/sword-app/spec/tags/sword-2.0/SWORDProfile.html?revision=377#depositreceipt].
7
+ class DepositReceipt
8
+
9
+ #Boolean value indicating whether there is an Atom::Entry associated with this receipt.
10
+ attr_reader :has_entry
11
+
12
+ #The Atom::Entry associated with this receipt, or nil if not supplied. The Atom::Entry will be automatically fetched from the server when necessary.
13
+ attr_reader :entry
14
+
15
+ #The location header returned by the Sword server, usually after Posting or Putting.
16
+ attr_reader :location
17
+
18
+ #The http status code returned by the Sword server.
19
+ attr_reader :status_code
20
+
21
+ #The http status message returned by the Sword server.
22
+ attr_reader :status_message
23
+
24
+ #Create a new DepositReceipt using the Response object returned by the server.
25
+ #===Parameters
26
+ #response:: the response object returned by the request
27
+ #connection:: a Sword2Ruby::Connection object
28
+ def initialize(response, connection)
29
+ @location = response.header["location"]
30
+ @status_code = response.code
31
+ @status_message = response.message
32
+
33
+ if response.body
34
+ #If a receipt was returned, parse it
35
+ @entry = ::Atom::Entry.parse(response.body)
36
+ @entry.http = connection
37
+ @has_entry = true
38
+ else
39
+ #if the receipt was not returned, try and retrieve it
40
+ if @location
41
+ @entry = ::Atom::Entry.parse(connection.get(@location).body)
42
+ @has_entry = true
43
+ else
44
+ #Otherwise, there is no receipt (e.g. for a delete)
45
+ @has_entry = false
46
+ @entry = nil
47
+ end
48
+ end
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,12 @@
1
+ require 'atom/element'
2
+
3
+ module Sword2Ruby
4
+ #Extensions to the atom-tools[https://github.com/bct/atom-tools/wiki] Atom::Element class to support Sword2 operations.
5
+ #These methods are additive to those supplied by the atom-tools gem.
6
+ #
7
+ #Please see the {atom-tools documentation}[http://rdoc.info/github/bct/atom-tools/master/frames] for a complete list of attributes and methods.
8
+ class ::Atom::Element
9
+ #Sword2Ruby::Connection (Atom::HTTP) object to facilitate connections in derived classes, such as Atom::Entry, Atom::Feed, Atom::Workspace and Atom::Collection.
10
+ attr_accessor :http
11
+ end
12
+ end