middleman-hashicorp 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48894cc818c6519f28f263c6c0744fd750ee15e5
4
- data.tar.gz: b0bf6f0cf09d42872fa6bc338ae2384e0bc73b70
3
+ metadata.gz: 7bae9cd8e18d5fc4f58643ce4ecc4307be8bbf57
4
+ data.tar.gz: ed9bbe1aa3f918154d6b361e9932a1786ba7c615
5
5
  SHA512:
6
- metadata.gz: 267866fd439dcaba37d96e83ed1144dd62d7bb7352b1603111d9bd73149ec11c9f5c91a1eb185c563e4579927857ba6d24092c3c4628ebc8d0b29a5354eeb08a
7
- data.tar.gz: 07fd2273aee1d944d1b8ecd8540fd5b054f09e1400c50da8af3d140cdf3dde215d0f35cf2c20fb2805799ae65e87f2ce21042c293b858748b16f33e9d39a3f7c
6
+ metadata.gz: 822ca0ee7e0364e76083418432d83a7d2df3b983d80fca13023dacf2c144e49086ede06f92c728bdd6e2f8a487fbc5218f205fc47a9a0f1c2f26b839db0ebb68
7
+ data.tar.gz: 53880ccae80c71ee051cfca5e588bc8ea512ad536a98166b40f36cf05b658ec800d4a036d5f6d27db2e94306e9c12492350561b2666aa8cca71b94211e1f2b31
data/README.md CHANGED
@@ -31,7 +31,11 @@ If you are a HashiCorp employee and are deploying a HashiCorp middleman site, yo
31
31
  activate :hashicorp do |h|
32
32
  h.name = "packer"
33
33
  h.version = "0.7.0"
34
- h.github_slug = "mitchellh/packer"
34
+ h.github_slug = "hashicorp/terraform"
35
+
36
+ # Disable fetching release information - this is useful for non-product site
37
+ # or local development.
38
+ h.releases_enabled = false
35
39
 
36
40
  # Disable some extensions
37
41
  h.minify_javascript = false
@@ -1,6 +1,5 @@
1
1
  module Middleman
2
2
  module HashiCorp
3
- require_relative "bintray"
4
3
  require_relative "redcarpet"
5
4
  require_relative "releases"
6
5
  require_relative "rouge"
@@ -8,13 +7,6 @@ module Middleman
8
7
  end
9
8
 
10
9
  class Middleman::HashiCorpExtension < ::Middleman::Extension
11
- option :bintray_enabled, false, "Whether Bintray is enabeld"
12
- option :bintray_repo, nil, "The Bintray repo name (e.g. mitchellh/packer)"
13
- option :bintray_user, nil, "The Bintray http basic auth user (e.g. mitchellh)"
14
- option :bintray_key, nil, "The Bintray http basic auth key (e.g. abcd1234)"
15
- option :bintray_exclude_proc, nil, "A filter to apply for packages"
16
- option :bintray_prefixed, true, "Whether packages are prefixed with the project name"
17
-
18
10
  option :name, nil, "The name of the package (e.g. 'consul')"
19
11
  option :version, nil, "The version of the package (e.g. 0.1.0)"
20
12
  option :minify_javascript, true, "Whether to minimize JS or not"
@@ -147,7 +139,7 @@ class Middleman::HashiCorpExtension < ::Middleman::Extension
147
139
  end
148
140
 
149
141
  #
150
- # Calculate the architecture for the given filename (from Bintray).
142
+ # Calculate the architecture for the given filename.
151
143
  #
152
144
  # @return [String]
153
145
  #
@@ -199,30 +191,20 @@ class Middleman::HashiCorpExtension < ::Middleman::Extension
199
191
  end
200
192
 
201
193
  #
202
- # Query the Bintray API to get the real product download versions.
194
+ # Query the API to get the real product download versions.
203
195
  #
204
196
  # @return [Hash]
205
197
  #
206
198
  def product_versions
207
- if !options.bintray_enabled && !options.releases_enabled
208
- return {
199
+ if options.releases_enabled
200
+ Middleman::HashiCorp::Releases.fetch(options.name, options.version)
201
+ else
202
+ {
209
203
  "HashiOS" => {
210
204
  "amd64" => "/0.1.0_hashios_amd64.zip",
211
205
  "i386" => "/0.1.0_hashios_i386.zip",
212
206
  }
213
207
  }
214
208
  end
215
-
216
- if options.bintray_repo
217
- Middleman::HashiCorp::BintrayAPI.new(
218
- repo: options.bintray_repo,
219
- user: options.bintray_user,
220
- key: options.bintray_key,
221
- filter: options.bintray_exclude_proc,
222
- prefixed: options.bintray_prefixed,
223
- ).downloads_for_version(options.version)
224
- else
225
- Middleman::HashiCorp::Releases.fetch(options.name, options.version)
226
- end
227
209
  end
228
210
  end
@@ -29,7 +29,7 @@ class Middleman::HashiCorp::RedcarpetHTML < ::Middleman::Renderers::MiddlemanRed
29
29
  #
30
30
  def list_item(text, list_type)
31
31
  md = text.match(/(<code>(.+?)<\/code>)/)
32
- linked = !text.match(/^(<p>)?<a(.+?)>(.+?)<\/a>\s*?[-:]?/).nil?
32
+ linked = !text.match(/\A(<p>)?<a(.+?)>(.+?)<\/a>\s*?[-:]?/).nil?
33
33
 
34
34
  if !md.nil? && !linked
35
35
  container, name = md.captures
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module HashiCorp
3
- VERSION = "0.3.3"
3
+ VERSION = "0.3.4"
4
4
  end
5
5
  end
@@ -7,7 +7,7 @@ class Middleman::HashiCorpExtension
7
7
  app = middleman_app
8
8
  @instance = Middleman::HashiCorpExtension.new(
9
9
  app,
10
- bintray_enabled: false,
10
+ releases_enabled: false,
11
11
  name: "consul",
12
12
  version: "0.1.0",
13
13
  github_slug: "hashicorp/this_project",
@@ -25,7 +25,7 @@ class Middleman::HashiCorpExtension
25
25
  slugless_app,
26
26
  name: "consul",
27
27
  version: "0.1.0",
28
- bintray_enabled: false,
28
+ releases_enabled: false,
29
29
  )
30
30
  slugless_instance.app = slugless_app
31
31
  expect(slugless_instance.app.github_url).to eq(false)
@@ -37,7 +37,7 @@ class Middleman::HashiCorpExtension
37
37
  app = middleman_app
38
38
  @instance = Middleman::HashiCorpExtension.new(
39
39
  app,
40
- bintray_enabled: false,
40
+ releases_enabled: false,
41
41
  name: "consul",
42
42
  version: "0.1.0",
43
43
  github_slug: "hashicorp/this_project",
@@ -90,6 +90,9 @@ module Middleman::HashiCorp
90
90
  - `two` - has a [link_two](#link_two) inside
91
91
 
92
92
  - `three`: is regular but with a colon
93
+
94
+ - `four` - is
95
+ [on the next](#line)
93
96
  EOH
94
97
  output = <<-EOH.gsub(/^ {8}/, "")
95
98
  <ul>
@@ -99,6 +102,9 @@ module Middleman::HashiCorp
99
102
  </li>
100
103
  <li><p><a name="three" /><a href="#three"><code>three</code></a>: is regular but with a colon</p>
101
104
  </li>
105
+ <li><p><a name="four" /><a href="#four"><code>four</code></a> - is
106
+ <a href="#line">on the next</a></p>
107
+ </li>
102
108
  </ul>
103
109
  EOH
104
110
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-hashicorp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Vargo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-22 00:00:00.000000000 Z
11
+ date: 2016-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman
@@ -177,7 +177,6 @@ files:
177
177
  - docker/Dockerfile
178
178
  - docker/entrypoint.sh
179
179
  - lib/middleman-hashicorp.rb
180
- - lib/middleman-hashicorp/bintray.rb
181
180
  - lib/middleman-hashicorp/extension.rb
182
181
  - lib/middleman-hashicorp/redcarpet.rb
183
182
  - lib/middleman-hashicorp/releases.rb
@@ -1,98 +0,0 @@
1
- require "open-uri"
2
-
3
- class Middleman::HashiCorp::BintrayAPI
4
- attr_reader :filter
5
- attr_reader :prefixed
6
-
7
- #
8
- # @param [String] :repo (e.g. mitchellh/packer)
9
- # @param [String] :user (e.g. mitchellh/packer)
10
- # @param [String] :key (e.g. abcd1234)
11
- # @param [Proc] :filter
12
- # @param [Boolean] :prefixed
13
- #
14
- def initialize(repo: nil, user: nil, key: nil, filter: nil, prefixed: true)
15
- set_or_raise(:repo, repo)
16
- set_or_raise(:user, user)
17
- set_or_raise(:key, key)
18
-
19
- @filter = filter || Proc.new {}
20
- @prefixed = prefixed
21
- end
22
-
23
- #
24
- # Get the structured downloads for the given version and required OSes.
25
- #
26
- # @example
27
- # api.downloads_for_version("1.0.0") #=>
28
- # {
29
- # "os" => {
30
- # "arch" => "http://download.url",
31
- # }
32
- # }
33
- #
34
- # @return [Hash]
35
- #
36
- def downloads_for_version(version)
37
- url = "http://dl.bintray.com/#{repo}/"
38
- options = { http_basic_authentication: [user, key] }
39
-
40
- if prefixed
41
- project = repo.split("/", 2).last
42
- regex = /(#{Regexp.escape(project)}_#{Regexp.escape(version)}_.+?)('|")/
43
- else
44
- regex = /(#{Regexp.escape(version)}_.+?)('|")/
45
- end
46
-
47
- result = {}
48
-
49
- open(url, options) do |file|
50
- file.readlines.each do |line|
51
- if line.chomp! =~ regex
52
- filename = $1
53
-
54
- # Hardcoded filter
55
- next if filename.include?("SHA256SUMS")
56
-
57
- os = filename.strip.split("_")[-2].strip
58
-
59
- # Custom filter
60
- next if filter.call(os, filename)
61
-
62
- arch = line.split("_").last.split(".", 2).first
63
-
64
- result[os] ||= {}
65
- result[os][arch] = "https://dl.bintray.com/#{repo}/#{filename}"
66
- end
67
- end
68
- end
69
-
70
- result
71
- rescue OpenURI::HTTPError
72
- # Ignore HTTP errors and just have no versions
73
- return {}
74
- end
75
-
76
- private
77
-
78
- #
79
- # Magical method that checks if the value is truly present (i.e. not an
80
- # empty string), raising an exception if it is not. If the value is present,
81
- # the named instance variable and attr_reader are defined.
82
- #
83
- # @raise [RuntimeError]
84
- # @return [true]
85
- #
86
- def set_or_raise(key, value)
87
- value = value.to_s.strip
88
-
89
- if value.empty?
90
- raise "Bintray #{key} was not given!"
91
- end
92
-
93
- instance_variable_set(:"@#{key}", value)
94
- self.class.send(:attr_reader, :"#{key}")
95
-
96
- true
97
- end
98
- end