<< | Index | >>
Task
Experiment
def compositions(model, session=@session) link = HtmlGrid::Link.new(:show, model, session, self) #link.href = @lookandfeel._event_url(:show, {:pointer => model.pointer})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
Run
Result
Note
Refactoring
class Pointer def to_csv @directions.collect { |orig| step = orig.collect { |arg| if(arg.is_a? Pointer) arg else arg.to_s.gsub('%','%%').gsub(/[:!,.]/u, '%\0') end } step.join(',') }.join(',') end end
def compositions(model, session=@session) link = HtmlGrid::Link.new(:show, model, session, self) link.href = @lookandfeel._event_url(:show, {:pointer => model.pointer})smart_link = model.pointer.to_csv.gsub(/registration/, 'reg').gsub(/sequence/, 'seq').gsub(/package/, 'pack').split(/,/)
if smart_link.include?('reg')
link.href = @lookandfeel._event_url(:show, smart_link)
else # This is an old format by using the default pointer format
link.href = @lookandfeel._event_url(:show, {:pointer => model.pointer})
end
Result
Next
Experiment
if(@session.allowed?('edit', 'org.oddb.drugs')) PointerLink.new(:ikscd, model, @session, self) else evt = @session.state.respond_to?(:suggest_choose) ? :suggest_choose : :show link = HtmlGrid::Link.new(:ikscd, model, @session, self) link.value = model.ikscd #args = {:pointer => model.pointer} #link.href = @lookandfeel.event_url(evt, args)smart_link = model.pointer.to_csv.gsub(/registration/, 'reg').gsub(/sequence/, 'seq').gsub(/package/, 'pack').split(/,/)
if evt == :show and smart_link.include?('reg')
link.href = @lookandfeel.event_url(evt, smart_link)
else
link.href = @lookandfeel.event_url(evt, {:pointer => model.pointer})
end
link end end
Result
Note
Experiment
if(@session.allowed?('edit', model)) PointerLink.new(:seqnr, model, @session, self) else evt = @session.state.respond_to?(:suggest_choose) ? :suggest_choose : :show link = HtmlGrid::Link.new(:seqnr, model, @session, self) #args = {:pointer => model.pointer} #link.href = @lookandfeel.event_url(evt, args)smart_link_format = model.pointer.to_csv.gsub(/registration/, 'reg').gsub(/sequence/, 'seq').gsub(/package/, 'pack').split(/,/)
if evt == :show and smart_link_format.include?('reg')
link.href = @lookandfeel.event_url(evt, smart_link_format)
else
old_link_format = {:pointer => model.pointer}
link.href = @lookandfeel.event_url(evt, old_link_format)
end
link.value = model.seqnr link end end
Result
Next
git status
# modified: src/state/global.rb # modified: src/util/persistence.rb # modified: src/util/validator.rb # modified: src/view/additional_information.rb # modified: src/view/admin/registration.rb # modified: src/view/admin/sequence.rb # modified: src/view/pointersteps.rb # modified: src/view/pointervalue.rb
One by one
Note
masa@masa ~/ywesee/oddb.org $ ruby test/suite.rb 4116 tests, 6570 assertions, 0 failures, 15 errors
Commit
server git pull (error!
)
$ git pull remote: Counting objects: 46, done. remote: Compressing objects: 100% (26/26), done. remote: Total 26 (delta 20), reused 0 (delta 0) Unpacking objects: 100% (26/26), done. From /home/ywesee/git/oddb.org 81ca738..d8a4e48 master -> origin Updating 81ca738..d8a4e48 error: Your local changes to the following files would be overwritten by merge: src/util/persistence.rb Please, commit your changes or stash them before you can merge. Aborting