Class: Api

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/llt/review/api.rb

Instance Method Summary collapse

Instance Method Details

#expand_perseids_urls(params, key, sosol_path) ⇒ Object



70
71
72
73
74
75
# File 'lib/llt/review/api.rb', line 70

def expand_perseids_urls(params, key, sosol_path)
  t = Array(params[key])
  params[key] = t.map do |publication_id|
    "http://#{sosol_path}/dmm_api/item/TreebankCite/#{publication_id}"
  end
end

#process_diff(params) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/llt/review/api.rb', line 55

def process_diff(params)
  gold = Array(params[:gold])
  rev  = Array(params[:reviewable])

  comp_param = params[:compare]
  comparables = comp_param ? Array(comp_param).map(&:to_sym) : nil

  klass = params[:type]
  # return an error if klass is neither treebank nor Alignment

  diff = LLT::Review.const_get(klass.capitalize).new
  diff.diff(gold, rev, comparables)
  diff
end

#process_params(params) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/llt/review/api.rb', line 43

def process_params(params)
  if backend = params[:backend]
    p = case backend
        when 'perseids'     then 'sosol.perseids.org/sosol'
        when 'perseids-dev' then 'dev.alpheios.net:3000'
        end

    expand_perseids_urls(params, :gold, p)
    expand_perseids_urls(params, :reviewable, p)
  end
end