Skip to content

Commit

Permalink
Pedantic rubocop cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
davidski committed Sep 29, 2015
1 parent 7b81318 commit 9a4fad7
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 57 deletions.
4 changes: 2 additions & 2 deletions attributes/default.rb
Expand Up @@ -19,7 +19,7 @@
# limitations under the License.
#

default['r']['cran_mirror'] = "http://cran.fhcrc.org/"
default['r']['cran_mirror'] = 'http://cran.fhcrc.org/'

case node['platform_family']
when 'debian'
Expand All @@ -29,7 +29,7 @@
default['r']['version'] = '3.0.1'
default['r']['checksum'] = 'af90488af3141103b211dc81b6f17d1f0faf4f17684c579a32dfeb25d0d87134'
default['r']['install_method'] = 'source'
default['r']['config_opts'] = [ "--with-x=no" ]
default['r']['config_opts'] = ['--with-x=no']
end

default['r']['install_dev'] = true
11 changes: 5 additions & 6 deletions attributes/install.rb
@@ -1,9 +1,8 @@
include_attribute "r"

include_attribute 'r'

case node['r']['install_method']
when "package"
default['r']['install_dir'] = "/usr/lib/R"
when "source"
default['r']['install_dir'] = node['kernel']['machine'] == 'x86_64' ? "/usr/local/lib64/R" : "/usr/local/lib/R"
when 'package'
default['r']['install_dir'] = '/usr/lib/R'
when 'source'
default['r']['install_dir'] = node['kernel']['machine'] == 'x86_64' ? '/usr/local/lib64/R' : '/usr/local/lib/R'
end
10 changes: 5 additions & 5 deletions libraries/default.rb
@@ -1,8 +1,8 @@

def r_package_installed?(package)
require "rinruby"
R.echo(enable=false)
R.eval "packages = installed.packages()[,1]"
packages = R.pull "packages"
return packages.include?(package)
require 'rinruby'
R.echo(enable: false)
R.eval 'packages = installed.packages()[,1]'
packages = R.pull 'packages'
packages.include?(package)
end
22 changes: 11 additions & 11 deletions metadata.rb
@@ -1,15 +1,15 @@
name "r"
maintainer "Steven Danna"
maintainer_email "steve@opscode.com"
license "Apache 2.0"
description "Installs/Configures R"
name 'r'
maintainer 'Steven Danna'
maintainer_email 'steve@opscode.com'
license 'Apache 2.0'
description 'Installs/Configures R'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.3.0"
version '0.3.0'

depends "apt"
depends "ark"
depends "build-essential"
depends 'apt'
depends 'ark'
depends 'build-essential'
depends 'readline'

supports "ubuntu"
supports "centos"
supports 'ubuntu'
supports 'centos'
18 changes: 9 additions & 9 deletions providers/package.rb
Expand Up @@ -26,46 +26,46 @@ def whyrun_supported?

action :install do
if @current_resource.exists
Chef::Log.info "#{ @new_resource.name } already exists - nothing to do."
Chef::Log.info "#{@new_resource.name} already exists - nothing to do."
else
converge_by("Create #{ @new_resource.name }") do
converge_by("Create #{@new_resource.name}") do
install_package
end
end
end

action :upgrade do
converge_by("Create #{ @new_resource.name }") do
converge_by("Create #{@new_resource.name}") do
install_package
end
end

action :remove do
if @current_resource.exists
converge_by("Remove #{ @new_resource.name }") do
converge_by("Remove #{@new_resource.name}") do
remove_package
end
else
Chef::Log.info "#{ @new_resource.name } doesn't exists - nothing to do."
Chef::Log.info "#{@new_resource.name} doesn't exists - nothing to do."
end
end

def load_current_resource
@current_resource = Chef::Resource::RPackage.new(@new_resource.name)
@current_resource.name(@new_resource.name)
@current_resource.package(@new_resource.package)
if r_package_installed?(@current_resource.package)

only_if r_package_installed?(@current_resource.package) do
@current_resource.exists = true
end
end

def install_package
require "rinruby"
require 'rinruby'
R.eval "install.packages('#{new_resource.package}')", false
end

def remove_package
require "rinruby"
require 'rinruby'
R.eval "remove.packages('#{new_resource.package}')", false
end
10 changes: 4 additions & 6 deletions recipes/default.rb
Expand Up @@ -19,11 +19,9 @@
# limitations under the License.
#

chef_gem "rinruby"
chef_gem 'rinruby'

if node['r']['install_repo']
include_recipe "r::repo"
end
include_recipe 'r::repo' if node['r']['install_repo']

include_recipe "r::install_#{node['r']['install_method']}"

Expand All @@ -36,6 +34,6 @@
# Setting the default CRAN mirror makes
# remote administration of R much easier.
template "#{node['r']['install_dir']}/etc/Rprofile.site" do
mode "0555"
variables( :cran_mirror => node['r']['cran_mirror'])
mode '0555'
variables(cran_mirror: node['r']['cran_mirror'])
end
8 changes: 4 additions & 4 deletions recipes/install_source.rb
Expand Up @@ -20,15 +20,15 @@
#

r_version = node['r']['version']
major_version = r_version.split(".").first
major_version = r_version.split('.').first

# Command to check if we should be installing R or not.
is_installed_command = "R --version | grep -q #{r_version}"

package "gcc-gfortran"
package 'gcc-gfortran'

include_recipe "build-essential"
include_recipe "ark"
include_recipe 'build-essential'
include_recipe 'ark'

# required unless "--with-readline=no" is used
include_recipe 'readline'
Expand Down
26 changes: 13 additions & 13 deletions recipes/repo.rb
Expand Up @@ -21,28 +21,28 @@
#

case node['platform_family']
when "debian"
include_recipe "apt"
when 'debian'
include_recipe 'apt'

case node['platform']
when "debian"
postfix = if node['r']['version'] && node['r']['version'].split(".").first == "2"
""
when 'debian'
postfix = if node['r']['version'] && node['r']['version'].split('.').first == '2'
''
else
"3"
'3'
end
distro_name = "#{node['lsb']['codename']}-cran#{postfix}"
keyserver_url = "pgp.mit.edu"
key_id = "381BA480"
when "ubuntu"
keyserver_url = 'pgp.mit.edu'
key_id = '381BA480'
when 'ubuntu'
distro_name = node['lsb']['codename']
keyserver_url = "keyserver.ubuntu.com"
key_id = "E084DAB9"
keyserver_url = 'keyserver.ubuntu.com'
key_id = 'E084DAB9'
else
return "platform not supported"
return 'platform not supported'
end

apt_repository "cran-apt-repo" do
apt_repository 'cran-apt-repo' do
uri "#{node['r']['cran_mirror']}/bin/linux/#{node['platform']}"
distribution "#{distro_name}/"
components []
Expand Down
2 changes: 1 addition & 1 deletion resources/package.rb
Expand Up @@ -22,7 +22,7 @@
actions :install, :remove, :upgrade
default_action :install

attribute :package, :kind_of => String, :name_attribute => true
attribute :package, { kind_of: String }, name_attribute: true

attr_accessor :exists

Expand Down

0 comments on commit 9a4fad7

Please sign in to comment.