ruby-fedora 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 1.0.4 2009-07-10
2
+
3
+ !! Not Backwards Compatible with Fedora < 3.2.* !!
4
+
5
+ * 1 major enhancement:
6
+ * ruby-fedora is now compatible with Fedora 3.2.1
7
+
1
8
  == 1.0.0 2009-02-04
2
9
 
3
10
  * 1 major enhancement:
data/README.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == Getting Help
2
+
3
+ * Project Homepage: <http://yourmediashelf.com/activefedora>
4
+ * Further documentation is available at <http://projects.mediashelf.us/show/active-fedora>
5
+ * Community Discussions & Mailing List are located at <http://groups.google.com/group/active-fedora>
6
+
1
7
  == Installation
2
8
 
3
9
  gem install ruby-fedora
@@ -37,3 +43,32 @@ rake pkg
37
43
  == TODO
38
44
 
39
45
  - remove anything in test/* that are no longer relevant
46
+
47
+ == LICENSE:
48
+
49
+ Copyright (c) 2009 Matt Zumwalt
50
+
51
+ This program is free software: you can redistribute it and/or modify
52
+ it under the terms of the GNU Lesser General Public License (LGPL) as
53
+ published by the Free Software Foundation, either version 3 of the License,
54
+ or (at your option) any later version.
55
+
56
+ This program is distributed in the hope that it will be useful,
57
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
58
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
59
+ GNU General Public License for more details.
60
+
61
+ You should have received a copy of the GNU Lesser General Public License
62
+ along with this program. If not, see <http://www.gnu.org/licenses/> or
63
+ see <http://www.gnu.org/licenses/lgpl.html>.
64
+
65
+ The above copyright notice and this permission notice shall be
66
+ included in all copies or substantial portions of the Software.
67
+
68
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
69
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
70
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
71
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
72
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
73
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
74
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -4,13 +4,19 @@ require 'fedora/repository'
4
4
  class Fedora::Datastream < Fedora::BaseObject
5
5
  def initialize(attrs = nil)
6
6
  super
7
- @attributes[:controlGroup] = 'M' if @attributes[:mimeType]
8
- # TODO: check for required attributes
7
+ self.control_group='M' if @attributes[:mimeType]
9
8
  end
10
9
 
11
10
  def pid
12
11
  attributes[:pid]
13
12
  end
13
+
14
+ def control_group
15
+ @attributes[:controlGroup]
16
+ end
17
+ def control_group=(cg)
18
+ @attributes[:controlGroup]=cg
19
+ end
14
20
 
15
21
  def dsid
16
22
  if attributes.has_key?(:dsid)
@@ -20,6 +26,14 @@ class Fedora::Datastream < Fedora::BaseObject
20
26
  end
21
27
  end
22
28
 
29
+ def label
30
+ @attributes[:dsLabel]
31
+ end
32
+
33
+ def label=(new_label)
34
+ @attributes[:dsLabel] = new_label
35
+ end
36
+
23
37
  # See http://www.fedora.info/definitions/identifiers/
24
38
  def uri
25
39
  "fedora:info/#{pid}/datastreams/#{dsid}"
@@ -21,6 +21,7 @@ module Fedora
21
21
  Thread.current[:repo]=nil
22
22
  end
23
23
  def self.register(url, surrogate=nil)
24
+ url = url.to_s.chop if url.to_s =~ /\/\Z/
24
25
  Thread.current[:repo]= Fedora::Repository.new(url, surrogate)
25
26
  begin
26
27
  repo = Thread.current[:repo]
@@ -75,7 +76,7 @@ module Fedora
75
76
  # The field "pid" is always included.
76
77
  #
77
78
  # == Examples
78
- # find_objects("label=Image1"
79
+ # find_objects("label=Image1")
79
80
  # find_objects("pid~demo:*", "label=test")
80
81
  # find_objects("label=Image1", :include => :all)
81
82
  # find_objects("label=Image1", :include => [:label])
@@ -88,7 +89,7 @@ module Fedora
88
89
  fields = (fields.nil? || (fields == :all)) ? ALL_FIELDS : ([:pid] + ([fields].flatten! - [:pid]))
89
90
 
90
91
  query = args.join(' ')
91
- params = { :format => 'xml', :query => query }
92
+ params = { :resultFormat => 'xml', :query => query }
92
93
  params[:maxResults] = options[:limit] if options[:limit]
93
94
  params[:sessionToken] = options[:sessionToken] if options[:sessionToken]
94
95
  includes = fields.inject("") { |s, f| s += "&#{f}=true"; s }
@@ -155,11 +156,12 @@ module Fedora
155
156
  case object
156
157
  when Fedora::FedoraObject
157
158
  response = connection.put("#{url_for(object)}?" + object.attributes.to_fedora_query)
158
- response.code == '307'
159
+ response.code == '200' || '307'
159
160
  when Fedora::Datastream
160
161
  raise ArgumentError, "Missing dsID attribute" if object.dsid.nil?
161
162
  response = connection.put("#{url_for(object)}?" + object.attributes.to_fedora_query, object.blob)
162
- response.code == '201'
163
+ response.code == '200' || '201'
164
+ return response.code
163
165
  else
164
166
  raise ArgumentError, "Unknown object type"
165
167
  end
data/lib/ruby-fedora.rb CHANGED
@@ -3,7 +3,7 @@ gem 'xml-simple'
3
3
  $LOAD_PATH.unshift File.dirname(__FILE__) unless
4
4
  $LOAD_PATH.include?(File.dirname(__FILE__)) || $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
5
5
  module Fedora #:nodoc:
6
- VERSION = '1.0.2'
6
+ VERSION = '1.0.4'
7
7
  end
8
8
  #extended to remove facets dep
9
9
  class Hash
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-fedora
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - MediaShelf
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-26 00:00:00 -06:00
12
+ date: 2009-07-10 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -50,7 +50,7 @@ dependencies:
50
50
  requirements:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: 1.2.3
53
+ version: 1.4.1
54
54
  version:
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: mocha
@@ -107,7 +107,7 @@ files:
107
107
  - lib/ruby-fedora.rb
108
108
  - lib/util/class_level_inheritable_attributes.rb
109
109
  has_rdoc: true
110
- homepage: gem install ruby-fedora
110
+ homepage: "Project Homepage: <http://yourmediashelf.com/activefedora>"
111
111
  post_install_message: PostInstall.txt
112
112
  rdoc_options:
113
113
  - --main
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  version:
129
129
  requirements: []
130
130
 
131
- rubyforge_project: ruby-fedora
131
+ rubyforge_project: rubyfedora
132
132
  rubygems_version: 1.3.1
133
133
  signing_key:
134
134
  specification_version: 2