Skip to content

Commit

Permalink
Merge pull request #785 from JCotton1123/dynamic-deflate-types
Browse files Browse the repository at this point in the history
Add deflate params: types, notes
  • Loading branch information
Morgan Haskel committed Jul 29, 2014
2 parents 4469e5d + e496d85 commit 90163b1
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 14 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* [Class: apache::mod::wsgi](#class-apachemodwsgi)
* [Class: apache::mod::fcgid](#class-apachemodfcgid)
* [Class: apache::mod::negotiation](#class-apachemodnegotiation)
* [Class: apache::mod::deflate](#class-apachemoddeflate)
* [Defined Type: apache::vhost](#defined-type-apachevhost)
* [Parameter: `directories` for apache::vhost](#parameter-directories-for-apachevhost)
* [SSL parameters for apache::vhost](#ssl-parameters-for-apachevhost)
Expand Down Expand Up @@ -722,6 +723,28 @@ A string that sets the `ForceLanguagePriority` option. Defaults to `Prefer Fallb

An array of languages to set the `LanguagePriority` option of the module.

####Class: `apache::mod::deflate`

Installs and configures mod_deflate. If no parameters are provided, a default configuration is applied.

```puppet
class { '::apache::mod::deflate':
types => [ 'text/html', 'text/css' ],
notes => {
'Input' => 'instream',
'Ratio' => 'ratio',
},
}
```

#####`types`

An array of mime types that will be deflated.

#####`notes`

A hash where the key represents the type and the value represents the note name.

####Defined Type: `apache::vhost`

The Apache module allows a lot of flexibility in the setup and configuration of virtual hosts. This flexibility is due, in part, to `vhost`'s being a defined resource type, which allows it to be evaluated multiple times with different parameters.
Expand Down
16 changes: 14 additions & 2 deletions manifests/mod/deflate.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
class apache::mod::deflate {
class apache::mod::deflate (
$types = [
'text/html text/plain text/xml',
'text/css',
'application/x-javascript application/javascript application/ecmascript',
'application/rss+xml'
],
$notes = {
'Input' => 'instream',
'Output' => 'outstream',
'Ratio' => 'ratio'
}
) {
::apache::mod { 'deflate': }
# Template uses no variables

file { 'deflate.conf':
ensure => file,
path => "${::apache::mod_dir}/deflate.conf",
Expand Down
17 changes: 12 additions & 5 deletions spec/classes/mod/deflate_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,28 @@ def general_deflate_specs

it do
is_expected.to contain_file("deflate.conf").with_content(
"AddOutputFilterByType DEFLATE text/html text/plain text/xml\n"\
"AddOutputFilterByType DEFLATE text/css\n"\
"AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript\n"\
"AddOutputFilterByType DEFLATE application/rss+xml\n"\
"AddOutputFilterByType DEFLATE text/html\n"\
"\n"\
"DeflateFilterNote Input instream\n"\
"DeflateFilterNote Output outstream\n"\
"DeflateFilterNote Ratio ratio\n"
)
end
end

describe 'apache::mod::deflate', :type => :class do
let :pre_condition do
'include apache'
'class { "apache":
default_mods => false,
}
class { "apache::mod::deflate":
types => [ "text/html", "text/css" ],
notes => {
"Input" => "instream",
"Ratio" => "ratio",
}
}
'
end

context "On a Debian OS with default params" do
Expand Down
13 changes: 6 additions & 7 deletions templates/mod/deflate.conf.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript
AddOutputFilterByType DEFLATE application/rss+xml
<%- @types.sort.each do |type| -%>
AddOutputFilterByType DEFLATE <%= type %>
<%- end -%>

DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
<%- @notes.sort.each do |type,note| -%>
DeflateFilterNote <%= type %> <%=note %>
<%- end -%>

0 comments on commit 90163b1

Please sign in to comment.