my_precious 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/my_precious/version.rb +1 -1
- data/lib/my_precious.rb +43 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9363adf2030b310af9f66d7ba0263ce1cd7ddbafba5f1a02ae0f204c19afac5
|
4
|
+
data.tar.gz: 1fb4a1c11be1593a8453d74d2f53949d6e1a38744b806f1e416b10edafd0955b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f56f4a2ca06f6c796ef6e3e673afa19b5806e61e60f3454703dc0b59bbb78c193f559aa41aa000297e25bcbd64605c917a0fe078e7bee07c2beb483482de2ae0
|
7
|
+
data.tar.gz: b5db56234e72011bfa018bef2d36abaad362d4e95ae88ae8c3aa5ab1db80efbebf693346aff4fd083c8ff7b5763d70998a579646375995fd5ac6a17c998ed441
|
data/Gemfile.lock
CHANGED
data/lib/my_precious/version.rb
CHANGED
data/lib/my_precious.rb
CHANGED
@@ -8,26 +8,56 @@ module MyPrecious
|
|
8
8
|
class CLI < Thor
|
9
9
|
|
10
10
|
desc 'bring_forth FILE', 'creates a .precious FILE where users can write their LOTR code'
|
11
|
-
def bring_forth(
|
12
|
-
file = File.open(
|
13
|
-
puts "You have succesfully brought forth
|
11
|
+
def bring_forth(file_name)
|
12
|
+
file = File.open(file_name + '.precious', 'w')
|
13
|
+
puts "You have succesfully brought forth #{file_name}.precious"
|
14
14
|
end
|
15
15
|
|
16
16
|
desc 'parse FILE', 'parse a .precious FILE and output the result'
|
17
|
-
def parse
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
def parse reader_file_name, writer_file_name
|
18
|
+
exts_are_valid = check_reader_and_writer_exts(reader_file_name, writer_file_name)
|
19
|
+
if exts_are_valid
|
20
|
+
file = File.open(reader_file_name, 'r')
|
21
|
+
Parser.parse_file file, writer_file_name
|
22
|
+
puts "You have successfully transcribed #{reader_file_name}.precious into #{writer_file_name}.rb"
|
23
|
+
file.close
|
24
|
+
end
|
22
25
|
end
|
23
26
|
|
24
|
-
# def
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
27
|
+
# def speak_friend file_name
|
28
|
+
# isvalid = check_ext(file_name)
|
29
|
+
# if isvalid
|
30
|
+
# file = File.open file_name
|
28
31
|
|
29
|
-
#
|
32
|
+
# puts "You ran #{file_name}"
|
33
|
+
# end
|
30
34
|
# end
|
31
35
|
|
36
|
+
private
|
37
|
+
|
38
|
+
def check_ext(file_name)
|
39
|
+
accepted_writer_formats = '.rb'
|
40
|
+
ext = File.extname(file_name)
|
41
|
+
if accepted_writer_formats == ext
|
42
|
+
return true
|
43
|
+
else
|
44
|
+
raise "#{file_name} is not a *Gollum Cough* *Gollum Cough* ruby (file)!"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def check_reader_and_writer_exts(reader_file, writer_file)
|
49
|
+
isvalid = false;
|
50
|
+
accepted_reader_formats = '.precious'
|
51
|
+
accepted_writer_formats = '.rb'
|
52
|
+
|
53
|
+
ext = File.extname(reader_file)
|
54
|
+
if accepted_reader_formats == ext
|
55
|
+
isvalid = true
|
56
|
+
else
|
57
|
+
raise "#{reader_file} is not a *Gollum Cough* *Gollum Cough* precious (file)!"
|
58
|
+
end
|
59
|
+
check_ext(writer_file)
|
60
|
+
end
|
61
|
+
|
32
62
|
end #end of CLI
|
33
63
|
end
|