<< | Index | >>
suspend
Current status
1) Error: test_update(ODDB::SwissmedicPluginTest): NoMethodError: undefined method `each_registration' for <FlexMock:app>:FlexMock /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:105:in `method_missing' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:191:in `flexmock_wrap' /usr/lib64/ruby/gems/1.8/gems/flexmock-0.8.6/lib/flexmock/core.rb:98:in `method_missing' /home/masa/ywesee/oddb.org/src/plugin/swissmedic.rb:65:in `set_all_export_flag_false' /home/masa/ywesee/oddb.org/src/plugin/swissmedic.rb:44:in `update' /home/masa/ywesee/oddb.org/test/test_plugin/swissmedic.rb:1462:in `test_update' 4098 tests, 6568 assertions, 0 failures, 1 errors
Updated
4101 tests, 6572 assertions, 0 failures, 0 errors
Commit
Problem
Commit
Note
Commit
Note
Task
Task
Design (for example)
Experiment
def resolve if(@session.request_path == @request_path) selfelsif(iksnr = @session.user_input(:swissmedicnr)) \
&& (pointer = @session.app.registration(iksnr).pointer) \
&& pointer.is_a?(Persistence::Pointer) \
&& (model = pointer.resolve(@session.app))
if(klass = resolve_state(pointer))
klass.new(@session, model)
else
State::Admin::TransparentLogin.new(@session, model)
end
elsif((pointer = @session.user_input(:pointer))\
&& pointer.is_a?(Persistence::Pointer)\
&& (model = pointer.resolve(@session.app))) if(klass = resolve_state(pointer)) klass.new(@session, model) else State::Admin::TransparentLogin.new(@session, model) end end end
Run
Access
Result
Experiment
def resolve if(@session.request_path == @request_path) selfelsif(iksnr = @session.user_input(:reg)) \
&& (pointer = @session.app.registration(iksnr).pointer) && pointer.is_a?(Persistence::Pointer) && (model = pointer.resolve(@session.app)) if(klass = resolve_state(pointer)) klass.new(@session, model) else State::Admin::TransparentLogin.new(@session, model) end elsif((pointer = @session.user_input(:pointer))\
&& pointer.is_a?(Persistence::Pointer)\
&& (model = pointer.resolve(@session.app))) if(klass = resolve_state(pointer)) klass.new(@session, model) else State::Admin::TransparentLogin.new(@session, model) end end end
alias :reg :iksnr
Access
Result
Experiment
alias :drug :resolve
EVENTS = [ ... :drug, ...
Access
Result
Experiment
def resolve if(@session.request_path == @request_path) self else iksnr = @session.user_input(:reg) seqnr = @session.user_input(:seq) ikscd = @session.user_input(:pack) pointer = if iksnr && seqnr && ikscd @session.app.registration(iksnr).sequence(seqnr).package(ikscd).pointer elsif iksnr && seqnr @session.app.registration(iksnr).sequence(seqnr).pointer elsif iksnr @session.app.registration(iksnr).pointer else @session.user_input(:pointer) end if pointer.is_a?(Persistence::Pointer) \ && (model = pointer.resolve(@session.app)) if(klass = resolve_state(pointer)) klass.new(@session, model) else State::Admin::TransparentLogin.new(@session, model) end end end end alias :drug :resolve
Access
Result
Note
Next
Experiment
class PointerLink < View::PointerValue def init super arguments = {'pointer' => @model.pointer.to_s} iksnr = if match = @model.pointer.to_s.match(/registration,(\d+)/) match[1] end seqnr = if match = @model.pointer.to_s.match(/sequence,(\d+)/) match[1] end ikscd = if match = @model.pointer.to_s.match(/package,(\d+)/) match[1] end smart_link = if iksnr && seqnr && ikscd {:reg => iksnr, :seq => seqnr, :pack => ikscd} elsif iksnr && seqnr {:reg => iksnr, :seq => seqnr} elsif iksnr {:reg => iksnr} end if smart_link @attributes['href'] = @lookandfeel._event_url(:drug, smart_link) else @attributes['href'] = @lookandfeel._event_url(:resolve, arguments) end #@attributes['href'] = @lookandfeel._event_url(:resolve, arguments) end
Result
Refactor
class PointerLink < View::PointerValue def init super arguments = {'pointer' => @model.pointer.to_s} # @model.pointer.to_s might be like this: # :!registration,31706!sequence,01!package,017. # in such case, URL link will be smarter than the URL by using pointer # z.B.) http://ch.oddb.org/de/gcc/drug/reg/31706/seq/01/pack/017 # The old format is also available. list = @model.pointer.to_s.gsub(/\./,'').split(/!/).delete_if{|v| v == ":"}.map{|i| i.split(",")}.flatten nrs = Hash[*list] iksnr = nrs['registration'] seqnr = nrs['sequence'] ikscd = nrs['package'] smart_link = if iksnr && seqnr && ikscd {:reg => iksnr, :seq => seqnr, :pack => ikscd} elsif iksnr && seqnr {:reg => iksnr, :seq => seqnr} elsif iksnr {:reg => iksnr} end if smart_link @attributes['href'] = @lookandfeel._event_url(:drug, smart_link) else @attributes['href'] = @lookandfeel._event_url(:resolve, arguments) end end
Result
Next
Goal
Experiment
def show if(@session.request_path == @request_path) self else iksnr = @session.user_input(:reg) seqnr = @session.user_input(:seq) ikscd = @session.user_input(:pack) pointer = if iksnr && seqnr && ikscd @session.app.registration(iksnr).sequence(seqnr).package(ikscd).pointer elsif iksnr && seqnr @session.app.registration(iksnr).sequence(seqnr).pointer elsif iksnr @session.app.registration(iksnr).pointer else @session.user_input(:pointer) end if pointer.is_a?(Persistence::Pointer) \ && (model = pointer.resolve(@session.app)) \ && klass = resolve_state(pointer, :readonly) klass.new(@session, model) end end end
Access
Result
Next
Experiment
def pointer_descr(model, session=@session) link = PointerLink.new(:pointer_descr, model, @session, self) unless(@session.allowed?('edit', model)) # model.pointer.to_s might be like this: # :!registration,31706!sequence,01!package,017. # in such case, URL link will be smarter than the URL by using pointer. # z.B.) http://ch.oddb.org/de/gcc/show/reg/31706/seq/01/pack/017 # The old format is also available. list = model.pointer.to_s.gsub(/\./,'').split(/!/).delete_if{|v| v == ":"}.map{|i| i.split(",")}.flatten nrs = Hash[*list] iksnr = nrs['registration'] seqnr = nrs['sequence'] ikscd = nrs['package'] smart_link = if iksnr && seqnr && ikscd {:reg => iksnr, :seq => seqnr, :pack => ikscd} elsif iksnr && seqnr {:reg => iksnr, :seq => seqnr} elsif iksnr {:reg => iksnr} end if smart_link link.href = @lookandfeel._event_url(:show, smart_link) else link.href = @lookandfeel._event_url(:show, {:pointer => model.pointer}) end end link end end
Result
Note