pupu 0.0.5.5 → 0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +0 -16
- data/LICENSE +1 -1
- data/README.textile +3 -3
- data/Rakefile +28 -0
- data/TODO.txt +3 -8
- data/bin/pupu +24 -19
- data/examples/merb/README.textile +5 -3
- data/examples/merb/Rakefile +3 -3
- data/examples/merb/config/framework.rb +4 -4
- data/examples/merb/config/init.rb +0 -7
- data/examples/merb/public/pupu/autocompleter/README.textile +2 -2
- data/examples/merb/public/pupu/autocompleter/config.rb +1 -1
- data/examples/merb/public/pupu/blueprint/config.rb +7 -7
- data/examples/merb/public/pupu/flash/config.rb +1 -1
- data/examples/merb/public/pupu/lighter/config.rb +2 -2
- data/examples/merb/public/pupu/mootools/README.textile +1 -1
- data/examples/merb/public/pupu/mootools/config.rb +1 -1
- data/examples/rango/README.textile +6 -4
- data/examples/rango/init.rb +0 -7
- data/examples/rango/media/pupu/autocompleter/README.textile +2 -2
- data/examples/rango/media/pupu/autocompleter/config.rb +1 -1
- data/examples/rango/media/pupu/blueprint/config.rb +7 -7
- data/examples/rango/media/pupu/flash/config.rb +1 -1
- data/examples/rango/media/pupu/lighter/config.rb +2 -2
- data/examples/rango/media/pupu/mootools/README.textile +1 -1
- data/examples/rango/media/pupu/mootools/config.rb +1 -1
- data/lib/pupu.rb +1 -2
- data/lib/pupu/adapters/merb.rb +0 -12
- data/lib/pupu/adapters/rails.rb +0 -12
- data/lib/pupu/adapters/rango.rb +3 -25
- data/lib/pupu/cli.rb +11 -13
- data/lib/pupu/dsl.rb +13 -34
- data/lib/pupu/exceptions.rb +0 -2
- data/lib/pupu/github.rb +11 -23
- data/lib/pupu/helpers.rb +2 -8
- data/lib/pupu/metadata.rb +0 -2
- data/lib/pupu/parser.rb +4 -19
- data/lib/pupu/pupu.rb +21 -47
- data/lib/pupu/version.rb +3 -1
- data/pupu.gemspec +7 -15
- data/pupu.pre.gemspec +33 -5
- data/script/spec +14 -0
- data/spec/data/public/pupu/autocompleter/README.textile +2 -2
- data/spec/data/public/pupu/autocompleter/config.rb +1 -3
- data/{examples/merb/public/pupu/lighter/images/.gitignore → spec/pupu/adapters/merb_spec.rb} +0 -0
- data/{examples/rails/app/views/examples/arguments.html.erb → spec/pupu/adapters/rango_spec.rb} +0 -0
- data/spec/pupu/dsl_spec.rb +0 -3
- data/spec/pupu/exceptions_spec.rb +0 -3
- data/spec/pupu/github_spec.rb +1 -4
- data/spec/pupu/helpers_spec.rb +2 -5
- data/spec/pupu/metadata_spec.rb +0 -3
- data/spec/pupu/parser_spec.rb +1 -4
- data/spec/pupu/pupu_spec.rb +0 -3
- data/stubs/pupu/content/config.rb.rbt +1 -3
- data/stubs/pupu/postprocess.rb +0 -8
- data/stubs/pupu/setup.rb +0 -4
- data/tasks/benchmark.rake +11 -0
- data/tasks/gem.rake +23 -0
- data/tasks/hooks.rake +12 -0
- data/tasks/release.rake +68 -0
- data/tasks/spec.rake +27 -0
- data/tasks/submodules.rake +33 -0
- data/tasks/yardoc.rake +9 -0
- metadata +199 -290
- data/.gitignore +0 -9
- data/Gemfile +0 -9
- data/examples/merb/.gitignore +0 -17
- data/examples/merb/Gemfile +0 -27
- data/examples/merb/public/pupu/autocompleter/.gitignore +0 -5
- data/examples/merb/public/pupu/blueprint/.gitignore +0 -5
- data/examples/merb/public/pupu/flash/.gitignore +0 -5
- data/examples/merb/public/pupu/lighter/.gitignore +0 -10
- data/examples/merb/public/pupu/mootools/.gitignore +0 -5
- data/examples/rails/.gitignore +0 -7
- data/examples/rails/Gemfile +0 -28
- data/examples/rails/README.textile +0 -5
- data/examples/rails/Rakefile +0 -10
- data/examples/rails/app/controllers/application_controller.rb +0 -10
- data/examples/rails/app/controllers/home_controller.rb +0 -8
- data/examples/rails/app/helpers/application_helper.rb +0 -3
- data/examples/rails/app/views/examples/dependencies.html.erb +0 -0
- data/examples/rails/app/views/examples/simple.html.erb +0 -4
- data/examples/rails/app/views/index.html.erb +0 -7
- data/examples/rails/app/views/layout.html.erb +0 -12
- data/examples/rails/config/boot.rb +0 -110
- data/examples/rails/config/environment.rb +0 -55
- data/examples/rails/config/environments/development.rb +0 -17
- data/examples/rails/config/environments/production.rb +0 -28
- data/examples/rails/config/environments/test.rb +0 -28
- data/examples/rails/config/initializers/backtrace_silencers.rb +0 -7
- data/examples/rails/config/initializers/inflections.rb +0 -10
- data/examples/rails/config/initializers/mime_types.rb +0 -5
- data/examples/rails/config/initializers/new_rails_defaults.rb +0 -21
- data/examples/rails/config/initializers/session_store.rb +0 -15
- data/examples/rails/config/routes.rb +0 -43
- data/examples/rails/db/seeds.rb +0 -7
- data/examples/rails/public/404.html +0 -30
- data/examples/rails/public/422.html +0 -30
- data/examples/rails/public/500.html +0 -30
- data/examples/rails/public/favicon.ico +0 -0
- data/examples/rails/public/robots.txt +0 -5
- data/examples/rails/script/about +0 -4
- data/examples/rails/script/console +0 -3
- data/examples/rails/script/dbconsole +0 -3
- data/examples/rails/script/destroy +0 -3
- data/examples/rails/script/generate +0 -3
- data/examples/rails/script/performance/benchmarker +0 -3
- data/examples/rails/script/performance/profiler +0 -3
- data/examples/rails/script/plugin +0 -3
- data/examples/rails/script/runner +0 -3
- data/examples/rails/script/server +0 -3
- data/examples/rails/spec/application_spec.rb +0 -37
- data/examples/rails/spec/spec_helper.rb +0 -0
- data/examples/rango/.gitignore +0 -4
- data/examples/rango/Gemfile +0 -56
- data/examples/rango/media/pupu/autocompleter/.gitignore +0 -5
- data/examples/rango/media/pupu/blueprint/.gitignore +0 -5
- data/examples/rango/media/pupu/flash/.gitignore +0 -5
- data/examples/rango/media/pupu/lighter/.gitignore +0 -10
- data/examples/rango/media/pupu/lighter/images/.gitignore +0 -0
- data/examples/rango/media/pupu/mootools/.gitignore +0 -5
- data/gems/cache/media-path-0.1.2.gem +0 -0
- data/gems/cache/nake-0.0.8.gem +0 -0
- data/gems/cache/rspec-1.3.0.gem +0 -0
- data/gems/cache/term-ansicolor-1.0.4.gem +0 -0
- data/lib/pupu/tasks/pupu.nake +0 -52
- data/spec/data/public/pupu/autocompleter/.gitignore +0 -5
- data/stubs/pupu/content/%name%.gemspec.rbt +0 -47
- data/stubs/pupu/content/%name%.pre.gemspec.rbt +0 -8
- data/stubs/pupu/content/.gitignore +0 -12
- data/stubs/pupu/content/deps.rip +0 -5
- data/stubs/pupu/content/images/.gitignore +0 -0
- data/stubs/pupu/content/init.rb.rbt +0 -17
- data/stubs/pupu/content/lib/%name%.rb.rbt +0 -4
- data/stubs/pupu/content/lib/%name%/adapters/rails.rb +0 -0
- data/stubs/pupu/content/lib/%name%/adapters/rango.rb +0 -0
- data/stubs/pupu/content/spec/%name%/.gitignore +0 -0
- data/stubs/pupu/content/spec/%name%_spec.rb.rbt +0 -10
- data/stubs/pupu/content/spec/spec.opts +0 -5
- data/stubs/pupu/content/spec/spec_helper.rb.rbt +0 -7
- data/tasks.rb +0 -37
data/lib/pupu.rb
CHANGED
data/lib/pupu/adapters/merb.rb
CHANGED
@@ -1,18 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require "pupu"
|
4
2
|
require "pupu/helpers"
|
5
3
|
|
6
|
-
Pupu.framework = :merb
|
7
|
-
|
8
|
-
def Pupu.environment
|
9
|
-
Merb.environment
|
10
|
-
end
|
11
|
-
|
12
|
-
def Pupu.logger
|
13
|
-
Merb.logger
|
14
|
-
end
|
15
|
-
|
16
4
|
Merb::BootLoader.before_app_loads do
|
17
5
|
Pupu.root = Merb.root
|
18
6
|
Pupu.media_root = File.join(Merb.root, "public")
|
data/lib/pupu/adapters/rails.rb
CHANGED
@@ -1,18 +1,6 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require "pupu"
|
4
2
|
require "pupu/helpers"
|
5
3
|
|
6
|
-
Pupu.framework = :rails
|
7
|
-
|
8
|
-
def Pupu.environment
|
9
|
-
Rails.environment
|
10
|
-
end
|
11
|
-
|
12
|
-
def Pupu.logger
|
13
|
-
Rails.logger
|
14
|
-
end
|
15
|
-
|
16
4
|
Pupu.root = Rails.root
|
17
5
|
Pupu.media_root = File.join(Rails.root, "public")
|
18
6
|
ActionView::Base.send(:include, Pupu::Helpers)
|
data/lib/pupu/adapters/rango.rb
CHANGED
@@ -1,32 +1,10 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require "pupu"
|
4
2
|
require "pupu/helpers"
|
5
3
|
|
6
|
-
Pupu.framework = :rango
|
7
|
-
|
8
|
-
def Pupu.environment
|
9
|
-
Rango.environment
|
10
|
-
end
|
11
|
-
|
12
|
-
def Pupu.logger
|
13
|
-
Rango.logger
|
14
|
-
end
|
15
|
-
|
16
4
|
Rango.after_boot(:register_pupu) do
|
17
|
-
Pupu.root =
|
18
|
-
|
19
|
-
|
5
|
+
Pupu.root = Project.root
|
6
|
+
Pupu.media_prefix = Project.settings.media_prefix
|
7
|
+
Pupu.media_root = Project.settings.media_root
|
20
8
|
Rango::Helpers.send(:include, Pupu::Helpers)
|
21
9
|
Rango.logger.info("Pupu plugin registered")
|
22
10
|
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/cli.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require "fileutils"
|
4
2
|
require "yaml"
|
5
3
|
require "ostruct"
|
@@ -9,7 +7,7 @@ require "pupu/pupu"
|
|
9
7
|
require "pupu/github"
|
10
8
|
|
11
9
|
# copyied from merb.thor, this part is actually my code as well :)
|
12
|
-
module
|
10
|
+
module ColorfulMessages
|
13
11
|
# red
|
14
12
|
def error(*messages)
|
15
13
|
puts messages.map { |msg| "\033[1;31m#{msg}\033[0m" }
|
@@ -40,15 +38,16 @@ end
|
|
40
38
|
|
41
39
|
module Pupu
|
42
40
|
class CLI
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
include ColorfulMessages
|
42
|
+
attr_reader :args
|
43
|
+
def initialize(args)
|
44
|
+
@args = args
|
46
45
|
self.detect
|
47
46
|
self.load_config
|
48
47
|
self.parse_argv
|
49
48
|
self.check_setup
|
50
49
|
note "Using media directory: #{::Pupu.media_root}"
|
51
|
-
note "Using strategy: #{
|
50
|
+
note "Using strategy: #{Pupu.strategy}"
|
52
51
|
end
|
53
52
|
|
54
53
|
def parse_argv
|
@@ -63,7 +62,7 @@ module Pupu
|
|
63
62
|
elsif argument.match(/--strategy=(.+)/)
|
64
63
|
self.args.delete(argument)
|
65
64
|
if %[copy submodules].include?($1)
|
66
|
-
|
65
|
+
Pupu.strategy = $1.to_sym
|
67
66
|
else
|
68
67
|
abort "Available strategies: copy, submodules"
|
69
68
|
end
|
@@ -77,7 +76,7 @@ module Pupu
|
|
77
76
|
path ||= ["media", "public"].find { |directory| File.directory?(directory) }
|
78
77
|
return if path.nil?
|
79
78
|
::Pupu.media_root = File.expand_path(path)
|
80
|
-
|
79
|
+
Pupu.strategy ||= :copy
|
81
80
|
end
|
82
81
|
|
83
82
|
def check_setup
|
@@ -87,9 +86,8 @@ module Pupu
|
|
87
86
|
def install
|
88
87
|
self.args.each do |pupu|
|
89
88
|
begin
|
90
|
-
GitHub.install(pupu
|
91
|
-
rescue PluginIsAlreadyInstalled
|
92
|
-
puts e.backtrace.join("\n- ")
|
89
|
+
GitHub.install(pupu)
|
90
|
+
rescue PluginIsAlreadyInstalled
|
93
91
|
info "Plugin #{pupu} is already installed, skipping"
|
94
92
|
end
|
95
93
|
end
|
@@ -148,7 +146,7 @@ module Pupu
|
|
148
146
|
# search on github
|
149
147
|
require "yaml"
|
150
148
|
require "open-uri"
|
151
|
-
open("
|
149
|
+
open("http://github.com/api/v1/yaml/search/pupu") do |stream|
|
152
150
|
repositories = YAML::load(stream.read)["repositories"]
|
153
151
|
repositories.each do |repository|
|
154
152
|
repository = OpenStruct.new(repository)
|
data/lib/pupu/dsl.rb
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require "ostruct"
|
4
2
|
require "media-path"
|
5
|
-
require "pupu/parser"
|
6
3
|
|
7
4
|
class Hash
|
8
5
|
def to_html_attrs
|
@@ -12,19 +9,12 @@ end
|
|
12
9
|
|
13
10
|
module Pupu
|
14
11
|
class DSL
|
15
|
-
attr_reader :output, :path
|
16
|
-
|
17
|
-
|
18
|
-
@page.files
|
19
|
-
end
|
20
|
-
|
21
|
-
def initialize(pupu, page = Page.new)
|
22
|
-
@pupu = pupu
|
23
|
-
@page = page
|
12
|
+
attr_reader :output, :files, :path
|
13
|
+
def initialize(pupu)
|
14
|
+
@pupu = pupu
|
24
15
|
@output = Array.new
|
25
|
-
@files =
|
16
|
+
@files = Array.new
|
26
17
|
@dependencies = Array.new
|
27
|
-
puts "DSL: #{page.inspect}"
|
28
18
|
@path = pupu.file("config.rb")
|
29
19
|
end
|
30
20
|
|
@@ -59,28 +49,17 @@ module Pupu
|
|
59
49
|
def javascript(basename, params = Hash.new)
|
60
50
|
path = @pupu.javascript(basename).url
|
61
51
|
tag = "<script src='#{path}' type='text/javascript'></script>"
|
62
|
-
|
63
|
-
|
64
|
-
end
|
65
|
-
unless files.include?(path)
|
66
|
-
files.push(path)
|
67
|
-
@output.push(tag)
|
68
|
-
end
|
52
|
+
@files.push(path)
|
53
|
+
@output.push(tag)
|
69
54
|
end
|
70
55
|
|
71
56
|
def stylesheet(basename, params = Hash.new)
|
72
57
|
path = @pupu.stylesheet(basename).url
|
73
|
-
condition = params.delete(:if)
|
74
58
|
default = {media: 'screen', rel: 'stylesheet', type: 'text/css'}
|
75
59
|
params = default.merge(params)
|
76
60
|
tag = "<link href='#{path}' #{params.to_html_attrs} />"
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
unless files.include?(path)
|
81
|
-
files.push(path)
|
82
|
-
@output.push(tag)
|
83
|
-
end
|
61
|
+
@files.push(path)
|
62
|
+
@output.push(tag)
|
84
63
|
end
|
85
64
|
|
86
65
|
def javascripts(*names)
|
@@ -95,7 +74,7 @@ module Pupu
|
|
95
74
|
end
|
96
75
|
end
|
97
76
|
|
98
|
-
# parameter :type, optional
|
77
|
+
# parameter :type, :optional => ["local", "request"] do |type|
|
99
78
|
# javascript "autocompleter.#{type}"
|
100
79
|
# end
|
101
80
|
|
@@ -103,11 +82,11 @@ module Pupu
|
|
103
82
|
# javascript "mootools-1.2-more" if boolean
|
104
83
|
# end
|
105
84
|
def parameter(name, params = Hash.new, &block)
|
106
|
-
# pupu :autocompleter, type
|
107
|
-
# @pupu.params: { type
|
85
|
+
# pupu :autocompleter, :type => "request"
|
86
|
+
# @pupu.params: { :type => "request" }
|
108
87
|
|
109
|
-
# pupu :mootools, more
|
110
|
-
# @pupu.params: { more
|
88
|
+
# pupu :mootools, :more => true
|
89
|
+
# @pupu.params: { :more => true }
|
111
90
|
if @pupu.params.key?(name)
|
112
91
|
block.call(@pupu.params[name])
|
113
92
|
end
|
data/lib/pupu/exceptions.rb
CHANGED
data/lib/pupu/github.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require "fileutils"
|
4
2
|
require "yaml"
|
5
3
|
require "ostruct"
|
@@ -21,21 +19,20 @@ module Pupu
|
|
21
19
|
class << self
|
22
20
|
include ShellExtensions
|
23
21
|
# GitHub.install("autocompleter")
|
24
|
-
# GitHub.install("botanicus/autocompleter"
|
25
|
-
def install(repo
|
22
|
+
# GitHub.install("botanicus/autocompleter")
|
23
|
+
def install(repo)
|
26
24
|
user, repo = repo.split("/") if repo.match(%r{/})
|
27
25
|
user = ENV["USER"] unless user
|
28
26
|
url = "git://github.com/#{user}/pupu-#{repo}.git"
|
29
|
-
|
30
|
-
self.
|
31
|
-
self.install_dependencies(@pupu, options)
|
27
|
+
self.install_files(repo, url)
|
28
|
+
self.install_dependencies(@pupu)
|
32
29
|
# TODO: git commit [files] -m "Added pupu #{repo} from #{url}"
|
33
30
|
end
|
34
31
|
|
35
32
|
def update(pupu_name)
|
36
33
|
if pupu_name
|
37
34
|
pupu = Pupu[pupu_name]
|
38
|
-
if
|
35
|
+
if Pupu.strategy.eql?(:submodules)
|
39
36
|
puts %(git fetch)
|
40
37
|
puts %(git reset origin/master --hard)
|
41
38
|
else
|
@@ -66,7 +63,7 @@ module Pupu
|
|
66
63
|
revision = %x(git log | head -1).chomp.sub(/^commit /, "")
|
67
64
|
dsl = DSL.new(pupu)
|
68
65
|
dependencies = dsl.get_dependencies.map { |dependency| dependency.name }
|
69
|
-
params = {revision
|
66
|
+
params = {:revision => revision, :repozitory => url, :dependencies => dependencies}
|
70
67
|
Dir.chdir(@pupu.root.to_s) do
|
71
68
|
File.open("metadata.yml", "w") do |file|
|
72
69
|
file.puts(params.to_yaml)
|
@@ -74,26 +71,17 @@ module Pupu
|
|
74
71
|
end
|
75
72
|
end
|
76
73
|
|
77
|
-
def install_dependencies(pupu
|
74
|
+
def install_dependencies(pupu)
|
78
75
|
dsl = DSL.new(pupu)
|
79
76
|
dsl.instance_eval(File.read(pupu.file("config.rb").path))
|
80
77
|
dsl.get_dependencies.each do |dependency|
|
81
|
-
|
82
|
-
info "Installing dependency #{dependency}"
|
83
|
-
self.install(dependency.name.to_s, options) # FIXME: "user/repo"
|
84
|
-
rescue PluginIsAlreadyInstalled => exception
|
85
|
-
puts "~ #{exception.message}"
|
86
|
-
end
|
78
|
+
self.install(dependency.name.to_s) # FIXME: "user/repo"
|
87
79
|
end
|
88
80
|
end
|
89
81
|
|
90
|
-
def install_files(repo, url
|
82
|
+
def install_files(repo, url)
|
91
83
|
chdir do |media_dir|
|
92
|
-
if File.directory?(repo)
|
93
|
-
raise PluginIsAlreadyInstalled, "Pupu #{repo} already exist"
|
94
|
-
elsif File.directory?(repo) && options[:force]
|
95
|
-
FileUtils.rm_r(repo)
|
96
|
-
end
|
84
|
+
raise PluginIsAlreadyInstalled if File.directory?(repo) # TODO: custom exception class
|
97
85
|
run("git clone #{url} #{repo}") || abort("Git failed")
|
98
86
|
Dir.chdir(repo) do
|
99
87
|
proceed_files(repo, url)
|
@@ -116,7 +104,7 @@ module Pupu
|
|
116
104
|
end
|
117
105
|
@pupu = Pupu[repo]
|
118
106
|
self.save_metadata(@pupu, url)
|
119
|
-
FileUtils.rm_r(".git") if
|
107
|
+
FileUtils.rm_r(".git") if Pupu.strategy.eql?(:copy)
|
120
108
|
rescue Exception => exception
|
121
109
|
FileUtils.rm_r(repo) if File.directory?(repo)
|
122
110
|
raise exception
|
data/lib/pupu/helpers.rb
CHANGED
@@ -1,19 +1,13 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require "pupu/parser"
|
4
2
|
|
5
3
|
module Pupu
|
6
4
|
module Helpers
|
7
|
-
def pupu_page
|
8
|
-
@page ||= Page.new
|
9
|
-
end
|
10
|
-
|
11
5
|
# Use it in your layout
|
12
|
-
# Example: pupu :autocompleter, type
|
6
|
+
# Example: pupu :autocompleter, :type => "local"
|
13
7
|
def pupu(name, params = Hash.new)
|
14
8
|
comment = if params.empty? then "<!-- Pupu #{name} without params -->"
|
15
9
|
else "<!-- Pupu #{name} with params #{params.inspect} -->" end
|
16
|
-
[comment,
|
10
|
+
[comment, Parser.new(name, params).parse!, "", ""].join("\n")
|
17
11
|
end
|
18
12
|
end
|
19
13
|
end
|
data/lib/pupu/metadata.rb
CHANGED
data/lib/pupu/parser.rb
CHANGED
@@ -1,34 +1,19 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require "pupu/dsl"
|
4
2
|
require "pupu/pupu"
|
5
3
|
|
6
4
|
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
|
-
|
18
5
|
class Parser
|
19
|
-
def initialize(plugin_name, plugin_params
|
6
|
+
def initialize(plugin_name, plugin_params)
|
20
7
|
@plugin = Pupu[plugin_name, plugin_params]
|
21
8
|
@output = Array.new
|
22
|
-
|
23
|
-
@page = page
|
24
|
-
@dsl = DSL.new(@plugin, page)
|
9
|
+
@dsl = DSL.new(@plugin)
|
25
10
|
@@loaded ||= Hash.new
|
26
11
|
@@loaded[@plugin.name] = Array.new
|
27
12
|
end
|
28
13
|
|
29
14
|
def loaded?
|
30
15
|
# The reason why just array with plugin names isn't enough is that every time it can be called
|
31
|
-
# with different parameters. For example pupu :mootools and then pupu :mootools, more
|
16
|
+
# with different parameters. For example pupu :mootools and then pupu :mootools, :more => true
|
32
17
|
@@loaded[@plugin.name] && @dsl.files.all? do |file|
|
33
18
|
@@loaded[@plugin.name].include?(file)
|
34
19
|
end
|
@@ -45,7 +30,7 @@ module Pupu
|
|
45
30
|
|
46
31
|
def add_dependencies
|
47
32
|
@dsl.get_dependencies.each do |dependency|
|
48
|
-
parser = Parser.new(dependency.name, dependency.params
|
33
|
+
parser = Parser.new(dependency.name, dependency.params)
|
49
34
|
@output.push(parser.parse!) unless parser.loaded?
|
50
35
|
end
|
51
36
|
end
|
data/lib/pupu/pupu.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require "yaml"
|
4
2
|
require "ostruct"
|
5
3
|
require "fileutils"
|
@@ -9,54 +7,27 @@ require "pupu/metadata"
|
|
9
7
|
|
10
8
|
module Pupu
|
11
9
|
# this must be set in adapters
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.root=(path)
|
17
|
-
@@root = path
|
18
|
-
end
|
19
|
-
|
20
|
-
def self.framework
|
21
|
-
@@framework
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.framework=(framework)
|
25
|
-
@@framework = framework
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.environment?(environment)
|
29
|
-
self.environment.eql?(environment)
|
30
|
-
end
|
31
|
-
|
32
|
-
# @example Pupu.media_prefix("media").url
|
33
|
-
# => "/media/pupu/autocompleter/javascripts/autocompleter.js"
|
34
|
-
def self.media_prefix=(prefix)
|
35
|
-
MediaPath.rewrite { |path| File.join(prefix, path) }
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.media_root
|
39
|
-
@@media_root ||= Dir.pwd
|
40
|
-
end
|
10
|
+
class << self
|
11
|
+
attr_accessor :root
|
41
12
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
# @example Pupu.rewrite { |path| "http://media.domain.org/#{path}" }.url
|
48
|
-
# # => "http://media.domain.org/pupu/autocompleter/javascripts/autocompleter.js"
|
49
|
-
def rewrite(&block)
|
50
|
-
MediaPath.rewrite(&block)
|
51
|
-
end
|
13
|
+
# @example Pupu.media_prefix("media").url
|
14
|
+
# => "/media/pupu/autocompleter/javascripts/autocompleter.js"
|
15
|
+
def media_prefix=(prefix)
|
16
|
+
MediaPath.rewrite { |path| File.join(prefix, path) }
|
17
|
+
end
|
52
18
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
19
|
+
# TODO: media_root or media_root?
|
20
|
+
def media_root=(path)
|
21
|
+
MediaPath.media_root = path
|
22
|
+
@media_root = path
|
23
|
+
end
|
24
|
+
attr_reader :media_root
|
57
25
|
|
58
|
-
|
59
|
-
|
26
|
+
# @example Pupu.rewrite { |path| "http://media.domain.org/#{path}" }.url
|
27
|
+
# # => "http://media.domain.org/pupu/autocompleter/javascripts/autocompleter.js"
|
28
|
+
def rewrite(&block)
|
29
|
+
MediaPath.rewrite(&block)
|
30
|
+
end
|
60
31
|
end
|
61
32
|
|
62
33
|
class Pupu
|
@@ -73,6 +44,9 @@ module Pupu
|
|
73
44
|
File.join(::Pupu.media_root, "pupu")
|
74
45
|
end
|
75
46
|
|
47
|
+
# strategies: submodules, copy
|
48
|
+
cattr_accessor :strategy
|
49
|
+
|
76
50
|
def root
|
77
51
|
# TODO: it should be configurable
|
78
52
|
# root = ::Pupu.root.sub(%r[#{Regexp::quote(::Pupu.root)}], '').chomp("/")
|