middleman-releases 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +5 -0
- data/Gemfile +18 -0
- data/README.md +34 -0
- data/Rakefile +4 -0
- data/features/support/env.rb +4 -0
- data/lib/middleman-releases.rb +8 -0
- data/lib/releases/extension.rb +38 -0
- data/lib/releases/instance.rb +43 -0
- data/middleman-releases.gemspec +24 -0
- metadata +67 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f873043471e2aaebd94c999b5ec8651b626a421d
|
4
|
+
data.tar.gz: 4b898bc54770634e8a672f413bf54f14217d54c4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f76de4709cb193e4fa5f4489b4c42263621f48058a6370124c011f9593552cd2a33df808689d61f100abca8152e08cd87729c8d25769ccdcd89f06b4e7df8c49
|
7
|
+
data.tar.gz: c05e7a155f2f9d1a5412fadbe13597e9a07fce6bf782ec7f2aff9d894f3c959e7f5df41a65f8a35bb77beb05017bb8ee9d955b2c822f75e85994f7229f1326cc
|
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# If you do not have OpenSSL installed, update
|
2
|
+
# the following line to use "http://" instead
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in middleman-releases.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
group :development do
|
9
|
+
gem 'rake'
|
10
|
+
gem 'rdoc'
|
11
|
+
gem 'yard'
|
12
|
+
end
|
13
|
+
|
14
|
+
group :test do
|
15
|
+
gem 'cucumber'
|
16
|
+
gem 'aruba'
|
17
|
+
gem 'rspec'
|
18
|
+
end
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# middleman-releases
|
2
|
+
|
3
|
+
Manage a directory of software releases in your project.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add the gem to your Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'middleman-releases'
|
11
|
+
```
|
12
|
+
|
13
|
+
Then run bundle.
|
14
|
+
|
15
|
+
```
|
16
|
+
$> bundle install
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
In your template file, you can optionally access a release instance using the helper method.
|
21
|
+
|
22
|
+
```slim
|
23
|
+
= current_release.title
|
24
|
+
```
|
25
|
+
|
26
|
+
|
27
|
+
## Configuration
|
28
|
+
Configuration options can be defined in your `config.rb` file.
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
activate :releases do |releases|
|
32
|
+
# releases.layout = 'custom_layout'
|
33
|
+
end
|
34
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Releases
|
2
|
+
class Extension < ::Middleman::Extension
|
3
|
+
option :layout, 'release', 'Layout for rendering an individual release'
|
4
|
+
|
5
|
+
def initialize(app, options_hash={}, &block)
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
9
|
+
def after_configuration
|
10
|
+
@_releases = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def releases
|
14
|
+
@_releases.sort_by(&:date).reverse
|
15
|
+
end
|
16
|
+
|
17
|
+
def manipulate_resource_list(resources)
|
18
|
+
resources.each do |resource|
|
19
|
+
if resource.path.start_with?('releases/')
|
20
|
+
layout = resource.metadata[:options].fetch(:layout, options[:layout]).to_s
|
21
|
+
resource.add_metadata(options: { layout: layout })
|
22
|
+
|
23
|
+
@_releases << Instance.from(resource, self)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
helpers do
|
29
|
+
def releases_controller
|
30
|
+
app.extensions[:releases]
|
31
|
+
end
|
32
|
+
|
33
|
+
def current_release
|
34
|
+
Releases::Instance.from(current_resource, self)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Releases
|
2
|
+
class Instance
|
3
|
+
attr_accessor :controller, :resource, :tag
|
4
|
+
|
5
|
+
def self.from(resource, controller)
|
6
|
+
tag = resource.data[:tag]
|
7
|
+
|
8
|
+
new(controller, resource, tag: tag)
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(controller, resource, attributes = {})
|
12
|
+
@controller = controller
|
13
|
+
@resource = resource
|
14
|
+
|
15
|
+
attributes.each do |key, value|
|
16
|
+
self.public_send("#{ key }=", value)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def title
|
21
|
+
resource.data[:title].presence || tag
|
22
|
+
end
|
23
|
+
|
24
|
+
def body
|
25
|
+
resource.render(layout: false)
|
26
|
+
end
|
27
|
+
|
28
|
+
def date
|
29
|
+
return @_date if @_date
|
30
|
+
|
31
|
+
frontmatter_date = resource.data['date']
|
32
|
+
|
33
|
+
# First get the date from frontmatter
|
34
|
+
if frontmatter_date.is_a? Time
|
35
|
+
@_date = frontmatter_date.in_time_zone
|
36
|
+
else
|
37
|
+
@_date = Time.zone.parse(frontmatter_date.to_s)
|
38
|
+
end
|
39
|
+
|
40
|
+
@_date
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "middleman-releases"
|
6
|
+
s.version = "0.1.0"
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Matt Millsaps-Brewer"]
|
9
|
+
s.email = ["matt@madebylotus.com"]
|
10
|
+
s.homepage = "http://www.madebylotus.com"
|
11
|
+
s.summary = %q{Provides a way to define software downloads in your project}
|
12
|
+
s.description = %q{Manage a directory of software releases in your project}
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
# The version of middleman-core your extension depends on
|
20
|
+
s.add_runtime_dependency("middleman-core", [">= 4.0.0"])
|
21
|
+
|
22
|
+
# Additional dependencies
|
23
|
+
# s.add_runtime_dependency("gem-name", "gem-version")
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-releases
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Millsaps-Brewer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-03-22 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: 4.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.0
|
27
|
+
description: Manage a directory of software releases in your project
|
28
|
+
email:
|
29
|
+
- matt@madebylotus.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- Gemfile
|
36
|
+
- README.md
|
37
|
+
- Rakefile
|
38
|
+
- features/support/env.rb
|
39
|
+
- lib/middleman-releases.rb
|
40
|
+
- lib/releases/extension.rb
|
41
|
+
- lib/releases/instance.rb
|
42
|
+
- middleman-releases.gemspec
|
43
|
+
homepage: http://www.madebylotus.com
|
44
|
+
licenses: []
|
45
|
+
metadata: {}
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
requirements: []
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 2.5.2
|
63
|
+
signing_key:
|
64
|
+
specification_version: 4
|
65
|
+
summary: Provides a way to define software downloads in your project
|
66
|
+
test_files:
|
67
|
+
- features/support/env.rb
|