middleman-build-reporter 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/.travis.yml +3 -0
  4. data/Gemfile +3 -0
  5. data/README.md +118 -0
  6. data/Rakefile +12 -0
  7. data/features/build_reporter.feature +21 -0
  8. data/features/custom_build_reporter_file_name.feature +6 -0
  9. data/features/extended_build_reporter.feature +12 -0
  10. data/features/json_build_reporter.feature +21 -0
  11. data/features/no_explicit_version.feature +6 -0
  12. data/features/step_definitions/git_steps.rb +19 -0
  13. data/features/step_definitions/json_reporter_file_steps.rb +31 -0
  14. data/features/step_definitions/version_steps.rb +5 -0
  15. data/features/support/env.rb +4 -0
  16. data/features/support/helpers.rb +7 -0
  17. data/fixtures/basic-app/config.rb +4 -0
  18. data/fixtures/basic-app/source/images/background.png +0 -0
  19. data/fixtures/basic-app/source/images/middleman.png +0 -0
  20. data/fixtures/basic-app/source/index.html.erb +10 -0
  21. data/fixtures/basic-app/source/javascripts/all.js +1 -0
  22. data/fixtures/basic-app/source/layouts/layout.erb +19 -0
  23. data/fixtures/basic-app/source/stylesheets/all.css +55 -0
  24. data/fixtures/basic-app/source/stylesheets/normalize.css +375 -0
  25. data/fixtures/custom-reporter-file-name/config.rb +4 -0
  26. data/fixtures/custom-reporter-file-name/source/images/background.png +0 -0
  27. data/fixtures/custom-reporter-file-name/source/images/middleman.png +0 -0
  28. data/fixtures/custom-reporter-file-name/source/index.html.erb +10 -0
  29. data/fixtures/custom-reporter-file-name/source/javascripts/all.js +1 -0
  30. data/fixtures/custom-reporter-file-name/source/layouts/layout.erb +19 -0
  31. data/fixtures/custom-reporter-file-name/source/stylesheets/all.css +55 -0
  32. data/fixtures/custom-reporter-file-name/source/stylesheets/normalize.css +375 -0
  33. data/fixtures/extended-build-reporter/.build_reporter.yml +4 -0
  34. data/fixtures/extended-build-reporter/config.rb +4 -0
  35. data/fixtures/extended-build-reporter/source/images/background.png +0 -0
  36. data/fixtures/extended-build-reporter/source/images/middleman.png +0 -0
  37. data/fixtures/extended-build-reporter/source/index.html.erb +10 -0
  38. data/fixtures/extended-build-reporter/source/javascripts/all.js +1 -0
  39. data/fixtures/extended-build-reporter/source/layouts/layout.erb +19 -0
  40. data/fixtures/extended-build-reporter/source/stylesheets/all.css +55 -0
  41. data/fixtures/extended-build-reporter/source/stylesheets/normalize.css +375 -0
  42. data/fixtures/json-reporter-file/config.rb +5 -0
  43. data/fixtures/json-reporter-file/source/images/background.png +0 -0
  44. data/fixtures/json-reporter-file/source/images/middleman.png +0 -0
  45. data/fixtures/json-reporter-file/source/index.html.erb +10 -0
  46. data/fixtures/json-reporter-file/source/javascripts/all.js +1 -0
  47. data/fixtures/json-reporter-file/source/layouts/layout.erb +19 -0
  48. data/fixtures/json-reporter-file/source/stylesheets/all.css +55 -0
  49. data/fixtures/json-reporter-file/source/stylesheets/normalize.css +375 -0
  50. data/fixtures/no-version/config.rb +3 -0
  51. data/fixtures/no-version/source/images/background.png +0 -0
  52. data/fixtures/no-version/source/images/middleman.png +0 -0
  53. data/fixtures/no-version/source/index.html.erb +10 -0
  54. data/fixtures/no-version/source/javascripts/all.js +1 -0
  55. data/fixtures/no-version/source/layouts/layout.erb +19 -0
  56. data/fixtures/no-version/source/stylesheets/all.css +55 -0
  57. data/fixtures/no-version/source/stylesheets/normalize.css +375 -0
  58. data/lib/middleman-build-reporter/extension.rb +29 -0
  59. data/lib/middleman-build-reporter/reporter.rb +68 -0
  60. data/lib/middleman-build-reporter/version.rb +5 -0
  61. data/lib/middleman-build-reporter.rb +9 -0
  62. data/lib/middleman_extension.rb +1 -0
  63. data/middleman-build-reporter.gemspec +32 -0
  64. data/spec/middleman-build-reporter/extension_spec.rb +82 -0
  65. data/spec/middleman-build-reporter/reporter_spec.rb +184 -0
  66. data/spec/spec_helper.rb +35 -0
  67. metadata +248 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b39877eb52f82b5dd645fa574f290dabbeda31ab
4
+ data.tar.gz: c4eda5340278dd8a1805c36c73b94cabdbd804be
5
+ SHA512:
6
+ metadata.gz: 2fd1ef6f55335ae01ada5ec5015463e21c931c7d15a40bd5ed4ff05ba4c389043486a5df21e2db02891b8a6555fc70d9f8d1d6636ca0575ce1029667f6895ec5
7
+ data.tar.gz: bfb45f439283acac26763344244d6bfba9f530a2ad62ce1e3a1ef47f728194c134fa354483ca53cbef10e95ac7b06be569bc6bad3de3f4f819fdf5c2ac124aa9
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ tmp
2
+ Gemfile.lock
3
+ coverage
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - '2.1.2'
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.md ADDED
@@ -0,0 +1,118 @@
1
+ [![Build Status](https://travis-ci.org/mdb/middleman-build-reporter.svg?branch=master)](https://travis-ci.org/mdb/middleman-build-reporter)
2
+
3
+ # middleman-build-reporter
4
+
5
+ Fingerprint your [Middleman](http://middlemanapp.com) build with YAML and/or JSON files reporting build-time details.
6
+
7
+ middleman-build-reporter helps you understand what code has been deployed to an environment.
8
+
9
+ ## Output
10
+
11
+ middleman-build-reporter can output YAML and/or JSON:
12
+
13
+ The `build/build.yaml`:
14
+
15
+ ```yaml
16
+ branch: master
17
+ revision: 244921c81c9e21a1973659df5f702937b91cfcd4
18
+ build_time: 2014-09-20 10:50:55 -0400
19
+ version: 1.2.3
20
+ ```
21
+
22
+ The `build/build.json`:
23
+
24
+ ```json
25
+ {
26
+ "branch": "master",
27
+ "revision": "244921c81c9e21a1973659df5f702937b91cfcd4",
28
+ "build_time": "2014-09-20 10:50:55 -0400",
29
+ "version": "1.2.3"
30
+ }
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ In your `Gemfile`:
36
+
37
+ ```ruby
38
+ gem 'middleman-build-reporter'
39
+ ```
40
+
41
+ Install it:
42
+
43
+ ```bash
44
+ $ bundle install
45
+ ```
46
+
47
+ Activate it within your `config.rb`:
48
+
49
+ ```
50
+ activate :build_reporter
51
+ ```
52
+
53
+ Supported configuration
54
+
55
+ ```ruby
56
+ activate :build_reporter do |build|
57
+ # optional; the path to your project repository root
58
+ # this must be absolute or relative from your build directory
59
+ # defaults to app root
60
+ build.repo_root = '../../../'
61
+
62
+ # optional; the version of your app
63
+ # defaults to ''
64
+ build.version = '1.2.3'
65
+
66
+ # optional; the build reporter file name
67
+ # defaults to 'build'
68
+ build.reporter_file = 'build'
69
+
70
+ # optional; an array of desired build reporter file formats
71
+ # supported formats: yaml, json
72
+ # defaults to ['yaml']
73
+ build.reporter_file_formats = ['json', 'json']
74
+ end
75
+ ```
76
+
77
+ ## Reporting additional custom build details
78
+
79
+ Add any additional build details to a `.build_reporter.yml` file in your project's root.
80
+
81
+ The `.build_reporter.yml` can be produced as part of your app's build process, or manually managed.
82
+
83
+ ### Example - custom extended details:
84
+
85
+ The `.build_reporter.yml`:
86
+
87
+ ```
88
+ ---
89
+ foo: 'bar'
90
+ ```
91
+
92
+ The output `build/build.yaml`:
93
+
94
+ ```
95
+ branch: master
96
+ revision: 244921c81c9e21a1973659df5f702937b91cfcd4
97
+ build_time: 2014-09-20 10:50:55 -0400
98
+ version: 1.2.3
99
+ foo: bar
100
+ ```
101
+
102
+ ### Example - using .build_reporter.yml to override built-in middleman-build-reporter details:
103
+
104
+ The `.build_reporter.yml`:
105
+
106
+ ```
107
+ ---
108
+ revision: 'some_revision'
109
+ ```
110
+
111
+ The output `build/build.yaml`:
112
+
113
+ ```
114
+ branch: master
115
+ revision: some_revision
116
+ build_time: 2014-09-20 10:50:55 -0400
117
+ version: 1.2.3
118
+ ```
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'cucumber/rake/task'
4
+ require 'rake/clean'
5
+
6
+ Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
7
+ t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'Fivemat'}"
8
+ end
9
+
10
+ RSpec::Core::RakeTask.new
11
+
12
+ task default: [:spec, :cucumber]
@@ -0,0 +1,21 @@
1
+ Feature: Build reporter
2
+
3
+ Scenario: build.yaml should report a branch
4
+ Given a successfully built app at "basic-app"
5
+ When I cd to "build"
6
+ Then the file "build.yaml" should report the current branch
7
+
8
+ Scenario: build.yaml should report a revision
9
+ Given a successfully built app at "basic-app"
10
+ When I cd to "build"
11
+ Then the file "build.yaml" should report the current git revision
12
+
13
+ Scenario: build.yaml should report a build time
14
+ Given a successfully built app at "basic-app"
15
+ When I cd to "build"
16
+ Then the file "build.yaml" should report the build time
17
+
18
+ Scenario: build.yaml should report a version
19
+ Given a successfully built app at "basic-app"
20
+ When I cd to "build"
21
+ Then the file "build.yaml" should contain "version: 1.2.3"
@@ -0,0 +1,6 @@
1
+ Feature: Custom build reporter file name declared in config.rb
2
+
3
+ Scenario: the build report should be written to the custom file name
4
+ Given a successfully built app at "custom-reporter-file-name"
5
+ When I cd to "build"
6
+ Then a file named "custom.yaml" should exist
@@ -0,0 +1,12 @@
1
+ Feature: Extended build reporter details
2
+
3
+ Scenario: build.yaml should report the custom supplemental details
4
+ Given a successfully built app at "extended-build-reporter"
5
+ When I cd to "build"
6
+ Then the file "build.yaml" should contain "some_key: some value"
7
+ And the file "build.yaml" should contain "another_key: another value"
8
+
9
+ Scenario: build.yaml should override built-in details
10
+ Given a successfully built app at "extended-build-reporter"
11
+ When I cd to "build"
12
+ Then the file "build.yaml" should contain "version: 3.3.3"
@@ -0,0 +1,21 @@
1
+ Feature: JSON build reporter file
2
+
3
+ Scenario: build.json should report a branch
4
+ Given a successfully built app at "json-reporter-file"
5
+ When I cd to "build"
6
+ Then the JSON file "build.json" should report the current branch
7
+
8
+ Scenario: build.yaml should report a revision
9
+ Given a successfully built app at "json-reporter-file"
10
+ When I cd to "build"
11
+ Then the JSON file "build.json" should report the current git revision
12
+
13
+ Scenario: build.json should report a build time
14
+ Given a successfully built app at "json-reporter-file"
15
+ When I cd to "build"
16
+ Then the JSON file "build.json" should report the build time
17
+
18
+ Scenario: build.json should report a version
19
+ Given a successfully built app at "json-reporter-file"
20
+ When I cd to "build"
21
+ Then the JSON file "build.json" should report version "1.2.3"
@@ -0,0 +1,6 @@
1
+ Feature: No explicit version declared in the config
2
+
3
+ Scenario: build should report an empty version number
4
+ Given a successfully built app at "no-version"
5
+ When I cd to "build"
6
+ Then the file "build.yaml" should report an empty version
@@ -0,0 +1,19 @@
1
+ Then /the file "([^"]*)" should report the current branch/ do |file|
2
+ branch = Git.open('.').current_branch
3
+
4
+ prep_for_fs_check do
5
+ expect(YAML.load(File.read(file))['branch']).to eq branch
6
+ end
7
+ end
8
+
9
+ Then /the file "([^"]*)" should report the current git revision/ do |file|
10
+ partial_content = "revision: #{Git.open('.').log.first}"
11
+
12
+ check_file_content(file, partial_content, true)
13
+ end
14
+
15
+ Then /the file "([^"]*)" should report the build time/ do |file|
16
+ partial_content = "build_time: '#{Time.now.strftime('%Y-%m-%d %H:%M')}"
17
+
18
+ check_file_content(file, partial_content, true)
19
+ end
@@ -0,0 +1,31 @@
1
+ Then /the JSON file "([^"]*)" should report the current branch/ do |file|
2
+ prep_for_fs_check do
3
+ json = JSON.parse(File.open(file).read)
4
+
5
+ expect(json['branch']).to eq "#{Git.open(gem_root_relative_to_features).current_branch}"
6
+ end
7
+ end
8
+
9
+ Then /the JSON file "([^"]*)" should report the current git revision/ do |file|
10
+ prep_for_fs_check do
11
+ json = JSON.parse(File.open(file).read)
12
+
13
+ expect(json['revision']).to eq "#{Git.open(gem_root_relative_to_features).log.first}"
14
+ end
15
+ end
16
+
17
+ Then /the JSON file "([^"]*)" should report the build time/ do |file|
18
+ prep_for_fs_check do
19
+ json = JSON.parse(File.open(file).read)
20
+
21
+ expect(json['build_time']).to include "#{Time.now.strftime('%Y-%m-%d %H:%M')}"
22
+ end
23
+ end
24
+
25
+ Then /the JSON file "([^"]*)" should report version "([^"]*)"/ do |file, version|
26
+ prep_for_fs_check do
27
+ json = JSON.parse(File.open(file).read)
28
+
29
+ expect(json['version']).to eq version
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ Then /the file "([^"]*)" should report an empty version/ do |file|
2
+ partial_content = /version: ''$/
3
+
4
+ check_file_content(file, partial_content, true)
5
+ end
@@ -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-build-reporter')
@@ -0,0 +1,7 @@
1
+ module Helpers
2
+ def gem_root_relative_to_features
3
+ '../../../../'
4
+ end
5
+ end
6
+
7
+ World(Helpers)
@@ -0,0 +1,4 @@
1
+ activate :build_reporter do |build|
2
+ build.repo_root = '../../../'
3
+ build.version = '1.2.3'
4
+ end
@@ -0,0 +1,10 @@
1
+ ---
2
+ title: Welcome to Middleman
3
+ ---
4
+
5
+ <div class="welcome">
6
+ <h1>Middleman is Watching</h1>
7
+ <p class="doc">
8
+ <%= link_to "Read Online Documentation", "http://middlemanapp.com/" %>
9
+ </p><!-- .doc -->
10
+ </div><!-- .welcome -->
@@ -0,0 +1 @@
1
+ //= require_tree .
@@ -0,0 +1,19 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+
6
+ <!-- Always force latest IE rendering engine or request Chrome Frame -->
7
+ <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
8
+
9
+ <!-- Use title if it's in the page YAML frontmatter -->
10
+ <title><%= current_page.data.title || "The Middleman" %></title>
11
+
12
+ <%= stylesheet_link_tag "normalize", "all" %>
13
+ <%= javascript_include_tag "all" %>
14
+ </head>
15
+
16
+ <body class="<%= page_classes %>">
17
+ <%= yield %>
18
+ </body>
19
+ </html>
@@ -0,0 +1,55 @@
1
+ @charset "utf-8";
2
+
3
+ body {
4
+ background: #d4d4d4 url("../images/background.png");
5
+ text-align: center;
6
+ font-family: sans-serif; }
7
+
8
+ h1 {
9
+ color: rgba(0, 0, 0, .3);
10
+ font-weight: bold;
11
+ font-size: 32px;
12
+ letter-spacing: -1px;
13
+ text-transform: uppercase;
14
+ text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
15
+ background: url("../images/middleman.png") no-repeat center 100px;
16
+ padding: 350px 0 10px;
17
+ margin: 0; }
18
+
19
+ .doc {
20
+ font-size: 14px;
21
+ margin: 0; }
22
+ .doc:before,
23
+ .doc:after {
24
+ opacity: .2;
25
+ padding: 6px;
26
+ font-style: normal;
27
+ position: relative;
28
+ content: "•"; }
29
+ .doc a {
30
+ color: rgba(0, 0, 0, 0.3); }
31
+ .doc a:hover {
32
+ color: #666; }
33
+
34
+ .welcome {
35
+ -webkit-animation-name: welcome;
36
+ -webkit-animation-duration: .9s; }
37
+
38
+ @-webkit-keyframes welcome {
39
+ from {
40
+ -webkit-transform: scale(0);
41
+ opacity: 0;
42
+ }
43
+ 50% {
44
+ -webkit-transform: scale(0);
45
+ opacity: 0;
46
+ }
47
+ 82.5% {
48
+ -webkit-transform: scale(1.03);
49
+ -webkit-animation-timing-function: ease-out;
50
+ opacity: 1;
51
+ }
52
+ to {
53
+ -webkit-transform: scale(1);
54
+ }
55
+ }