sufia-models 2.0.1 → 3.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.
- checksums.yaml +4 -4
- data/app/models/checksum_audit_log.rb +1 -15
- data/app/models/domain_term.rb +3 -15
- data/app/models/geo_names_resource.rb +1 -13
- data/app/models/local_authority.rb +12 -17
- data/app/models/local_authority_entry.rb +1 -15
- data/app/models/single_use_link.rb +2 -3
- data/app/models/trophy.rb +1 -1
- data/app/models/version_committer.rb +1 -15
- data/lib/sufia/models/engine.rb +1 -1
- data/lib/sufia/models/generic_file/accessible_attributes.rb +87 -0
- data/lib/sufia/models/generic_file/permissions.rb +2 -1
- data/lib/sufia/models/generic_file/web_form.rb +4 -1
- data/lib/sufia/models/generic_file.rb +3 -0
- data/lib/sufia/models/user.rb +9 -2
- data/lib/sufia/models/version.rb +1 -1
- data/lib/sufia/models.rb +6 -2
- data/lib/tasks/resque.rake +27 -0
- data/sufia-models.gemspec +13 -11
- metadata +49 -41
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: da8e62620ca985d9111fbcf1486646a1fbf8aabb
         | 
| 4 | 
            +
              data.tar.gz: 83104eb983f38d1b77e9b6347452e1630dc28f4a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c446b6fbccabcf456e201e5680c09086c1b15f3fc2305a676ee30851389f822cfc011c5c718d94c8ea6b1b8d407a0c29c00f679dc3a2dd4e31dcd89f29672951
         | 
| 7 | 
            +
              data.tar.gz: e825707338bfdd0091187f82269f9834edda62ad34227dd21e27aa95d5c1500203fea6a724fbba634535f6444fc21b9c621fe0706e2cc23428948dd3d6533219
         | 
| @@ -1,19 +1,5 @@ | |
| 1 | 
            -
            # Copyright © 2012 The Pennsylvania State University
         | 
| 2 | 
            -
            #
         | 
| 3 | 
            -
            # Licensed under the Apache License, Version 2.0 (the "License");
         | 
| 4 | 
            -
            # you may not use this file except in compliance with the License.
         | 
| 5 | 
            -
            # You may obtain a copy of the License at
         | 
| 6 | 
            -
            #
         | 
| 7 | 
            -
            # http://www.apache.org/licenses/LICENSE-2.0
         | 
| 8 | 
            -
            #
         | 
| 9 | 
            -
            # Unless required by applicable law or agreed to in writing, software
         | 
| 10 | 
            -
            # distributed under the License is distributed on an "AS IS" BASIS,
         | 
| 11 | 
            -
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 12 | 
            -
            # See the License for the specific language governing permissions and
         | 
| 13 | 
            -
            # limitations under the License.
         | 
| 14 | 
            -
             | 
| 15 1 | 
             
            class ChecksumAuditLog < ActiveRecord::Base
         | 
| 16 | 
            -
              attr_accessible :pass, :pid, :dsid, :version, :created_at
         | 
| 2 | 
            +
              attr_accessible :pass, :pid, :dsid, :version, :created_at if Rails::VERSION::MAJOR == 3
         | 
| 17 3 |  | 
| 18 4 | 
             
              def ChecksumAuditLog.get_audit_log(version)
         | 
| 19 5 | 
             
                ChecksumAuditLog.find_or_create_by_pid_and_dsid_and_version(:pid => version.pid,
         | 
    
        data/app/models/domain_term.rb
    CHANGED
    
    | @@ -1,18 +1,6 @@ | |
| 1 | 
            -
            # Copyright © 2012 The Pennsylvania State University
         | 
| 2 | 
            -
            #
         | 
| 3 | 
            -
            # Licensed under the Apache License, Version 2.0 (the "License");
         | 
| 4 | 
            -
            # you may not use this file except in compliance with the License.
         | 
| 5 | 
            -
            # You may obtain a copy of the License at
         | 
| 6 | 
            -
            #
         | 
| 7 | 
            -
            # http://www.apache.org/licenses/LICENSE-2.0
         | 
| 8 | 
            -
            #
         | 
| 9 | 
            -
            # Unless required by applicable law or agreed to in writing, software
         | 
| 10 | 
            -
            # distributed under the License is distributed on an "AS IS" BASIS,
         | 
| 11 | 
            -
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 12 | 
            -
            # See the License for the specific language governing permissions and
         | 
| 13 | 
            -
            # limitations under the License.
         | 
| 14 | 
            -
             | 
| 15 1 | 
             
            class DomainTerm < ActiveRecord::Base
         | 
| 16 | 
            -
              attr_accessible :model, :term
         | 
| 2 | 
            +
              attr_accessible :model, :term if Rails::VERSION::MAJOR == 3
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              # TODO we should add an index on this join table and remove the uniq query
         | 
| 17 5 | 
             
              has_and_belongs_to_many :local_authorities, :uniq=> true 
         | 
| 18 6 | 
             
            end
         | 
| @@ -1,16 +1,4 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
            #
         | 
| 3 | 
            -
            # Licensed under the Apache License, Version 2.0 (the "License");
         | 
| 4 | 
            -
            # you may not use this file except in compliance with the License.
         | 
| 5 | 
            -
            # You may obtain a copy of the License at
         | 
| 6 | 
            -
            #
         | 
| 7 | 
            -
            # http://www.apache.org/licenses/LICENSE-2.0
         | 
| 8 | 
            -
            #
         | 
| 9 | 
            -
            # Unless required by applicable law or agreed to in writing, software
         | 
| 10 | 
            -
            # distributed under the License is distributed on an "AS IS" BASIS,
         | 
| 11 | 
            -
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 12 | 
            -
            # See the License for the specific language governing permissions and
         | 
| 13 | 
            -
            # limitations under the License.
         | 
| 1 | 
            +
            require 'active_resource'
         | 
| 14 2 |  | 
| 15 3 | 
             
            class GeoNamesResource < ActiveResource::Base
         | 
| 16 4 | 
             
              self.site = "http://api.geonames.org/"
         | 
| @@ -1,22 +1,9 @@ | |
| 1 | 
            -
            # Copyright © 2012 The Pennsylvania State University
         | 
| 2 | 
            -
            #
         | 
| 3 | 
            -
            # Licensed under the Apache License, Version 2.0 (the "License");
         | 
| 4 | 
            -
            # you may not use this file except in compliance with the License.
         | 
| 5 | 
            -
            # You may obtain a copy of the License at
         | 
| 6 | 
            -
            #
         | 
| 7 | 
            -
            # http://www.apache.org/licenses/LICENSE-2.0
         | 
| 8 | 
            -
            #
         | 
| 9 | 
            -
            # Unless required by applicable law or agreed to in writing, software
         | 
| 10 | 
            -
            # distributed under the License is distributed on an "AS IS" BASIS,
         | 
| 11 | 
            -
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 12 | 
            -
            # See the License for the specific language governing permissions and
         | 
| 13 | 
            -
            # limitations under the License.
         | 
| 14 | 
            -
             | 
| 15 1 | 
             
            require 'rdf'
         | 
| 16 2 | 
             
            require 'rdf/rdfxml'
         | 
| 17 3 |  | 
| 18 4 | 
             
            class LocalAuthority < ActiveRecord::Base
         | 
| 19 | 
            -
              attr_accessible :name
         | 
| 5 | 
            +
              attr_accessible :name if Rails::VERSION::MAJOR == 3
         | 
| 6 | 
            +
              # TODO we should add an index on this join table and remove the uniq query
         | 
| 20 7 | 
             
              has_and_belongs_to_many :domain_terms, :uniq=> true 
         | 
| 21 8 | 
             
              has_many :local_authority_entries
         | 
| 22 9 |  | 
| @@ -37,7 +24,11 @@ class LocalAuthority < ActiveRecord::Base | |
| 37 24 | 
             
                    end
         | 
| 38 25 | 
             
                  end
         | 
| 39 26 | 
             
                end
         | 
| 40 | 
            -
                LocalAuthorityEntry.import | 
| 27 | 
            +
                if LocalAuthorityEntry.respond_to? :import
         | 
| 28 | 
            +
                  LocalAuthorityEntry.import entries
         | 
| 29 | 
            +
                else
         | 
| 30 | 
            +
                  entries.each { |e| e.save! }
         | 
| 31 | 
            +
                end
         | 
| 41 32 | 
             
              end
         | 
| 42 33 |  | 
| 43 34 | 
             
              def self.harvest_tsv(name, sources, opts = {})
         | 
| @@ -55,7 +46,11 @@ class LocalAuthority < ActiveRecord::Base | |
| 55 46 | 
             
                    end
         | 
| 56 47 | 
             
                  end
         | 
| 57 48 | 
             
                end
         | 
| 58 | 
            -
                LocalAuthorityEntry.import | 
| 49 | 
            +
                if LocalAuthorityEntry.respond_to? :import
         | 
| 50 | 
            +
                  LocalAuthorityEntry.import entries
         | 
| 51 | 
            +
                else
         | 
| 52 | 
            +
                  entries.each { |e| e.save! }
         | 
| 53 | 
            +
                end
         | 
| 59 54 | 
             
              end
         | 
| 60 55 |  | 
| 61 56 | 
             
              def self.register_vocabulary(model, term, name)
         | 
| @@ -1,18 +1,4 @@ | |
| 1 | 
            -
            # Copyright © 2012 The Pennsylvania State University
         | 
| 2 | 
            -
            #
         | 
| 3 | 
            -
            # Licensed under the Apache License, Version 2.0 (the "License");
         | 
| 4 | 
            -
            # you may not use this file except in compliance with the License.
         | 
| 5 | 
            -
            # You may obtain a copy of the License at
         | 
| 6 | 
            -
            #
         | 
| 7 | 
            -
            # http://www.apache.org/licenses/LICENSE-2.0
         | 
| 8 | 
            -
            #
         | 
| 9 | 
            -
            # Unless required by applicable law or agreed to in writing, software
         | 
| 10 | 
            -
            # distributed under the License is distributed on an "AS IS" BASIS,
         | 
| 11 | 
            -
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 12 | 
            -
            # See the License for the specific language governing permissions and
         | 
| 13 | 
            -
            # limitations under the License.
         | 
| 14 | 
            -
             | 
| 15 1 | 
             
            class LocalAuthorityEntry < ActiveRecord::Base
         | 
| 16 2 | 
             
              belongs_to :local_authority
         | 
| 17 | 
            -
              attr_accessible :local_authority, :label, :uri
         | 
| 3 | 
            +
              attr_accessible :local_authority, :label, :uri if Rails::VERSION::MAJOR == 3
         | 
| 18 4 | 
             
            end
         | 
| @@ -1,7 +1,6 @@ | |
| 1 1 | 
             
            class SingleUseLink < ActiveRecord::Base
         | 
| 2 2 |  | 
| 3 | 
            -
              attr_accessible :downloadKey, :expires, :itemId, :path
         | 
| 4 | 
            -
             | 
| 3 | 
            +
              attr_accessible :downloadKey, :expires, :itemId, :path if Rails::VERSION::MAJOR == 3
         | 
| 5 4 |  | 
| 6 5 |  | 
| 7 6 | 
             
              def self.create_show(item_id)
         | 
| @@ -20,7 +19,7 @@ class SingleUseLink < ActiveRecord::Base | |
| 20 19 | 
             
              protected
         | 
| 21 20 | 
             
              def self.create_path(itemId, path)
         | 
| 22 21 | 
             
                 expires = DateTime.now.advance(hours:24)
         | 
| 23 | 
            -
                 key = Digest::SHA2.new <<  | 
| 22 | 
            +
                 key = Digest::SHA2.new << rand(1000000000).to_s
         | 
| 24 23 | 
             
                 return create({downloadKey:key.to_s, expires:expires, path:path, itemId:itemId} )
         | 
| 25 24 | 
             
              end
         | 
| 26 25 | 
             
            end
         | 
    
        data/app/models/trophy.rb
    CHANGED
    
    
| @@ -1,17 +1,3 @@ | |
| 1 | 
            -
            # Copyright © 2012 The Pennsylvania State University
         | 
| 2 | 
            -
            #
         | 
| 3 | 
            -
            # Licensed under the Apache License, Version 2.0 (the "License");
         | 
| 4 | 
            -
            # you may not use this file except in compliance with the License.
         | 
| 5 | 
            -
            # You may obtain a copy of the License at
         | 
| 6 | 
            -
            #
         | 
| 7 | 
            -
            # http://www.apache.org/licenses/LICENSE-2.0
         | 
| 8 | 
            -
            #
         | 
| 9 | 
            -
            # Unless required by applicable law or agreed to in writing, software
         | 
| 10 | 
            -
            # distributed under the License is distributed on an "AS IS" BASIS,
         | 
| 11 | 
            -
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 12 | 
            -
            # See the License for the specific language governing permissions and
         | 
| 13 | 
            -
            # limitations under the License.
         | 
| 14 | 
            -
             | 
| 15 1 | 
             
            class VersionCommitter < ActiveRecord::Base
         | 
| 16 | 
            -
              attr_accessible :obj_id, :datastream_id, :version_id, :committer_login
         | 
| 2 | 
            +
              attr_accessible :obj_id, :datastream_id, :version_id, :committer_login if Rails::VERSION::MAJOR == 3
         | 
| 17 3 | 
             
            end
         | 
    
        data/lib/sufia/models/engine.rb
    CHANGED
    
    | @@ -36,7 +36,7 @@ module Sufia | |
| 36 36 | 
             
                  initializer "patches" do
         | 
| 37 37 | 
             
                    require 'sufia/models/active_fedora/redis'
         | 
| 38 38 | 
             
                    require 'sufia/models/active_record/redis'
         | 
| 39 | 
            -
                    require 'sufia/models/active_support/core_ext/marshal'
         | 
| 39 | 
            +
                    require 'sufia/models/active_support/core_ext/marshal' unless Rails::VERSION::MAJOR == 4
         | 
| 40 40 | 
             
                  end
         | 
| 41 41 |  | 
| 42 42 | 
             
                  initializer 'requires' do
         | 
| @@ -0,0 +1,87 @@ | |
| 1 | 
            +
            module Sufia
         | 
| 2 | 
            +
              module GenericFile
         | 
| 3 | 
            +
                module AccessibleAttributes
         | 
| 4 | 
            +
                  extend ActiveSupport::Concern
         | 
| 5 | 
            +
                  included do
         | 
| 6 | 
            +
                    class_attribute :_accessible_attributes
         | 
| 7 | 
            +
                    self._accessible_attributes = {}
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  def accessible_attributes(role = :default)
         | 
| 11 | 
            +
                     self.class._accessible_attributes[role] || []
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  # Sanitize the provided attributes using only those that are specified
         | 
| 15 | 
            +
                  # as accessible by attr_accessor
         | 
| 16 | 
            +
                  # @param [Hash] attributes the raw parameters
         | 
| 17 | 
            +
                  # @param [Hash] args a hash of options
         | 
| 18 | 
            +
                  # @option args [Symbol] :as (:default) the role to use
         | 
| 19 | 
            +
                  # @return A sanitized hash of parameters
         | 
| 20 | 
            +
                  def sanitize_attributes(attributes = {}, args = {})
         | 
| 21 | 
            +
                    role = args[:as] || :default
         | 
| 22 | 
            +
                    attributes.select { |k,v| accessible_attributes.include?(k.to_sym)}
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  module ClassMethods
         | 
| 26 | 
            +
                    # Specifies a white list of model attributes that can be set via
         | 
| 27 | 
            +
                    # mass-assignment.
         | 
| 28 | 
            +
                    #
         | 
| 29 | 
            +
                    # Like +attr_protected+, a role for the attributes is optional,
         | 
| 30 | 
            +
                    # if no role is provided then :default is used. A role can be defined by
         | 
| 31 | 
            +
                    # using the :as option.
         | 
| 32 | 
            +
                    #
         | 
| 33 | 
            +
                    # Mass-assignment will only set attributes in this list, to assign to
         | 
| 34 | 
            +
                    # the rest of # attributes you can use direct writer methods. This is
         | 
| 35 | 
            +
                    # meant to protect sensitive attributes from being overwritten by 
         | 
| 36 | 
            +
                    # malicious users # tampering with URLs or forms. 
         | 
| 37 | 
            +
                    #
         | 
| 38 | 
            +
                    #   class Customer
         | 
| 39 | 
            +
                    #     include ActiveModel::MassAssignmentSecurity
         | 
| 40 | 
            +
                    #
         | 
| 41 | 
            +
                    #     attr_accessor :name, :credit_rating
         | 
| 42 | 
            +
                    #
         | 
| 43 | 
            +
                    #     attr_accessible :name
         | 
| 44 | 
            +
                    #     attr_accessible :name, :credit_rating, :as => :admin
         | 
| 45 | 
            +
                    #
         | 
| 46 | 
            +
                    #     def assign_attributes(values, options = {})
         | 
| 47 | 
            +
                    #       sanitize_for_mass_assignment(values, options[:as]).each do |k, v|
         | 
| 48 | 
            +
                    #         send("#{k}=", v)
         | 
| 49 | 
            +
                    #       end
         | 
| 50 | 
            +
                    #     end
         | 
| 51 | 
            +
                    #   end
         | 
| 52 | 
            +
                    #
         | 
| 53 | 
            +
                    # When using the :default role:
         | 
| 54 | 
            +
                    #
         | 
| 55 | 
            +
                    #   customer = Customer.new
         | 
| 56 | 
            +
                    #   customer.assign_attributes({ "name" => "David", "credit_rating" => "Excellent", :last_login => 1.day.ago }, :as => :default)
         | 
| 57 | 
            +
                    #   customer.name          # => "David"
         | 
| 58 | 
            +
                    #   customer.credit_rating # => nil
         | 
| 59 | 
            +
                    #
         | 
| 60 | 
            +
                    #   customer.credit_rating = "Average"
         | 
| 61 | 
            +
                    #   customer.credit_rating # => "Average"
         | 
| 62 | 
            +
                    #
         | 
| 63 | 
            +
                    # And using the :admin role:
         | 
| 64 | 
            +
                    #
         | 
| 65 | 
            +
                    #   customer = Customer.new
         | 
| 66 | 
            +
                    #   customer.assign_attributes({ "name" => "David", "credit_rating" => "Excellent", :last_login => 1.day.ago }, :as => :admin)
         | 
| 67 | 
            +
                    #   customer.name          # => "David"
         | 
| 68 | 
            +
                    #   customer.credit_rating # => "Excellent"
         | 
| 69 | 
            +
                    #
         | 
| 70 | 
            +
                    # Note that using <tt>Hash#except</tt> or <tt>Hash#slice</tt> in place of
         | 
| 71 | 
            +
                    # +attr_accessible+ to sanitize attributes provides basically the same
         | 
| 72 | 
            +
                    # functionality, but it makes a bit tricky to deal with nested attributes.
         | 
| 73 | 
            +
                    def attr_accessible(*args)
         | 
| 74 | 
            +
                      options = args.extract_options!
         | 
| 75 | 
            +
                      role = options[:as] || :default
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                      self._accessible_attributes ||= {}
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                      Array.wrap(role).each do |name|
         | 
| 80 | 
            +
                        self._accessible_attributes[name] = args.map &:to_sym
         | 
| 81 | 
            +
                      end
         | 
| 82 | 
            +
                    end
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                  end
         | 
| 85 | 
            +
                end
         | 
| 86 | 
            +
              end
         | 
| 87 | 
            +
            end
         | 
| @@ -37,7 +37,8 @@ module Sufia | |
| 37 37 | 
             
                    params[:new_group_name].each { |name, access| perm_hash['group'][name] = access } if params[:new_group_name].present?
         | 
| 38 38 |  | 
| 39 39 | 
             
                    params[:user].each { |name, access| perm_hash['person'][name] = access} if params[:user]
         | 
| 40 | 
            -
                    params[:group].each { |name, access| perm_hash['group'][name] = access} if params[:group]
         | 
| 40 | 
            +
                    params[:group].each { |name, access| perm_hash['group'][name] = access if ['read', 'edit'].include?(access)} if params[:group]
         | 
| 41 | 
            +
             | 
| 41 42 | 
             
                    rightsMetadata.update_permissions(perm_hash)
         | 
| 42 43 | 
             
                  end
         | 
| 43 44 |  | 
| @@ -2,6 +2,7 @@ module Sufia | |
| 2 2 | 
             
              module GenericFile
         | 
| 3 3 | 
             
                module WebForm
         | 
| 4 4 | 
             
                  extend ActiveSupport::Concern
         | 
| 5 | 
            +
                  include Sufia::GenericFile::AccessibleAttributes
         | 
| 5 6 | 
             
                  included do
         | 
| 6 7 | 
             
                    before_save :remove_blank_assertions
         | 
| 7 8 | 
             
                  end
         | 
| @@ -26,7 +27,9 @@ module Sufia | |
| 26 27 | 
             
                  end
         | 
| 27 28 |  | 
| 28 29 | 
             
                  def terms_for_display
         | 
| 29 | 
            -
                     | 
| 30 | 
            +
                    # 'type' is the RDF.type assertion, which is not present by default, but may be
         | 
| 31 | 
            +
                    # provided in some RDF schemas
         | 
| 32 | 
            +
                    self.descMetadata.class.fields
         | 
| 30 33 | 
             
                  end
         | 
| 31 34 |  | 
| 32 35 | 
             
                  def to_jq_upload
         | 
| @@ -9,6 +9,7 @@ module Sufia | |
| 9 9 | 
             
                autoload :Actions
         | 
| 10 10 | 
             
                autoload :Permissions
         | 
| 11 11 | 
             
                autoload :WebForm, 'sufia/models/generic_file/web_form'
         | 
| 12 | 
            +
                autoload :AccessibleAttributes, 'sufia/models/generic_file/accessible_attributes'
         | 
| 12 13 | 
             
                include Sufia::ModelMethods
         | 
| 13 14 | 
             
                include Sufia::Noid
         | 
| 14 15 | 
             
                include Sufia::GenericFile::Thumbnail
         | 
| @@ -35,6 +36,8 @@ module Sufia | |
| 35 36 |  | 
| 36 37 | 
             
                  around_save :characterize_if_changed, :retry_warming
         | 
| 37 38 | 
             
                  before_destroy :cleanup_trophies
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  attr_accessible *(ds_specs['descMetadata'][:type].fields + [:permissions])
         | 
| 38 41 | 
             
                end
         | 
| 39 42 |  | 
| 40 43 |  | 
    
        data/lib/sufia/models/user.rb
    CHANGED
    
    | @@ -33,8 +33,7 @@ module Sufia::User | |
| 33 33 | 
             
                acts_as_followable
         | 
| 34 34 |  | 
| 35 35 | 
             
                # Setup accessible (or protected) attributes for your model
         | 
| 36 | 
            -
                attr_accessible  | 
| 37 | 
            -
                :group_list, :groups_last_update, :facebook_handle, :twitter_handle, :googleplus_handle
         | 
| 36 | 
            +
                attr_accessible *permitted_attributes if Rails::VERSION::MAJOR == 3
         | 
| 38 37 |  | 
| 39 38 | 
             
                # Add user avatar (via paperclip library)
         | 
| 40 39 | 
             
                has_attached_file :avatar, :styles => { medium: "300x300>", thumb: "100x100>" }, :default_url => '/assets/missing_:style.png'
         | 
| @@ -89,6 +88,14 @@ module Sufia::User | |
| 89 88 | 
             
              end
         | 
| 90 89 |  | 
| 91 90 | 
             
              module ClassMethods
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                def permitted_attributes
         | 
| 93 | 
            +
                  [:email, :login, :display_name, :address, :admin_area, 
         | 
| 94 | 
            +
                    :department, :title, :office, :chat_id, :website, :affiliation, 
         | 
| 95 | 
            +
                    :telephone, :avatar, :group_list, :groups_last_update, :facebook_handle,
         | 
| 96 | 
            +
                    :twitter_handle, :googleplus_handle]
         | 
| 97 | 
            +
                end
         | 
| 98 | 
            +
             | 
| 92 99 | 
             
                def current
         | 
| 93 100 | 
             
                  Thread.current[:user]
         | 
| 94 101 | 
             
                end
         | 
    
        data/lib/sufia/models/version.rb
    CHANGED
    
    
    
        data/lib/sufia/models.rb
    CHANGED
    
    | @@ -1,13 +1,17 @@ | |
| 1 1 | 
             
            require "sufia/models/version"
         | 
| 2 2 | 
             
            require "sufia/models/engine"
         | 
| 3 3 | 
             
            require 'hydra/head'
         | 
| 4 | 
            -
            require 'devise'
         | 
| 5 4 | 
             
            require 'nest'
         | 
| 6 5 | 
             
            require 'mailboxer'
         | 
| 7 6 | 
             
            require 'acts_as_follower'
         | 
| 8 7 | 
             
            require 'paperclip'
         | 
| 9 8 | 
             
            require 'RMagick'
         | 
| 10 | 
            -
             | 
| 9 | 
            +
            begin
         | 
| 10 | 
            +
              # activerecord-import 0.3.1 does not support rails 4, so we don't require it.
         | 
| 11 | 
            +
              require 'activerecord-import'
         | 
| 12 | 
            +
            rescue LoadError
         | 
| 13 | 
            +
              $stderr.puts "Sufia-models is unable to load activerecord-import"
         | 
| 14 | 
            +
            end
         | 
| 11 15 | 
             
            require 'resque/server'
         | 
| 12 16 |  | 
| 13 17 | 
             
            module Sufia
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            # Copyright © 2012 The Pennsylvania State University
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            # Licensed under the Apache License, Version 2.0 (the "License");
         | 
| 4 | 
            +
            # you may not use this file except in compliance with the License.
         | 
| 5 | 
            +
            # You may obtain a copy of the License at
         | 
| 6 | 
            +
            #
         | 
| 7 | 
            +
            # http://www.apache.org/licenses/LICENSE-2.0
         | 
| 8 | 
            +
            #
         | 
| 9 | 
            +
            # Unless required by applicable law or agreed to in writing, software
         | 
| 10 | 
            +
            # distributed under the License is distributed on an "AS IS" BASIS,
         | 
| 11 | 
            +
            # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
         | 
| 12 | 
            +
            # See the License for the specific language governing permissions and
         | 
| 13 | 
            +
            # limitations under the License.
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            require 'resque/pool/tasks'
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            # This provides access to the Rails env within all Resque workers
         | 
| 18 | 
            +
            task 'resque:setup' => :environment
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            # Set up resque-pool
         | 
| 21 | 
            +
            task 'resque:pool:setup' do
         | 
| 22 | 
            +
              ActiveRecord::Base.connection.disconnect!
         | 
| 23 | 
            +
              Resque::Pool.after_prefork do |job|
         | 
| 24 | 
            +
                ActiveRecord::Base.establish_connection
         | 
| 25 | 
            +
                Resque.redis.client.reconnect
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
    
        data/sufia-models.gemspec
    CHANGED
    
    | @@ -1,11 +1,10 @@ | |
| 1 1 | 
             
            # coding: utf-8
         | 
| 2 | 
            -
             | 
| 3 | 
            -
             | 
| 4 | 
            -
            require 'sufia/models/version'
         | 
| 2 | 
            +
            version = File.read(File.expand_path("../../SUFIA_VERSION", __FILE__)).strip
         | 
| 3 | 
            +
             | 
| 5 4 |  | 
| 6 5 | 
             
            Gem::Specification.new do |spec|
         | 
| 7 6 | 
             
              spec.name          = "sufia-models"
         | 
| 8 | 
            -
              spec.version       =  | 
| 7 | 
            +
              spec.version       = version 
         | 
| 9 8 | 
             
              spec.authors       = [
         | 
| 10 9 | 
             
                "Jeremy Friesen",
         | 
| 11 10 | 
             
              ]
         | 
| @@ -27,18 +26,21 @@ Gem::Specification.new do |spec| | |
| 27 26 |  | 
| 28 27 | 
             
              spec.add_development_dependency "bundler", "~> 1.3"
         | 
| 29 28 | 
             
              spec.add_development_dependency "rake"
         | 
| 30 | 
            -
             | 
| 31 | 
            -
              spec.add_dependency ' | 
| 29 | 
            +
             | 
| 30 | 
            +
              spec.add_dependency 'rails', '>= 3.2.13', '< 5.0'
         | 
| 31 | 
            +
              spec.add_dependency 'activeresource' # No longer a dependency of rails 4.0
         | 
| 32 | 
            +
              spec.add_dependency "hydra-head", "~> 6.3.0"
         | 
| 33 | 
            +
              spec.add_dependency 'active-fedora', "~> 6.4.0"
         | 
| 34 | 
            +
             | 
| 32 35 | 
             
              spec.add_dependency 'nest', '~> 1.1.1'
         | 
| 33 36 | 
             
              spec.add_dependency 'resque', '~> 1.23.0'#, :require => 'resque/server'
         | 
| 34 37 | 
             
              spec.add_dependency 'resque-pool', '0.3.0'
         | 
| 35 38 | 
             
              spec.add_dependency 'noid', '~> 0.6.6'
         | 
| 36 | 
            -
              spec.add_dependency 'mailboxer', '0. | 
| 39 | 
            +
              spec.add_dependency 'curationexperts-mailboxer', '0.10.3'
         | 
| 37 40 | 
             
              spec.add_dependency 'acts_as_follower', '0.1.1'
         | 
| 38 41 | 
             
              spec.add_dependency 'rmagick'
         | 
| 39 | 
            -
              spec.add_dependency 'paperclip', '3. | 
| 42 | 
            +
              spec.add_dependency 'paperclip', '~> 3.4.0'
         | 
| 40 43 | 
             
              spec.add_dependency 'zipruby', '0.3.6'
         | 
| 41 | 
            -
               | 
| 42 | 
            -
              spec.add_dependency ' | 
| 43 | 
            -
             | 
| 44 | 
            +
              # https://github.com/zdennis/activerecord-import/pull/79
         | 
| 45 | 
            +
              #spec.add_dependency 'activerecord-import', '0.3.0' # 0.3.1 caused a bug in testing: "SQLite3::SQLException: near ",": syntax error: INSERT INTO..."
         | 
| 44 46 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: sufia-models
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version:  | 
| 4 | 
            +
              version: 3.0.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Jeremy Friesen
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2013- | 
| 11 | 
            +
            date: 2013-07-22 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -42,30 +42,64 @@ dependencies: | |
| 42 42 | 
             
              name: rails
         | 
| 43 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 44 | 
             
                requirements:
         | 
| 45 | 
            -
                - -  | 
| 45 | 
            +
                - - '>='
         | 
| 46 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 47 47 | 
             
                    version: 3.2.13
         | 
| 48 | 
            +
                - - <
         | 
| 49 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 50 | 
            +
                    version: '5.0'
         | 
| 48 51 | 
             
              type: :runtime
         | 
| 49 52 | 
             
              prerelease: false
         | 
| 50 53 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 54 | 
             
                requirements:
         | 
| 52 | 
            -
                - -  | 
| 55 | 
            +
                - - '>='
         | 
| 53 56 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 57 | 
             
                    version: 3.2.13
         | 
| 58 | 
            +
                - - <
         | 
| 59 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 60 | 
            +
                    version: '5.0'
         | 
| 61 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 62 | 
            +
              name: activeresource
         | 
| 63 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 64 | 
            +
                requirements:
         | 
| 65 | 
            +
                - - '>='
         | 
| 66 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 67 | 
            +
                    version: '0'
         | 
| 68 | 
            +
              type: :runtime
         | 
| 69 | 
            +
              prerelease: false
         | 
| 70 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 71 | 
            +
                requirements:
         | 
| 72 | 
            +
                - - '>='
         | 
| 73 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 74 | 
            +
                    version: '0'
         | 
| 55 75 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 76 | 
             
              name: hydra-head
         | 
| 57 77 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 78 | 
             
                requirements:
         | 
| 59 79 | 
             
                - - ~>
         | 
| 60 80 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            -
                    version:  | 
| 81 | 
            +
                    version: 6.3.0
         | 
| 82 | 
            +
              type: :runtime
         | 
| 83 | 
            +
              prerelease: false
         | 
| 84 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 85 | 
            +
                requirements:
         | 
| 86 | 
            +
                - - ~>
         | 
| 87 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 88 | 
            +
                    version: 6.3.0
         | 
| 89 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 90 | 
            +
              name: active-fedora
         | 
| 91 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 92 | 
            +
                requirements:
         | 
| 93 | 
            +
                - - ~>
         | 
| 94 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 95 | 
            +
                    version: 6.4.0
         | 
| 62 96 | 
             
              type: :runtime
         | 
| 63 97 | 
             
              prerelease: false
         | 
| 64 98 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 99 | 
             
                requirements:
         | 
| 66 100 | 
             
                - - ~>
         | 
| 67 101 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            -
                    version:  | 
| 102 | 
            +
                    version: 6.4.0
         | 
| 69 103 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 104 | 
             
              name: nest
         | 
| 71 105 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -123,19 +157,19 @@ dependencies: | |
| 123 157 | 
             
                  - !ruby/object:Gem::Version
         | 
| 124 158 | 
             
                    version: 0.6.6
         | 
| 125 159 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            -
              name: mailboxer
         | 
| 160 | 
            +
              name: curationexperts-mailboxer
         | 
| 127 161 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 162 | 
             
                requirements:
         | 
| 129 163 | 
             
                - - '='
         | 
| 130 164 | 
             
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            -
                    version: 0. | 
| 165 | 
            +
                    version: 0.10.3
         | 
| 132 166 | 
             
              type: :runtime
         | 
| 133 167 | 
             
              prerelease: false
         | 
| 134 168 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 169 | 
             
                requirements:
         | 
| 136 170 | 
             
                - - '='
         | 
| 137 171 | 
             
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            -
                    version: 0. | 
| 172 | 
            +
                    version: 0.10.3
         | 
| 139 173 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 140 174 | 
             
              name: acts_as_follower
         | 
| 141 175 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -168,16 +202,16 @@ dependencies: | |
| 168 202 | 
             
              name: paperclip
         | 
| 169 203 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 170 204 | 
             
                requirements:
         | 
| 171 | 
            -
                - -  | 
| 205 | 
            +
                - - ~>
         | 
| 172 206 | 
             
                  - !ruby/object:Gem::Version
         | 
| 173 | 
            -
                    version: 3. | 
| 207 | 
            +
                    version: 3.4.0
         | 
| 174 208 | 
             
              type: :runtime
         | 
| 175 209 | 
             
              prerelease: false
         | 
| 176 210 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 177 211 | 
             
                requirements:
         | 
| 178 | 
            -
                - -  | 
| 212 | 
            +
                - - ~>
         | 
| 179 213 | 
             
                  - !ruby/object:Gem::Version
         | 
| 180 | 
            -
                    version: 3. | 
| 214 | 
            +
                    version: 3.4.0
         | 
| 181 215 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 182 216 | 
             
              name: zipruby
         | 
| 183 217 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -192,34 +226,6 @@ dependencies: | |
| 192 226 | 
             
                - - '='
         | 
| 193 227 | 
             
                  - !ruby/object:Gem::Version
         | 
| 194 228 | 
             
                    version: 0.3.6
         | 
| 195 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 196 | 
            -
              name: activerecord-import
         | 
| 197 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 198 | 
            -
                requirements:
         | 
| 199 | 
            -
                - - '='
         | 
| 200 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 201 | 
            -
                    version: 0.3.0
         | 
| 202 | 
            -
              type: :runtime
         | 
| 203 | 
            -
              prerelease: false
         | 
| 204 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 205 | 
            -
                requirements:
         | 
| 206 | 
            -
                - - '='
         | 
| 207 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 208 | 
            -
                    version: 0.3.0
         | 
| 209 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 210 | 
            -
              name: devise
         | 
| 211 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 212 | 
            -
                requirements:
         | 
| 213 | 
            -
                - - '>='
         | 
| 214 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 215 | 
            -
                    version: '0'
         | 
| 216 | 
            -
              type: :runtime
         | 
| 217 | 
            -
              prerelease: false
         | 
| 218 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 219 | 
            -
                requirements:
         | 
| 220 | 
            -
                - - '>='
         | 
| 221 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 222 | 
            -
                    version: '0'
         | 
| 223 229 | 
             
            description: Models and services for sufia
         | 
| 224 230 | 
             
            email:
         | 
| 225 231 | 
             
            - jeremy.n.friesen@gmail.com
         | 
| @@ -261,6 +267,7 @@ files: | |
| 261 267 | 
             
            - lib/sufia/models/file_content/extract_metadata.rb
         | 
| 262 268 | 
             
            - lib/sufia/models/file_content/versions.rb
         | 
| 263 269 | 
             
            - lib/sufia/models/generic_file.rb
         | 
| 270 | 
            +
            - lib/sufia/models/generic_file/accessible_attributes.rb
         | 
| 264 271 | 
             
            - lib/sufia/models/generic_file/actions.rb
         | 
| 265 272 | 
             
            - lib/sufia/models/generic_file/audit.rb
         | 
| 266 273 | 
             
            - lib/sufia/models/generic_file/characterization.rb
         | 
| @@ -285,6 +292,7 @@ files: | |
| 285 292 | 
             
            - lib/sufia/models/user.rb
         | 
| 286 293 | 
             
            - lib/sufia/models/utils.rb
         | 
| 287 294 | 
             
            - lib/sufia/models/version.rb
         | 
| 295 | 
            +
            - lib/tasks/resque.rake
         | 
| 288 296 | 
             
            - lib/tasks/sufia-models_tasks.rake
         | 
| 289 297 | 
             
            - sufia-models.gemspec
         | 
| 290 298 | 
             
            homepage: https://github.com/jeremyf/sufia
         |