-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
58 lines (53 loc) · 1.32 KB
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ENV['GEM_PATH'] = '/home/brousali/gems'
#ENV['GEM_HOME'] = '/home/brousali/gems'
require 'rubygems'
require 'sinatra'
require 'haml'
#require 'rspec'
class Build
attr_accessor :filename, :date, :branch, :ext, :version
def initialize(filename, date, branch, ext, version=0)
@filename = filename
@date = date
@branch = branch
@ext = ext
@version = version
end
end
def parseBuilds(name)
hash = {}
Dir.chdir(name)
Dir.glob("*") { |filename|
file = filename.split("_")
date = file[1].gsub("-","\/")
branch = file[2]
ext = File.extname(filename)
if name != "stable"
hash[date] ||= [] #check if exists, init
hash[date] << Build.new(filename, date, branch.chomp(ext), ext)
else
hash[ext] = Build.new(filename, date, branch, ext, file[3].chomp(ext))
end
}
Dir.chdir("../")
return hash
end
get '/?' do
@dir = Dir.getwd
begin
@stable = parseBuilds("stable")
@android = parseBuilds("android")
@iphone = parseBuilds("iphone")
rescue
@android = []
@stable = []
@iphone = []
end
Dir.chdir(@dir)
haml :index
end
#describe "parseBuilds test" do
# it "should do some shit" do
# parseBuilds("name").should == {}
# end
#end