Sha256: afbf28f24925ffba67a6c2b0ffe021f2a3baf95b63650cb2d80a9b326be7d6a2

Contents?: true

Size: 1.98 KB

Versions: 62

Compression:

Stored size: 1.98 KB

Contents

#
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
#
# Copyright 2012, Riot Games
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

provides "nginx"
provides "nginx/version"
provides "nginx/configure_arguments"
provides "nginx/prefix"
provides "nginx/conf_path"

def parse_flags(flags)
  prefix = nil
  conf_path = nil

  flags.each do |flag|
    case flag
    when /^--prefix=(.+)$/
      prefix = $1
    when /^--conf-path=(.+)$/
      conf_path = $1
    end
  end

  [ prefix, conf_path ]
end

nginx Mash.new unless nginx
nginx[:version]             = nil unless nginx[:version]
nginx[:configure_arguments] = Array.new unless nginx[:configure_arguments]
nginx[:prefix]              = nil unless nginx[:prefix]
nginx[:conf_path]           = nil unless nginx[:conf_path]

status, stdout, stderr = run_command(:no_status_check => true, :command => "<%= @nginx_bin %> -V")

if status == 0
  stderr.split("\n").each do |line|
    case line
    when /^configure arguments:(.+)/
      # This could be better: I'm splitting on configure arguments which removes them and also 
      # adds a blank string at index 0 of the array. This is why we drop index 0 and map to 
      # add the '--' prefix back to the configure argument.
      nginx[:configure_arguments] = $1.split(/\s--/).drop(1).map { |ca| "--#{ca}" }

      prefix, conf_path = parse_flags(nginx[:configure_arguments])

      nginx[:prefix] = prefix
      nginx[:conf_path] = conf_path
    when /^nginx version: nginx\/(.+)/
      nginx[:version] = $1
    end
  end
end

Version data entries

62 entries across 62 versions & 2 rubygems

Version Path
berkshelf-0.1.2 spec/fixtures/cookbooks/nginx-0.100.5/templates/default/plugins/nginx.rb.erb
berkshelf-0.1.1 spec/fixtures/cookbooks/nginx-0.100.5/templates/default/plugins/nginx.rb.erb