roger 1.3.5 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -2
  3. data/README.md +5 -5
  4. data/doc/cli.md +6 -6
  5. data/doc/{mockupfile.md → rogerfile.md} +10 -10
  6. data/doc/templating.md +76 -6
  7. data/lib/roger/cli/test.rb +1 -1
  8. data/lib/roger/generators/generator.rb +1 -1
  9. data/lib/roger/generators/new.rb +6 -6
  10. data/lib/roger/project.rb +35 -15
  11. data/lib/roger/release/finalizers/git_branch.rb +3 -3
  12. data/lib/roger/release/finalizers/rsync.rb +1 -1
  13. data/lib/roger/release/processors/mockup.rb +1 -1
  14. data/lib/roger/release/processors/url_relativizer.rb +1 -0
  15. data/lib/roger/release.rb +32 -50
  16. data/lib/roger/{mockupfile.rb → rogerfile.rb} +18 -11
  17. data/lib/roger/server.rb +1 -1
  18. data/lib/roger/template/helpers/capture.rb +53 -0
  19. data/lib/roger/template/helpers/partial.rb +37 -0
  20. data/lib/roger/template/template_context.rb +32 -0
  21. data/lib/roger/template.rb +25 -91
  22. data/lib/roger/test.rb +1 -1
  23. data/lib/roger/version.rb +1 -1
  24. data/test/helpers/cli.rb +5 -5
  25. data/test/unit/cli/cli_serve_test.rb +14 -14
  26. data/test/unit/cli/cli_test_test.rb +4 -4
  27. data/test/unit/generators_test.rb +1 -1
  28. data/test/unit/mockupfile_test.rb +38 -0
  29. data/test/unit/rack/roger_test.rb +1 -1
  30. data/test/unit/release/finalizers/dir_test.rb +43 -0
  31. data/test/unit/release/finalizers/git_branch_test.rb +26 -0
  32. data/test/unit/release/injector_test.rb +66 -0
  33. data/test/unit/release/processors/url_relativizer_test.rb +1 -1
  34. data/test/unit/release/scm/base_test.rb +23 -0
  35. data/test/unit/release/scm/git_test.rb +58 -0
  36. data/test/unit/release_test.rb +95 -5
  37. data/test/unit/server_test.rb +1 -1
  38. data/test/unit/template_test.rb +33 -0
  39. data/test/unit/test_test.rb +2 -2
  40. metadata +20 -8
  41. data/lib/roger/extractor.rb +0 -94
  42. /data/examples/default_template/{Mockupfile → Rogerfile} +0 -0
  43. /data/test/project/{Mockupfile → Rogerfile} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 933f5afa9f6bede1db36b2344edce2b0e088cdc0
4
- data.tar.gz: 8ff81b43a2f3555a65866c74c4fe4ddb71380dc8
3
+ metadata.gz: 49a1a247ec24477695446f28ee9fc18303c679db
4
+ data.tar.gz: ec29ac61a0ea48418f81114a3826dbdf56ed3efd
5
5
  SHA512:
6
- metadata.gz: 0c74286a83d50ec67361aeb9dedfac0d5562954874135f21bdd27f0c1c204a5215a7c28554405396b46e6c444231dfff60d733585acac489fe4bc70aba05bc0f
7
- data.tar.gz: 3323b1f5612fd2d438492fc61000611bad8deb3f773e6f52187b42afe38bc5e5b6d9afacd03a9ca2ef103e41b0d79fc71b7bca14d0a272cd224703aa4061f566
6
+ metadata.gz: 256706c9c7e39642602d4dc33b85211b3ffb47889890e3334eaed3804331937ff4ffafb3fc8cb8d497daab234d847632d9986e8afadcffc19adad9be1b5510df
7
+ data.tar.gz: 2317f5b6140e265463ff6d797d2e2f103e33146ff1b22ef1a8184609ae168eb0c522f992d2176af94b5f896a3e1ed37874946bca70feef1dc16cb74a9a2f906b
data/CHANGELOG.md CHANGED
@@ -1,7 +1,12 @@
1
1
  # Changelog
2
2
 
3
- ## Version 1.3.5
4
- * Backmerge fix for `cp -RL` on linux
3
+ ## Version 1.4.0
4
+ * Rename Mockupfile to Rogerfile
5
+ * Remove the deprecated `Roger::Extractor` (use `Roger::Template` instead)
6
+ * Add support for template helpers through `Roger::Template.register MyHelpersModule`
7
+ * Add more documentation on templating
8
+ * Comment method from Rogerfile will no longer add ! to js/css comments
9
+ * Heavily increase test coverage
5
10
 
6
11
  ## Version 1.3.4
7
12
  * Require the correct "English" module (with capital E) for $CHILD_STATUS
data/README.md CHANGED
@@ -25,7 +25,7 @@ We assume you have a working Ruby 1.9.x or higher running.
25
25
  1. Create a new project
26
26
 
27
27
  ```shell
28
- mockup generate new PROJECT_DIR
28
+ roger generate new PROJECT_DIR
29
29
  ```
30
30
 
31
31
  Replace `PROJECT_DIR` with your project name
@@ -33,7 +33,7 @@ We assume you have a working Ruby 1.9.x or higher running.
33
33
  1. Start the development server
34
34
 
35
35
  ```shell
36
- mockup serve
36
+ roger serve
37
37
  ```
38
38
 
39
39
  Open your webbrowser and go to `http://localhost:9000/`
@@ -41,7 +41,7 @@ We assume you have a working Ruby 1.9.x or higher running.
41
41
  1. Release your project
42
42
 
43
43
  ```shell
44
- mockup release
44
+ roger release
45
45
  ```
46
46
 
47
47
  ## Where to go from here?
@@ -49,8 +49,8 @@ We assume you have a working Ruby 1.9.x or higher running.
49
49
  Read more documentation:
50
50
 
51
51
  * [**Templating** Learn the power of Roger built in templating](doc/templating.md)
52
- * [**CLI** Learn about the different `mockup` commands](doc/cli.md)
53
- * [**Mockupfile** Learn how to configure and extend your Project](doc/mockupfile.md)
52
+ * [**CLI** Learn about the different `roger` commands](doc/cli.md)
53
+ * [**Rogerfile** Learn how to configure and extend your Project](doc/rogerfile.md)
54
54
 
55
55
  ## Why?
56
56
 
data/doc/cli.md CHANGED
@@ -3,25 +3,25 @@
3
3
  The easiest way to get help is through the commandline by running
4
4
 
5
5
  ```shell
6
- mockup help
6
+ roger help
7
7
  ```
8
8
 
9
9
  or to get help on a specific subcommand
10
10
 
11
11
  ```shell
12
- mockup help [subcommand]
12
+ roger help [subcommand]
13
13
  ```
14
14
 
15
15
  ## Generate
16
16
 
17
17
  ```shell
18
- mockup generate [generator] [options]
18
+ roger generate [generator] [options]
19
19
  ```
20
20
 
21
21
  ## Serve
22
22
 
23
23
  ```shell
24
- mockup serve [options]
24
+ roger serve [options]
25
25
  ```
26
26
 
27
27
  Starts a webserver (port 9000 by default)
@@ -30,7 +30,7 @@ Starts a webserver (port 9000 by default)
30
30
  ## Release
31
31
 
32
32
  ```shell
33
- mockup release [options]
33
+ roger release [options]
34
34
  ```
35
35
 
36
36
  Releases the project
@@ -38,7 +38,7 @@ Releases the project
38
38
  ## Test
39
39
 
40
40
  ```shell
41
- mockup test [options]
41
+ roger test [options]
42
42
  ```
43
43
 
44
44
  Tests the project
@@ -1,6 +1,6 @@
1
- # Mockupfile
1
+ # Rogerfile
2
2
 
3
- The mockupfile is where all the project configuration for releasing, serving etc. happens.
3
+ The rogerfile is where all the project configuration for releasing, serving etc. happens.
4
4
 
5
5
  ## Example
6
6
 
@@ -12,23 +12,23 @@ Sass::Plugin.options[:template_location] = "./html/stylesheets"
12
12
  Sass::Plugin.options[:css_location] = "./html/stylesheets"
13
13
 
14
14
  # Set verbosity to true (you can also pass --verbose to roger)
15
- # mockup.project.options[:verbose] = true
15
+ # roger.project.options[:verbose] = true
16
16
 
17
17
  # These are defaults, but can be set here
18
- # mockup.project.html_path = mockup.project.path + "html"
19
- # mockup.project.partial_path = mockup.project.path + "partials"
18
+ # roger.project.html_path = roger.project.path + "html"
19
+ # roger.project.partial_path = roger.project.path + "partials"
20
20
 
21
21
  # Server is a regular Rack interface.
22
- mockup.serve do |server|
22
+ roger.serve do |server|
23
23
  server.use :sass
24
24
  end
25
25
 
26
26
  # Define tests
27
- mockup.test do |t|
27
+ roger.test do |t|
28
28
  t.use :jshint
29
29
  end
30
30
 
31
- mockup.release do |release|
31
+ roger.release do |release|
32
32
 
33
33
  # The variables below can be used anywhere in this section
34
34
  release.target_path # The target path where releases are put
@@ -40,8 +40,8 @@ mockup.release do |release|
40
40
  release.scm.version # Get the git version
41
41
  release.scm.date # Get the git date
42
42
 
43
- # Extract mockup (this is optional)
44
- # release.mockup
43
+ # Extract project (this is optional)
44
+ # release.use :mockup
45
45
 
46
46
  # Create custom banner
47
47
  #
data/doc/templating.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Before we get started, it's good to know that there are a couple of "special" folders within any Roger project. Don't worry, you can configure these; they're not hard-coded. The folders are:
6
6
 
7
- * **project-path** this is the main directory containing the Mockupfile and all other directories.
7
+ * **project-path** this is the main directory containing the Rogerfile and all other directories.
8
8
  * **html-path** this is the directory where all your HTML/CSS/Javascript will go (in subdirectories of course).
9
9
  * **partials-path** this is the directory where all partials reside.
10
10
  * **layouts-path** this is the directory where the layouts hang out.
@@ -25,9 +25,9 @@ Only the html-path has to exist. The others are not required.
25
25
 
26
26
  ## HTML
27
27
 
28
- The html-path is actually the root for all you front-end code. This is what will be served as the document-root with `mockup serve` and will be the base for a release when using `mockup release`.
28
+ The html-path is actually the root for all you front-end code. This is what will be served as the document-root with `roger serve` and will be the base for a release when using `roger release`.
29
29
 
30
- In the html-path you can put static files (images, documents, etc.) but also templates. Anything that the [Tilt Engine](https://github.com/rtomayko/tilt) can handle is ok. The only thing Mockup adds is handling for front-matter, layouts and partials.
30
+ In the html-path you can put static files (images, documents, etc.) but also templates. Anything that the [Tilt Engine](https://github.com/rtomayko/tilt) can handle is ok. The only thing Roger adds is handling for front-matter, layouts and partials.
31
31
 
32
32
  ## Front-matter
33
33
 
@@ -44,10 +44,9 @@ these values in the templates (layouts and partials included) by using `document
44
44
 
45
45
  ## Layouts
46
46
 
47
- Layouts are basically "wrap" templates. The layout will wrap around the rendered template. In the template front-matter you define what layout it should use by setting the `layout` key.
48
-
49
- ### An example
47
+ Layouts are basically "wrap" templates. The layout will wrap around the rendered template. In the template front-matter you define what layout it should use by setting the `layout` key. See the example below.
50
48
 
49
+ ### Basic layout example
51
50
 
52
51
  #### html/template.html.erb
53
52
  ```erb
@@ -73,6 +72,45 @@ Template
73
72
  Layout (after)
74
73
  ```
75
74
 
75
+ ### Advanced layouts
76
+
77
+ #### Using `content_for`
78
+
79
+ You can have multiple regions in your layout. That way you can yield multiple times for each region. See the example below for usage on `content_for :name do ... end` and `yield :name`.
80
+
81
+ ##### `content_for` example
82
+
83
+ ###### html/template.html.erb
84
+ ```erb
85
+ ---
86
+ layout: default
87
+ ---
88
+
89
+ <% content_for :sidebar %>
90
+ Sidebar
91
+ <% end %>
92
+
93
+ The is the rest of the content
94
+ ```
95
+
96
+ ###### layouts/default.html.erb
97
+ ```erb
98
+ <% yield %>
99
+
100
+ <div class="sidebar">
101
+ <% yield :sidebar %>
102
+ </div>
103
+ ```
104
+
105
+ ###### Result
106
+ ```
107
+ The is the rest of the content
108
+
109
+ <div class="sidebar">
110
+ Sidebar
111
+ </div>
112
+ ```
113
+
76
114
  ## Partials
77
115
 
78
116
  Partials are little pieces of template that can be easily reused. You can access the partials throught the `partial("partialpath")` method. You can optionall pass variables to the partial by passing a ruby hash of options as a second parameter. This works like this:
@@ -87,6 +125,38 @@ In the partial these can be accessed as local variables. So for instance in you
87
125
  <%= key %>
88
126
  ```
89
127
 
128
+ ### Blocks
129
+
130
+ Just like `content_for` partials also accept block syntax. This way you can pass a block of HTML to the partial. It works like this:
131
+
132
+ ```erb
133
+ <% partial "my-partial" do %>
134
+ Pass it to the partial
135
+ <% end %>
136
+ ```
137
+
138
+ Within your partial file you can then use the content by yielding it:
139
+
140
+ ```erb
141
+ <div class="my-partial">
142
+ <% yield %>
143
+ </div>
144
+ ```
145
+
146
+ ## Helpers
147
+ Template helpers allow you to have custom functions in your templates. These functions will be executed in the same context as the template is in. This means they will have access to all other template features like the `document` and `env` variables.
148
+
149
+ A helper is nothing more than a plain old Ruby module containing a bunch of functions.
150
+
151
+ ### Registering helpers
152
+ Registering helpers can best be done in the Rogerfile. For every helper you want to register you need to call:
153
+
154
+ ```ruby
155
+ Roger::Template.register MyHelperModule
156
+ ```
157
+
158
+ After registration the helpers are available for use in all templates, partials, layouts, etc.
159
+
90
160
  ## Access to Project
91
161
 
92
162
  You can access the Roger project with all it's might and glory by accessing `env["roger.project"]`.
@@ -7,7 +7,7 @@ module Roger
7
7
 
8
8
  default_task :all
9
9
 
10
- desc "all", "Run all tests defined in Mockupfile. (this is the default action)"
10
+ desc "all", "Run all tests defined in Rogerfile. (this is the default action)"
11
11
  def all
12
12
  # If we use fail here the test breaks; no idea why
13
13
  # rubocop:disable Style/SignalException:
@@ -13,7 +13,7 @@ class Roger::Generators::GeneratorGenerator < Roger::Generators::Base
13
13
  def create_lib_file
14
14
  destination = "#{path}/#{name}_generator.rb"
15
15
  template("templates/generator.tt", destination)
16
- say "Add `require #{destination}` to your mockup file and run mockup generate #{name}."
16
+ say "Add `require #{destination}` to your Rogerfile and run roger generate #{name}."
17
17
  end
18
18
  end
19
19
 
@@ -1,12 +1,12 @@
1
1
  require "shellwords"
2
2
 
3
- # Generator to create a new HTML mockup based on an existing skeleton
3
+ # Generator to create a new HTML project based on an existing skeleton
4
4
  class Roger::Generators::NewGenerator < Thor::Group
5
5
  include Thor::Actions
6
6
 
7
- desc "Create a new HTML mockup based on an existing skeleton"
7
+ desc "Create a new HTML roger project based on an existing skeleton"
8
8
 
9
- argument :path, type: :string, required: true, desc: "Path to generate mockup into"
9
+ argument :path, type: :string, required: true, desc: "Path to generate project into"
10
10
 
11
11
  class_option(
12
12
  :template,
@@ -29,7 +29,7 @@ class Roger::Generators::NewGenerator < Thor::Group
29
29
  def validate_path_is_empty
30
30
  return unless File.directory?(destination_root)
31
31
 
32
- say "Directory #{destination_root} already exists, please only use this to create new mockups"
32
+ say "Directory #{destination_root} already exists, please only use this to create new projects"
33
33
  exit(1)
34
34
  end
35
35
 
@@ -48,7 +48,7 @@ class Roger::Generators::NewGenerator < Thor::Group
48
48
  puts e.backtrace.join("\n")
49
49
  end
50
50
 
51
- def create_mockup
51
+ def create_project
52
52
  directory(".", ".")
53
53
  end
54
54
 
@@ -71,7 +71,7 @@ class Roger::Generators::NewGenerator < Thor::Group
71
71
 
72
72
  def temp_directory
73
73
  # Hack to create temp directory
74
- t = Tempfile.new("htmlmockup-generate-new")
74
+ t = Tempfile.new("roger-generate-new")
75
75
  tmp_dir = Pathname.new(t.path)
76
76
  t.close
77
77
  t.unlink
data/lib/roger/project.rb CHANGED
@@ -2,20 +2,20 @@ require File.dirname(__FILE__) + "/release"
2
2
  require File.dirname(__FILE__) + "/server"
3
3
  require File.dirname(__FILE__) + "/test"
4
4
 
5
- require File.dirname(__FILE__) + "/mockupfile"
5
+ require File.dirname(__FILE__) + "/rogerfile"
6
6
 
7
7
  module Roger
8
- # Loader for mockupfile and project dependencies
8
+ # Loader for rogerfile and project dependencies
9
9
  class Project
10
10
  # @attr :path [Pathname] The project path
11
- # @attr :html_path [Pathname] The path of the HTML mockup
12
- # @attr :partial_path [Pathname] The path for the partials for this mockup
13
- # @attr :mockupfile [Mockupfile] The Mockupfile for this project
14
- # @attr :mockupfile_path [Pathname] The path to the Mockupfile
11
+ # @attr :html_path [Pathname] The path of the HTML of this project
12
+ # @attr :partial_path [Pathname] The path for the partials for this project
13
+ # @attr :rogerfile [Rogerfile] The Rogerfile for this project
14
+ # @attr :rogerfile_path [Pathname] The path to the Rogerfile
15
15
  # @attr :mode [nil, :test, :server, :release] The mode we're currently in.
16
16
  # If nil, we aren't doing anything.
17
17
  attr_accessor :path, :html_path, :partial_path, :layouts_path,
18
- :mockupfile, :mockupfile_path, :mode
18
+ :rogerfile, :rogerfile_path, :mode
19
19
 
20
20
  attr_accessor :shell
21
21
 
@@ -28,7 +28,7 @@ module Roger
28
28
  html_path: @path + "html",
29
29
  partial_path: @path + "partials",
30
30
  layouts_path: @path + "layouts",
31
- mockupfile_path: @path + "Mockupfile",
31
+ rogerfile_path: @path + "Rogerfile",
32
32
  server: {},
33
33
  release: {},
34
34
  test: {}
@@ -38,7 +38,8 @@ module Roger
38
38
  options.each { |k, v| @options[k.is_a?(String) ? k.to_sym : k] = v }
39
39
 
40
40
  initialize_accessors
41
- initialize_mockup
41
+ intialize_rogerfile_path
42
+ initialize_roger
42
43
  end
43
44
 
44
45
  def shell
@@ -76,21 +77,40 @@ module Roger
76
77
 
77
78
  protected
78
79
 
80
+ def intialize_rogerfile_path
81
+ # We stop immediately if rogerfile is not a Pathname
82
+ unless @options[:rogerfile_path].is_a? Pathname
83
+ self.rogerfile_path = @options[:rogerfile_path]
84
+ return
85
+ end
86
+
87
+ # If roger file exist we're good to go
88
+ if @options[:rogerfile_path].exist?
89
+ self.rogerfile_path = @options[:rogerfile_path]
90
+ else
91
+ # If the rogerfile does not exist we check for deprecated Mockupfile
92
+ mockupfile_path = path + "Mockupfile"
93
+ if mockupfile_path.exist?
94
+ warn("Mockupfile has been deprecated! Please rename Mockupfile to Rogerfile")
95
+ self.rogerfile_path = mockupfile_path
96
+ end
97
+ end
98
+ end
99
+
79
100
  def initialize_accessors
80
101
  self.html_path = @options[:html_path]
81
102
  self.partial_path =
82
103
  @options[:partials_path] || @options[:partial_path] || html_path + "../partials/"
83
104
  self.layouts_path = @options[:layouts_path]
84
- self.mockupfile_path = @options[:mockupfile_path]
85
105
  self.shell = @options[:shell]
86
106
  end
87
107
 
88
- def initialize_mockup
89
- if mockupfile_path
90
- @mockupfile = Mockupfile.new(self, mockupfile_path)
91
- @mockupfile.load
108
+ def initialize_roger
109
+ if rogerfile_path
110
+ @rogerfile = Rogerfile.new(self, rogerfile_path)
111
+ @rogerfile.load
92
112
  else
93
- @mockupfile = Mockupfile.new(self)
113
+ @rogerfile = Rogerfile.new(self)
94
114
  end
95
115
  end
96
116
 
@@ -22,7 +22,7 @@ module Roger::Release::Finalizers
22
22
 
23
23
  def call(release, options = {})
24
24
  @options = @options.dup.update(options)
25
- remote = find_git_remote
25
+ remote = find_git_remote(release.project.path)
26
26
  branch = @options[:branch]
27
27
 
28
28
  tmp_dir = Pathname.new(::Dir.mktmpdir)
@@ -126,10 +126,10 @@ module Roger::Release::Finalizers
126
126
  path
127
127
  end
128
128
 
129
- def find_git_remote
129
+ def find_git_remote(path)
130
130
  remote =
131
131
  @options[:remote] ||
132
- `git --git-dir=#{find_git_dir} config --get remote.origin.url`
132
+ `git --git-dir=#{Shellwords.escape(find_git_dir(path).to_s)} config --get remote.origin.url`
133
133
 
134
134
  remote.strip!
135
135
 
@@ -2,7 +2,7 @@ require "shellwords"
2
2
  require "English"
3
3
 
4
4
  module Roger::Release::Finalizers
5
- # Finalizes the release by uploading your mockup with rsync to a remote server
5
+ # Finalizes the release by uploading your project with rsync to a remote server
6
6
  #
7
7
  # @see RsyncFinalizer#initialize for options
8
8
  #
@@ -52,7 +52,7 @@ module Roger::Release::Processors
52
52
  end
53
53
  end
54
54
 
55
- # Runs the extractor on a single file and return processed source.
55
+ # Runs the template on a single file and return processed source.
56
56
  def extract_source_from_file(file_path, env = {})
57
57
  Roger::Template.open(
58
58
  file_path,
@@ -1,3 +1,4 @@
1
+ require "hpricot"
1
2
  require File.dirname(__FILE__) + "../../../resolver"
2
3
 
3
4
  module Roger::Release::Processors
data/lib/roger/release.rb CHANGED
@@ -72,9 +72,9 @@ module Roger
72
72
  end
73
73
 
74
74
  # Accessor for source_path
75
- # The source path is the root of the mockup
75
+ # The source path is the root of the project
76
76
  #
77
- # @return Pathanem the source_path
77
+ # @return Pathname the source_path
78
78
  def source_path
79
79
  Pathname.new(config[:source_path])
80
80
  end
@@ -166,18 +166,6 @@ module Roger
166
166
  end
167
167
  end
168
168
 
169
- # Extract the mockup, this will happen anyway, and will always happen first
170
- # This method gives you a way to pass options to the extractor.
171
- #
172
- # @param Hash options Options hash passed to extractor
173
- #
174
- # @deprecated Don't use the extractor anymore, use release.use(:mockup, options) processor
175
- def extract(options = {})
176
- warn(self, "Don't use the extractor anymore, use release.use(:mockup, options)
177
- and release.use(:url_relativizer, options) processors")
178
- @extractor_options = options
179
- end
180
-
181
169
  # Actually perform the release
182
170
  def run!
183
171
  project.mode = :release
@@ -202,6 +190,33 @@ module Roger
202
190
  project.mode = nil
203
191
  end
204
192
 
193
+ # @param [String] string The string to comment
194
+ #
195
+ # @option options [:html, :css, :js] :style The comment style to use
196
+ # (default=:js, which is the same as :css)
197
+ # @option options [Boolean] :per_line Comment per line or make one block? (default=true)
198
+ def comment(string, options = {})
199
+ options = {
200
+ style: :css,
201
+ per_line: true
202
+ }.update(options)
203
+
204
+ commenters = {
205
+ html: proc { |s| "<!-- #{s} -->" },
206
+ css: proc { |s| "/* #{s} */" },
207
+ js: proc { |s| "/* #{s} */" }
208
+ }
209
+
210
+ commenter = commenters[options[:style]] || commenters[:js]
211
+
212
+ if options[:per_line]
213
+ string = string.split(/\r?\n/)
214
+ string.map { |s| commenter.call(s) }.join("\n")
215
+ else
216
+ commenter.call(string)
217
+ end
218
+ end
219
+
205
220
  protected
206
221
 
207
222
  def get_files_default_path
@@ -243,8 +258,7 @@ module Roger
243
258
  end
244
259
  end
245
260
 
246
- # Checks if deprecated extractor options have been set
247
- # Checks if the mockup will be runned
261
+ # Checks if the project will be runned
248
262
  # If config[:blank] is true it will automatically add UrlRelativizer or Mockup processor
249
263
  def validate_stack!
250
264
  return if config[:blank]
@@ -252,11 +266,6 @@ module Roger
252
266
  mockup_options = {}
253
267
  relativizer_options = {}
254
268
 
255
- if @extractor_options
256
- mockup_options = { env: @extractor_options[:env] }
257
- relativizer_options = { url_attributes: @extractor_options[:url_attributes] }
258
- end
259
-
260
269
  unless find_in_stack(Roger::Release::Processors::Mockup)
261
270
  @stack.unshift([Roger::Release::Processors::Mockup.new, mockup_options])
262
271
  end
@@ -273,10 +282,11 @@ module Roger
273
282
  end
274
283
 
275
284
  def copy_source_path_to_build_path!
285
+ mkdir(build_path)
286
+
276
287
  if config[:cp]
277
288
  copy_source_path_to_build_path_using_system
278
289
  else
279
- mkdir(build_path)
280
290
  cp_r(source_path.children, build_path)
281
291
  end
282
292
  end
@@ -316,37 +326,9 @@ module Roger
316
326
  log(self, "Cleaning up build path #{build_path}")
317
327
  rm_rf(build_path)
318
328
  end
319
-
320
- # @param [String] string The string to comment
321
- #
322
- # @option options [:html, :css, :js] :style The comment style to use
323
- # (default=:js, which is the same as :css)
324
- # @option options [Boolean] :per_line Comment per line or make one block? (default=true)
325
- def comment(string, options = {})
326
- options = {
327
- style: :css,
328
- per_line: true
329
- }.update(options)
330
-
331
- commenters = {
332
- html: proc { |s| "<!-- #{s} -->" },
333
- css: proc { |s| "/*! #{s} */" },
334
- js: proc { |s| "/*! #{s} */" }
335
- }
336
-
337
- commenter = commenters[options[:style]] || commenters[:js]
338
-
339
- if options[:per_line]
340
- string = string.split(/\r?\n/)
341
- string.map { |s| commenter.call(s) }.join("\n")
342
- else
343
- commenter.call(s)
344
- end
345
- end
346
329
  end
347
330
  end
348
331
 
349
- require File.dirname(__FILE__) + "/extractor"
350
332
  require File.dirname(__FILE__) + "/release/scm"
351
333
  require File.dirname(__FILE__) + "/release/injector"
352
334
  require File.dirname(__FILE__) + "/release/cleaner"
@@ -1,15 +1,22 @@
1
1
  module Roger
2
- # Loader for mockupfile
3
- class Mockupfile
4
- # This is the context for the mockupfile evaluation. It should be empty except for the
5
- # #mockup method.
2
+ # Loader for rogerfile
3
+ class Rogerfile
4
+ # This is the context for the rogerfile evaluation. It should be empty except for the
5
+ # #roger method (and deprecated #mockup method).
6
6
  class Context
7
- def initialize(mockupfile)
8
- @_mockupfile = mockupfile
7
+ def initialize(rogerfile)
8
+ @_rogerfile = rogerfile
9
9
  end
10
10
 
11
+ def roger
12
+ @_rogerfile
13
+ end
14
+
15
+ # @deprecated Please use roger method instead.
11
16
  def mockup
12
- @_mockupfile
17
+ warn("The use of mockup has been deprecated; please use roger instead")
18
+ warn(" on #{caller.first}")
19
+ roger
13
20
  end
14
21
 
15
22
  def binding
@@ -17,15 +24,15 @@ module Roger
17
24
  end
18
25
  end
19
26
 
20
- # @attr :path [Pathname] The path of the Mockupfile for this project
27
+ # @attr :path [Pathname] The path of the rogerfile for this project
21
28
  attr_accessor :path, :project
22
29
 
23
30
  def initialize(project, path = nil)
24
31
  @project = project
25
- @path = (path && Pathname.new(path)) || Pathname.new(project.path + "Mockupfile")
32
+ @path = (path && Pathname.new(path)) || Pathname.new(project.path + "Rogerfile")
26
33
  end
27
34
 
28
- # Actually load the mockupfile
35
+ # Actually load the rogerfile
29
36
  def load
30
37
  return unless File.exist?(@path) && !self.loaded?
31
38
 
@@ -35,7 +42,7 @@ module Roger
35
42
  @loaded = true
36
43
  end
37
44
 
38
- # Wether or not the Mockupfile has been loaded
45
+ # Wether or not the rogerfile has been loaded
39
46
  def loaded?
40
47
  @loaded
41
48
  end