-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Fastfile
73 lines (58 loc) · 1.39 KB
/
Fastfile
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
lane :all do
read_json_test
download_json_test
write_json_test
merge_jsons_test
end
lane :read_json_test do
my_json = read_json(
json_path: "#{__dir__}/spec/resources/example.json",
verbose: true
)
p(my_json)
end
lane :read_json_string_test do
my_json = read_json(
json_string: "{\r\n \"name\": \"Martin\",\r\n \"age\": 30\r\n }\r\n ",
verbose: true
)
p(my_json)
end
lane :download_json_test do
my_json = download_json(
json_url: "https://gist.githubusercontent.com/MartinGonzalez/77b28af666fc2ee844c96cf6c8c221a2/raw/d23feabf25abe39c9c7243fd23f92efa7f50a3fd/someExample.json",
verbose: true
)
p(my_json)
end
lane :write_json_test do
hash = {
name: "Martin",
age: 30
}
file_path = "#{__dir__}/tmp/test.json"
file_dir = File.dirname("../#{file_path}")
write_json(
hash: hash,
file_path: file_path,
verbose: true
)
p(File.read("../#{file_path}"))
FileUtils.rm_rf(file_dir)
end
lane :merge_jsons_test do
output_path = "#{__dir__}/tmp/merged.json"
merged_hash = merge_jsons(
jsons_paths: [
"#{__dir__}/spec/resources/example.json",
"#{__dir__}/spec/resources/example2.json"
],
output_path: output_path,
verbose: true
)
puts("Hash Value")
puts(merged_hash)
puts("Json file Value")
puts(File.read("../#{output_path}"))
FileUtils.rm_rf(File.dirname("../#{output_path}"))
end