middleman-pipeline 3.0.0.rc.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ Gemfile.lock
3
+ tmp
4
+ .rbenv-*
5
+ .sass-cache
6
+ .pipeline-tmp
@@ -0,0 +1,10 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - jruby-18mode
6
+ - jruby-19mode
7
+
8
+ script: "bundle exec rake test"
9
+
10
+ env: TEST=true
data/Gemfile ADDED
@@ -0,0 +1,23 @@
1
+ source :rubygems
2
+
3
+ git "git://github.com/middleman/middleman.git" do
4
+ # gem "middleman"
5
+ gem "middleman-core"
6
+ gem "middleman-more"
7
+ end
8
+
9
+ # Specify your gem's dependencies in middleman-blog.gemspec
10
+ gemspec
11
+
12
+ group :development do
13
+ gem "rake", "~> 0.9.2"
14
+ gem "rdoc", "~> 3.9"
15
+ gem "yard", "~> 0.8.0"
16
+ end
17
+
18
+ group :test do
19
+ gem "cucumber", "~> 1.2.0"
20
+ gem "fivemat"
21
+ gem "aruba", "~> 0.4.11"
22
+ gem "rspec", "~> 2.7"
23
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Thomas Reynolds
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,49 @@
1
+ # middleman-pipeline
2
+
3
+ # Install
4
+
5
+ ```
6
+ gem install middleman-pipeline
7
+ ```
8
+
9
+ If you already have a Middleman project:
10
+ Add `middleman-pipeline` to your `Gemfile`, and open your `config.rb` and add:
11
+
12
+ ```
13
+ activate :pipeline
14
+ ```
15
+
16
+ # Community
17
+
18
+ The official community forum is available at:
19
+
20
+ http://forum.middlemanapp.com/
21
+
22
+ # Bug Reports
23
+
24
+ GitHub Issues are used for managing bug reports and feature requests. If you run into issues, please search the issues and submit new problems:
25
+
26
+ https://github.com/middleman/middleman-pipeline/issues
27
+
28
+ The best way to get quick responses to your issues and swift fixes to your bugs is to submit detailed bug reports, include test cases and respond to developer questions in a timely manner. Even better, if you know Ruby, you can submit Pull Requests containing Cucumber Features which describe how your feature should work or exploit the bug you are submitting.
29
+
30
+ # Build & Dependency Status
31
+
32
+ [![Build Status](http://travis-ci.org/middleman/middleman-pipeline.png)](http://travis-ci.org/middleman/middleman-pipeline)
33
+
34
+ # How to Run Cucumber Tests
35
+
36
+ 1. Checkout Repository: `git clone https://github.com/middleman/middleman-pipeline.git`
37
+ 2. Install Bundler: `gem install bundler`
38
+ 3. Run `bundle install` inside the project root to install the gem dependencies.
39
+ 4. Run test cases: `bundle exec rake test`
40
+
41
+ # Donate
42
+
43
+ [![Click here to lend your support to Middleman](https://www.pledgie.com/campaigns/15807.png)](http://www.pledgie.com/campaigns/15807)
44
+
45
+ # License
46
+
47
+ Copyright (c) 2012 Thomas Reynolds. MIT Licensed, see [LICENSE] for details.
48
+
49
+ [LICENSE]: https://github.com/middleman/middleman-pipeline/blob/master/LICENSE
@@ -0,0 +1,18 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'cucumber/rake/task'
5
+
6
+ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
7
+ ENV["TEST"] = "true"
8
+ t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
9
+ end
10
+
11
+ require 'rake/clean'
12
+
13
+ task :test => ["cucumber"]
14
+
15
+ desc "Build HTML documentation"
16
+ task :doc do
17
+ sh 'bundle exec yard'
18
+ end
@@ -0,0 +1,10 @@
1
+ Feature: Middleman Create Assetfile CLI
2
+
3
+ Scenario: Create a new Assetfile
4
+ Given I run `middleman init MY_PROJECT`
5
+ Then the exit status should be 0
6
+ When I cd to "MY_PROJECT"
7
+ And I run `middleman assetfile`
8
+ Then the exit status should be 0
9
+ Then the following files should exist:
10
+ | Assetfile |
@@ -0,0 +1,22 @@
1
+ Feature: Pipeline
2
+
3
+ Scenario: Base Server
4
+ Given the Server is running at "pipeline-app"
5
+ When I go to "/assets/one_and_two.js"
6
+ Then I should see "file1"
7
+ And I should see "file2"
8
+ When I go to "/assets/cstest.js"
9
+ Then I should see "typeof"
10
+
11
+ Scenario: Base Build
12
+ Given a successfully built app at "pipeline-app"
13
+ When I cd to "build"
14
+ Then the following files should exist:
15
+ | assets/one_and_two.js |
16
+ | assets/cstest.js |
17
+ Then the following files should not exist:
18
+ | assets/one_and_two/file1.js |
19
+ | assets/one_and_two/file2.js |
20
+ | assets/cstest.js.coffee |
21
+ And the file "assets/one_and_two.js" should contain "file1"
22
+ And the file "assets/cstest.js" should contain "typeof"
@@ -0,0 +1,4 @@
1
+ PROJECT_ROOT_PATH = File.dirname(File.dirname(File.dirname(__FILE__)))
2
+ require "middleman-core"
3
+ require "middleman-core/step_definitions"
4
+ require File.join(PROJECT_ROOT_PATH, 'lib', 'middleman-pipeline')
@@ -0,0 +1,8 @@
1
+ # Do not include "input" or "output" directives
2
+
3
+ # Run Middleman on files first
4
+ filter ::Middleman::Pipeline::Filter
5
+
6
+ match "one_and_two/*.js" do
7
+ filter Rake::Pipeline::ConcatFilter, "one_and_two.js"
8
+ end
@@ -0,0 +1,2 @@
1
+ require "middleman-pipeline"
2
+ activate :pipeline
@@ -0,0 +1 @@
1
+ function file1() {}
@@ -0,0 +1 @@
1
+ function file2() {}
@@ -0,0 +1,8 @@
1
+ require "middleman-core"
2
+ require "middleman-more"
3
+ require "middleman-pipeline/template"
4
+
5
+ Middleman::Extensions.register(:pipeline) do
6
+ require "middleman-pipeline/extension"
7
+ Middleman::Pipeline
8
+ end
@@ -0,0 +1,175 @@
1
+ require "rake-pipeline"
2
+ require "rake-pipeline/middleware"
3
+ require "rake-pipeline-web-filters"
4
+
5
+ # Rake::Pipeline extension
6
+ module Middleman::Pipeline
7
+
8
+ # Setup extension
9
+ class << self
10
+
11
+ # Once registered
12
+ def registered(app, options={})
13
+ app.after_configuration do
14
+ ::Middleman::Sitemap::Resource.send :include, ResourceInstanceMethods
15
+
16
+ asset_file = options[:Assetfile] || File.expand_path("Assetfile", root)
17
+ input_path = options[:input] || "assets"
18
+
19
+ # Pass along details to filter
20
+ ::Middleman::Pipeline::Filter.instance = self
21
+ ::Middleman::Pipeline::Filter.input_path = input_path
22
+
23
+ if asset_file.is_a?(String)
24
+ begin
25
+ pipeline_source = File.read(asset_file)
26
+
27
+ if pipeline_source =~ /^input/
28
+ puts "== Warning: Do not include 'input' directive in Assetfile"
29
+ end
30
+
31
+ if pipeline_source =~ /^output/
32
+ puts "== Warning: Do not include 'output' directive in Assetfile"
33
+ end
34
+
35
+ full_input_path = File.expand_path(input_path, source_dir)
36
+ full_output_path = File.expand_path(".pipeline-tmp", root)
37
+
38
+ final_asset_source = <<END
39
+ build do
40
+ input "#{full_input_path}"
41
+ output "#{full_output_path}"
42
+
43
+ #{pipeline_source}
44
+ end
45
+ END
46
+ rescue
47
+ puts "== Error: Could not read Assetfile (#{asset_file})"
48
+ end
49
+
50
+ if final_asset_source
51
+ pipeline = ::Rake::Pipeline.class_eval final_asset_source, asset_file, 1
52
+ end
53
+ else
54
+ pipeline = asset_file
55
+ end
56
+
57
+ if pipeline
58
+ sitemap.register_resource_list_manipulator(
59
+ :pipeline,
60
+ PipelineManager.new(self, pipeline, input_path),
61
+ false
62
+ )
63
+
64
+ map("/#{input_path}") { run ::Rake::Pipeline::Middleware.new(self, pipeline) }
65
+
66
+ end
67
+ end
68
+ end
69
+
70
+ alias :included :registered
71
+ end
72
+
73
+ module ResourceInstanceMethods
74
+
75
+ def pipeline_ignored?
76
+ @_pipeline_ignored || false
77
+ end
78
+
79
+ def pipeline_ignored=(v)
80
+ @_pipeline_ignored = v
81
+ end
82
+
83
+ def ignored?
84
+ if pipeline_ignored?
85
+ true
86
+ else
87
+ super
88
+ end
89
+ end
90
+ end
91
+
92
+ class PipelineManager
93
+ def initialize(app, pipeline, input_path)
94
+ @app = app
95
+ @pipeline = pipeline
96
+ @input_path = input_path
97
+ end
98
+
99
+ # Update the main sitemap resource list
100
+ # @return [void]
101
+ def manipulate_resource_list(resources)
102
+ @pipeline.invoke_clean
103
+
104
+ resources.each do |r|
105
+ if r.path =~ %r{^#{@input_path}}
106
+ r.pipeline_ignored = true
107
+ end
108
+ end
109
+
110
+ resources + @pipeline.output_files.map do |file|
111
+ path = File.join(@input_path, file.path)
112
+ ::Middleman::Sitemap::Resource.new(
113
+ @app.sitemap,
114
+ path,
115
+ File.expand_path(path, @app.source_dir)
116
+ )
117
+ end
118
+ end
119
+ end
120
+
121
+ class Filter < ::Rake::Pipeline::Filter
122
+ class << self
123
+ attr_accessor :instance
124
+ attr_accessor :input_path
125
+ end
126
+
127
+ def initialize
128
+ @app = self.class.instance
129
+ @input_path = self.class.input_path
130
+
131
+ @resource_for_path = {}
132
+
133
+ block = proc do |input|
134
+ resource = resource_for_path(input)
135
+
136
+ if resource.template?
137
+ extensionless = @app.sitemap.extensionless_path(input)
138
+ @resource_for_path[extensionless] = resource
139
+ extensionless
140
+ else
141
+ input
142
+ end
143
+ end
144
+
145
+ super(&block)
146
+ end
147
+
148
+ def resource_for_path(path)
149
+ @resource_for_path[path] ||= begin
150
+ full_path = File.join(@input_path, path)
151
+
152
+ ::Middleman::Sitemap::Resource.new(
153
+ @app.sitemap,
154
+ @app.sitemap.file_to_path(full_path),
155
+ File.expand_path(full_path, @app.source_dir)
156
+ )
157
+ end
158
+ end
159
+
160
+ def generate_output(inputs, output)
161
+ inputs.each do |input|
162
+ resource = resource_for_path(input.path)
163
+
164
+ out = if resource.template?
165
+ resource.render
166
+ else
167
+ input.read
168
+ end
169
+
170
+ output.write out
171
+ end
172
+ end
173
+ end
174
+
175
+ end
@@ -0,0 +1,25 @@
1
+ require "middleman-core/cli"
2
+
3
+ module Middleman
4
+ module Pipeline
5
+
6
+ # A template that generates a blog-specific config.rb
7
+ # and a set of example templates for index, layout, tags, and calendar.
8
+ class Assetfile < ::Thor
9
+ include Thor::Actions
10
+ check_unknown_options!
11
+
12
+ namespace :assetfile
13
+
14
+ def self.source_root
15
+ File.join(File.dirname(__FILE__), 'template')
16
+ end
17
+
18
+ desc "assetfile", "Create an Assetfile for Rake::Pipeline"
19
+
20
+ def assetfile
21
+ template "Assetfile.tt", File.join(ENV["MM_ROOT"], "Assetfile")
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,31 @@
1
+ # Do not include "input" or "output" directives,
2
+ # Middleman will set these internally
3
+
4
+ # Run Middleman on files first (optional)
5
+ filter ::Middleman::Pipeline::Filter
6
+
7
+ # View more Rake::Pipline docs online:
8
+ # http://rubydoc.info/github/livingsocial/rake-pipeline
9
+
10
+ # this block will take all JS inputs, wrap them in a closure,
11
+ # add some additional metadata, and concatenate them all into
12
+ # application.scripts.js.
13
+ # match "*.js" do
14
+ # filter ClosureWrapper
15
+ # filter DataWrapper
16
+ # filter Rake::Pipeline::ConcatFilter, "application.scripts.js"
17
+ # end
18
+
19
+ # this block will take all HTML and CSS inputs, convert them
20
+ # into JavaScript
21
+ # match "*/*.{html,css}" do
22
+ # filter DataWrapper
23
+ # filter Rake::Pipeline::ConcatFilter, "application.assets.js"
24
+ # end
25
+
26
+ # match "*.js" do
27
+ # filter Rake::Pipeline::ConcatFilter, "application.js"
28
+ # end
29
+
30
+ # copy any unprocessed files over to the output directory
31
+ # filter Rake::Pipeline::ConcatFilter
@@ -0,0 +1,5 @@
1
+ module Middleman
2
+ module Pipeline
3
+ VERSION = "3.0.0.rc.2"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require "middleman-pipeline"
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "middleman-pipeline/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "middleman-pipeline"
7
+ s.version = Middleman::Pipeline::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Thomas Reynolds"]
10
+ s.email = ["me@tdreyno.com"]
11
+ s.homepage = "https://github.com/middleman/middleman-pipeline"
12
+ s.summary = %q{Rake::Pipeline support for Middleman}
13
+ s.description = %q{Rake::Pipeline support for Middleman}
14
+
15
+ s.rubyforge_project = "middleman-pipeline"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ # s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency("middleman-more", Middleman::Pipeline::VERSION)
23
+ s.add_dependency("rake-pipeline")
24
+ s.add_dependency("rake-pipeline-web-filters")
25
+ end
metadata ADDED
@@ -0,0 +1,122 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: middleman-pipeline
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.0.rc.2
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Thomas Reynolds
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: middleman-more
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.0.rc.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.0.rc.2
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake-pipeline
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake-pipeline-web-filters
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Rake::Pipeline support for Middleman
63
+ email:
64
+ - me@tdreyno.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - .travis.yml
71
+ - Gemfile
72
+ - LICENSE
73
+ - README.md
74
+ - Rakefile
75
+ - features/cli.feature
76
+ - features/pipeline.feature
77
+ - features/support/env.rb
78
+ - fixtures/pipeline-app/Assetfile
79
+ - fixtures/pipeline-app/config.rb
80
+ - fixtures/pipeline-app/source/assets/cstest.js.coffee
81
+ - fixtures/pipeline-app/source/assets/one_and_two/file1.js
82
+ - fixtures/pipeline-app/source/assets/one_and_two/file2.js
83
+ - fixtures/pipeline-app/source/index.html.erb
84
+ - lib/middleman-pipeline.rb
85
+ - lib/middleman-pipeline/extension.rb
86
+ - lib/middleman-pipeline/template.rb
87
+ - lib/middleman-pipeline/template/Assetfile.tt
88
+ - lib/middleman-pipeline/version.rb
89
+ - lib/middleman_extension.rb
90
+ - middleman-pipeline.gemspec
91
+ homepage: https://github.com/middleman/middleman-pipeline
92
+ licenses: []
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ segments:
104
+ - 0
105
+ hash: 3257995787160982128
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>'
110
+ - !ruby/object:Gem::Version
111
+ version: 1.3.1
112
+ requirements: []
113
+ rubyforge_project: middleman-pipeline
114
+ rubygems_version: 1.8.23
115
+ signing_key:
116
+ specification_version: 3
117
+ summary: Rake::Pipeline support for Middleman
118
+ test_files:
119
+ - features/cli.feature
120
+ - features/pipeline.feature
121
+ - features/support/env.rb
122
+ has_rdoc: