├── .foodcritic ├── .gitignore ├── .kitchen.docker.yml ├── .kitchen.yml ├── .rubocop.yml ├── .travis.yml ├── Berksfile ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Gemfile ├── LICENSE ├── MAINTAINERS.md ├── MAINTAINERS.toml ├── README.md ├── REDESIGN.md ├── Rakefile ├── TESTING.md ├── attributes └── default.rb ├── chefignore ├── definitions ├── ruby_packages.rb └── ruby_symlinks.rb ├── metadata.rb ├── recipes ├── 1.8.rb ├── 1.9.1.rb ├── 1.9.rb ├── default.rb └── symlinks.rb ├── spec ├── spec_helper.rb └── unit │ └── recipes │ └── default_spec.rb ├── tasks └── maintainers.rb └── test ├── fixtures └── cookbooks │ └── test │ ├── README.md │ ├── metadata.rb │ └── recipes │ └── default.rb └── integration └── default └── serverspec ├── default_spec.rb └── spec_helper.rb /.foodcritic: -------------------------------------------------------------------------------- 1 | ~FC015 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.rbc 2 | .config 3 | coverage 4 | InstalledFiles 5 | lib/bundler/man 6 | pkg 7 | rdoc 8 | spec/reports 9 | test/tmp 10 | test/version_tmp 11 | tmp 12 | _Store 13 | *~ 14 | *# 15 | .#* 16 | \#*# 17 | .*.sw[a-z] 18 | *.un~ 19 | *.tmp 20 | *.bk 21 | *.bkup 22 | 23 | # ruby/bundler files 24 | .ruby-version 25 | .ruby-gemset 26 | .rvmrc 27 | Gemfile.lock 28 | .bundle 29 | *.gem 30 | 31 | # YARD artifacts 32 | .yardoc 33 | _yardoc 34 | doc/ 35 | .idea 36 | 37 | #chef stuff 38 | Berksfile.lock 39 | .kitchen 40 | .kitchen.local.yml 41 | vendor/ 42 | .coverage/ 43 | .zero-knife.rb 44 | 45 | #vagrant stuff 46 | .vagrant/ 47 | .vagrant.d/ 48 | .kitchen/ 49 | -------------------------------------------------------------------------------- /.kitchen.docker.yml: -------------------------------------------------------------------------------- 1 | settings: 2 | parallel: true 3 | 4 | driver: 5 | name: docker 6 | # privileged is required otherwise the container doesn't boot right 7 | privileged: true 8 | 9 | platforms: 10 | - name: centos-6 11 | driver: 12 | image: centos:6 13 | platform: rhel 14 | run_command: /sbin/init 15 | provision_command: 16 | - /usr/bin/yum install -y initscripts net-tools wget 17 | - name: centos-7 18 | driver: 19 | image: centos:7 20 | platform: rhel 21 | run_command: /usr/lib/systemd/systemd 22 | provision_command: 23 | - /bin/yum install -y initscripts net-tools wget 24 | - name: ubuntu-12.04 25 | driver: 26 | image: ubuntu-upstart:12.04 27 | platform: ubuntu 28 | disable_upstart: false 29 | run_command: /sbin/init 30 | provision_command: 31 | - /usr/bin/apt-get update 32 | - /usr/bin/apt-get install apt-transport-https net-tools -y 33 | - name: ubuntu-14.04 34 | driver: 35 | image: ubuntu-upstart:14.04 36 | platform: ubuntu 37 | disable_upstart: false 38 | run_command: /sbin/init 39 | provision_command: 40 | - /usr/bin/apt-get update 41 | - /usr/bin/apt-get install apt-transport-https net-tools -y 42 | 43 | suites: 44 | - name: default 45 | run_list: 46 | - recipe[ruby::default] 47 | attributes: 48 | -------------------------------------------------------------------------------- /.kitchen.yml: -------------------------------------------------------------------------------- 1 | driver: 2 | name: vagrant 3 | 4 | provisioner: 5 | name: chef_zero 6 | 7 | platforms: 8 | - name: centos-5.11 9 | - name: centos-6.7 10 | - name: centos-7.2 11 | - name: debian-7.9 12 | run_list: apt::default 13 | - name: debian-8.2 14 | run_list: apt::default 15 | - name: fedora-22 16 | run_list: yum::dnf_yum_compat 17 | - name: fedora-23 18 | run_list: yum::dnf_yum_compat 19 | - name: ubuntu-12.04 20 | run_list: apt::default 21 | - name: ubuntu-14.04 22 | run_list: apt::default 23 | 24 | suites: 25 | - name: default 26 | run_list: 27 | - recipe[ruby::default] 28 | attributes: 29 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | AllCops: 2 | Exclude: 3 | - vendor/**/* 4 | - Guardfile 5 | 6 | AlignParameters: 7 | Enabled: false 8 | ClassLength: 9 | Enabled: false 10 | CyclomaticComplexity: 11 | Enabled: false 12 | Documentation: 13 | Enabled: false 14 | Encoding: 15 | Enabled: false 16 | Style/FileName: 17 | Enabled: false 18 | Style/Alias: 19 | Enabled: false 20 | Style/SpaceBeforeFirstArg: 21 | Enabled: false 22 | LineLength: 23 | Enabled: false 24 | MethodLength: 25 | Enabled: false 26 | Metrics/AbcSize: 27 | Enabled: false 28 | PerceivedComplexity: 29 | Enabled: false 30 | Style/ClassAndModuleChildren: 31 | Enabled: false 32 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | 3 | # install the pre-release chef-dk. Use chef-stable-precise to install the stable release 4 | addons: 5 | apt: 6 | sources: 7 | - chef-current-precise 8 | packages: 9 | - chefdk 10 | 11 | services: docker 12 | 13 | env: 14 | matrix: 15 | - INSTANCE=default-ubuntu-1204 16 | - INSTANCE=default-ubuntu-1404 17 | - INSTANCE=default-centos-6 18 | - INSTANCE=default-centos-7 19 | 20 | # Don't `bundle install` 21 | install: echo "skip bundle install" 22 | 23 | # Ensure we make ChefDK's Ruby the default 24 | before_script: 25 | # https://github.com/zuazo/kitchen-in-travis-native/issues/1#issuecomment-142230889 26 | - sudo iptables -L DOCKER || ( echo "DOCKER iptables chain missing" ; sudo iptables -N DOCKER ) 27 | - eval "$(/opt/chefdk/bin/chef shell-init bash)" 28 | - /opt/chefdk/embedded/bin/chef gem install kitchen-docker 29 | - /opt/chefdk/embedded/bin/chef gem install rubocop -v 0.37 30 | script: 31 | - /opt/chefdk/embedded/bin/chef --version 32 | - /opt/chefdk/embedded/bin/rubocop --version 33 | - /opt/chefdk/embedded/bin/rubocop 34 | - /opt/chefdk/embedded/bin/foodcritic --version 35 | - /opt/chefdk/embedded/bin/foodcritic . --exclude spec 36 | - /opt/chefdk/embedded/bin/rspec 37 | - KITCHEN_LOCAL_YAML=.kitchen.docker.yml /opt/chefdk/embedded/bin/kitchen verify ${INSTANCE} 38 | -------------------------------------------------------------------------------- /Berksfile: -------------------------------------------------------------------------------- 1 | source 'https://supermarket.chef.io' 2 | 3 | metadata 4 | 5 | group :integration do 6 | cookbook 'yum' 7 | cookbook 'apt' 8 | cookbook 'test', path: './test/fixtures/cookbooks/test' 9 | end 10 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # ruby Cookbook CHANGELOG 2 | This file is used to list changes made in each version of the ruby cookbook. 3 | 4 | ## v1.0.0 (2016-02-08) 5 | - Marking this cookbook as officially deprecated. See the readme for additional information 6 | - Added support for RHEL 7 and new Fedora package naming schemas 7 | - Expanded Test Kitchen testing platforms and added serverspec tests 8 | - Added Travis CI testing and integration testing with Kitchen Docker 9 | - Added Rubocop config and resolved all issues 10 | - Resolved foodcritic warnings and added a .foodcritic file to disable the definition warning 11 | - Updated contributing and testing documentation 12 | - Add maintainers.md file 13 | - Added a Rakefile for simplified testing 14 | - Added a chefignore file to reduce the number of files uploaded to the chef server 15 | - Added suse to the metadata.rb 16 | - Added issues_url and source_url to the metadata.rb 17 | - Added a simple chefspec to ensure the compile phase completes 18 | 19 | ## v0.9.3 20 | The "Don't Be Hasty" release. 21 | - Remove `ruby-mode` package (fixes several issues) 22 | - Add `name` to metadata (also fixes several issues) 23 | - Create test kitchen harness 24 | - CHEF is now the maintainer 25 | - Create `cookbook_version` attribute to specify the version originating from the cookbook. **This is an internally used attribute primarily, and may change in the future, or be removed**. 26 | 27 | ## v0.9.2 28 | - "Initial" public release. 29 | - First entry in the CHANGELOG.md, because we have to start somewhere. 30 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Please refer to 2 | https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD 3 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | group :rake do 4 | gem 'rake' 5 | gem 'tomlrb' 6 | end 7 | 8 | group :lint do 9 | gem 'foodcritic', '~> 6.0' 10 | gem 'rubocop', '~> 0.36' 11 | end 12 | 13 | group :unit do 14 | gem 'berkshelf', '~> 4.0' 15 | gem 'chefspec', '~> 4.5' 16 | end 17 | 18 | group :kitchen_common do 19 | gem 'test-kitchen', '~> 1.5' 20 | end 21 | 22 | group :kitchen_vagrant do 23 | gem 'kitchen-vagrant', '~> 0.19' 24 | end 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /MAINTAINERS.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Maintainers 4 | This file lists how this cookbook project is maintained. When making changes to the system, this 5 | file tells you who needs to review your patch - you need a simple majority of maintainers 6 | for the relevant subsystems to provide a :+1: on your pull request. Additionally, you need 7 | to not receive a veto from a Lieutenant or the Project Lead. 8 | 9 | Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) 10 | for details on the process and how to become a maintainer or the project lead. 11 | 12 | # Project Maintainer 13 | * [Tim Smith](https://github.com/tas50) 14 | 15 | # Maintainers 16 | * [Jennifer Davis](https://github.com/sigje) 17 | * [Sean OMeara](https://github.com/someara) 18 | * [Tim Smith](https://github.com/tas50) 19 | * [Thom May](https://github.com/thommay) 20 | -------------------------------------------------------------------------------- /MAINTAINERS.toml: -------------------------------------------------------------------------------- 1 | # 2 | # This file is structured to be consumed by both humans and computers. 3 | # It is a TOML document containing Markdown 4 | # 5 | [Preamble] 6 | title = "Maintainers" 7 | text = """ 8 | This file lists how this cookbook project is maintained. When making changes to the system, this 9 | file tells you who needs to review your patch - you need a simple majority of maintainers 10 | for the relevant subsystems to provide a :+1: on your pull request. Additionally, you need 11 | to not receive a veto from a Lieutenant or the Project Lead. 12 | 13 | Check out [How Cookbooks are Maintained](https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/CONTRIBUTING.MD) 14 | for details on the process and how to become a maintainer or the project lead. 15 | """ 16 | 17 | [Org] 18 | [Org.Components] 19 | [Org.Components.Core] 20 | title = "Project Maintainer" 21 | 22 | lieutenant = 'tas50' 23 | 24 | maintainers = [ 25 | 'sigje', 26 | 'someara', 27 | 'tas50', 28 | 'thommay' 29 | ] 30 | 31 | [people] 32 | [people.sigje] 33 | name = "Jennifer Davis" 34 | github = "sigje" 35 | 36 | [people.someara] 37 | name = "Sean OMeara" 38 | github = "someara" 39 | 40 | [people.tas50] 41 | name = "Tim Smith" 42 | github = "tas50" 43 | 44 | [people.thommay] 45 | name = "Thom May" 46 | github = "thommay" 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ruby Cookbook 2 | [![Build Status](https://travis-ci.org/chef-cookbooks/ruby.svg?branch=master)](http://travis-ci.org/chef-cookbooks/ruby) [![Cookbook Version](https://img.shields.io/cookbook/v/ruby.svg)](https://supermarket.chef.io/cookbooks/ruby) 3 | 4 | Installs Ruby and related packages. 5 | 6 | # DEPRECATION NOTICE 7 | As the pace of Ruby development has increased and the era of Ruby 1.8 / 1.9 has come to an end, we see little need for this cookbook. It is officially considered deprecated, and we recommend against its use. We're open to a complete rethinking of the cookbook with a whole new codebase and functionality. If you're interested shoot us an e-mail at cookbooks@chef.io 8 | 9 | # Requirements 10 | ## Platform 11 | Tested on Ubuntu 10.04. Debian and Gentoo should also work fully. CentOS, Red Hat, Fedora and Arch are partially supported. 12 | 13 | # Attributes 14 | - `node[:languages][:ruby][:default_version]` - The Ruby version to install 15 | - with the ruby recipe and create symlinks for with the symlinks 16 | - recipe. 17 | 18 | # Usage 19 | Previous versions of this cookbook gave you no control over which version of Ruby would be installed. We are now in the middle of an awkward period where you are equally likely to want 1.8 or 1.9. You may even want both. This is now catered for. To install specific versions side-by-side, use the 1.8, 1.9 or 1.9.1 recipes. The ruby recipe will install the version specified by `node[:languages][:ruby][:default_version]`. If you want to do something other than install these packages, the `ruby_packages` definition is provided as a wrapper around the package resource. Just specify the version number. 20 | 21 | For example, to use the default recipe in a role named "base", use 'ruby' in the run list and set the `node[:languages[:ruby][:default_version]` attribute: 22 | 23 | ``` 24 | { 25 | "name": "base", 26 | "description": "Base role is applied to all systems", 27 | "json_class": "Chef::Role", 28 | "default_attributes": { 29 | }, 30 | "override_attributes": { 31 | "languages": { 32 | "ruby": { 33 | "default_version": "1.8" 34 | } 35 | } 36 | }, 37 | "chef_type": "role", 38 | "run_list": [ 39 | "recipe[ruby]" 40 | ] 41 | } 42 | ``` 43 | 44 | Many scripts, including those provided by Rails, don't ask for a particular version of Ruby such as "ruby1.8" and simply look for "ruby" instead. Sometimes a symlink is provided and sometimes the executable is simply called "ruby" in the first place but generally speaking, it is difficult to predict this behaviour, especially when Ruby Gems is thrown into the mix. The symlinks recipe seeks to relieve you of this headache by creating symlinks for the common executables pointing to the Ruby version specified by `node[:languages][:ruby][:default_version]`. This is also available as a definition called +ruby_symlinks+, which is a wrapper around the link resource. As before, just specify the version number. Non-symlinks will not be overwritten unless you set force to true. You can also set a path other than /usr/bin if necessary. 45 | 46 | _IMPORTANT!_ Only Ubuntu, Debian and Gentoo support installing a specific Ruby version at all. yum-based distributions install 1.8 by default but require you to give the full package version otherwise. Maybe some magic could be added to Chef? Arch installs 1.9.2 by default but 1.8 is only available from AUR. Additionally, Ubuntu and Debian group 1.9.2 with 1.9.1 while Gentoo lumps all 1.9 releases together. 47 | 48 | # License and Author 49 | - Author: Joshua Timberman ([joshua@chef.io](mailto:joshua@chef.io)) 50 | - James Le Cuirot ([developers@findsyou.com](mailto:developers@findsyou.com)) 51 | - ```text 52 | - Copyright 2009-2015, Chef Software, Inc. 53 | - Copyright: 2010, FindsYou Limited 54 | 55 | 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 56 | 57 | ``` 58 | http://www.apache.org/licenses/LICENSE-2.0 59 | ``` 60 | 61 | 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. ``` 62 | -------------------------------------------------------------------------------- /REDESIGN.md: -------------------------------------------------------------------------------- 1 | # Redesign Proposal 2 | 3 | ## Out of Scope 4 | 5 | - this IS NOT an rvm cookbook 6 | - this IS NOT an rbenv cookbook 7 | - this IS NOT a chruby cookbook 8 | 9 | ## Problem 10 | 11 | Existing ruby cookbooks all try to do too many things and fail to deliver useful use cases to 12 | either library cookbooks or users. 13 | 14 | They rely on overriding attributes and source-vs-binary package installs and try to do too much. 15 | 16 | Mostly cookbooks want to have a sane way of saying 'i want a ruby in the path' or 'i need at least 17 | ruby 2.1 installed somewhere'. These use cases can be dealt with using recipes, but should not 18 | be attribute driven. 19 | 20 | Users want the ability to install either from packages easily or to build a given exact version of 21 | ruby and install it someone custom -- maybe wiring up to /usr/local or not. These use cases should 22 | be entirely resource-driven. 23 | 24 | ## Requirements 25 | 26 | ### Resource Driven Cookbook With No Attributes 27 | 28 | Any new 2.0 version of this cookbook MUST be attribute-free and MUST be implemented using 12.x style 29 | new resources. The implementation of the cookbook SHOULD be designed so that it MAY be included into 30 | chef-client core at some later date. 31 | 32 | There will be no 'source'-vs-'package' attribute, no way to override attributes, etc. 33 | 34 | ### Package Installs 35 | 36 | Package installs will generally install the latest version of ruby on the operating system. This will 37 | mostly be offered as a default installation method for community cookbooks which only wish to declare that they 38 | want "A" version of ruby installed and do not care. As some of the operating systems that we support 39 | install ruby 1.8.5 and other old rubies by default use of package installs is asserting that either those 40 | distros are unsupported, or that the cookbook is back-compat to the oldest ruby on the oldest operating 41 | system that it supports. 42 | 43 | This also may be acceptable for individual users who are only concerned with one distro version who 44 | want to install that ruby and use it. 45 | 46 | There is an issue with more recent Ubuntu versions where there are multiple different versions of ruby 47 | in packages. The proposed solution for this is to install the highest supported version of ruby on 48 | the distro (PPAs and external repos are out of scope). Package installs will NOT support installing 49 | from different locations or installing different ruby package versions. 50 | 51 | ### Source Installs 52 | 53 | Source installs should be handled by a resource. The implementation should likely use the ruby-install gem. 54 | It should be possible to fully customize the installation location of the ruby. 55 | 56 | ### "I NEED RUBY" 57 | 58 | There needs to be a way for a cookbook to depend on the ruby cookbook such that ANY installed ruby via ANY 59 | method is fine with it. There is no control over the version, and typically this will default to a package 60 | install. If the user has installed ruby via source for some other version, and wired that version up to 61 | the PATH, then that will satisfy this requirement and no package installation or source installation will 62 | occur. 63 | 64 | ### "I NEED RUBY X.Y.Z" 65 | 66 | Cookbooks that want to specify a version of ruby MUST use the source-installing resource. If a cookbook wants 67 | a ruby >= 2.1, and wants it to be portable, it MUST use the source installation method. 68 | 69 | ### Recipes 70 | 71 | FIXME: no recipes this is just the "I NEED RUBY" resource use case 72 | 73 | The default recipe MUST be equivalent to the "I NEED RUBY" use case. This use case asserts "i do not care, I just 74 | need ruby in my PATH". 75 | 76 | Any source install which wires up its ruby to the PATH will also satisfy this use case. 77 | 78 | This recipe MUST not be tweakable by attributes. 79 | 80 | If a ruby has been installed via packages or installed via source and wired up to the PATH, this recipe is a NOP 81 | 82 | ### Ruby Version Recipes 83 | 84 | FIXME: no recipes this is just the "I NEED RUBY >= 2.1" resource use case 85 | 86 | These recipe are satisfied if the appropriate ruby version has been source installed into the server. We need 87 | a library method to query so that the cookbook can determine where the ruby version it wants has been installed. 88 | 89 | There needs to be a default location to install the ruby, and it MUST not wire these ruby versions up to /usr/local. 90 | 91 | These recipes MUST not be tweakable by attributes, they feed state to each other via state held in libraries. 92 | 93 | ## Implementation Details 94 | 95 | ### ruby-install and Omnibus Chef 96 | 97 | The source installs MUST use ruby-install rather than rolling its own use case. The cookbook MUST assume omnibus-chef 98 | and a recent enough ruby that ruby-install works. Porting the cookbook to gem installs on RHEL5 is explicitly 99 | out of scope. 100 | 101 | ### Library helpers 102 | 103 | This cookbook will need to track how it is invoked. 104 | 105 | When cookbooks declare that they want 'A' ruby in the PATH that needs to be satisfied by later declarations to 106 | either package install ruby or to source install ruby and wire it up to /usr/local. 107 | 108 | When cookbooks declare that they want 'A' ruby-2.1 then that needs to be satisfied by later declarations to 109 | install ruby 2.1 somewhere. 110 | 111 | Cookbooks need an API to determine where the user installed ruby-2.1 112 | 113 | This design REPLACES attributes with state held in PORO in library files that is driven by resources. 114 | 115 | ### Symlinks 116 | 117 | Resources should take an argument to wire up symlinks to a user specified directory (e.g. `/usr/local`) 118 | 119 | ### S3 upload/download 120 | 121 | Building ruby from source takes a long time, there should be a way to build it once on a server, upload to an S3 122 | bucket and then download from the bucket (see https://github.com/lamont-granquist/sk_ruby) 123 | 124 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rspec/core/rake_task' 2 | require 'rubocop/rake_task' 3 | require 'foodcritic' 4 | require 'kitchen' 5 | 6 | require_relative 'tasks/maintainers' 7 | 8 | # Style tests. Rubocop and Foodcritic 9 | namespace :style do 10 | desc 'Run Ruby style checks' 11 | RuboCop::RakeTask.new(:ruby) 12 | 13 | desc 'Run Chef style checks' 14 | FoodCritic::Rake::LintTask.new(:chef) do |t| 15 | t.options = { 16 | fail_tags: ['any'] 17 | } 18 | end 19 | end 20 | 21 | desc 'Run all style checks' 22 | task style: ['style:chef', 'style:ruby'] 23 | 24 | # Rspec and ChefSpec 25 | desc 'Run ChefSpec examples' 26 | RSpec::Core::RakeTask.new(:spec) 27 | 28 | # Integration tests. Kitchen.ci 29 | namespace :integration do 30 | desc 'Run Test Kitchen with Vagrant' 31 | task :vagrant do 32 | Kitchen.logger = Kitchen.default_file_logger 33 | Kitchen::Config.new.instances.each do |instance| 34 | instance.test(:always) 35 | end 36 | end 37 | end 38 | 39 | desc 'Run all tests on Travis' 40 | task travis: ['style', 'spec', 'integration:cloud'] 41 | 42 | # Default 43 | task default: ['style', 'spec', 'integration:vagrant'] 44 | -------------------------------------------------------------------------------- /TESTING.md: -------------------------------------------------------------------------------- 1 | Please refer to 2 | https://github.com/chef-cookbooks/community_cookbook_documentation/blob/master/TESTING.MD 3 | -------------------------------------------------------------------------------- /attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Author: Joshua Timberman 3 | # Copyright (c) 2014, Chef Software, Inc 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | default['ruby']['cookbook_version'] = case node['platform_family'] 19 | when 'debian' then '1.9.1' 20 | when 'gentoo' then '1.9' 21 | when 'smartos' then '193' 22 | when 'rhel', 'fedora' then 'unused' 23 | else 24 | node['languages']['ruby']['version'] 25 | end 26 | -------------------------------------------------------------------------------- /chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # to a chef-server or supermarket. 3 | # Lines that start with '# ' are comments. 4 | 5 | # OS generated files # 6 | ###################### 7 | .DS_Store 8 | Icon? 9 | nohup.out 10 | ehthumbs.db 11 | Thumbs.db 12 | 13 | # SASS # 14 | ######## 15 | .sass-cache 16 | 17 | # EDITORS # 18 | ########### 19 | \#* 20 | .#* 21 | *~ 22 | *.sw[a-z] 23 | *.bak 24 | REVISION 25 | TAGS* 26 | tmtags 27 | *_flymake.* 28 | *_flymake 29 | *.tmproj 30 | .project 31 | .settings 32 | mkmf.log 33 | 34 | ## COMPILED ## 35 | ############## 36 | a.out 37 | *.o 38 | *.pyc 39 | *.so 40 | *.com 41 | *.class 42 | *.dll 43 | *.exe 44 | */rdoc/ 45 | 46 | # Testing # 47 | ########### 48 | .watchr 49 | .rspec 50 | spec/* 51 | spec/fixtures/* 52 | test/* 53 | features/* 54 | examples/* 55 | Guardfile 56 | Procfile 57 | .kitchen* 58 | .rubocop.yml 59 | spec/* 60 | Rakefile 61 | .travis.yml 62 | .foodcritic 63 | .codeclimate.yml 64 | 65 | # SCM # 66 | ####### 67 | .git 68 | */.git 69 | .gitignore 70 | .gitmodules 71 | .gitconfig 72 | .gitattributes 73 | .svn 74 | */.bzr/* 75 | */.hg/* 76 | */.svn/* 77 | 78 | # Berkshelf # 79 | ############# 80 | Berksfile 81 | Berksfile.lock 82 | cookbooks/* 83 | tmp 84 | 85 | # Cookbooks # 86 | ############# 87 | CONTRIBUTING* 88 | CHANGELOG* 89 | TESTING* 90 | MAINTAINERS.toml 91 | 92 | # Strainer # 93 | ############ 94 | Colanderfile 95 | Strainerfile 96 | .colander 97 | .strainer 98 | 99 | # Vagrant # 100 | ########### 101 | .vagrant 102 | Vagrantfile 103 | -------------------------------------------------------------------------------- /definitions/ruby_packages.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby 3 | # Definition:: ruby_packages 4 | # 5 | # Copyright 2008-2009, Opscode, Inc. 6 | # Copyright 2010, FindsYou Limited 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | 21 | define :ruby_packages, action: :install do 22 | rv = params[:name].to_s 23 | raise 'A Ruby version such as 1.8, 1.9 or 1.9.1 must be given' if rv.empty? 24 | 25 | packages = case node['platform_family'] 26 | when 'debian' 27 | [ 28 | "ruby#{rv}-full", 29 | "libopenssl-ruby#{rv}", 30 | ('libshadow-ruby1.8' if rv == '1.8') 31 | ].compact 32 | 33 | when 'gentoo' 34 | rv = rv.slice(0..2) 35 | target = 'ruby' + rv.delete('.') 36 | 37 | [ 38 | # ruby-ssl is before ruby to ensure that ruby is initially 39 | # installed with the ssl USE flag enabled. 40 | "virtual/ruby-ssl:#{target}", 41 | "dev-lang/ruby:#{rv}", 42 | "virtual/ruby-rdoc:#{target}", 43 | ('dev-ruby/ruby-shadow' if rv == '1.8') 44 | ].compact 45 | 46 | when 'rhel' 47 | if node['platform_version'].to_i >= 7 48 | %w( 49 | ruby 50 | ruby-doc 51 | ruby-libs 52 | ruby-devel 53 | ruby-irb 54 | ) 55 | else 56 | %w( 57 | ruby 58 | ruby-ri 59 | ruby-docs 60 | ruby-rdoc 61 | ruby-libs 62 | ruby-devel 63 | ruby-irb 64 | ) 65 | end 66 | 67 | when 'fedora' 68 | if node['platform_version'].to_i >= 20 69 | %w( 70 | ruby 71 | ruby-doc 72 | ruby-libs 73 | ruby-devel 74 | ruby-irb 75 | ) 76 | else 77 | %w( 78 | ruby 79 | ruby-ri 80 | ruby-docs 81 | ruby-rdoc 82 | ruby-libs 83 | ruby-devel 84 | ruby-irb 85 | ) 86 | end 87 | 88 | when 'arch' 89 | # 1.8 only available from AUR. :( 90 | %w( 91 | ruby 92 | ruby-docs 93 | ) 94 | 95 | when 'smartos' 96 | ["ruby-#{rv}"] 97 | end 98 | 99 | unless packages.nil? 100 | packages.each do |pkg| 101 | package pkg do 102 | action params[:action] 103 | end 104 | end 105 | end 106 | end 107 | -------------------------------------------------------------------------------- /definitions/ruby_symlinks.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby 3 | # Definition:: ruby_symlinks 4 | # 5 | # Copyright 2010, FindsYou Limited 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | define :ruby_symlinks, action: :create, force: false, path: '/usr/bin' do 21 | rv = params[:name].to_s 22 | rv = rv.slice(0..2).delete('.') if node['platform'] == 'gentoo' 23 | 24 | %w( ruby irb erb ri testrb rdoc gem rake ).each do |name| 25 | path = ::File.join(params[:path], name) 26 | scope = self 27 | 28 | link path do 29 | to path + rv 30 | action params[:action] 31 | 32 | unless params[:force] 33 | not_if do 34 | if ::File.exist?(path) && !::File.symlink?(path) 35 | scope.log "Not modifying non-symbolic-link #{path}" 36 | true 37 | end 38 | end 39 | end 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | name 'ruby' 2 | maintainer 'Chef Software, Inc.' 3 | maintainer_email 'cookbooks@chef.io' 4 | license 'Apache 2.0' 5 | description 'Installs Ruby and related packages' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '1.0.0' 8 | 9 | recipe 'ruby', 'Installs Ruby and related packages' 10 | recipe '1.8', 'Installs Ruby 1.8 and related packages' 11 | recipe '1.9', 'Installs Ruby 1.9 and related packages' 12 | recipe '1.9.1', 'Installs Ruby 1.9.1 and related packages' 13 | recipe 'symlinks', 'Installs symlinks for the default Ruby version' 14 | 15 | %w( amazon arch centos debian fedora gentoo oracle redhat scientific suse ubuntu ).each do |os| 16 | supports os 17 | end 18 | 19 | source_url 'https://github.com/chef-cookbooks/ruby' if respond_to?(:source_url) 20 | issues_url 'https://github.com/chef-cookbooks/ruby/issues' if respond_to?(:issues_url) 21 | -------------------------------------------------------------------------------- /recipes/1.8.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby 3 | # Recipe:: 1.8 4 | # 5 | # Copyright 2010, FindsYou Limited 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | log 'ruby-1.8-unsupported' do 20 | message <<-EOH 21 | Ruby 1.8 is EOL and unsupported upstream. 22 | Consider upgrading to a current, supported version. 23 | https://www.ruby-lang.org/en/news/2013/06/30/we-retire-1-8-7/ 24 | EOH 25 | level :warn 26 | end 27 | 28 | ruby_packages '1.8' 29 | -------------------------------------------------------------------------------- /recipes/1.9.1.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby 3 | # Recipe:: 1.9.1 4 | # 5 | # Copyright 2010, FindsYou Limited 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | ruby_packages '1.9.1' 21 | -------------------------------------------------------------------------------- /recipes/1.9.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby 3 | # Recipe:: 1.9 4 | # 5 | # Copyright 2010, FindsYou Limited 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | ruby_packages '1.9' 21 | -------------------------------------------------------------------------------- /recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby 3 | # Recipe:: default 4 | # 5 | # Copyright 2010, FindsYou Limited 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | ruby_packages node['ruby']['cookbook_version'] 21 | -------------------------------------------------------------------------------- /recipes/symlinks.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: ruby 3 | # Recipe:: symlinks 4 | # 5 | # Copyright 2010, FindsYou Limited 6 | # 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # 19 | 20 | ruby_symlinks node['languages']['ruby']['default_version'] || '1.8' 21 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'chefspec' 2 | require 'chefspec/berkshelf' 3 | 4 | at_exit { ChefSpec::Coverage.report! } 5 | -------------------------------------------------------------------------------- /spec/unit/recipes/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'default recipe on Ubuntu 14.04' do 4 | let(:chef_run) do 5 | ChefSpec::ServerRunner.new do |node| 6 | node.automatic[:lsb][:codename] = 'trusty' 7 | end.converge('ruby::default') 8 | end 9 | 10 | it 'converges successfully' do 11 | expect { :chef_run }.to_not raise_error 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /tasks/maintainers.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright:: Copyright (c) 2015 Chef Software, Inc. 3 | # License:: Apache License, Version 2.0 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | require 'rake' 19 | 20 | SOURCE = File.join(File.dirname(__FILE__), '..', 'MAINTAINERS.toml') 21 | TARGET = File.join(File.dirname(__FILE__), '..', 'MAINTAINERS.md') 22 | 23 | begin 24 | require 'tomlrb' 25 | task default: 'maintainers:generate' 26 | 27 | namespace :maintainers do 28 | desc 'Generate MarkDown version of MAINTAINERS file' 29 | task :generate do 30 | @toml = Tomlrb.load_file SOURCE 31 | out = "\n\n" 32 | 33 | out << preamble 34 | out << project_lieutenant 35 | out << all_maintainers 36 | 37 | File.open(TARGET, 'w') do |fn| 38 | fn.write out 39 | end 40 | end 41 | end 42 | 43 | rescue LoadError 44 | STDERR.puts "\n*** TomlRb not available.\n\n" 45 | end 46 | 47 | private 48 | 49 | def preamble 50 | <<-EOL 51 | # #{@toml['Preamble']['title']} 52 | #{@toml['Preamble']['text']} 53 | EOL 54 | end 55 | 56 | def project_lieutenant 57 | <<-EOL 58 | # #{@toml['Org']['Components']['Core']['title']} 59 | #{github_link(@toml['Org']['Components']['Core']['lieutenant'])} 60 | 61 | EOL 62 | end 63 | 64 | def all_maintainers 65 | text = "# Maintainers\n" 66 | @toml['Org']['Components']['Core']['maintainers'].each do |m| 67 | text << "#{github_link(m)}\n" 68 | end 69 | text 70 | end 71 | 72 | def github_link(person) 73 | name = @toml['people'][person]['name'] 74 | github = @toml['people'][person]['github'] 75 | "* [#{name}](https://github.com/#{github})" 76 | end 77 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/test/README.md: -------------------------------------------------------------------------------- 1 | # test 2 | 3 | Cookbook used for testing parent 4 | 5 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/test/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'test' 2 | version '0.1.0' 3 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/test/recipes/default.rb: -------------------------------------------------------------------------------- 1 | execute 'apt-get update' if platform_family?('debian') 2 | -------------------------------------------------------------------------------- /test/integration/default/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | ruby_ver = case os[:family] 4 | when 'debian', 'ubuntu' 5 | 'ruby1.9.1' 6 | else 7 | 'ruby' 8 | end 9 | 10 | describe package(ruby_ver) do 11 | it { should be_installed } 12 | end 13 | 14 | describe file("/usr/bin/#{ruby_ver}") do 15 | it { should be_file } 16 | it { should be_executable } 17 | end 18 | -------------------------------------------------------------------------------- /test/integration/default/serverspec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | # Required by serverspec 4 | set :backend, :exec 5 | --------------------------------------------------------------------------------