Skip to content

Commit

Permalink
Add OpenSUSE support
Browse files Browse the repository at this point in the history
  • Loading branch information
hartmantis committed Jun 28, 2015
1 parent 7d91ef2 commit 47ac530
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 3 deletions.
1 change: 1 addition & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ platforms:
shell: "'/bin/sh'"
- name: centos-7.1
- name: fedora-21
- name: opensuse-13.1

suites:
- name: default
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ A Chef cookbook for installing GIMP.
Requirements
============

This cookbook currently supports OS X, Windows, Debian/Ubuntu, and FreeBSD, and
the various RHEL variants. It uses the dmg, windows, apt, and freebsd community
cookbooks, respectively, for these platforms.
This cookbook currently supports OS X, Windows, Debian/Ubuntu, FreeBSD, the
assorted RHEL variants, and OpenSUSE. It uses the dmg, windows, apt, freebsd,
and zypper community cookbooks to enable that platform support.

Usage
=====
Expand Down Expand Up @@ -92,6 +92,10 @@ Provider for FreeBSD platforms.

Provider for Red Hat/CentOS/Scientific/Amazon/Fedora platforms.

***Chef::Provider::GimpApp::Opensuse***

Provider for OpenSUSE platforms.

***Chef::Provider::GimpApp::Package***

A generic provider for any platform that can install GIMP with a Chef package
Expand Down
1 change: 1 addition & 0 deletions libraries/provider_gimp_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
require_relative 'provider_gimp_app_debian'
require_relative 'provider_gimp_app_freebsd'
require_relative 'provider_gimp_app_mac_os_x'
require_relative 'provider_gimp_app_opensuse'
require_relative 'provider_gimp_app_rhel'
require_relative 'provider_gimp_app_windows'

Expand Down
47 changes: 47 additions & 0 deletions libraries/provider_gimp_app_opensuse.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Encoding: UTF-8
#
# Cookbook Name:: gimp
# Library:: provider_gimp_app_opensuse
#
# Copyright 2015 Jonathan Hartman
#
# 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.
#

require 'chef/provider/lwrp_base'
require 'chef/dsl/include_recipe'
require_relative 'provider_gimp_app'
require_relative 'provider_gimp_app_package'

class Chef
class Provider
class GimpApp < Provider::LWRPBase
# A GIMP provider for OpenSUSE.
#
# @author Jonathan Hartman <j@p4nt5.com>
class Opensuse < GimpApp::Package
include Chef::DSL::IncludeRecipe

#
# Update Zypper before trying to install the GIMP package.
#
# (see GimpApp::Package#install!)
#
def install!
include_recipe 'zypper'
super
end
end
end
end
end
3 changes: 3 additions & 0 deletions libraries/provider_mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@
resource: :gimp_app,
provider: Chef::Provider::GimpApp::Rhel)
end
Chef::Platform.set(platform: :opensuse,
resource: :gimp_app,
provider: Chef::Provider::GimpApp::Opensuse)
2 changes: 2 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
depends 'windows', '~> 1.37'
depends 'apt', '~> 2.7'
depends 'freebsd', '~> 0.3'
depends 'zypper', '~> 0.1'

supports 'mac_os_x'
supports 'windows'
Expand All @@ -24,4 +25,5 @@
supports 'scientific'
supports 'amazon'
supports 'fedora'
supports 'opensuse'
# rubocop:enable SingleSpaceBeforeFirstArg
21 changes: 21 additions & 0 deletions spec/libraries/provider_gimp_app_opensuse_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Encoding: UTF-8

require_relative '../spec_helper'
require_relative '../../libraries/provider_gimp_app_opensuse'

describe Chef::Provider::GimpApp::Opensuse do
let(:name) { 'default' }
let(:new_resource) { Chef::Resource::GimpApp.new(name, nil) }
let(:provider) { described_class.new(new_resource, nil) }

describe '#install!' do
it 'uses a package to install GIMP' do
p = provider
expect(p).to receive(:include_recipe).with('zypper')
expect(p).to receive(:package).with('gimp').and_yield
expect(p).to receive(:version).with(nil)
expect(p).to receive(:action).with(:install)
p.send(:install!)
end
end
end
8 changes: 8 additions & 0 deletions spec/libraries/provider_mapping_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,12 @@
end
end
end

context 'OpenSUSE' do
let(:platform) { :opensuse }

it 'uses the OpenSUSE app provider' do
expect(app_provider).to eq(Chef::Provider::GimpApp::Opensuse)
end
end
end
11 changes: 11 additions & 0 deletions spec/support/cookbooks/zypper/metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Encoding: UTF-8
#
# rubocop:disable SingleSpaceBeforeFirstArg
name 'zypper'
maintainer 'test'
maintainer_email 'example@example.com'
license 'apache2'
description 'zypper'
long_description 'zypper'
version '0.0.1'
# rubocop:enable SingleSpaceBeforeFirstArg
1 change: 1 addition & 0 deletions test/fixtures/cookbooks/gimp_test/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
supports 'scientific'
supports 'amazon'
supports 'fedora'
supports 'opensuse'
# rubocop:enable SingleSpaceBeforeFirstArg

0 comments on commit 47ac530

Please sign in to comment.