middleman-releases 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/lib/middleman-releases.rb +1 -0
- data/lib/releases/commands/release.rb +74 -0
- data/lib/releases/commands/release.tt +7 -0
- data/lib/releases/extension.rb +1 -0
- data/middleman-releases.gemspec +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 329c68d01efd17938005668a2ceb7795961dc671
|
4
|
+
data.tar.gz: 2a589586cc4e9c6682af4bd0284fe0c1ac72676b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4801fb20b7707f9204ed3a72fa7e684ea9c7f5b198def70d664db4dc4f2bc2a990c930f130441ccef37e71c263813242ff4f3ffa3854155453f00458c1a76985
|
7
|
+
data.tar.gz: e15546dbaffa81f7bcb1f4e8dc3a85135b0d5ceb6cec0aacecb3f3e171e7499390d8bd8939d238282c1669daee545b734bc8815b14ba09d057834a750151be7e
|
data/README.md
CHANGED
@@ -23,6 +23,14 @@ In your template file, you can optionally access a release instance using the he
|
|
23
23
|
= current_release.title
|
24
24
|
```
|
25
25
|
|
26
|
+
## Generate New Software Release
|
27
|
+
This gem includes a CLI command to generate a new software release from a template file.
|
28
|
+
|
29
|
+
```shell
|
30
|
+
# Sets the date and git tag of the release, opens for editing immediately
|
31
|
+
$> bundle exec middleman release v4.0.0 --date "2017-04-01 17:00pm EST" --edit
|
32
|
+
```
|
33
|
+
|
26
34
|
|
27
35
|
## Configuration
|
28
36
|
Configuration options can be defined in your `config.rb` file.
|
@@ -30,5 +38,7 @@ Configuration options can be defined in your `config.rb` file.
|
|
30
38
|
```ruby
|
31
39
|
activate :releases do |releases|
|
32
40
|
# releases.layout = 'custom_layout'
|
41
|
+
# releases.releases_dir = 'releases'
|
42
|
+
# releases.new_release_template = File.expand_path('../custom_template.tt', __FILE__)
|
33
43
|
end
|
34
44
|
```
|
data/lib/middleman-releases.rb
CHANGED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'middleman-core/cli'
|
2
|
+
require 'date'
|
3
|
+
|
4
|
+
module Middleman
|
5
|
+
module Cli
|
6
|
+
|
7
|
+
##
|
8
|
+
# This class provides an "release" command for the middleman CLI.
|
9
|
+
#
|
10
|
+
# @usage bundle exec middleman release --help
|
11
|
+
# @usage bundle exec middleman release v3.1.4
|
12
|
+
# @usage bundle exec middleman release v3.1.4 --date "2017-03-19 4:00pm EST" --edit
|
13
|
+
#
|
14
|
+
##
|
15
|
+
class Release < ::Thor::Group
|
16
|
+
include Thor::Actions
|
17
|
+
|
18
|
+
check_unknown_options!
|
19
|
+
|
20
|
+
# Template files are relative to this file
|
21
|
+
# @return [String]
|
22
|
+
def self.source_root
|
23
|
+
File.dirname( __FILE__ )
|
24
|
+
end
|
25
|
+
|
26
|
+
argument :tag, type: :string
|
27
|
+
|
28
|
+
class_option "date",
|
29
|
+
aliases: "-d",
|
30
|
+
desc: "The date to create the post with (defaults to now)"
|
31
|
+
|
32
|
+
class_option "edit",
|
33
|
+
aliases: "-e",
|
34
|
+
desc: "Edit the newly created software release",
|
35
|
+
default: false,
|
36
|
+
type: :boolean
|
37
|
+
|
38
|
+
def release
|
39
|
+
@tag = tag
|
40
|
+
@date = options[:date] ? ::Time.zone.parse(options[:date]) : Time.zone.now
|
41
|
+
|
42
|
+
app = ::Middleman::Application.new do
|
43
|
+
config[:mode] = :config
|
44
|
+
config[:disable_sitemap] = true
|
45
|
+
config[:watcher_disable] = true
|
46
|
+
config[:exit_before_ready] = true
|
47
|
+
end
|
48
|
+
|
49
|
+
releases_manager = app.extensions[:releases]
|
50
|
+
|
51
|
+
release_dir_name = @tag
|
52
|
+
absolute_release_path = File.join( app.source_dir, releases_manager.options.releases_dir, release_dir_name, "index.html.markdown" )
|
53
|
+
|
54
|
+
template releases_manager.options.new_release_template, absolute_release_path
|
55
|
+
|
56
|
+
# Edit option process
|
57
|
+
if options[ :edit ]
|
58
|
+
editor = ENV.fetch('MM_EDITOR', ENV.fetch('EDITOR', nil ))
|
59
|
+
|
60
|
+
if editor
|
61
|
+
system( "#{ editor } #{ absolute_release_path }" )
|
62
|
+
else
|
63
|
+
throw "Could not find a suitable editor. Try setting the environment variable MM_EDITOR."
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
protected
|
69
|
+
|
70
|
+
# Add to CLI
|
71
|
+
Base.register(self, 'release', 'release TAG [options]', 'Create a new software release')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
data/lib/releases/extension.rb
CHANGED
@@ -2,6 +2,7 @@ module Releases
|
|
2
2
|
class Extension < ::Middleman::Extension
|
3
3
|
option :layout, 'release', 'Layout for rendering an individual release'
|
4
4
|
option :releases_dir, 'releases', 'Directory containing releases'
|
5
|
+
option :new_release_template, File.expand_path('../commands/release.tt', __FILE__), 'Path (relative to project root) to an ERb template that will be used to generate new software releases from the "middleman release" command.'
|
5
6
|
|
6
7
|
expose_to_template :releases, :latest_release
|
7
8
|
|
data/middleman-releases.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-releases
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Millsaps-Brewer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|
@@ -37,6 +37,8 @@ files:
|
|
37
37
|
- Rakefile
|
38
38
|
- features/support/env.rb
|
39
39
|
- lib/middleman-releases.rb
|
40
|
+
- lib/releases/commands/release.rb
|
41
|
+
- lib/releases/commands/release.tt
|
40
42
|
- lib/releases/extension.rb
|
41
43
|
- lib/releases/instance.rb
|
42
44
|
- middleman-releases.gemspec
|