code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
# 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 |
BmiDss::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_... | Ruby |
BmiDss::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web se... | Ruby |
BmiDss::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test s... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
BmiDss::Application.initialize!
| 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.requir... | Ruby |
BmiDss::Application.routes.draw do
get "main/index"
match 'main' => 'main#index', :as => :main
match 'home' => 'home#index', :as => :home
match 'about' => 'home#about', :as => :about
match 'contact' => 'home#contact', :as => :contact
match 'patTest' => 'home#patTest', :as => :pattest
match 'calculate' =... | Ruby |
module ApplicationHelper
end
| Ruby |
module MainHelper
end
| Ruby |
module BmisHelper
end
| Ruby |
module HomeHelper
def meta_title
case
when controller_name.casecmp("docs") == 0
cname = "#{action_name.titleize} :: DataTable API Reference :: "
when controller_name.casecmp("interactive") == 0 || controller_name.casecmp("image") == 0
cname = "#{action_name.titleize} :: Chart Galler... | Ruby |
class Bmi < ActiveRecord::Base
validates :race, :presence => true
validates :gender, :presence => true
validates :weight_lb, :presence => true
validates :height_inch, :presence => true
validates :height_ft, :presence => true
validates :age, :presence => true
#validates_length_of :race, :minimal=> 1,:allow... | Ruby |
class HomeController < ApplicationController
def index
require 'sqlite3'
#These are the variables for weight and age.
validateWeight = params[:weight_lb].to_i
validateAge = params[:age].to_i
#Because the graphs were built and the databases optimized for the
#75- 350 weight range... | Ruby |
class BmisController < ApplicationController
# GET /bmis
# GET /bmis.json
def index
@bmis = ''
end
# GET /bmis/1
# GET /bmis/1.json
def show
@bmi = Bmi.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @bmi }
end
end
# ... | Ruby |
class MainController < ApplicationController
def index
end
end
| Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
#kerry
#rashidkkk
#fff
end
| Ruby |
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake/dsl_definition'
require 'rake'
BmiDss::Application.load_tasks
| Ruby |
#!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake/dsl_definition'
require 'rake'
BmiDss::Application.load_tasks
| Ruby |
source 'http://rubygems.org'
gem "google_visualr"
#"~> 2.1.0"
gem 'lazy_high_charts', '~> 1.1.5'
gem 'rails'
# '3.1.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
#gem 'sqlite3'
gem 'sqlite3'
#'1.3.4'
#gem 'pg'
# Gems used only for assets and not required
# in prod... | Ruby |
class CreateBmis < ActiveRecord::Migration
def change
create_table :bmis do |t|
t.integer :age
t.string :race
t.string :gender
t.string :activity_level
t.integer :weight_lb
t.integer :weight_kg
t.integer :height_inch
t.integer :height_feet
t.integer :height_cm... | Ruby |
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run BmiDss::Application
| Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integrati... | Ruby |
require "rubygems"
require "active_record"
ActiveRecord::Base.establish_connection(
:adapter => 'oracle_enhanced',
:database => 'BMCSMDB',
:username => 'webuser',
:password => 'bmcdevdb',
:host => '10.18.8.111',
:cursor_sharing => 'similar')
class Model < ActiveRecord::Base
before_create :ge... | 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 |
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 |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
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 |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
source "https://rubygems.org"
def location_for(place, fake_version = nil)
mdata = /^(git:[^#]*)#(.*)/.match(place)
if mdata
[fake_version, { :git => mdata[1], :branch => mdata[2], :require => false }].compact
elsif place =~ /^file:\/\/(.*)/
['>= 0', { :path => File.expand_path(mdata[1]), :require => fals... | Ruby |
#!/usr/bin/env rspec
require 'spec_helper'
describe "the is_function_available function" do
before :all do
Puppet::Parser::Functions.autoloader.loadall
end
before :each do
@scope = Puppet::Parser::Scope.new
end
it "should exist" do
Puppet::Parser::Functions.function("is_function_available").sho... | 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 |
# 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.
*Examples:*
prefix(['a','b','c'], 'p')
Will return: ['pa','pb','pc']
EOS
) do |arguments|
# Technically we support two arguments but onl... | 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 |
require 'puppet/util/execution'
module Puppet::Parser::Functions
newfunction(:validate_cmd, :doc => <<-'ENDHEREDOC') do |args|
Perform validation of a string with an external command.
The first argument of this function should be a string to
test, and the second argument should be a path to a test comman... | Ruby |
#
# delete.rb
#
# TODO(Krzysztof Wilczynski): We need to add support for regular expression ...
module Puppet::Parser::Functions
newfunction(:delete, :type => :rvalue, :doc => <<-EOS
Deletes all instances of a given element from an array, substring from a
string, or key from a hash.
*Examples:*
delete(['a','b... | 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 |
#
# reject.rb
#
module Puppet::Parser::Functions
newfunction(:reject, :type => :rvalue, :doc => <<-EOS) do |args|
This function searches through an array and rejects all elements that match
the provided regular expression.
*Examples:*
reject(['aaa','bbb','ccc','aaaddd'], 'aaa')
Would return:
['bbb','ccc'... | 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 |
#
# has_interface_with
#
module Puppet::Parser::Functions
newfunction(:has_interface_with, :type => :rvalue, :doc => <<-EOS
Returns boolean based on kind and value:
* macaddress
* netmask
* ipaddress
* network
has_interface_with("macaddress", "x:x:x:x:x:x")
has_interface_with("ipaddress", "127.0.0.1") =>... | Ruby |
#
# concat.rb
#
module Puppet::Parser::Functions
newfunction(:concat, :type => :rvalue, :doc => <<-EOS
Appends the contents of array 2 onto array 1.
*Example:*
concat(['1','2','3'],['4','5','6'])
Would result in:
['1','2','3','4','5','6']
EOS
) do |arguments|
# Check that 2 arguments have been g... | 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 |argume... | 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(:pick, :type => :rvalue, :doc => <<-EOS
This function is similar to a coalesce function in SQL in that it will return
the first value in a list of values that is not undefined or an empty string
(two things in Puppet that will return a boolean false value). Typically,
this... | 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 |
module Puppet::Parser::Functions
newfunction(:to_bytes, :type => :rvalue, :doc => <<-EOS
Converts the argument into bytes, for example 4 kB becomes 4096.
Takes a single string value as an argument.
EOS
) do |arguments|
raise(Puppet::ParseError, "to_bytes(): Wrong number of arguments " +
"... | 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 numb... | 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 |
#
# join.rb
#
module Puppet::Parser::Functions
newfunction(:join_keys_to_values, :type => :rvalue, :doc => <<-EOS
This function joins each key of a hash to that key's corresponding value with a
separator. Keys and values are cast to strings. The return value is an array in
which each element is one joined key/value ... | 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 |
#
# is_string.rb
#
module Puppet::Parser::Functions
newfunction(:is_string, :type => :rvalue, :doc => <<-EOS
Returns true if the variable passed to this function is a string.
EOS
) do |arguments|
raise(Puppet::ParseError, "is_string(): Wrong number of arguments " +
"given (#{arguments.size} for 1)")... | Ruby |
module Puppet::Parser::Functions
newfunction(:floor, :type => :rvalue, :doc => <<-EOS
Returns the largest integer less or equal to the argument.
Takes a single numeric value as an argument.
EOS
) do |arguments|
raise(Puppet::ParseError, "floor(): Wrong number of arguments " +
"given (#{ar... | Ruby |
module Puppet::Parser::Functions
newfunction(:max, :type => :rvalue, :doc => <<-EOS
Returns the highest value of all arguments.
Requires at least one argument.
EOS
) do |args|
raise(Puppet::ParseError, "max(): Wrong number of arguments " +
"need at least one") if args.size == 0
# Som... | Ruby |
module Puppet::Parser::Functions
newfunction(:validate_hash, :doc => <<-'ENDHEREDOC') do |args|
Validate that all passed values are hash data structures. Abort catalog
compilation if any value fails this check.
The following values will pass:
$my_hash = { 'one' => 'two' }
validate_hash(... | Ruby |
module Puppet::Parser::Functions
newfunction(:count, :type => :rvalue, :arity => -2, :doc => <<-EOS
Takes an array as first argument and an optional second argument.
Count the number of elements in array that matches second argument.
If called with only an array it counts the number of elements that are not nil/undef... | Ruby |
#
# keys.rb
#
module Puppet::Parser::Functions
newfunction(:keys, :type => :rvalue, :doc => <<-EOS
Returns the keys of a hash as an array.
EOS
) do |arguments|
raise(Puppet::ParseError, "keys(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
hash = argume... | Ruby |
#
# values.rb
#
module Puppet::Parser::Functions
newfunction(:values, :type => :rvalue, :doc => <<-EOS
When given a hash this function will return the values of that hash.
*Examples:*
$hash = {
'a' => 1,
'b' => 2,
'c' => 3,
}
values($hash)
This example would return:
[1,2,3]
... | Ruby |
# Test whether a given class or definition is defined
require 'puppet/parser/functions'
Puppet::Parser::Functions.newfunction(:ensure_resource,
:type => :statement,
:doc => <<-'ENDOFDOC'
Takes a resource type, title, and a list of attributes t... | Ruby |
#
# swapcase.rb
#
module Puppet::Parser::Functions
newfunction(:swapcase, :type => :rvalue, :doc => <<-EOS
This function will swap the existing case of a string.
*Examples:*
swapcase("aBcD")
Would result in: "AbCd"
EOS
) do |arguments|
raise(Puppet::ParseError, "swapcase(): Wrong number of argumen... | Ruby |
#
# shuffle.rb
#
module Puppet::Parser::Functions
newfunction(:shuffle, :type => :rvalue, :doc => <<-EOS
Randomizes the order of a string or array elements.
EOS
) do |arguments|
raise(Puppet::ParseError, "shuffle(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size <... | Ruby |
#
# is_mac_address.rb
#
module Puppet::Parser::Functions
newfunction(:is_mac_address, :type => :rvalue, :doc => <<-EOS
Returns true if the string passed to this function is a valid mac address.
EOS
) do |arguments|
if (arguments.size != 1) then
raise(Puppet::ParseError, "is_mac_address(): Wrong numb... | Ruby |
module Puppet::Parser::Functions
newfunction(:dirname, :type => :rvalue, :doc => <<-EOS
Returns the dirname of a path.
EOS
) do |arguments|
raise(Puppet::ParseError, "dirname(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
path = arguments[0]
ret... | Ruby |
#
# is_function_available.rb
#
module Puppet::Parser::Functions
newfunction(:is_function_available, :type => :rvalue, :doc => <<-EOS
This function accepts a string as an argument, determines whether the
Puppet runtime has access to a function by that name. It returns a
true if the function exists, false if not.
... | Ruby |
# Test whether a given class or definition is defined
require 'puppet/parser/functions'
Puppet::Parser::Functions.newfunction(:defined_with_params,
:type => :rvalue,
:doc => <<-'ENDOFDOC'
Takes a resource reference and an optional hash of attr... | Ruby |
#
# capitalize.rb
#
module Puppet::Parser::Functions
newfunction(:capitalize, :type => :rvalue, :doc => <<-EOS
Capitalizes the first letter of a string or array of strings.
Requires either a single string or an array as an input.
EOS
) do |arguments|
raise(Puppet::ParseError, "capitalize(): Wrong... | Ruby |
#
# is_float.rb
#
module Puppet::Parser::Functions
newfunction(:is_float, :type => :rvalue, :doc => <<-EOS
Returns true if the variable passed to this function is a float.
EOS
) do |arguments|
if (arguments.size != 1) then
raise(Puppet::ParseError, "is_float(): Wrong number of arguments "+
"... | Ruby |
#
# abs.rb
#
module Puppet::Parser::Functions
newfunction(:abs, :type => :rvalue, :doc => <<-EOS
Returns the absolute value of a number, for example -34.56 becomes
34.56. Takes a single integer and float value as an argument.
EOS
) do |arguments|
raise(Puppet::ParseError, "abs(): Wrong number of a... | Ruby |
#
# str2saltedsha512.rb
#
module Puppet::Parser::Functions
newfunction(:str2saltedsha512, :type => :rvalue, :doc => <<-EOS
This converts a string to a salted-SHA512 password hash (which is used for
OS X versions >= 10.7). Given any simple string, you will get a hex version
of a salted-SHA512 password hash that can b... | Ruby |
#
# strip.rb
#
module Puppet::Parser::Functions
newfunction(:strip, :type => :rvalue, :doc => <<-EOS
This function removes leading and trailing whitespace from a string or from
every string inside an array.
*Examples:*
strip(" aaa ")
Would result in: "aaa"
EOS
) do |arguments|
raise(Puppet::P... | Ruby |
#
# num2bool.rb
#
module Puppet::Parser::Functions
newfunction(:num2bool, :type => :rvalue, :doc => <<-EOS
This function converts a number or a string representation of a number into a
true boolean. Zero or anything non-numeric becomes false. Numbers higher then 0
become true.
EOS
) do |arguments|
raise(P... | Ruby |
#
# reverse.rb
#
module Puppet::Parser::Functions
newfunction(:reverse, :type => :rvalue, :doc => <<-EOS
Reverses the order of a string or array.
EOS
) do |arguments|
raise(Puppet::ParseError, "reverse(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
val... | Ruby |
#
# values_at.rb
#
module Puppet::Parser::Functions
newfunction(:values_at, :type => :rvalue, :doc => <<-EOS
Finds value inside an array based on location.
The first argument is the array you want to analyze, and the second element can
be a combination of:
* A single numeric index
* A range in the form of 'start-s... | Ruby |
module Puppet::Parser::Functions
newfunction(:validate_string, :doc => <<-'ENDHEREDOC') do |args|
Validate that all passed values are string data structures. Abort catalog
compilation if any value fails this check.
The following values will pass:
$my_string = "one two"
validate_string($... | Ruby |
#
# lstrip.rb
#
module Puppet::Parser::Functions
newfunction(:lstrip, :type => :rvalue, :doc => <<-EOS
Strips leading spaces to the left of a string.
EOS
) do |arguments|
raise(Puppet::ParseError, "lstrip(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
... | Ruby |
#
# sort.rb
#
module Puppet::Parser::Functions
newfunction(:sort, :type => :rvalue, :doc => <<-EOS
Sorts strings and arrays lexically.
EOS
) do |arguments|
if (arguments.size != 1) then
raise(Puppet::ParseError, "sort(): Wrong number of arguments "+
"given #{arguments.size} for 1")
end
... | Ruby |
#
# member.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(:member, :type => :rvalue, :doc => <<-EOS
This function determines if a variable is a member of an array.
... | Ruby |
#
# hash.rb
#
module Puppet::Parser::Functions
newfunction(:hash, :type => :rvalue, :doc => <<-EOS
This function converts an array into a hash.
*Examples:*
hash(['a',1,'b',2,'c',3])
Would return: {'a'=>1,'b'=>2,'c'=>3}
EOS
) do |arguments|
raise(Puppet::ParseError, "hash(): Wrong number of argument... | Ruby |
#
# zip.rb
#
module Puppet::Parser::Functions
newfunction(:zip, :type => :rvalue, :doc => <<-EOS
Takes one element from first array and merges corresponding elements from second array. This generates a sequence of n-element arrays, where n is one more than the count of arguments.
*Example:*
zip(['1','2','3'],[... | Ruby |
#
# parsejson.rb
#
module Puppet::Parser::Functions
newfunction(:parsejson, :type => :rvalue, :doc => <<-EOS
This function accepts JSON as a string and converts into the correct Puppet
structure.
EOS
) do |arguments|
if (arguments.size != 1) then
raise(Puppet::ParseError, "parsejson(): Wrong number ... | Ruby |
#
# chomp.rb
#
module Puppet::Parser::Functions
newfunction(:chomp, :type => :rvalue, :doc => <<-'EOS'
Removes the record separator from the end of a string or an array of
strings, for example `hello\n` becomes `hello`.
Requires a single string or array as an input.
EOS
) do |arguments|
raise... | Ruby |
#
# type.rb
#
module Puppet::Parser::Functions
newfunction(:type, :type => :rvalue, :doc => <<-EOS
Returns the type when passed a variable. Type can be one of:
* string
* array
* hash
* float
* integer
* boolean
EOS
) do |arguments|
raise(Puppet::ParseError, "type(): Wrong number of arguments " +
"... | Ruby |
#
# join.rb
#
module Puppet::Parser::Functions
newfunction(:join, :type => :rvalue, :doc => <<-EOS
This function joins an array into a string using a seperator.
*Examples:*
join(['a','b','c'], ",")
Would result in: "a,b,c"
EOS
) do |arguments|
# Technically we support two arguments but only first i... | Ruby |
#
# upcase.rb
#
module Puppet::Parser::Functions
newfunction(:upcase, :type => :rvalue, :doc => <<-EOS
Converts a string or an array of strings to uppercase.
*Examples:*
upcase("abcd")
Will return:
ASDF
EOS
) do |arguments|
raise(Puppet::ParseError, "upcase(): Wrong number of arguments " +
... | Ruby |
#
# grep.rb
#
module Puppet::Parser::Functions
newfunction(:grep, :type => :rvalue, :doc => <<-EOS
This function searches through an array and returns any elements that match
the provided regular expression.
*Examples:*
grep(['aaa','bbb','ccc','aaaddd'], 'aaa')
Would return:
['aaa','aaaddd']
EOS
) ... | Ruby |
module Puppet::Parser::Functions
newfunction(:validate_augeas, :doc => <<-'ENDHEREDOC') do |args|
Perform validation of a string using an Augeas lens
The first argument of this function should be a string to
test, and the second argument should be the name of the Augeas lens to use.
If Augeas fails to... | Ruby |
#
# is_ip_address.rb
#
module Puppet::Parser::Functions
newfunction(:is_ip_address, :type => :rvalue, :doc => <<-EOS
Returns true if the string passed to this function is a valid IP address.
EOS
) do |arguments|
require 'ipaddr'
if (arguments.size != 1) then
raise(Puppet::ParseError, "is_ip_add... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.