This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/ruby | |
| class ConstantTest | |
| class FooTest | |
| def self.yep | |
| puts "yep" | |
| end | |
| end | |
| self.const_get("FooTest").yep | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BaseTesting | |
| STORE = :data_mapper | |
| def initialize | |
| Puppet::Node.terminus_class = STORE | |
| Puppet::Node::Facts.terminus_class = STORE | |
| end | |
| def node_test | |
| node = Puppet::Node.new("foo.madstop.com") | |
| node.environment = "production" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ChecksumTesting | |
| require 'digest/md5' | |
| require 'benchmark' | |
| def benchmark(label) | |
| seconds = Benchmark.realtime { yield } | |
| puts "%s in %0.2f seconds" % [label, seconds] | |
| end | |
| def initialize(file) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'json' | |
| class JsonTester | |
| def self.from_json(text) | |
| data = JSON.parse(text) | |
| p data | |
| if data.include?("data") | |
| data = data["data"] | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class RailsBenchmarking | |
| BRANCHES = %w{rails/new rails/normal rails/new_no_accum} | |
| attr_accessor :type, :host | |
| def clear | |
| system("rm -rf #{path}") | |
| end | |
| def initialize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SortedWalking | |
| class Vertex | |
| attr_accessor :weight, :label | |
| def initialize(label, weight = nil) | |
| @label = label | |
| @weight = weight || 5 | |
| end | |
| def to_s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class BaseTesting | |
| STORE = :data_mapper | |
| def initialize | |
| Puppet::Node.terminus_class = STORE | |
| Puppet::Node::Facts.terminus_class = STORE | |
| end | |
| def node_test | |
| node = Puppet::Node.new("foo.madstop.com") | |
| node.environment = "production" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/ruby | |
| class Metric | |
| def +(value) | |
| self.class.new(@value + value.to_i) | |
| end | |
| def initialize(value = 0) | |
| @value = value | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Exec { path => "/usr/bin:/usr/sbin:/bin" } | |
| class cc { notify { 'cc': } } | |
| define util() { | |
| exec { "util_$name": command => 'echo hoho', require => Class[cc] } | |
| } | |
| define job() { | |
| include cc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Puppet::Parser::Functions.newfunction :load_data, :type => :statement do |args| | |
| if args.length == 1 | |
| klass = args[0] | |
| else | |
| klass = resource.title | |
| end | |
| datadir = "/Users/luke/git/clients/redhat/data" | |
| dirs = datadir.split("/") + klass.split("::") |