-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up providers to prep for addition of Windows + direct DL support
- Loading branch information
1 parent
5254e19
commit 4993d2a
Showing
10 changed files
with
267 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Encoding: UTF-8 | ||
# | ||
# Cookbook Name:: divvy | ||
# Library:: provider_divvy_app | ||
# | ||
# 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_relative 'resource_divvy_app' | ||
require_relative 'provider_divvy_app_mac_os_x' | ||
|
||
class Chef | ||
class Provider | ||
# A Chef provider for the Divvy app. | ||
# | ||
# @author Jonathan Hartman <j@p4nt5.com> | ||
class DivvyApp < Provider::LWRPBase | ||
use_inline_resources | ||
|
||
# | ||
# WhyRun is supported by this provider. | ||
# | ||
# @return [TrueClass, FalseClass] | ||
# | ||
def whyrun_supported? | ||
true | ||
end | ||
|
||
# | ||
# Install the app if it's not already. | ||
# | ||
action :install do | ||
install! | ||
new_resource.installed(true) | ||
end | ||
|
||
private | ||
|
||
# | ||
# Do the actual app installation. | ||
# | ||
# @raise [NotImplementedError] if not defined for this provider. | ||
# | ||
def install! | ||
fail(NotImplementedError, | ||
"`install!` method not implemented for #{self.class} provider") | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Encoding: UTF-8 | ||
# | ||
# Cookbook Name:: divvy | ||
# Library:: provider_divvy_app_mac_os_x | ||
# | ||
# 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_relative 'provider_divvy_app' | ||
require_relative 'provider_divvy_app_mac_os_x_app_store' | ||
|
||
class Chef | ||
class Provider | ||
class DivvyApp < Provider::LWRPBase | ||
# An empty parent class for the Divvy for OS X providers. | ||
# | ||
# @author Jonathan Hartman <j@p4nt5.com> | ||
class MacOsX < DivvyApp | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Encoding: UTF-8 | ||
# | ||
# Cookbook Name:: divvy | ||
# Library:: provider_divvy_app_mac_os_x_app_store | ||
# | ||
# 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_relative 'provider_divvy_app' | ||
require_relative 'provider_divvy_app_mac_os_x' | ||
|
||
class Chef | ||
class Provider | ||
class DivvyApp < Provider::LWRPBase | ||
class MacOsX < DivvyApp | ||
# A Chef provider for OS X App Store Divvy installs. | ||
# | ||
# @author Jonathan Hartman <j@p4nt5.com> | ||
class AppStore < MacOsX | ||
private | ||
|
||
# | ||
# (see DivvyApp#install!) | ||
# | ||
def install! | ||
mac_app_store_app 'Divvy - Window Manager' do | ||
bundle_id 'com.mizage.divvy' | ||
action :install | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
spec/libraries/provider_divvy_app_mac_os_x_app_store_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_divvy_app_mac_os_x_app_store' | ||
|
||
describe Chef::Provider::DivvyApp::MacOsX::AppStore do | ||
let(:name) { 'Some App' } | ||
let(:new_resource) { Chef::Resource::DivvyApp.new(name, nil) } | ||
let(:provider) { described_class.new(new_resource, nil) } | ||
|
||
describe '#install!' do | ||
it 'installs the app from the App Store' do | ||
p = provider | ||
expect(p).to receive(:mac_app_store_app).with('Divvy - Window Manager') | ||
.and_yield | ||
expect(p).to receive(:bundle_id).with('com.mizage.divvy') | ||
expect(p).to receive(:action).with(:install) | ||
p.send(:install!) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Encoding: UTF-8 | ||
|
||
require_relative '../spec_helper' | ||
require_relative '../../libraries/provider_divvy_app_mac_os_x' | ||
|
||
describe Chef::Provider::DivvyApp::MacOsX do | ||
let(:name) { 'Some App' } | ||
let(:new_resource) { Chef::Resource::DivvyApp.new(name, nil) } | ||
let(:provider) { described_class.new(new_resource, nil) } | ||
|
||
describe '#install!' do | ||
it 'raises an error' do | ||
expect { provider.send(:install!) }.to raise_error(NotImplementedError) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Encoding: UTF-8 | ||
|
||
require_relative '../spec_helper' | ||
require_relative '../../libraries/provider_divvy_app' | ||
|
||
describe Chef::Provider::DivvyApp do | ||
let(:name) { 'Some App' } | ||
let(:new_resource) { Chef::Resource::DivvyApp.new(name, nil) } | ||
let(:provider) { described_class.new(new_resource, nil) } | ||
|
||
describe '#whyrun_supported?' do | ||
it 'returns true' do | ||
expect(provider.whyrun_supported?).to eq(true) | ||
end | ||
end | ||
|
||
describe '#action_install' do | ||
before(:each) do | ||
allow_any_instance_of(described_class).to receive(:install!) | ||
end | ||
|
||
it 'calls the child `install!` method ' do | ||
expect_any_instance_of(described_class).to receive(:install!) | ||
provider.action_install | ||
end | ||
|
||
it 'sets the resource installed status' do | ||
p = provider | ||
p.action_install | ||
expect(p.new_resource.installed?).to eq(true) | ||
end | ||
end | ||
|
||
describe '#install!' do | ||
it 'raises an error' do | ||
expect { provider.send(:install!) }.to raise_error(NotImplementedError) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters