Skip to content

Commit 69d266d

Browse files
committed
moon_json: applications[icon]
1 parent 3ac2000 commit 69d266d

File tree

1 file changed

+41
-21
lines changed

1 file changed

+41
-21
lines changed

src/moon_json/applications/icon.cr

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,46 @@
1818
# -----------------------------------------------------------------------
1919

2020
module MoonScript
21-
class MoonJson
22-
class Parser
23-
def parse_application_icon: String
24-
location = @parser.location
25-
icon = @parser.read_string
26-
path = Path[root, icon].to_s
27-
28-
error! :application_icon_not_exists do
29-
end
30-
31-
block do
32-
end
33-
34-
snippet snippet_data(location)
35-
end unless File.eixsts?(path)
36-
37-
rescue JSON::ParseExceptione
38-
error! :application_icon_invalid do
39-
end
40-
end
21+
class MoonJson
22+
class Parser
23+
def parse_application_icon : String
24+
location =
25+
@parser.location
26+
27+
icon =
28+
@parser.read_string
29+
30+
path =
31+
Path[root, icon].to_s
32+
33+
error! :application_icon_not_exists do
34+
block do
35+
text "The"
36+
bold "icon"
37+
text "field of"
38+
text "points to a file that does not exists."
39+
end
40+
41+
block do
42+
text "It should point to an image which will be used to generate"
43+
end
44+
45+
snippet snippet_data(location)
46+
end unless File.exists?(path)
47+
48+
icon
49+
rescue JSON::ParseException
50+
error! :application_icon_invalid do
51+
block do
52+
text "The"
53+
bold "icon"
54+
text "field"
55+
text "should be a string, but it's not:"
56+
end
57+
58+
snippet snippet_data
4159
end
60+
end
4261
end
43-
end
62+
end
63+
end

0 commit comments

Comments
 (0)