pupu 0.0.5.2 → 0.0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pupu/adapters/rango.rb +10 -0
- data/lib/pupu/dsl.rb +5 -3
- data/lib/pupu/helpers.rb +5 -1
- data/lib/pupu/parser.rb +16 -3
- data/lib/pupu/version.rb +1 -1
- metadata +2 -2
data/lib/pupu/adapters/rango.rb
CHANGED
@@ -20,3 +20,13 @@ Rango.after_boot(:register_pupu) do
|
|
20
20
|
Rango::Helpers.send(:include, Pupu::Helpers)
|
21
21
|
Rango.logger.info("Pupu plugin registered")
|
22
22
|
end
|
23
|
+
|
24
|
+
module Pupu
|
25
|
+
module Helpers
|
26
|
+
def pupu_page
|
27
|
+
# page = get_context_value(:page) # TOHLE KUNDA NEFUNGUJE V TEMPLEJTACH :(
|
28
|
+
# set_context_value(:page, page || Page.new)
|
29
|
+
context[:pupu_page] ||= Page.new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/pupu/dsl.rb
CHANGED
@@ -13,15 +13,17 @@ module Pupu
|
|
13
13
|
class DSL
|
14
14
|
attr_reader :output, :path
|
15
15
|
|
16
|
-
@@files ||= Array.new
|
17
16
|
def files
|
18
|
-
|
17
|
+
@page.files
|
19
18
|
end
|
20
19
|
|
21
|
-
def initialize(pupu)
|
20
|
+
def initialize(pupu, page = Page.new)
|
22
21
|
@pupu = pupu
|
22
|
+
@page = page
|
23
23
|
@output = Array.new
|
24
|
+
@files = files
|
24
25
|
@dependencies = Array.new
|
26
|
+
puts "DSL: #{page.inspect}"
|
25
27
|
@path = pupu.file("config.rb")
|
26
28
|
end
|
27
29
|
|
data/lib/pupu/helpers.rb
CHANGED
@@ -4,12 +4,16 @@ require "pupu/parser"
|
|
4
4
|
|
5
5
|
module Pupu
|
6
6
|
module Helpers
|
7
|
+
def pupu_page
|
8
|
+
@page ||= Page.new
|
9
|
+
end
|
10
|
+
|
7
11
|
# Use it in your layout
|
8
12
|
# Example: pupu :autocompleter, type: "local"
|
9
13
|
def pupu(name, params = Hash.new)
|
10
14
|
comment = if params.empty? then "<!-- Pupu #{name} without params -->"
|
11
15
|
else "<!-- Pupu #{name} with params #{params.inspect} -->" end
|
12
|
-
[comment,
|
16
|
+
[comment, pupu_page.parse(name, params).parse!, "", ""].join("\n")
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
data/lib/pupu/parser.rb
CHANGED
@@ -4,11 +4,24 @@ require "pupu/dsl"
|
|
4
4
|
require "pupu/pupu"
|
5
5
|
|
6
6
|
module Pupu
|
7
|
+
class Page
|
8
|
+
attr_reader :files
|
9
|
+
def initialize
|
10
|
+
@files = Array.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def parse(name, options)
|
14
|
+
Parser.new(name, options, self)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
7
18
|
class Parser
|
8
|
-
def initialize(plugin_name, plugin_params)
|
19
|
+
def initialize(plugin_name, plugin_params, page = Page.new)
|
9
20
|
@plugin = Pupu[plugin_name, plugin_params]
|
10
21
|
@output = Array.new
|
11
|
-
|
22
|
+
puts "Parser: #{page.inspect}"
|
23
|
+
@page = page
|
24
|
+
@dsl = DSL.new(@plugin, page)
|
12
25
|
@@loaded ||= Hash.new
|
13
26
|
@@loaded[@plugin.name] = Array.new
|
14
27
|
end
|
@@ -32,7 +45,7 @@ module Pupu
|
|
32
45
|
|
33
46
|
def add_dependencies
|
34
47
|
@dsl.get_dependencies.each do |dependency|
|
35
|
-
parser = Parser.new(dependency.name, dependency.params)
|
48
|
+
parser = Parser.new(dependency.name, dependency.params, @page)
|
36
49
|
@output.push(parser.parse!) unless parser.loaded?
|
37
50
|
end
|
38
51
|
end
|
data/lib/pupu/version.rb
CHANGED