middleman-build-info 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +19 -4
- data/lib/middleman-build-info/updater.rb +18 -2
- data/lib/middleman-build-info/version.rb +1 -1
- metadata +8 -9
- data/lib/middleman-build-info/monkey.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ce843c4bbe2b0f41077fc376dc5108a8f08e25e
|
4
|
+
data.tar.gz: 0265c5496f66fe3b821a745be5c728291c9ce585
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6eda5f6b40a8d19f881ac4ee20fbc0d24ccd9bfa3f7778a552dbd9f45f8ef0291d530f80d1f325fc6be4a22f38d50187a0dd1842779bd2c5efb898e7ae547a47
|
7
|
+
data.tar.gz: 3410f3995ab6344925a8da534feacbe3e0500af015621f7f51079951298a7dbf4d1e9228c46cf4dc20a260878949028e66ebcd9196b786550d078454e69330c5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -32,13 +32,28 @@ There are a couple of settings you can override from your `config.rb` file:
|
|
32
32
|
```ruby
|
33
33
|
activate :build_info do |option|
|
34
34
|
# Name of the build info file (default: 'build.json')
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
option.filename = 'build.json'
|
36
|
+
|
37
|
+
# Relative path to build file from MM root (default: '')
|
38
|
+
option.relative_path = ''
|
39
|
+
|
40
|
+
# Print build info after a successful build (default: true)
|
41
|
+
option.display_info_after_build = true
|
39
42
|
end
|
40
43
|
```
|
41
44
|
|
45
|
+
## Helper
|
46
|
+
|
47
|
+
The `build_info` helper is available to use in your views. You can pass a key to retrieve a single value or without parameters to retrieve the full hash.
|
48
|
+
|
49
|
+
```erb
|
50
|
+
<p class="build-number"><%= build_info(:number) %></p>
|
51
|
+
```
|
52
|
+
|
53
|
+
It's worth mentioning that:
|
54
|
+
* During **development** this helper will return the information about the current build.
|
55
|
+
* During the **build** process it will return the information about the new build instead.
|
56
|
+
|
42
57
|
## Upcoming Features
|
43
58
|
|
44
59
|
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.
|
@@ -1,15 +1,19 @@
|
|
1
|
-
require '
|
1
|
+
require 'active_support/core_ext/hash/keys'
|
2
|
+
require 'active_support/core_ext/string/inflections'
|
2
3
|
require 'json'
|
3
4
|
|
4
5
|
module Middleman
|
5
6
|
module BuildInfo
|
6
7
|
class Updater
|
7
8
|
|
9
|
+
include Padrino::Helpers::FormatHelpers
|
10
|
+
|
8
11
|
def initialize(app, options)
|
12
|
+
@start_time = Time.now
|
9
13
|
@app = app
|
10
14
|
@options = options
|
11
15
|
@file = File.join(@app.root_path, @options[:relative_path], @options[:filename])
|
12
|
-
@file_relative = File.join(@options[:relative_path], @options[:filename]).
|
16
|
+
@file_relative = File.join(@options[:relative_path], @options[:filename]).gsub(/^\//,'')
|
13
17
|
|
14
18
|
@backup = read_info_file
|
15
19
|
app.set :build_info, @backup
|
@@ -56,12 +60,24 @@ module Middleman
|
|
56
60
|
{ number: 0, date: '' }
|
57
61
|
end
|
58
62
|
|
63
|
+
def elapsed_time
|
64
|
+
diff = ((Time.now - @start_time) * 1000).ceil
|
65
|
+
ss, ms = diff.divmod(1000)
|
66
|
+
mm, ss = ss.divmod(60)
|
67
|
+
time = []
|
68
|
+
time << pluralize(mm, "minute") unless mm.zero?
|
69
|
+
time << pluralize(ss, "second") unless ss.zero?
|
70
|
+
time << pluralize(ms, "millisecond") if time.empty? or not ms.zero?
|
71
|
+
time.join(', ')
|
72
|
+
end
|
73
|
+
|
59
74
|
def print_build_info(info)
|
60
75
|
return unless @options[:display_info_after_build]
|
61
76
|
@builder.say("\n Build Info:")
|
62
77
|
info.each_pair do |name, value|
|
63
78
|
@builder.say_status(name.to_s, value, :green)
|
64
79
|
end
|
80
|
+
@builder.say("\n Build finished in #{elapsed_time}.")
|
65
81
|
end
|
66
82
|
|
67
83
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-build-info
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mariano Cavallo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.3'
|
27
27
|
description: Incremental build information for Middleman
|
@@ -31,14 +31,13 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
- .gitignore
|
34
|
+
- ".gitignore"
|
35
35
|
- CHANGELOG.md
|
36
36
|
- Gemfile
|
37
37
|
- LICENSE.md
|
38
38
|
- README.md
|
39
39
|
- lib/middleman-build-info.rb
|
40
40
|
- lib/middleman-build-info/extension.rb
|
41
|
-
- lib/middleman-build-info/monkey.rb
|
42
41
|
- lib/middleman-build-info/updater.rb
|
43
42
|
- lib/middleman-build-info/version.rb
|
44
43
|
- lib/middleman_extension.rb
|
@@ -54,17 +53,17 @@ require_paths:
|
|
54
53
|
- lib
|
55
54
|
required_ruby_version: !ruby/object:Gem::Requirement
|
56
55
|
requirements:
|
57
|
-
- -
|
56
|
+
- - ">="
|
58
57
|
- !ruby/object:Gem::Version
|
59
58
|
version: 1.9.3
|
60
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
60
|
requirements:
|
62
|
-
- -
|
61
|
+
- - ">="
|
63
62
|
- !ruby/object:Gem::Version
|
64
63
|
version: '0'
|
65
64
|
requirements: []
|
66
65
|
rubyforge_project: middleman-build-info
|
67
|
-
rubygems_version: 2.
|
66
|
+
rubygems_version: 2.4.5
|
68
67
|
signing_key:
|
69
68
|
specification_version: 4
|
70
69
|
summary: Incremental build information for Middleman
|
@@ -1,22 +0,0 @@
|
|
1
|
-
class String
|
2
|
-
def without_leading_slash
|
3
|
-
self.gsub(/^\//,'')
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
class Hash
|
8
|
-
def symbolize_keys
|
9
|
-
self.inject({}) do |result, (key, value)|
|
10
|
-
new_key = case key
|
11
|
-
when String then key.to_sym
|
12
|
-
else key
|
13
|
-
end
|
14
|
-
new_value = case value
|
15
|
-
when Hash then symbolize_keys(value)
|
16
|
-
else value
|
17
|
-
end
|
18
|
-
result[new_key] = new_value
|
19
|
-
result
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|