/
list.fy
33 lines (30 loc) · 830 Bytes
/
list.fy
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
class Fancy Package {
class List {
def initialize: @package_list_file
def println {
packages each: |p| {
name, version, url = p
"#{name} (#{version})" println
}
}
def packages {
packages = []
try {
File open: @package_list_file modes: ['read] with: |f| {
f readlines each: |l| {
match l {
case /name=(.*) version=(.*) url=(.*)/ -> |_, name, version, url|
packages << (name, version, url)
}
}
}
} catch IOError => e {
# ignore file not found, as no packages might have been installed yet.
}
packages
}
def has_package?: package {
packages any?: |p| { (p first, p second) == (package first, package second) } # ignore url for now
}
}
}