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.
Files changed (141) hide show
  1. data/CHANGELOG +0 -16
  2. data/LICENSE +1 -1
  3. data/README.textile +3 -3
  4. data/Rakefile +28 -0
  5. data/TODO.txt +3 -8
  6. data/bin/pupu +24 -19
  7. data/examples/merb/README.textile +5 -3
  8. data/examples/merb/Rakefile +3 -3
  9. data/examples/merb/config/framework.rb +4 -4
  10. data/examples/merb/config/init.rb +0 -7
  11. data/examples/merb/public/pupu/autocompleter/README.textile +2 -2
  12. data/examples/merb/public/pupu/autocompleter/config.rb +1 -1
  13. data/examples/merb/public/pupu/blueprint/config.rb +7 -7
  14. data/examples/merb/public/pupu/flash/config.rb +1 -1
  15. data/examples/merb/public/pupu/lighter/config.rb +2 -2
  16. data/examples/merb/public/pupu/mootools/README.textile +1 -1
  17. data/examples/merb/public/pupu/mootools/config.rb +1 -1
  18. data/examples/rango/README.textile +6 -4
  19. data/examples/rango/init.rb +0 -7
  20. data/examples/rango/media/pupu/autocompleter/README.textile +2 -2
  21. data/examples/rango/media/pupu/autocompleter/config.rb +1 -1
  22. data/examples/rango/media/pupu/blueprint/config.rb +7 -7
  23. data/examples/rango/media/pupu/flash/config.rb +1 -1
  24. data/examples/rango/media/pupu/lighter/config.rb +2 -2
  25. data/examples/rango/media/pupu/mootools/README.textile +1 -1
  26. data/examples/rango/media/pupu/mootools/config.rb +1 -1
  27. data/lib/pupu.rb +1 -2
  28. data/lib/pupu/adapters/merb.rb +0 -12
  29. data/lib/pupu/adapters/rails.rb +0 -12
  30. data/lib/pupu/adapters/rango.rb +3 -25
  31. data/lib/pupu/cli.rb +11 -13
  32. data/lib/pupu/dsl.rb +13 -34
  33. data/lib/pupu/exceptions.rb +0 -2
  34. data/lib/pupu/github.rb +11 -23
  35. data/lib/pupu/helpers.rb +2 -8
  36. data/lib/pupu/metadata.rb +0 -2
  37. data/lib/pupu/parser.rb +4 -19
  38. data/lib/pupu/pupu.rb +21 -47
  39. data/lib/pupu/version.rb +3 -1
  40. data/pupu.gemspec +7 -15
  41. data/pupu.pre.gemspec +33 -5
  42. data/script/spec +14 -0
  43. data/spec/data/public/pupu/autocompleter/README.textile +2 -2
  44. data/spec/data/public/pupu/autocompleter/config.rb +1 -3
  45. data/{examples/merb/public/pupu/lighter/images/.gitignore → spec/pupu/adapters/merb_spec.rb} +0 -0
  46. data/{examples/rails/app/views/examples/arguments.html.erb → spec/pupu/adapters/rango_spec.rb} +0 -0
  47. data/spec/pupu/dsl_spec.rb +0 -3
  48. data/spec/pupu/exceptions_spec.rb +0 -3
  49. data/spec/pupu/github_spec.rb +1 -4
  50. data/spec/pupu/helpers_spec.rb +2 -5
  51. data/spec/pupu/metadata_spec.rb +0 -3
  52. data/spec/pupu/parser_spec.rb +1 -4
  53. data/spec/pupu/pupu_spec.rb +0 -3
  54. data/stubs/pupu/content/config.rb.rbt +1 -3
  55. data/stubs/pupu/postprocess.rb +0 -8
  56. data/stubs/pupu/setup.rb +0 -4
  57. data/tasks/benchmark.rake +11 -0
  58. data/tasks/gem.rake +23 -0
  59. data/tasks/hooks.rake +12 -0
  60. data/tasks/release.rake +68 -0
  61. data/tasks/spec.rake +27 -0
  62. data/tasks/submodules.rake +33 -0
  63. data/tasks/yardoc.rake +9 -0
  64. metadata +199 -290
  65. data/.gitignore +0 -9
  66. data/Gemfile +0 -9
  67. data/examples/merb/.gitignore +0 -17
  68. data/examples/merb/Gemfile +0 -27
  69. data/examples/merb/public/pupu/autocompleter/.gitignore +0 -5
  70. data/examples/merb/public/pupu/blueprint/.gitignore +0 -5
  71. data/examples/merb/public/pupu/flash/.gitignore +0 -5
  72. data/examples/merb/public/pupu/lighter/.gitignore +0 -10
  73. data/examples/merb/public/pupu/mootools/.gitignore +0 -5
  74. data/examples/rails/.gitignore +0 -7
  75. data/examples/rails/Gemfile +0 -28
  76. data/examples/rails/README.textile +0 -5
  77. data/examples/rails/Rakefile +0 -10
  78. data/examples/rails/app/controllers/application_controller.rb +0 -10
  79. data/examples/rails/app/controllers/home_controller.rb +0 -8
  80. data/examples/rails/app/helpers/application_helper.rb +0 -3
  81. data/examples/rails/app/views/examples/dependencies.html.erb +0 -0
  82. data/examples/rails/app/views/examples/simple.html.erb +0 -4
  83. data/examples/rails/app/views/index.html.erb +0 -7
  84. data/examples/rails/app/views/layout.html.erb +0 -12
  85. data/examples/rails/config/boot.rb +0 -110
  86. data/examples/rails/config/environment.rb +0 -55
  87. data/examples/rails/config/environments/development.rb +0 -17
  88. data/examples/rails/config/environments/production.rb +0 -28
  89. data/examples/rails/config/environments/test.rb +0 -28
  90. data/examples/rails/config/initializers/backtrace_silencers.rb +0 -7
  91. data/examples/rails/config/initializers/inflections.rb +0 -10
  92. data/examples/rails/config/initializers/mime_types.rb +0 -5
  93. data/examples/rails/config/initializers/new_rails_defaults.rb +0 -21
  94. data/examples/rails/config/initializers/session_store.rb +0 -15
  95. data/examples/rails/config/routes.rb +0 -43
  96. data/examples/rails/db/seeds.rb +0 -7
  97. data/examples/rails/public/404.html +0 -30
  98. data/examples/rails/public/422.html +0 -30
  99. data/examples/rails/public/500.html +0 -30
  100. data/examples/rails/public/favicon.ico +0 -0
  101. data/examples/rails/public/robots.txt +0 -5
  102. data/examples/rails/script/about +0 -4
  103. data/examples/rails/script/console +0 -3
  104. data/examples/rails/script/dbconsole +0 -3
  105. data/examples/rails/script/destroy +0 -3
  106. data/examples/rails/script/generate +0 -3
  107. data/examples/rails/script/performance/benchmarker +0 -3
  108. data/examples/rails/script/performance/profiler +0 -3
  109. data/examples/rails/script/plugin +0 -3
  110. data/examples/rails/script/runner +0 -3
  111. data/examples/rails/script/server +0 -3
  112. data/examples/rails/spec/application_spec.rb +0 -37
  113. data/examples/rails/spec/spec_helper.rb +0 -0
  114. data/examples/rango/.gitignore +0 -4
  115. data/examples/rango/Gemfile +0 -56
  116. data/examples/rango/media/pupu/autocompleter/.gitignore +0 -5
  117. data/examples/rango/media/pupu/blueprint/.gitignore +0 -5
  118. data/examples/rango/media/pupu/flash/.gitignore +0 -5
  119. data/examples/rango/media/pupu/lighter/.gitignore +0 -10
  120. data/examples/rango/media/pupu/lighter/images/.gitignore +0 -0
  121. data/examples/rango/media/pupu/mootools/.gitignore +0 -5
  122. data/gems/cache/media-path-0.1.2.gem +0 -0
  123. data/gems/cache/nake-0.0.8.gem +0 -0
  124. data/gems/cache/rspec-1.3.0.gem +0 -0
  125. data/gems/cache/term-ansicolor-1.0.4.gem +0 -0
  126. data/lib/pupu/tasks/pupu.nake +0 -52
  127. data/spec/data/public/pupu/autocompleter/.gitignore +0 -5
  128. data/stubs/pupu/content/%name%.gemspec.rbt +0 -47
  129. data/stubs/pupu/content/%name%.pre.gemspec.rbt +0 -8
  130. data/stubs/pupu/content/.gitignore +0 -12
  131. data/stubs/pupu/content/deps.rip +0 -5
  132. data/stubs/pupu/content/images/.gitignore +0 -0
  133. data/stubs/pupu/content/init.rb.rbt +0 -17
  134. data/stubs/pupu/content/lib/%name%.rb.rbt +0 -4
  135. data/stubs/pupu/content/lib/%name%/adapters/rails.rb +0 -0
  136. data/stubs/pupu/content/lib/%name%/adapters/rango.rb +0 -0
  137. data/stubs/pupu/content/spec/%name%/.gitignore +0 -0
  138. data/stubs/pupu/content/spec/%name%_spec.rb.rbt +0 -10
  139. data/stubs/pupu/content/spec/spec.opts +0 -5
  140. data/stubs/pupu/content/spec/spec_helper.rb.rbt +0 -7
  141. data/tasks.rb +0 -37
@@ -2,7 +2,7 @@
2
2
  javascript "mootools-1.2-core"
3
3
 
4
4
  # parameters of plugin
5
- # pupu :mootools, more: true
5
+ # pupu :mootools, :more => true
6
6
  parameter :more do |boolean|
7
7
  javascript "mootools-1.2-more" if boolean
8
8
  end
@@ -1,8 +1,7 @@
1
- # encoding: utf-8
2
-
3
1
  require "media-path"
4
2
  require "pupu/exceptions"
5
3
  require "pupu/pupu"
6
4
 
7
5
  module Pupu
6
+ VERSION ||= "0.0.2"
8
7
  end
@@ -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")
@@ -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)
@@ -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 = Rango.root
18
- #Pupu.media_prefix = Project.settings.media_prefix
19
- #Pupu.media_root = Project.settings.media_root
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
@@ -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 Kernel
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
- attr_reader :args, :options
44
- def initialize(args, options = Hash.new)
45
- @args, @options = args, options
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: #{::Pupu.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
- ::Pupu.strategy = $1.to_sym
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
- ::Pupu.strategy ||= :copy
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, options)
91
- rescue PluginIsAlreadyInstalled => e
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("https://github.com/api/v1/yaml/search/pupu") do |stream|
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)
@@ -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
- def files
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 = 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
- if params[:if]
63
- tag = "<!--[if #{params[:if]}]>" + tag + "<![endif]-->"
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
- if condition
78
- tag = "<!--[if #{condition}]>" + tag + "<![endif]-->"
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: ["local", "request"] do |type|
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: "request"
107
- # @pupu.params: { type: "request" }
85
+ # pupu :autocompleter, :type => "request"
86
+ # @pupu.params: { :type => "request" }
108
87
 
109
- # pupu :mootools, more: true
110
- # @pupu.params: { more: true }
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
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Pupu
4
2
  class PupuRootNotFound < StandardError
5
3
  end
@@ -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", force: true)
25
- def install(repo, options = Hash.new)
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
- info "Installing #{repo}"
30
- self.install_files(repo, url, options)
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 ::Pupu.strategy.eql?(:submodules)
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: revision, repozitory: url, dependencies: dependencies}
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, options = Hash.new)
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
- begin
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, options = Hash.new)
82
+ def install_files(repo, url)
91
83
  chdir do |media_dir|
92
- if File.directory?(repo) && !options[:force]
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 ::Pupu.strategy.eql?(:copy)
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
@@ -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: "local"
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, pupu_page.parse(name, params).parse!, "", ""].join("\n")
10
+ [comment, Parser.new(name, params).parse!, "", ""].join("\n")
17
11
  end
18
12
  end
19
13
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Pupu
4
2
  class Metadata
5
3
  class << self
@@ -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, page = Page.new)
6
+ def initialize(plugin_name, plugin_params)
20
7
  @plugin = Pupu[plugin_name, plugin_params]
21
8
  @output = Array.new
22
- puts "Parser: #{page.inspect}"
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: true
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, @page)
33
+ parser = Parser.new(dependency.name, dependency.params)
49
34
  @output.push(parser.parse!) unless parser.loaded?
50
35
  end
51
36
  end
@@ -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
- def self.root
13
- @@root ||= Dir.pwd
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
- def self.media_root=(path)
43
- MediaPath.media_root = path
44
- @@media_root = path
45
- end
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
- # strategies: submodules, copy
54
- def self.strategy
55
- @@strategy ||= :copy
56
- end
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
- def self.strategy=(strategy)
59
- @@strategy = strategy
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("/")