sept 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sept.rb +23 -31
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a03df0b67e266bad1ede1071e07d84365ff0798b
4
- data.tar.gz: 59058e4e21ef1b2bd85f807296f2e18e4d41e1cf
3
+ metadata.gz: fb1123d437cba85deb14a79a038dd0aa4b272e69
4
+ data.tar.gz: 1b2bede9ccc7260dc82f462ca0a5c7d507c1bb1b
5
5
  SHA512:
6
- metadata.gz: 860ed5624374fcddd5bed6d5683e4389b151659d09875499c3eccbc0ee059f5ec327a5132249be0b2da33a2d0ab9eeb34193ded6a73459df4520285f3d5ec985
7
- data.tar.gz: 2092728efa0cefe9583cece36bff957743230d7a9d2d56495ec71259be7c7f2038bb7b01136514a27ded8a4f73e2827c7ec9e38f2e28528a22ed40e16dd8eef3
6
+ metadata.gz: ad5998567dfdeedc9378f2d23ccdbf4aa6f8a579c5a103e587fe920c2d88df7de8d672bd4fbccecea745b2efc8cc38a1b387c878de0348bebc8e689032fe56f5
7
+ data.tar.gz: bedcbba640d5b9147b48eb9a0b38f4ac9e0e646ff87922df05ead2d3d9fdffb0355e390264a58719430a181960eb8247b43be83b281861d6976f9cab6c6f3da9
data/lib/sept.rb CHANGED
@@ -18,7 +18,15 @@
18
18
  # (tr
19
19
  # (td SEPT)
20
20
  # (td %{param})))))
21
+ # Learn more at:
22
+ # - https://rubygems.org/gems/sept
23
+ # - https://github.com/bouncepaw/sept
21
24
  class Sept
25
+
26
+ # Constructor
27
+ #
28
+ # @param params [Hash] Hash with parameters. Keys are symbols, values are strings.
29
+ # @params files_to_parse [Array] List of files program will try to parse
22
30
  def initialize(params, files_to_parse)
23
31
  @params = params
24
32
  @html = ''
@@ -26,11 +34,17 @@ class Sept
26
34
  files_to_parse.each { |f| self.cook f }
27
35
  end
28
36
 
37
+ # Method that generates ready HTML file from Sept file
38
+ #
39
+ # @param file [String] Sept file
40
+ # @return [String] HTML file
29
41
  def generate(file)
30
42
  self.to_html(self.prepare(SXP.read(file))) % @params
31
43
  end
32
44
 
33
45
  # Function that 'cooks' passed file. It logs some info. The name is bad
46
+ #
47
+ # @param filename [String] Name of file to 'cook'
34
48
  def cook(filename)
35
49
  unless File.extname(filename) == ".sept"
36
50
  puts "#{filename} is not `.sept` file, so can't parse it!".red
@@ -50,14 +64,17 @@ class Sept
50
64
  puts "parsed #{filename} and saved in #{new_filename}:\n #{new_file}"
51
65
  end
52
66
 
53
- # Recursive function that turns everything in `node` to a string
54
- # [:sym, [1, "str"]] => ["sym", ["1", "str"]]
67
+ # Recursive function that turns everything in `node` to a string and handles
68
+ # including of other files (well, will handle)
69
+ #
70
+ # @param node [Array, String] A Sept node
55
71
  def prepare(node)
56
72
  node.each_with_index do |sub, i|
57
73
  if sub.is_a? Array
58
74
  self.prepare sub
59
75
  else
60
76
  node[i] = sub.to_s
77
+ # TODO: finish this thing
61
78
  if node[0] == "#include"
62
79
  file = self.generate File.read node[1].to_s
63
80
  node.pop until node.length == 0
@@ -67,7 +84,10 @@ class Sept
67
84
  end
68
85
  end
69
86
 
70
- # Function that turns array to something usable
87
+ # Recursive function that generates HTML string.
88
+ #
89
+ # @param node [Array, String] A Sept node
90
+ # @return [String]
71
91
  def to_html(node)
72
92
  if node.is_a? Array
73
93
  if node.length == 1 then @html << "<#{node[0]}/>"
@@ -81,33 +101,5 @@ class Sept
81
101
 
82
102
  @html
83
103
  end
84
-
85
- # Function that includes other files
86
- # (#include file.sept) => contents of file.sept
87
- def include_files(file)
88
-
89
- end
90
104
  end
91
105
 
92
- ARGV.length == 0 ? puts("Too few arguments".red) : case ARGV[0]
93
- when "-h" # help
94
- puts 'S-Expression Powered Template HyperText Markup Language',
95
- 'To get version, run `sept -v`',
96
- 'To pass some data, run `sept -d <data> files...`',
97
- '<data> is a ruby hash ({:key => "value",})',
98
- 'To pass some data via file, run `sept -f <datafile> files...`',
99
- '<datafile> is a file with ruby hash',
100
- 'Be careful! Any ruby code can be passed along with hash,',
101
- 'validation coming soon'
102
- when "-v" # version
103
- puts "SEPT HTML version 1.2"
104
- when "-d" # data
105
- puts "Passed data as argument"
106
- sept = Sept.new(eval(ARGV[1]), ARGV[2..-1])
107
- when '-f' # file
108
- puts "Passed data as file"
109
- sept = Sept.new(eval(File.read ARGV[1]), ARGV[2..-1])
110
- else
111
- puts "No passed data"
112
- sept = Sept.new({}, ARGV)
113
- end
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sept
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
- - Timur Isamgilov
7
+ - Timur Ismagilov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []