code
stringlengths
1
1.73M
language
stringclasses
1 value
# # uriescape.rb # require 'uri' module Puppet::Parser::Functions newfunction(:uriescape, :type => :rvalue, :doc => <<-EOS Urlencodes a string or array of strings. Requires either a single string or an array as an input. EOS ) do |arguments| raise(Puppet::ParseError, "uriescape(): Wrong number of...
Ruby
# # rstrip.rb # module Puppet::Parser::Functions newfunction(:rstrip, :type => :rvalue, :doc => <<-EOS Strips leading spaces to the right of the string. EOS ) do |arguments| raise(Puppet::ParseError, "rstrip(): Wrong number of arguments " + "given (#{arguments.size} for 1)") if arguments.size < 1 ...
Ruby
# Test whether a given class or definition is defined require 'puppet/parser/functions' Puppet::Parser::Functions.newfunction(:getparam, :type => :rvalue, :doc => <<-'ENDOFDOC' Takes a resource reference and name of the parameter and returns v...
Ruby
module Puppet::Parser::Functions newfunction(:validate_re, :doc => <<-'ENDHEREDOC') do |args| Perform simple validation of a string against one or more regular expressions. The first argument of this function should be a string to test, and the second argument should be a stringified regular expression ...
Ruby
module Puppet::Parser::Functions newfunction(:loadyaml, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| Load a YAML file containing an array, string, or hash, and return the data in the corresponding native data type. For example: $myhash = loadyaml('/etc/puppet/data/myhash.yaml') ENDH...
Ruby
# # chop.rb # module Puppet::Parser::Functions newfunction(:chop, :type => :rvalue, :doc => <<-'EOS' Returns a new string with the last character removed. If the string ends with `\r\n`, both characters are removed. Applying chop to an empty string returns an empty string. If you wish to merely remove r...
Ruby
# # empty.rb # module Puppet::Parser::Functions newfunction(:empty, :type => :rvalue, :doc => <<-EOS Returns true if the variable is empty. EOS ) do |arguments| raise(Puppet::ParseError, "empty(): Wrong number of arguments " + "given (#{arguments.size} for 1)") if arguments.size < 1 value = arg...
Ruby
# # suffix.rb # module Puppet::Parser::Functions newfunction(:suffix, :type => :rvalue, :doc => <<-EOS This function applies a suffix to all elements in an array. *Examples:* suffix(['a','b','c'], 'p') Will return: ['ap','bp','cp'] EOS ) do |arguments| # Technically we support two arguments but onl...
Ruby
module Puppet::Parser::Functions newfunction(:getvar, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| Lookup a variable in a remote namespace. For example: $foo = getvar('site::data::foo') # Equivalent to $foo = $site::data::foo This is useful if the namespace itself is stored in ...
Ruby
# # delete_at.rb # module Puppet::Parser::Functions newfunction(:delete_at, :type => :rvalue, :doc => <<-EOS Deletes a determined indexed value from an array. *Examples:* delete_at(['a','b','c'], 1) Would return: ['a','c'] EOS ) do |arguments| raise(Puppet::ParseError, "delete_at(): Wrong number of...
Ruby
module Puppet::Parser::Functions newfunction(:min, :type => :rvalue, :doc => <<-EOS Returns the lowest value of all arguments. Requires at least one argument. EOS ) do |args| raise(Puppet::ParseError, "min(): Wrong number of arguments " + "need at least one") if args.size == 0 # Some...
Ruby
# # bool2num.rb # module Puppet::Parser::Functions newfunction(:bool2num, :type => :rvalue, :doc => <<-EOS Converts a boolean to a number. Converts the values: false, f, 0, n, and no to 0 true, t, 1, y, and yes to 1 Requires a single boolean or string as an input. EOS ) do |arguments| ...
Ruby
# # any2array.rb # module Puppet::Parser::Functions newfunction(:any2array, :type => :rvalue, :doc => <<-EOS This converts any object to an array containing that object. Empty argument lists are converted to an empty array. Arrays are left untouched. Hashes are converted to arrays of alternating keys and values. ...
Ruby
module Puppet::Parser::Functions newfunction(:has_key, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| Determine if a hash has a certain key value. Example: $my_hash = {'key_one' => 'value_one'} if has_key($my_hash, 'key_two') { notice('we will not reach here') } ...
Ruby
module Puppet::Parser::Functions newfunction(:validate_absolute_path, :doc => <<-'ENDHEREDOC') do |args| Validate the string represents an absolute path in the filesystem. This function works for windows and unix style paths. The following values will pass: $my_path = "C:/Program Files (x86)/Pu...
Ruby
# # range.rb # # TODO(Krzysztof Wilczynski): We probably need to approach numeric values differently ... module Puppet::Parser::Functions newfunction(:range, :type => :rvalue, :doc => <<-EOS When given range in the form of (start, stop) it will extrapolate a range as an array. *Examples:* range("0", "9") Wil...
Ruby
# # is_integer.rb # module Puppet::Parser::Functions newfunction(:is_integer, :type => :rvalue, :doc => <<-EOS Returns true if the variable returned to this string is an integer. EOS ) do |arguments| if (arguments.size != 1) then raise(Puppet::ParseError, "is_integer(): Wrong number of arguments "+ ...
Ruby
# # has_ip_network # module Puppet::Parser::Functions newfunction(:has_ip_network, :type => :rvalue, :doc => <<-EOS Returns true if the client has an IP address within the requested network. This function iterates through the 'interfaces' fact and checks the 'network_IFACE' facts, performing a simple string compari...
Ruby
module Puppet::Parser::Functions newfunction(:merge, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args| Merges two or more hashes together and returns the resulting hash. For example: $hash1 = {'one' => 1, 'two', => 2} $hash2 = {'two' => 'dos', 'three', => 'tres'} $merged_hash = me...
Ruby
# # strftime.rb # module Puppet::Parser::Functions newfunction(:strftime, :type => :rvalue, :doc => <<-EOS This function returns formatted time. *Examples:* To return the time since epoch: strftime("%s") To return the date: strftime("%Y-%m-%d") *Format meaning:* %a - The abbreviated weekday name (...
Ruby
module Puppet::Parser::Functions newfunction(:validate_array, :doc => <<-'ENDHEREDOC') do |args| Validate that all passed values are array data structures. Abort catalog compilation if any value fails this check. The following values will pass: $my_array = [ 'one', 'two' ] validate_arra...
Ruby
# # has_ip_address # module Puppet::Parser::Functions newfunction(:has_ip_address, :type => :rvalue, :doc => <<-EOS Returns true if the client has the requested IP address on some interface. This function iterates through the 'interfaces' fact and checks the 'ipaddress_IFACE' facts, performing a simple string compa...
Ruby
# # size.rb # # TODO(Krzysztof Wilczynski): Support for hashes would be nice too ... module Puppet::Parser::Functions newfunction(:size, :type => :rvalue, :doc => <<-EOS Returns the number of elements in a string or array. EOS ) do |arguments| raise(Puppet::ParseError, "size(): Wrong number of arguments ...
Ruby
# # ensure_packages.rb # require 'puppet/parser/functions' module Puppet::Parser::Functions newfunction(:ensure_packages, :type => :statement, :doc => <<-EOS Takes a list of packages and only installs them if they don't already exist. EOS ) do |arguments| raise(Puppet::ParseError, "ensure_packages(): Wron...
Ruby
Puppet::Type.newtype(:anchor) do desc <<-'ENDOFDESC' A simple resource type intended to be used as an anchor in a composite class. In Puppet 2.6, when a class declares another class, the resources in the interior class are not contained by the exterior class. This interacts badly with the pattern of composin...
Ruby
Puppet::Type.newtype(:file_line) do desc <<-EOT Ensures that a given line is contained within a file. The implementation matches the full line, including whitespace at the beginning and end. If the line is not contained in the given file, Puppet will add the line to ensure the desired state. Multi...
Ruby
module Facter module Util module PuppetSettings # This method is intended to provide a convenient way to evaluate a # Facter code block only if Puppet is loaded. This is to account for the # situation where the fact happens to be in the load path, but Puppet is # not loaded for whatever r...
Ruby
# Fact: is_pe, pe_version, pe_major_version, pe_minor_version, pe_patch_version # # Purpose: Return various facts about the PE state of the system # # Resolution: Uses a regex match against puppetversion to determine whether the # machine has Puppet Enterprise installed, and what version (overall, major, # minor, p...
Ruby
# This facter fact returns the value of the Puppet vardir setting for the node # running puppet or puppet agent. The intent is to enable Puppet modules to # automatically have insight into a place where they can place variable data, # regardless of the node's platform. # # The value should be directly usable in a File...
Ruby
# A facter fact to determine the root home directory. # This varies on PE supported platforms and may be # reconfigured by the end user. module Facter::Util::RootHome class << self def get_root_home root_ent = Facter::Util::Resolution.exec("getent passwd root") # The home directory is the sixth element in ...
Ruby
# A Facter plugin that loads facts from /etc/facter/facts.d # and /etc/puppetlabs/facter/facts.d. # # Facts can be in the form of JSON, YAML or Text files # and any executable that returns key=value pairs. # # In the case of scripts you can also create a file that # contains a cache TTL. For foo.sh store the ttl as ju...
Ruby
source 'https://rubygems.org' group :development, :test do gem 'rake', :require => false gem 'puppetlabs_spec_helper', :require => false gem 'puppet-lint', :require => false gem 'serverspec', :require => false gem 'beaker', :require => false gem...
Ruby
require 'puppetlabs_spec_helper/module_spec_helper'
Ruby
require 'beaker-rspec' hosts.each do |host| # Install Puppet install_package host, 'rubygems' on host, 'gem install puppet --no-ri --no-rdoc' on host, "mkdir -p #{host['distmoduledir']}" end RSpec.configure do |c| # Project root proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) # Re...
Ruby
require 'puppetlabs_spec_helper/rake_tasks'
Ruby
dir = File.expand_path(File.dirname(__FILE__)) $LOAD_PATH.unshift File.join(dir, 'lib') require 'mocha' require 'puppet' require 'rspec' require 'spec/autorun' Spec::Runner.configure do |config| config.mock_with :mocha end # We need this because the RAL uses 'should' as a method. This # allows us the same behav...
Ruby
environment = :production project_type = :stand_alone http_path = "/" css_dir = "../styles" sass_dir = "." images_dir = "images" sass_options = { :line_numbers => false, :debug_info => false } # output_style = :compressed # output_style = :compact output_style = :expanded
Ruby
require 'webrick' include WEBrick s = HTTPServer.new( :Port => 2010, :DocumentRoot => Dir::pwd ) s.mount('/sh/scripts', WEBrick::HTTPServlet::FileHandler, '../scripts') s.mount('/sh/styles', WEBrick::HTTPServlet::FileHandler, '../styles') trap('INT') { s.stop } s.start
Ruby
# Copyright 2008-2009 Nokia Siemens Networks Oyj # # 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...
Ruby
#!/usr/bin/env ruby class ExampleRemoteLibrary def count_items_in_directory(path) Dir.entries(path).find_all{|i| not i.match('^\.')}.length end def strings_should_be_equal(str1, str2) puts "Comparing '#{str1}' to '#{str2}'" if str1 != str2 raise RuntimeError, "Given strings are not equal" ...
Ruby
class RubyLibraryExample def get_server_language 'ruby' end # Basic communication def passing end def failing(message) raise message end def logging(message, level='INFO') puts "*#{level}* #{message}" end def returning 'returned string' end # Logging def one_message_w...
Ruby
# # setup.rb # # Copyright (c) 2000-2005 Minero Aoki # # This program is free software. # You can distribute/modify this program under the terms of # the GNU LGPL, Lesser General Public License version 2.1. # unless Enumerable.method_defined?(:map) # Ruby 1.4.6 module Enumerable alias map collect end end un...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
load File.dirname(__FILE__) + '/Rakefile' gem_spec
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
module Xbrlware module Taxonomies module IFRS20090401 # :nodoc: def AccountingProfit return {"xbrli:balance" => "credit","name" => "AccountingProfit","nillable" => "true","xbrli:periodType" => "duration","id" => "ifrs_AccountingProfit","substitutionGroup" => "xbrli:item","info:creationID" => "i200806241028411001"...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
# This patch is to fix a bug in Ruby 1.8.x CGI::unescapeHTML # Till we upgrade to Ruby 1.9, we will use this patch. Ruby 1.9 handles it properly. # Other alternative is using htmlentities - http://htmlentities.rubyforge.org/ # # Bug explanation, # CGI::unescapeHTML("Equity in Earnings&#160;of") returns "Equity in Earni...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
# namespace aware module NSAware # namespace and namespace prefix attr_accessor :ns, :nsp end
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
#!/usr/bin/ruby # # Author:: xbrlware@bitstat.com # # Copyright:: 2009, 2010 bitstat (http://www.bitstat.com). All Rights Reserved. # # License:: 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...
Ruby
require 'rubygems' # you need this when xbrlware is installed as gem require 'edgar' require 'xbrlware' dl=Edgar::HTMLFeedDownloader.new() url="http://www.sec.gov/Archives/edgar/data/843006/000135448809002030/0001354488-09-002030-index.htm" download_dir=url.split("/")[-2] # download dir is : 000135448809002030 dl.dow...
Ruby
require 'rubygems' # you need this when xbrlware is installed as gem require 'xbrlware' instance_file="c-20091230.xml" instance = Xbrlware.ins(instance_file) # Create parser instance item_name="NetIncomeLoss" # This is the item we are interested in. net_incomes = instance.item(item_name) # Extracts "NetIncomeLoss" i...
Ruby
require 'edgar' require 'xbrlware' d=Edgar::HTMLFeedDownloader.new url="http://www.sec.gov/Archives/edgar/data/1281761/000119312510036446/0001193125-10-036446-index.htm" download_dir=url.split("/")[-2] # download dir is : 000119312510036446 d.download(url, download_dir) ins=Xbrlware.ins(Xbrlware.file_grep(download_di...
Ruby
require 'xbrlware' r=Xbrlware::Report.new class << r public :xbrl_files end files=r.xbrl_files("../../../xbrlware-wiki/sample_reports/edgar_data") output = StringIO.new output << "|| *Instance + Taxonomy file size (KB)* || *Time (Seconds)* ||" output << "\n" files.each do |file_map| m=Benchmark.measure do in...
Ruby
require 'xbrlware' ## Assuming you have table "calculations" with below structure # id # element_name # element_value # element_label # period_start_date # period_end_date # parent_id def format_timeline(timeline) ## date format function return Xbrlware::DateUtil.stringify_date(timeline.value) unless timeline.is_du...
Ruby
require 'xbrlware' def format_timeline(timeline) ## date format function return Xbrlware::DateUtil.stringify_date(timeline.value) unless timeline.is_duration? header = StringIO.new header << Xbrlware::DateUtil.stringify_date(timeline.value["end_date"]) << " : " header << Xbrlware::DateUtil.months_between(timel...
Ruby
require 'rubygems' # you need this when xbrlware is installed as gem require 'xbrlware' instance=Xbrlware.ins("foo.xml") items=instance.item("ProfitLoss") puts "Profit-Loss \t Context" items.each do |item| puts item.value+" \t "+item.context.id end
Ruby
require 'rubygems' # you need this when xbrlware is installed as gem require 'edgar' require 'xbrlware' dl=Edgar::HTMLFeedDownloader.new() url="http://www.sec.gov/Archives/edgar/data/843006/000135448809002030/0001354488-09-002030-index.htm" download_dir=url.split("/")[-2] # download dir is : 000135448809002030 dl.dow...
Ruby
$:.push('gen-rb') require 'thrift' require 'thrift/transport/server_socket' require 'thrift/transport/buffered_transport' require 'thrift/server/simple_server' require 'rating' require 'rating-impl' # Thrift provides mutiple communication endpoints # - Here we will expose our service via a TCP socket # - Web-serv...
Ruby
# provide an implementation of Rating service class RatingImpl def piotroski(entity_name) # Code that use xbrlware goes here return 1 # return some dummy value end def altman_z(entity_name) # Code that use xbrlware goes here return 2.2567 # return some dummy value end end
Ruby
java_import javax.xml.XMLConstants java_import javax.xml.parsers.DocumentBuilder java_import javax.xml.parsers.DocumentBuilderFactory java_import javax.xml.transform.Source java_import javax.xml.transform.dom.DOMSource java_import javax.xml.transform.stream.StreamSource java_import javax.xml.validation.Schema java_impo...
Ruby
module XbrlTest class SchemaValidator def self.validate (xml_file, xsd_file) return end end end
Ruby
def first(name, &block) block = lambda{ puts "lambda"} if block.nil? second &block end def second(&block) yield end first("blk") { puts "Hello"} first("blk") def dummy(count, snipet=StringIO.new, &block) return snipet.string if count > 5 yield snipet count += 1 dummy(count, snipet, &block) end dummy(...
Ruby
module LinkbaseTestUtil def print_arc(arcs, indent=0) arcs.each do |arc| if arc.items.nil? || arc.items.size==0 puts " " * indent * 2 + arc.item_id + "[" + (arc.label if arc.respond_to?(:label)).to_s+"][role "+arc.role.to_s+"][order "+arc.order.to_s+"] = None .. ctx undefined.." else ...
Ruby
require 'test/unit' require 'xbrlware' require 'edgar' require 'tmpdir' begin require 'java' require File.dirname(__FILE__) + '/schema_validator_jruby' rescue Exception ENV["SCHEMA_VALIDATION"]="False" require File.dirname(__FILE__) + '/schema_validator_ruby' end $LOG.level = Logger::INFO
Ruby
#!/usr/bin/env ruby require 'json' RESET_PROB = 0.15; class Handler def gather_edges(json) {:edges => :IN_EDGES} end def scatter_edges(json) last_change = json['state'].to_f return {:edges => :OUT_EDGES} if last_change > 1e-2 return {:edges => :NO_EDGES} end def gather(json) edge = j...
Ruby
#!/usr/bin/env ruby require 'json' INFINITY = 1e99 class String alias :old_to_f :to_f def to_f return INFINITY if 0 >= self.length self.old_to_f end end class Handler def gather_edges(json) {:edges => :IN_EDGES} end def scatter_edges(json) {:edges => :OUT_EDGES} end def gather(jso...
Ruby
#!/usr/bin/env ruby def colorize(text, color_code) "\e[0;#{color_code}m#{text}\e[0m" end def red(text) colorize(text, 31) end def green(text) colorize(text, 32) end def cyan(text) colorize(text, 36) end begin # open new terminal fd = IO.sysopen("/dev/tty", "r") term = IO.new(fd,"r") thread = T...
Ruby
# Copyright 2008-2009 Nokia Siemens Networks Oyj # # 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...
Ruby
#!/usr/bin/env ruby class ExampleRemoteLibrary def count_items_in_directory(path) Dir.entries(path).find_all{|i| not i.match('^\.')}.length end def strings_should_be_equal(str1, str2) puts "Comparing '#{str1}' to '#{str2}'" if str1 != str2 raise RuntimeError, "Given strings are not equal" ...
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
require 'putty_parse.rb' anal = "..\\..\\win32\\analyzer.exe" #file = $*[0] file = '$stdin' #pgn_white_list = [127508] i = 0 (eval file).each { |l| i+=1 lp = parse_line(l) if lp && (defined? pgn_white_list || pgn_white_list.include?(lp["pgn"])) a = `echo #{i},#{lp["log_line"]} | #{anal} 2> tmp.tx...
Ruby
#!/usr/bin/env ruby # == Synopsis # # Chemical class to access data # == Copyright # Copyright (c) 2008 Carsten Niehaus <cniehaus at kde dot org> # Licence GPLv3 #This is just a shortcut class ChemicalValue < Struct.new(:value, :unit); end # This class represents a chemical element class ChemicalElement attr_acces...
Ruby
#!/usr/bin/env ruby # == Synopsis # # Chemical class to access data # == Copyright # Copyright (c) 2008 Carsten Niehaus <cniehaus at kde dot org> # Licence GPLv3 #This is just a shortcut class ChemicalValue < Struct.new(:value, :unit); end # This class represents a chemical element class ChemicalElement attr_acces...
Ruby
#!/usr/bin/env ruby # == Synopsis # This programm makes it possible to query the # == Usage # ruby query.eb [ -h | --help | -? ] [ -n elementnumber ] # # elementnumber:: # The +number+ of an element (eg '6' for Carbon) # # == Copyright # Copyright (c) 2008 Carsten Niehaus <cniehaus at kde dot org> # Licence GPLv3 re...
Ruby
#!/usr/bin/env ruby # == Synopsis # The parser parses the XML files provided by the BlueObelisk Project and # generates objects of the type ChemicalElement # == Copyright # Copyright (c) 2008 Carsten Niehaus <cniehaus at kde dot org> # Licence GPLv3 require "rexml/document" require "chemicalclasses" # This class pa...
Ruby