code
stringlengths
1
1.73M
language
stringclasses
1 value
Blog::Application.routes.draw do resources :locations resources :users resources :posts do resources :comments end resources :events do resources :responses end get "home/index" post 'user/signup', :to => 'users#signup' match '/login', :to => 'users#login', :as => 'login' match '...
Ruby
# Be sure to restart your server when you modify this file. Blog::Application.config.session_store :cookie_store, :key => '_blog_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table with "rails gene...
Ruby
# Be sure to restart your server when you modify this file. # # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters ...
Ruby
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attac...
Ruby
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a probl...
Ruby
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
Ruby
ActionMailer::Base.smtp_settings = { :address => 'smtp.sendgrid.net', :port => '587', :authentication => :plain, :user_name => ENV['SENDGRID_USERNAME'], :password => ENV['SENDGRID_PASSWORD'], :domain => 'heroku.com' } ActionMailer::Base.delivery_method = :smtp
Ruby
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format # (all these examples are active by default): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', ...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Blog::Application.initialize! #config.action_mailer.delivery_method = :smtp #mailer not working since service is not provided without paying
Ruby
require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
Ruby
require File.expand_path('../boot', __FILE__) require 'rails/all' if defined?(Bundler) # If you precompile assets before deploying to production, use this line Bundler.require(*Rails.groups(:assets => %w(development test))) # If you want your assets lazily compiled in production, use this line # Bundler.requi...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "css" sass_dir = "scss" images_dir = "images" javascripts_dir = "js" fonts_dir = "fonts" output_style = :expanded # To enable relative paths to assets via compass helper functions. Uncomment...
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'data_mapper', '~> 1.2' gem 'dm-postgres-adapter' gem 'google-api-client', '>= 0.4.3' group :development do gem 'dm-sqlite-adapter', '~> 1.2' gem 'do_sqlite3', '~> 0.10' end
Ruby
# Copyright (C) 2012 Google Inc. # # 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 writ...
Ruby
# -*- mode: ruby -*- # vi: set ft=ruby : require 'rubygems' require 'json' def configure_box(index, config) name = "local_dev-#{index}".intern config.vm.customize ["modifyvm", :id, "--memory", 1024*6] ip = "192.168.50.42" config.vm.define name do |slave_conf| slave_conf.vm.box = "precise" slave_con...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the chomp function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("chomp").should == "function_chomp" end it "should raise a ParseError if there is less than 1 arguments" do ...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the to_bytes function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("to_bytes").should == "function_to_bytes" end it "should raise a ParseError if there is less than 1 argume...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_array function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_array").should == "function_is_array" end it "should raise a ParseError if there is less than 1 argumen...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe Puppet::Parser::Functions.function(:get_module_path) do Internals = PuppetlabsSpec::PuppetInternals class StubModule attr_reader :path def initialize(path) @path = path end end def scope(environment = "production") Internals.sc...
Ruby
#! /usr/bin/env/ruby -S rspec require 'spec_helper' describe Puppet::Parser::Functions.function(:validate_bool) do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } describe 'when calling validate_bool from puppet' do %w{ true false }.each do |the_string| it "should not compile when #{the_string} ...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the member function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("member").should == "function_member" end it "should raise a ParseError if there is less than 1 arguments" do...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the parseyaml function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("parseyaml").should == "function_parseyaml" end it "should raise a ParseError if there is less than 1 argu...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe Puppet::Parser::Functions.function(:validate_array) do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } describe 'when calling validate_array from puppet' do %w{ true false }.each do |the_string| it "should not compile when #{the_string}...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the bool2num function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("bool2num").should == "function_bool2num" end it "should raise a ParseError if there is less than 1 argumen...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the size function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("size").should == "function_size" end it "should raise a ParseError if there is less than 1 arguments" do l...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the keys function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("keys").should == "function_keys" end it "should raise a ParseError if there is less than 1 arguments" do l...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe Puppet::Parser::Functions.function(:has_key) do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } describe 'when calling has_key from puppet' do it "should not compile when no arguments are passed" do pending("Fails on 2.6.x, see bug #1591...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the str2saltedsha512 function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("str2saltedsha512").should == "function_str2saltedsha512" end it "should raise a ParseError if ther...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the sort function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("sort").should == "function_sort" end it "should raise a ParseError if there is not 1 arguments" do lambda ...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the type function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("type").should == "function_type" end it "should raise a ParseError if there is less than 1 arguments" do la...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_numeric function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_numeric").should == "function_is_numeric" end it "should raise a ParseError if there is less than 1 a...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the strip function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("strip").should == "function_strip" end it "should raise a ParseError if there is less than 1 arguments" do ...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_domain_name function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_domain_name").should == "function_is_domain_name" end it "should raise a ParseError if there is l...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the num2bool function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("num2bool").should == "function_num2bool" end it "should raise a ParseError if there is less than 1 argumen...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the swapcase function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("swapcase").should == "function_swapcase" end it "should raise a ParseError if there is less than 1 argumen...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_integer function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_integer").should == "function_is_integer" end it "should raise a ParseError if there is less than 1 a...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the range function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("range").should == "function_range" end it "should raise a ParseError if there is less than 1 arguments" do ...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_float function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_float").should == "function_is_float" end it "should raise a ParseError if there is less than 1 argumen...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the time function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("time").should == "function_time" end it "should raise a ParseError if there is more than 2 arguments" do l...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_ip_address function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_ip_address").should == "function_is_ip_address" end it "should raise a ParseError if there is less...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the strftime function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("strftime").should == "function_strftime" end it "should raise a ParseError if there is less than 1 argumen...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_string function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_string").should == "function_is_string" end it "should raise a ParseError if there is less than 1 argu...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the values function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("values").should == "function_values" end it "should raise a ParseError if there is less than 1 arguments" do...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the upcase function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("upcase").should == "function_upcase" end it "should raise a ParseError if there is less than 1 arguments" do...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the grep function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("grep").should == "function_grep" end it "should raise a ParseError if there is less than 1 arguments" do l...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_mac_address function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_mac_address").should == "function_is_mac_address" end it "should raise a ParseError if there is l...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the lstrip function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("lstrip").should == "function_lstrip" end it "should raise a ParseError if there is less than 1 arguments" do...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the parsejson function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("parsejson").should == "function_parsejson" end it "should raise a ParseError if there is less than 1 argu...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the flatten function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("flatten").should == "function_flatten" end it "should raise a ParseError if there is less than 1 arguments" ...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the delete function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("delete").should == "function_delete" end it "should raise a ParseError if there is less than 1 arguments" do...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe Puppet::Parser::Functions.function(:validate_hash) do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } describe 'when calling validate_hash from puppet' do %w{ true false }.each do |the_string| it "should not compile when #{the_string}...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the validate_slength function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("validate_slength").should == "function_validate_slength" end it "should raise a ParseError if the...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the prefix function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("prefix").should == "function_prefix" end it "should raise a ParseError if there is less than 1 arguments" do...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the zip function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should raise a ParseError if there is less than 1 arguments" do lambda { scope.function_zip([]) }.should( raise_error(Puppet::ParseError)) end it "should be able to...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the capitalize function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("capitalize").should == "function_capitalize" end it "should raise a ParseError if there is less than 1 a...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe Puppet::Parser::Functions.function(:merge) do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } describe 'when calling merge from puppet' do it "should not compile when no arguments are passed" do pending("Fails on 2.6.x, see bug #15912")...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the fqdn_rotate function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("fqdn_rotate").should == "function_fqdn_rotate" end it "should raise a ParseError if there is less than ...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the rstrip function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("rstrip").should == "function_rstrip" end it "should raise a ParseError if there is less than 1 arguments" do...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the hash function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("hash").should == "function_hash" end it "should raise a ParseError if there is less than 1 arguments" do l...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the unique function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("unique").should == "function_unique" end it "should raise a ParseError if there is less than 1 arguments" do...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the downcase function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("downcase").should == "function_downcase" end it "should raise a ParseError if there is less than 1 argumen...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe Puppet::Parser::Functions.function(:validate_string) do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } describe 'when calling validate_string from puppet' do %w{ foo bar baz }.each do |the_string| it "should compile when #{the_string...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the join function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("join").should == "function_join" end it "should raise a ParseError if there is less than 1 arguments" do l...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the empty function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("empty").should == "function_empty" end it "should raise a ParseError if there is less than 1 arguments" do ...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the is_hash function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("is_hash").should == "function_is_hash" end it "should raise a ParseError if there is less than 1 arguments"...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the chop function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("chop").should == "function_chop" end it "should raise a ParseError if there is less than 1 arguments" do l...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the delete_at function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("delete_at").should == "function_delete_at" end it "should raise a ParseError if there is less than 1 argu...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the values_at function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("values_at").should == "function_values_at" end it "should raise a ParseError if there is less than 1 argu...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the squeeze function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("squeeze").should == "function_squeeze" end it "should raise a ParseError if there is less than 2 arguments"...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the shuffle function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("shuffle").should == "function_shuffle" end it "should raise a ParseError if there is less than 1 arguments"...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the abs function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("abs").should == "function_abs" end it "should raise a ParseError if there is less than 1 arguments" do lam...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the reverse function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("reverse").should == "function_reverse" end it "should raise a ParseError if there is less than 1 arguments"...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe Puppet::Parser::Functions.function(:getvar) do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } describe 'when calling getvar from puppet' do it "should not compile when no arguments are passed" do pending("Fails on 2.6.x, see bug #15912"...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' describe "the str2bool function" do let(:scope) { PuppetlabsSpec::PuppetInternals.scope } it "should exist" do Puppet::Parser::Functions.function("str2bool").should == "function_str2bool" end it "should raise a ParseError if there is less than 1 argumen...
Ruby
#!/usr/bin/env ruby require 'puppet' anchor = Puppet::Type.type(:anchor).new(:name => "ntp::begin") describe anchor do it "should stringify normally" do anchor.to_s.should == "Anchor[ntp::begin]" end end
Ruby
dir = File.expand_path(File.dirname(__FILE__)) $LOAD_PATH.unshift File.join(dir, 'lib') # Don't want puppet getting the command line arguments for rake or autotest ARGV.clear require 'puppet' require 'facter' require 'mocha' gem 'rspec', '>=2.0.0' require 'rspec/expectations' require 'puppetlabs_spec_helper/module_s...
Ruby
ENV['FOG_MOCK'] ||= 'true' ENV['AUTOTEST'] = 'true' ENV['WATCHR'] = '1' system 'clear' def growl(message) growlnotify = `which growlnotify`.chomp title = "Watchr Test Results" image = case message when /(\d+)\s+?(failure|error)/i ($1.to_i == 0) ? "~/.watchr_images/passed.png" : "~/.watchr_images/failed....
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' require 'rspec-puppet' describe 'defined_with_params' do describe 'when a resource is not specified' do it { should run.with_params().and_raise_error(ArgumentError) } end describe 'when compared against a resource with no attributes' do let :pre_conditi...
Ruby
#! /usr/bin/env ruby -S rspec require 'spec_helper' require 'rspec-puppet' describe 'ensure_resource' do describe 'when a type or title is not specified' do it do should run.with_params().and_raise_error(ArgumentError) should run.with_params(['type']).and_raise_error(ArgumentError) end end de...
Ruby
# Some monkey-patching to allow us to test private methods. class Class def publicize_methods(*methods) saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods self.class_eval { public(*saved_private_instance_methods) } yield self.class_eval { priva...
Ruby
require 'rspec' class Object # This is necessary because the RAL has a 'should' # method. alias :must :should alias :must_not :should_not end
Ruby
require 'rubygems' require 'puppetlabs_spec_helper/rake_tasks'
Ruby
Puppet::Type.type(:file_line).provide(:ruby) do def exists? lines.find do |line| line.chomp == resource[:line].chomp end end def create if resource[:match] handle_create_with_match() else handle_create_without_match() end end def destroy local_lines = lines Fi...
Ruby
# # prefix.rb # module Puppet::Parser::Functions newfunction(:prefix, :type => :rvalue, :doc => <<-EOS This function applies a prefix to all elements in an array. *Examles:* prefix(['a','b','c'], 'p') Will return: ['pa','pb','pc'] EOS ) do |arguments| # Technically we support two arguments but only...
Ruby
module Puppet::Parser::Functions newfunction(:get_module_path, :type =>:rvalue, :doc => <<-EOT Returns the absolute path of the specified module for the current environment. Example: $module_path = get_module_path('stdlib') EOT ) do |args| raise(Puppet::ParseError, "get_module_path(): Wrong...
Ruby
# # delete.rb # # TODO(Krzysztof Wilczynski): We need to add support for regular expression ... # TODO(Krzysztof Wilczynski): Support for strings and hashes too ... module Puppet::Parser::Functions newfunction(:delete, :type => :rvalue, :doc => <<-EOS Deletes a selected element from an array. *Examples:* dele...
Ruby
# # is_numeric.rb # module Puppet::Parser::Functions newfunction(:is_numeric, :type => :rvalue, :doc => <<-EOS Returns true if the variable passed to this function is a number. EOS ) do |arguments| if (arguments.size != 1) then raise(Puppet::ParseError, "is_numeric(): Wrong number of arguments "+ ...
Ruby
# # is_array.rb # module Puppet::Parser::Functions newfunction(:is_array, :type => :rvalue, :doc => <<-EOS Returns true if the variable passed to this function is an array. EOS ) do |arguments| raise(Puppet::ParseError, "is_array(): Wrong number of arguments " + "given (#{arguments.size} for 1)") if...
Ruby
# # flatten.rb # module Puppet::Parser::Functions newfunction(:flatten, :type => :rvalue, :doc => <<-EOS This function flattens any deeply nested arrays and returns a single flat array as a result. *Examples:* flatten(['a', ['b', ['c']]]) Would return: ['a','b','c'] EOS ) do |arguments| raise(Puppe...
Ruby
# # unique.rb # module Puppet::Parser::Functions newfunction(:unique, :type => :rvalue, :doc => <<-EOS This function will remove duplicates from strings and arrays. *Examples:* unique("aabbcc") Will return: abc You can also use this with arrays: unique(["a","a","b","b","c","c"]) This returns: ...
Ruby
# # str2bool.rb # module Puppet::Parser::Functions newfunction(:str2bool, :type => :rvalue, :doc => <<-EOS This converts a string to a boolean. This attempt to convert strings that contain things like: y, 1, t, true to 'true' and strings that contain things like: 0, f, n, false, no to 'false'. EOS ) do |argum...
Ruby
# # squeeze.rb # module Puppet::Parser::Functions newfunction(:squeeze, :type => :rvalue, :doc => <<-EOS Returns a new string where runs of the same character that occur in this set are replaced by a single character. EOS ) do |arguments| if ((arguments.size != 2) and (arguments.size != 1)) then rai...
Ruby
module Puppet::Parser::Functions newfunction(:validate_bool, :doc => <<-'ENDHEREDOC') do |args| Validate that all passed values are either true or false. Abort catalog compilation if any value fails this check. The following values will pass: $iamtrue = true validate_bool(true) ...
Ruby
module Puppet::Parser::Functions newfunction(:validate_slength, :doc => <<-'ENDHEREDOC') do |args| Validate that the first argument is a string (or an array of strings), and less/equal to than the length of the second argument. It fails if the first argument is not a string or array of strings, and if a...
Ruby
# # is_domain_name.rb # module Puppet::Parser::Functions newfunction(:is_domain_name, :type => :rvalue, :doc => <<-EOS Returns true if the string passed to this function is a syntactically correct domain name. EOS ) do |arguments| if (arguments.size != 1) then raise(Puppet::ParseError, "is_domain_na...
Ruby
# # time.rb # module Puppet::Parser::Functions newfunction(:time, :type => :rvalue, :doc => <<-EOS This function will return the current time since epoch as an integer. *Examples:* time() Will return something like: 1311972653 EOS ) do |arguments| # The Time Zone argument is optional ... time_z...
Ruby
# # is_hash.rb # module Puppet::Parser::Functions newfunction(:is_hash, :type => :rvalue, :doc => <<-EOS Returns true if the variable passed to this function is a hash. EOS ) do |arguments| raise(Puppet::ParseError, "is_hash(): Wrong number of arguments " + "given (#{arguments.size} for 1)") if argu...
Ruby
# # parseyaml.rb # module Puppet::Parser::Functions newfunction(:parseyaml, :type => :rvalue, :doc => <<-EOS This function accepts YAML as a string and converts it into the correct Puppet structure. EOS ) do |arguments| if (arguments.size != 1) then raise(Puppet::ParseError, "parseyaml(): Wrong num...
Ruby
# # fqdn_rotate.rb # module Puppet::Parser::Functions newfunction(:fqdn_rotate, :type => :rvalue, :doc => <<-EOS Rotates an array a random number of times based on a nodes fqdn. EOS ) do |arguments| raise(Puppet::ParseError, "fqdn_rotate(): Wrong number of arguments " + "given (#{arguments.size} for...
Ruby
# # downcase.rb # module Puppet::Parser::Functions newfunction(:downcase, :type => :rvalue, :doc => <<-EOS Converts the case of a string or all strings in an array to lower case. EOS ) do |arguments| raise(Puppet::ParseError, "downcase(): Wrong number of arguments " + "given (#{arguments.size} for ...
Ruby