Skip to content

Commit 31f17c1

Browse files
committed
moon_json: applications[title]
1 parent 0828f6a commit 31f17c1

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# -----------------------------------------------------------------------
2+
# This file is part of MoonScript
3+
#
4+
# MoonSript is free software: you can redistribute it and/or modify
5+
# it under the terms of the GNU General Public License as published by
6+
# the Free Software Foundation, either version 3 of the License, or
7+
# (at your option) any later version.
8+
#
9+
# MoonSript is distributed in the hope that it will be useful,
10+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
# GNU General Public License for more details.
13+
#
14+
# You should have received a copy of the GNU General Public License
15+
# along with MoonSript. If not, see <https://www.gnu.org/licenses/>.
16+
#
17+
# Copyright (C) 2025 Krisna Pranav, MoonScript Developers
18+
# -----------------------------------------------------------------------
19+
20+
module MoonScript
21+
class MoonJson
22+
class Parser
23+
def parse_application_title : String
24+
location =
25+
@parser.location
26+
27+
title =
28+
@parser.read_string
29+
30+
error! :application_title_empty do
31+
block do
32+
text "The"
33+
bold "title"
34+
text "field of the"
35+
bold "application object should not be empty"
36+
end
37+
38+
snippet snippet_data(location)
39+
end if title.empty?
40+
41+
title
42+
rescue JSON::ParseException
43+
error! :application_title_invalid do
44+
block do
45+
text "The"
46+
bold "title field"
47+
text "of the"
48+
bold "application object should be string"
49+
end
50+
51+
snippet snippet_data
52+
end
53+
end
54+
end
55+
end
56+
end

0 commit comments

Comments
 (0)