has_many :arc_thumbs
has_many :thumbs, :through => :arc_thumbs
- def site
- "http://bytatsu.net/uploader/mikumikudance"
+ def location_code
+ /([a-z]+)/.match(code).to_a[1]
end
- def url
- if locked?
- "#{site}/upload.cgi?mode=dl&file=#{number}"
- else
- "#{site}/src/#{code}.#{extname}"
+ def number
+ /([0-9]+)/.match(code).to_a[1].to_i
+ end
+
+ def site
+ case location_code
+ when "up"
+ "http://bytatsu.net/uploader/mikumikudance"
+ when "file"
+ "http://loda.jp/mmdfile"
end
end
- def number
- code[2..-1].to_i
+ def url
+ case location_code
+ when "up"
+ if locked?
+ "#{site}/upload.cgi?mode=dl&file=#{number}"
+ else
+ "#{site}/src/#{code}.#{extname}"
+ end
+ when "file"
+ if locked?
+ "#{site}/?mode=pass&idd=#{number}"
+ else
+ "#{site}/?id=#{number}"
+ end
+ end
end
class Search
describe Arc do
#
+ # location_code
+ #
+ it do
+ arc = Arc.new(:code => 'up0675', :extname => 'zip')
+ arc.location_code.should == 'up'
+ end
+ it do
+ arc = Arc.new(:code => 'file0121', :extname => 'zip', :locked => 1)
+ arc.location_code.should == 'file'
+ end
+ #
# url
#
it do
arc = Arc.new(:code => 'up0621', :extname => 'zip', :locked => 1)
arc.url.should == 'http://bytatsu.net/uploader/mikumikudance/upload.cgi?mode=dl&file=621'
end
+ it do
+ arc = Arc.new(:code => 'file0121', :extname => 'zip')
+ arc.url.should == 'http://loda.jp/mmdfile/?id=121'
+ end
+ it do
+ arc = Arc.new(:code => 'file0120', :extname => 'zip', :locked => 1)
+ arc.url.should == 'http://loda.jp/mmdfile/?mode=pass&idd=120'
+ end
#
# number
#