Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed lenses to a more OO style #14

Merged
merged 9 commits into from
Apr 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Bundler::GemHelper.install_tasks

RSpec::Core::RakeTask.new(:spec)

ZIP_URL = "https://github.com/projecthydra/hydra-jetty/archive/fedora-4a5.zip"
ZIP_URL = "https://github.com/projecthydra/hydra-jetty/archive/fedora-4a6.zip"
require 'jettywrapper'

task default: :ci
Expand Down
4 changes: 2 additions & 2 deletions fedora_lens.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ Gem::Specification.new do |spec|

spec.add_development_dependency "bundler", "~> 1.5"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
spec.add_development_dependency "rspec", '~> 2.99'
spec.add_development_dependency "childprocess"

spec.add_dependency 'rdf-turtle', '~> 1.1.2'
spec.add_dependency 'activemodel', '>= 4.0.2', "< 5.0"
spec.add_dependency 'nokogiri', '~> 1.6.1'
spec.add_dependency 'ldp', '0.0.4'
spec.add_dependency 'ldp', '0.0.5'
end
10 changes: 7 additions & 3 deletions lib/fedora_lens.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ module AttributeMethods
#HOST = "http://localhost:8080"

def self.connection
@@connection ||= Ldp::Client.new(HOST)
@@connection ||= Ldp::Client.new(host)
end

def self.host
HOST
end

included do
Expand Down Expand Up @@ -137,11 +141,11 @@ def find(id)
end

def id_to_uri(id)
HOST + (id.start_with?('/') ? id : '/' + id)
FedoraLens.host + (id.start_with?('/') ? id : '/' + id)
end

def uri_to_id(uri)
uri.to_s.sub(HOST, '')
uri.to_s.sub(FedoraLens.host, '')
end

def create(data)
Expand Down
5 changes: 1 addition & 4 deletions lib/fedora_lens/attribute_methods/write.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ def #{method_name}(value)
end

def write_attribute(attribute_name, value)
#column = column_for_attribute(attribute_name)
column = true # TODO check that attribute_name is valid

if column
if attributes_as_lenses.key?(attribute_name)
@attributes[attribute_name] = value
else
raise ActiveModel::MissingAttributeError, "can't write unknown attribute `#{attribute_name}'"
Expand Down
20 changes: 16 additions & 4 deletions lib/fedora_lens/lens.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
require 'active_support/core_ext/hash'

module FedoraLens
class Lens < ActiveSupport::HashWithIndifferentAccess
class Lens
attr_reader(:options)

def initialize(*options)
@options = options
end

def get(source)
self[:get].call(source)
raise NotImplementedError.new
end

def put(source, value)
self[:put].call(source, value)
raise NotImplementedError.new
end

def create(value)
self[:create].call(value)
raise NotImplementedError.new
end

def ==(other_lens)
self.class == other_lens.class && options == other_lens.options
end
end
end
Loading