middleman-build-info 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +4 -0
- data/LICENSE.md +22 -0
- data/README.md +53 -0
- data/lib/middleman-build-info.rb +7 -0
- data/lib/middleman-build-info/extension.rb +27 -0
- data/lib/middleman-build-info/monkey.rb +5 -0
- data/lib/middleman-build-info/updater.rb +66 -0
- data/lib/middleman-build-info/version.rb +5 -0
- data/lib/middleman_extension.rb +1 -0
- data/middleman-build-info.gemspec +22 -0
- data/middleman-build-info.png +0 -0
- metadata +71 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 54f8f1bc504aeda5b8adb6a5e35f9e79f7bce90e
|
4
|
+
data.tar.gz: ff95c2e46a6709e966ece79c6da8a13194c63d9d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 92656c17807b835913650bff48e62d04a64b606223bec213cb56507971c1525dd0d785ce306532bef6d87bce334ea72b247e7ed7ee793c6de884ed9f3c0a97a4
|
7
|
+
data.tar.gz: e272dd34a2047424c676ed567925eea8887b6c8b57b65715c6e05e1559283f397d5b80b9aa89d9d9372b78aa04170455581a72ef28979fea408621bafa572b3e
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Mariano Cavallo
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Middleman Build Info
|
2
|
+
|
3
|
+
`middleman-build-info` is an extension for the [Middleman] static site generator that mantains an incremental build number and date on a JSON file inside your project.
|
4
|
+
|
5
|
+
Once the extension is activated It will run and update the build file every time you build your project.
|
6
|
+
|
7
|
+
![IMAGE]
|
8
|
+
|
9
|
+
## Dependencies
|
10
|
+
|
11
|
+
* middleman-core (3.3+)
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
Add to your `Gemfile` and then run `bundle install`:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem "middleman-build-info", :git => 'https://github.com/mcavallo/middleman-build-info.git'
|
18
|
+
```
|
19
|
+
|
20
|
+
Then activate the extension in your `config.rb` file:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
activate :build_info
|
24
|
+
```
|
25
|
+
|
26
|
+
## Configuration
|
27
|
+
|
28
|
+
There are a couple of settings you can override from your `config.rb` file:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
activate :build_info do |option|
|
32
|
+
# Name of the build info file (default: 'build.json')
|
33
|
+
option.filename = 'build.json'
|
34
|
+
|
35
|
+
# Relative path to build file from MM root (default: '')
|
36
|
+
option.relative_path = ''
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
## Upcoming Features
|
41
|
+
|
42
|
+
I'm thinking about adding some Git information to the file as well like last commit hash, branch and committer at the time of the build. But I'm open to suggestions and pull requests.
|
43
|
+
|
44
|
+
[CHANGELOG]
|
45
|
+
|
46
|
+
## License
|
47
|
+
|
48
|
+
Copyright (c) 2014 Mariano Cavallo. MIT Licensed, see [LICENSE] for details.
|
49
|
+
|
50
|
+
[middleman]: http://middlemanapp.com
|
51
|
+
[IMAGE]: https://raw.githubusercontent.com/mcavallo/middleman-build-info/master/middleman-build-info.png
|
52
|
+
[CHANGELOG]: https://github.com/mcavallo/middleman-build-info/blob/master/CHANGELOG.md
|
53
|
+
[LICENSE]: https://github.com/mcavallo/middleman-build-info/blob/master/LICENSE.md
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'middleman-build-info/updater'
|
2
|
+
|
3
|
+
module Middleman
|
4
|
+
class BuildInfoExtension < Extension
|
5
|
+
|
6
|
+
option :filename, 'build.json', 'Build filename.'
|
7
|
+
option :relative_path, 'source', 'Relative path to build file from MM root.'
|
8
|
+
option :debug, true, ''
|
9
|
+
|
10
|
+
def initialize(app, options_hash={}, &block)
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def after_configuration
|
15
|
+
@updater = BuildInfo::Updater.new(@app, options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def before_build(builder)
|
19
|
+
@updater.update_build_info(builder)
|
20
|
+
end
|
21
|
+
|
22
|
+
def after_build
|
23
|
+
@updater.wrap_up
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'middleman-build-info/monkey'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module Middleman
|
5
|
+
module BuildInfo
|
6
|
+
class Updater
|
7
|
+
|
8
|
+
def initialize(app, options)
|
9
|
+
@app = app
|
10
|
+
@options = options
|
11
|
+
@file = File.join(@app.root_path, @options[:relative_path], @options[:filename])
|
12
|
+
@file_relative = File.join(@options[:relative_path], @options[:filename]).without_leading_slash
|
13
|
+
end
|
14
|
+
|
15
|
+
def update_build_info(builder)
|
16
|
+
@builder = builder
|
17
|
+
@backup = read_info_file
|
18
|
+
@new_info = get_updated_info(@backup)
|
19
|
+
write_info_file(@new_info) do
|
20
|
+
@builder.say_status('update', @file_relative, :yellow)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def wrap_up
|
25
|
+
return print_build_info(@new_info) unless @builder.had_errors
|
26
|
+
write_info_file(@backup) do
|
27
|
+
@builder.say_status('rollback', @file_relative, :yellow)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def write_info_file(info, &block)
|
34
|
+
json = "// Hands off!\n" + JSON.pretty_generate(info)
|
35
|
+
File.open(@file, "w") { |f| f.write(json) }
|
36
|
+
yield block
|
37
|
+
rescue
|
38
|
+
@builder.say_status('failed', @file_relative, :red)
|
39
|
+
end
|
40
|
+
|
41
|
+
def read_info_file
|
42
|
+
JSON.parse(File.read(@file))
|
43
|
+
rescue Errno::ENOENT, JSON::ParserError
|
44
|
+
default_template
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_updated_info(info)
|
48
|
+
info["number"] = info["number"].to_i + 1
|
49
|
+
info["date"] = Time.now.utc.to_s
|
50
|
+
info
|
51
|
+
end
|
52
|
+
|
53
|
+
def default_template
|
54
|
+
{ number: 0, date: '' }
|
55
|
+
end
|
56
|
+
|
57
|
+
def print_build_info(info)
|
58
|
+
@builder.say("\n Build Info:")
|
59
|
+
info.each_pair do |name, value|
|
60
|
+
@builder.say_status(name, value, :green)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "middleman-build-info.rb"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require 'middleman-build-info/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "middleman-build-info"
|
7
|
+
s.version = Middleman::BuildInfo::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Mariano Cavallo"]
|
10
|
+
s.email = ["mariano.cavallo@gmail.com"]
|
11
|
+
s.homepage = "https://github.com/mcavallo/middleman-build-info"
|
12
|
+
s.summary = %q{Incremental build information for Middleman}
|
13
|
+
s.description = %q{Incremental build information for Middleman}
|
14
|
+
s.license = "MIT"
|
15
|
+
|
16
|
+
s.rubyforge_project = "middleman-build-info"
|
17
|
+
s.files = `git ls-files -z`.split("\0")
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
s.required_ruby_version = '>= 1.9.3'
|
20
|
+
|
21
|
+
s.add_dependency("middleman-core", ["~> 3.3"])
|
22
|
+
end
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-build-info
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mariano Cavallo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: middleman-core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.3'
|
27
|
+
description: Incremental build information for Middleman
|
28
|
+
email:
|
29
|
+
- mariano.cavallo@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- CHANGELOG.md
|
36
|
+
- Gemfile
|
37
|
+
- LICENSE.md
|
38
|
+
- README.md
|
39
|
+
- lib/middleman-build-info.rb
|
40
|
+
- lib/middleman-build-info/extension.rb
|
41
|
+
- lib/middleman-build-info/monkey.rb
|
42
|
+
- lib/middleman-build-info/updater.rb
|
43
|
+
- lib/middleman-build-info/version.rb
|
44
|
+
- lib/middleman_extension.rb
|
45
|
+
- middleman-build-info.gemspec
|
46
|
+
- middleman-build-info.png
|
47
|
+
homepage: https://github.com/mcavallo/middleman-build-info
|
48
|
+
licenses:
|
49
|
+
- MIT
|
50
|
+
metadata: {}
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.9.3
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project: middleman-build-info
|
67
|
+
rubygems_version: 2.1.11
|
68
|
+
signing_key:
|
69
|
+
specification_version: 4
|
70
|
+
summary: Incremental build information for Middleman
|
71
|
+
test_files: []
|