repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
appcues/data-uploader
test/cli_test.rb
<filename>test/cli_test.rb<gh_stars>0 require 'test/unit' require 'json' require 'pp' CMD = "ruby bin/appcues-data-uploader" class CliTest < Test::Unit::TestCase def test_stdin verify_test_output(`#{CMD} -a 999 -d -q < test/test.csv`) verify_test_output(`#{CMD} -a 999 -d -q - < test/test.csv`) end def ...
ameuret/m2config
spec/setting_spec.rb
# -*- coding: utf-8 -*- require "env" describe M2Config::Setting do describe "::new" do it "stores the given value under the given key" do M2Config::Setting.new("answer",42) res = CFG.db[:setting].first expect(res[:value]).to eq("42") end it "updates the existing value if the give...
ameuret/m2config
spec/server_spec.rb
require "env" describe M2Config::Server do before(:each) do @srv = M2Config::Server.new @host = M2Config::Host.new({matching:"example.com", name: "ex", server_id:(rand 42)}) end describe '::new' do it 'creates a server entry with reasonable default settings' do res = CFG.db[:server].first ...
ameuret/m2config
lib/m2config/dir.rb
module M2Config class Dir < Sequel::Model(:directory) plugin :validation_helpers def initialize( fields ) fields[:default_ctype] ||= "application/octet-stream" fields[:index_file] ||= "index.html" raise ArgumentError, "Base directories are relative to chroot and must not start with a slas...
ameuret/m2config
lib/m2config/handler.rb
<filename>lib/m2config/handler.rb module M2Config class Handler < Sequel::Model(:handler) plugin :validation_helpers def initialize( fields ) raise ArgumentError, "The send and receive endpoints can not be the same" if fields[:send_spec] == fields[:recv_spec] fields[:recv_ident] ||= "" ...
ameuret/m2config
lib/m2config/route.rb
<filename>lib/m2config/route.rb module M2Config class Route < Sequel::Model(:route) many_to_one :host def initialize( fields ) fields[:target_id] = fields[:target].id fields[:target_type] = fields[:target].type fields.delete(:target) super(fields, false) save end def ...
ameuret/m2config
lib/m2config/server.rb
<reponame>ameuret/m2config<filename>lib/m2config/server.rb<gh_stars>0 module M2Config class Server < Sequel::Model(:server) ACCESS_LOG = '/logs/access.log' ERROR_LOG = '/logs/error.log' PID_FILE = '/run/mongrel2.pid' CONTROL_PORT = '' CHROOT = './' DEFAULT_HOST = 'localhost' NAME = 'main' ...
ameuret/m2config
spec/host_spec.rb
<gh_stars>0 require "env" describe M2Config::Host do before(:each) do @srv = CFG.add_server end describe "::new" do it "needs to know the domain name served" do M2Config::Host.new({matching:"example.com", name: "ex"}) res = CFG.db[:host].first expect(res[:matching]).to eq("example.com"...
ameuret/m2config
sample/full.rb
require "m2config" include M2Config cfg = M2Config::Config.new server = M2Config::Server.new exComHost = M2Config::Host.new({matching:"example.com", name:"ex"}) pubDir = M2Config::Dir.new({base:"public/",default_ctype: "text/html"}) pubRoute = M2Config::Route.new( {path:"/", target:pubDir} ) appHand = ...
ameuret/m2config
m2config.gemspec
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'm2config/version' Gem::Specification.new do |spec| spec.name = "m2config" spec.version = M2Config::VERSION spec.authors = ["<NAME>"] spec.email = ["<EMAIL>"] ...
ameuret/m2config
spec/dir_spec.rb
<filename>spec/dir_spec.rb require "env" describe M2Config::Dir do describe "::new" do it "needs to know the base path to handle" do M2Config::Dir.new({base:"images/"}) expect(CFG.db[:directory].first[:base]).to eq("images/") end it "defaults to application/octet-stream for the defaul...
ameuret/m2config
spec/proxy_spec.rb
require "env" M2Config::Config.new # Dummy call to ensure that model classes are required (cf. M2Config::new) describe M2Config::Proxy do describe "::new" do it "needs an address and a port number" do M2Config::Proxy.new({addr:"legacy.local", port: 8080}) res = CFG.db[:proxy].first expect(r...
ameuret/m2config
spec/mimetype_spec.rb
require 'env' describe M2Config::MimeType do describe '::new' do it 'reminds you that Mongrel2 wants the extension string to start with a .' do expect { M2Config::MimeType.new(extension:'bs', mimetype:'text/bullshit') }.to raise_exception(ArgumentError, /extension must start with a \./i) ...
ameuret/m2config
spec/env.rb
<reponame>ameuret/m2config require "bundler/setup" require "m2config" # rspec automatically adds ./lib to LOAD_PATH require "sqlite3" require "pp" require "pry" require "pry-nav" DEFAULT_DB_NAME = "config.sqlite" CUSTOM_DB_NAME = "custom.sqlite" EXISTING_DB_NAME = "empty.sqlite" RSpec.configure do |config| File.del...
ameuret/m2config
spec/handler_spec.rb
<gh_stars>0 # -*- coding: utf-8 -*- require "env" describe M2Config::Handler do describe "::new" do it "needs the ØMQ addresses and a send identifier" do M2Config::Handler.new({ send_spec:"tcp://10.0.0.1:8989", recv_spec:"tcp://10.0.0.1:9898", ...
ameuret/m2config
spec/m2config_spec.rb
require "env" TABLES = %w(directory handler host log mimetype proxy route server setting statistic filter) describe M2Config do describe "::new" do it 'creates a default database when name absent' do expect(File).to exist DEFAULT_DB_NAME end it 'learns the DB schema from the official sch...
ameuret/m2config
lib/m2config/host.rb
<reponame>ameuret/m2config module M2Config class Host < Sequel::Model(:host) one_to_many :routes, {class: "M2Config::Route"} def initialize( fields ) s = resolveServer fields fields[:server_id] = s.id if s raise ArgumentError, "Name can not be nil" if fields[:name].nil? super fields...
ameuret/m2config
lib/m2config/proxy.rb
<reponame>ameuret/m2config module M2Config class Proxy < Sequel::Model(:proxy) def initialize( fields ) super(fields, false) save end def type "proxy" end end end
ameuret/m2config
spec/route_spec.rb
<reponame>ameuret/m2config<gh_stars>0 require "env" describe M2Config::Route do describe "::new" do it "needs to know the path pattern and the target handler" do dirH = M2Config::Dir.new({base: "static/"}) M2Config::Route.new({path:"/blog", target: dirH}) res = CFG.db[:route].first exp...
ameuret/m2config
lib/m2config/setting.rb
<reponame>ameuret/m2config module M2Config class Setting < Sequel::Model(:setting) plugin :validation_helpers def initialize( key, value ) if s=Setting[key:key] s.update({value:value}) return s else fields = {} fields[:key] = key.to_s fields[:value] = va...
ameuret/m2config
lib/m2config.rb
<filename>lib/m2config.rb<gh_stars>0 require "sequel" require "uuid" module M2Config class Config DEFAULT_CONFIG = "config.sqlite" SCHEMA = File.read("#{File.dirname __FILE__}/m2config/schema.sql") attr_reader :db @@foundTables = [] def self.tables return @@foundTables unless...
ameuret/m2config
lib/m2config/mimetype.rb
require "mime/types" require "yaml" module M2Config class MimeType < Sequel::Model(:mimetype) MONGREL2_PREFS = YAML.load File.read "#{File.dirname(__FILE__)}/mongrel2.mime.yml" RECESSIVE = YAML.load File.read "#{File.dirname(__FILE__)}/mongrel2.mime.yml" SQL_FIND_DUPLICATES = <<-SQL ...
dorianlac/dnsdynamic
dnsdynamic.rb
<filename>dnsdynamic.rb<gh_stars>0 #!/usr/bin/env ruby require 'net/http' require 'net/https' #example -> ruby dnsdynamic.rb username password domain timeout username = ARGV[0] password = ARGV[1] domain = ARGV[2] timeout = ARGV[3] def change(username, password, domain, currentIP) http = Net::HTTP.new('dnsdynamic.or...
mrdaios/DevOnPods
AwesomeProject.podspec
<gh_stars>10-100 Pod::Spec.new do |s| s.name = "AwesomeProject" s.version = "1" s.summary = "Use Pods Demo" s.homepage = "https://github.com/DianQK/DevOnPods" s.license = { :type => "MIT", :file => "LICENSE" } s.author = { "DianQK" => "<EMAIL>" } s....
LegionIO/lex-elasticsearch
spec/legion/extensions/elasticsearch_spec.rb
<filename>spec/legion/extensions/elasticsearch_spec.rb RSpec.describe Legion::Extensions::Elasticsearch do it 'has a version number' do expect(Legion::Extensions::Elasticsearch::VERSION).not_to be nil end end
LegionIO/lex-elasticsearch
lib/legion/extensions/elasticsearch.rb
require 'legion/extensions/elasticsearch/version' module Legion module Extensions module Elasticsearch extend Legion::Extensions::Core if Legion::Extensions.const_defined? :Core end end end
proinsias/copier-python-template
copier-python-template/.mdl.rb
# frozen_string_literal: true all exclude_rule 'MD004' rule 'MD007', indent: 4 rule 'MD013', line_length: 120 rule 'MD026', punctuation: '.,:;' rule 'MD029', style: 'ordered'
olindata/puppetlabs-cloud_provisioner
lib/puppet/face/node_aws/list.rb
require 'puppet/cloudpack' require 'puppet/face/node_aws' Puppet::Face.define :node_aws, '0.0.1' do action :list do summary 'List AWS EC2 machine instances.' description <<-'EOT' This action obtains a list of instances from the cloud provider and displays them on the console output. For EC2 in...
olindata/puppetlabs-cloud_provisioner
lib/puppet/face/node_aws/create.rb
require 'puppet/cloudpack' require 'puppet/face/node_aws' Puppet::Face.define :node_aws, '0.0.1' do action :create do summary 'Create a new EC2 machine instance.' description <<-EOT This action launches a new Amazon EC2 instance and returns the public DNS name suitable for SSH access. A ne...
olindata/puppetlabs-cloud_provisioner
lib/puppet/face/node/install.rb
<filename>lib/puppet/face/node/install.rb require 'puppet/cloudpack' Puppet::Face.define :node, '0.0.1' do action :install do summary 'Install Puppet on a running node.' description <<-EOT Installs Puppet on an existing node at <hostname_or_ip>. It uses scp to copy installation requirements to th...
olindata/puppetlabs-cloud_provisioner
lib/puppet/face/node_aws/fingerprint.rb
require 'puppet/cloudpack' require 'puppet/face/node_aws' Puppet::Face.define :node_aws, '0.0.1' do action :fingerprint do summary 'Make a best effort to securely obtain the SSH host key fingerprint.' description <<-EOT This action attempts to retrieve a host key fingerprint by using the EC2 API ...
olindata/puppetlabs-cloud_provisioner
acceptance_tests/install.rb
<reponame>olindata/puppetlabs-cloud_provisioner # # This uses the test harness to install # and configure cloud provisioner # # This can be removed once the installation # of cloud provisioner is added to PE # # on every node, we need to install the fog gem controller = nil test_name "Install Puppet Cloud Provisioner" ...
olindata/puppetlabs-cloud_provisioner
spec/unit/puppet/face/node_aws/fingerprint_spec.rb
<filename>spec/unit/puppet/face/node_aws/fingerprint_spec.rb require 'spec_helper' require 'puppet/cloudpack' describe Puppet::Face[:node_aws, :current] do before :all do data = Fog::Compute::AWS::Mock.data['us-east-1'][Fog.credentials[:aws_access_key_id]] data[:images]['ami-12345'] = { 'imageId' => 'ami-123...
olindata/puppetlabs-cloud_provisioner
lib/puppet/face/node_gce.rb
<reponame>olindata/puppetlabs-cloud_provisioner require 'puppet/face' require 'pathname' require 'puppet/cloudpack/gce' Puppet::Face.define(:node_gce, '1.0.0') do copyright "Puppet Labs", 2013 license "Apache 2 license; see COPYING" summary "View and manage Google Compute nodes." description <<-'EOT' Th...
olindata/puppetlabs-cloud_provisioner
lib/puppet/face/node_aws/bootstrap.rb
<filename>lib/puppet/face/node_aws/bootstrap.rb require 'puppet/cloudpack' require 'puppet/face/node_aws' Puppet::Face.define :node_aws, '0.0.1' do action :bootstrap do summary 'Create and initialize an EC2 instance using Puppet.' description <<-EOT Creates an instance, classifies it, and signs its cer...
olindata/puppetlabs-cloud_provisioner
lib/puppet/face/node_aws/terminate.rb
require 'puppet/cloudpack' require 'puppet/face/node_aws' Puppet::Face.define :node_aws, '0.0.1' do action :terminate do summary 'Terminate an EC2 machine instance.' description <<-EOT Terminate the instance identified by <instance_name>. EOT arguments '<instance_name>' Puppet::CloudPack....
olindata/puppetlabs-cloud_provisioner
lib/puppet/application/node_gce.rb
<filename>lib/puppet/application/node_gce.rb require 'puppet/application/face_base' class Puppet::Application::Node_gce < Puppet::Application::FaceBase end
olindata/puppetlabs-cloud_provisioner
spec/unit/puppet/cloudpack/progressbar_spec.rb
require 'spec_helper' describe "Puppet::CloudPack.constants" do subject { Puppet::CloudPack.constants.collect { |k| k.to_s } } it { should include("ProgressBar") } end
olindata/puppetlabs-cloud_provisioner
lib/puppet/face/node/init.rb
<filename>lib/puppet/face/node/init.rb<gh_stars>1-10 require 'puppet/cloudpack' Puppet::Face.define :node, '0.0.1' do action :init do summary 'Install Puppet on a node and classify it.' description <<-EOT Installs Puppet on an arbitrary node (see "install"), classify it in Puppet Dashboard or Pup...
olindata/puppetlabs-cloud_provisioner
lib/puppet/face/node_aws.rb
require 'puppet/face' Puppet::Face.define(:node_aws, '0.0.1') do copyright "Puppet Labs", 2011 .. 2013 license "Apache 2 license; see COPYING" summary "View and manage Amazon AWS EC2 nodes." description <<-'EOT' This subcommand provides a command line interface to work with Amazon EC2 machine instan...
olindata/puppetlabs-cloud_provisioner
lib/puppet/cloudpack/installer.rb
require 'erb' require 'puppet' require 'puppet/cloudpack' module Puppet::CloudPack::Installer class << self def build_installer_template(name, options = {}) # binding is a kernel method ERB.new(File.read(find_template(name))).result(binding) end def lib_script_dir File.join(File.expan...
olindata/puppetlabs-cloud_provisioner
acceptance_tests/tests/create_ec2_instance.rb
# variables that need to be set at a higher level ami='ami-06ad526f' login='ubuntu' keypair=@options[:keypair] keyfile=@options[:keyfile] # this method can be used to parse out the nodes # that are described in STDOUT from the list # action def parse_node_list(stdout) node_status = {} entries = stdout.split("\ni")...
olindata/puppetlabs-cloud_provisioner
spec/unit/puppet/face/node_aws/bootstrap_spec.rb
<reponame>olindata/puppetlabs-cloud_provisioner require 'spec_helper' require 'puppet/cloudpack' describe Puppet::Face[:node_aws, :current] do before :each do @options = { :image => 'ami-12345', :keyname => 'some_keypair', :login => 'ubuntu', :keyfile ...
olindata/puppetlabs-cloud_provisioner
spec/unit/puppet/face/node/init_spec.rb
require 'spec_helper' require 'puppet/cloudpack' describe Puppet::Face[:node, :current] do before :each do @options = { :login => 'ubuntu', :keyfile => 'file_on_disk.txt', :installer_payload => 'some.tar.gz', :installer_answers => 'some.answers', :node_group ...
olindata/puppetlabs-cloud_provisioner
lib/puppet/cloudpack/gce.rb
require 'puppet/cloudpack' # This is a container for various horrible procedural code used to set up the # face actions for the `node_gce` face. It lives here because the design of # faces -- reinventing the Ruby object model, poorly -- makes it impossible to # do standard things such as module inclusion, or inherita...
olindata/puppetlabs-cloud_provisioner
lib/puppet/face/node_aws/list_keynames.rb
require 'puppet/face/node_aws' require 'puppet/cloudpack' Puppet::Face.define :node_aws, '0.0.1' do action :list_keynames do summary 'List available AWS EC2 key names.' description <<-'EOT' This action lists the available AWS EC2 key names and their fingerprints. Any key name from this list is ...
olindata/puppetlabs-cloud_provisioner
lib/puppet/application/node_aws.rb
require 'puppet/application/face_base' class Puppet::Application::Node_aws < Puppet::Application::FaceBase end
olindata/puppetlabs-cloud_provisioner
spec/spec_helper.rb
unless defined?(SPEC_HELPER_IS_LOADED) SPEC_HELPER_IS_LOADED = 1 dir = File.expand_path(File.dirname(__FILE__)) $LOAD_PATH.unshift("#{dir}/") $LOAD_PATH.unshift("#{dir}/lib") # a spec-specific test lib dir $LOAD_PATH.unshift("#{dir}/../lib") # Don't want puppet getting the command line arguments for rake or autotest...
olindata/puppetlabs-cloud_provisioner
spec/unit/puppet/face/node_aws/create_spec.rb
<filename>spec/unit/puppet/face/node_aws/create_spec.rb require 'spec_helper' require 'puppet/cloudpack' describe Puppet::Face[:node_aws, :current] do before :all do data = Fog::Compute::AWS::Mock.data['us-east-1'][Fog.credentials[:aws_access_key_id]] data[:images]['ami-12345'] = { 'imageId' => 'ami-12345' }...
olindata/puppetlabs-cloud_provisioner
spec/unit/puppet/face/node/install_spec.rb
<reponame>olindata/puppetlabs-cloud_provisioner<filename>spec/unit/puppet/face/node/install_spec.rb<gh_stars>1-10 require 'spec_helper' require 'puppet/cloudpack' require 'tempfile' describe Puppet::Face[:node, :current] do # we need to keep references to the Tempfile's we create # otherwise the created temporary ...
diegotoral/cache-money
lib/cash/mock.rb
<filename>lib/cash/mock.rb module Cash class Mock < HashWithIndifferentAccess attr_accessor :servers def get_multi(keys) slice(*keys).collect { |k,v| [k, Marshal.load(v)] }.to_hash end def set(key, value, ttl = 0, raw = false) self[key] = marshal(value, raw) end def get(key, raw...
diegotoral/cache-money
lib/cash/query/abstract.rb
<filename>lib/cash/query/abstract.rb module Cash module Query class Abstract delegate :with_exclusive_scope, :get, :table_name, :indices, :find_from_ids_without_cache, :cache_key, :columns_hash, :to => :@active_record def self.perform(*args) new(*args).perform end def initialize(...
diegotoral/cache-money
spec/cash/lock_spec.rb
<filename>spec/cash/lock_spec.rb require File.join(File.dirname(__FILE__), '..', 'spec_helper') module Cash describe Lock do describe '#synchronize' do it "yields the block" do block_was_called = false $lock.synchronize('lock_key') do block_was_called = true end bl...
diegotoral/cache-money
lib/cash/query/calculation.rb
module Cash module Query class Calculation < Abstract delegate :calculate_without_cache, :incr, :to => :@active_record def initialize(active_record, operation, column, options1, options2) super(active_record, options1, options2) @operation, @column = operation, column end ...
diegotoral/cache-money
lib/cash/transactional.rb
module Cash class Transactional attr_reader :memcache def initialize(memcache, lock) @memcache, @cache = [memcache, memcache] @lock = lock end def transaction exception_was_raised = false begin_transaction result = yield rescue Object => e exception_was_raised...
diegotoral/cache-money
lib/cash/request.rb
module Cash Request = {} end
diegotoral/cache-money
spec/cash/write_through_spec.rb
require File.join(File.dirname(__FILE__), '..', 'spec_helper') module Cash describe WriteThrough do describe 'ClassMethods' do describe 'after create' do it "inserts all indexed attributes into the cache" do story = Story.create!(:title => "I am delicious") Story.get("title/#{st...
diegotoral/cache-money
lib/cash/query/select.rb
module Cash module Query class Select < Abstract delegate :find_every_without_cache, :to => :@active_record protected def miss(_, miss_options) find_every_without_cache(miss_options) end def uncacheable find_every_without_cache(@options1) end end end end...
diegotoral/cache-money
spec/spec_helper.rb
<reponame>diegotoral/cache-money<filename>spec/spec_helper.rb dir = File.dirname(__FILE__) $LOAD_PATH.unshift "#{dir}/../lib" require 'rubygems' require 'spec' require 'pp' require 'cache_money' require 'memcache' require File.join(dir, '../config/environment') Spec::Runner.configure do |config| config.mock_with :r...
dannyflatiron/mechanics-of-migrations-online-web-pt-110419
artist.rb
class Artist<ActiveRecord::Base # this is extending the class with ActiveRecord end
poise/poise-tls-remote-file
test/cookbook/recipes/default.rb
# # Copyright 2017, <NAME> # # 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 writing, softwa...
poise/poise-tls-remote-file
test/spec/resources/poise_tls_remote_file_spec.rb
<reponame>poise/poise-tls-remote-file # # Copyright 2017, <NAME> # # 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 applicab...
poise/poise-tls-remote-file
chef/attributes/default.rb
# # Copyright 2017, <NAME> # # 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 writing, softwa...
poise/poise-tls-remote-file
lib/poise_tls_remote_file/resources/poise_tls_remote_file.rb
<gh_stars>0 # # Copyright 2017, <NAME> # # 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 wri...
MaxLap/winever
lib/winever/cron_entry.rb
module Winever class CronEntry attr_accessor :cron_time, :task_folder, :task_name, :working_directory, :parameters, :cron_line def self.from_cron_output cron_output, include_invalid=false entries = cron_output.split("\n").reject(&:empty?).map{|o| new(o)} entries = entries.select(&:valid?) unless ...
MaxLap/winever
lib/winever/cron_time.rb
<reponame>MaxLap/winever<filename>lib/winever/cron_time.rb module Winever class CronTime attr_accessor :string, :parts, :minute, :hour, :day, :month, :dow def initialize cron_time_string @string = cron_time_string @parts = Array.new(5, '') string_parts = cron_time_string.split(/ +/) ...
MaxLap/winever
lib/winever/command_line.rb
module Winever class CommandLine def self.run_from_command_line_options require 'optparse' options = {} OptionParser.new do |opts| opts.banner = "Usage: whenever [options]" opts.on('-i', '--update [identifier]', 'Default: full path to schedule.rb file') do |identifier| ...
MaxLap/winever
lib/winever/whenever_interface.rb
module Winever module WheneverInterface def self.run_from_winever? @run_from_winever || false end def self.remove_existing_tasks *names @existing_tasks_to_remove ||= [] @existing_tasks_to_remove.concat(names.flatten) end def self.existing_tasks_to_remove @existing_tasks_t...
MaxLap/winever
lib/winever/task_manager.rb
<reponame>MaxLap/winever module Winever class TaskManager def self.has_task_scheduler? return @has_task_scheduler unless @has_task_scheduler.nil? begin require 'win32/taskscheduler' @has_task_scheduler = true rescue LoadError => e @has_task_scheduler = false end ...
MaxLap/winever
test/unit/cron_time_test.rb
<reponame>MaxLap/winever require 'test_helper' describe Winever::CronTime do it "must support daily jobs with single specific time" do Winever::CronTime.new('12 10 * * *').supported?.must_equal true end it "must only support 5 time parts" do Winever::CronTime.new('12 10 * *').supported?.must_equal fals...
MaxLap/winever
lib/winever.rb
<reponame>MaxLap/winever require 'winever/version' require 'whenever' # A very tiny monkey patch of Whenever, adding some helper functions in the schedule. module Whenever class JobList # We are running from winever? If you need tasks only on your Windows or your Linux servers, you can use #winever? def wine...
MaxLap/winever
lib/winever/setup_schedule.rb
<gh_stars>0 if winever? set :job_template, "|:job" # Overwrite to put tasks in a different subfolder of the task scheduler. # Right now, anything other than \\ will break clear_tasks, so don't change folder for now. set :task_folder, "\\" job_type :command, ":task_folder|:task_name||:task :output" job_ty...
Fizziology/sina-weibo-rules
test/test_rule.rb
require 'helper' class TestRule < Test::Unit::TestCase context "SinaWeibo Rules" do context "without tags" do setup do @rule = SinaWeibo::Rule.new( '"bangor slov"') end should "allow creation of quoted rule" do assert{ @rule.value == "\"bangor slov\"" } assert{ @rule....
Fizziology/sina-weibo-rules
lib/sina-weibo-rules/version.rb
module SinaWeibo VERSION = File.open('VERSION', 'rb') { |f| f.read } end
Fizziology/sina-weibo-rules
lib/sina-weibo-rules/api.rb
<filename>lib/sina-weibo-rules/api.rb module SinaWeibo module API def add( rules = [] ) options = {queries: rules } SinaWeibo::Response.new self.class.post('/rules', body: options.to_json) end def remove( rules = [] ) options = {queries: rules } SinaWeibo::Response.new self.class...
Fizziology/sina-weibo-rules
lib/sina-weibo-rules.rb
require 'active_support' require 'httparty' require 'json' require 'logger' require 'sina-weibo-rules/api' require 'sina-weibo-rules/response' require 'sina-weibo-rules/rule' module SinaWeibo class Rules include HTTParty include SinaWeibo::API headers 'Accept' => 'application/json', 'Content-Type' => '...
Fizziology/sina-weibo-rules
test/helper.rb
<reponame>Fizziology/sina-weibo-rules require 'rubygems' require 'bundler' begin Bundler.setup(:default, :development) Bundler.require( :default, :development ) rescue Bundler::BundlerError => e $stderr.puts e.message $stderr.puts "Run `bundle install` to install missing gems" exit e.status_code end require '...
Fizziology/sina-weibo-rules
test/test_gnip-rules.rb
require 'helper' class TestSinaWeiboRules < Test::Unit::TestCase context 'SinaWeibo' do setup do @weibo = SinaWeibo::Rules.new end should "allow creation of rules" do response = @weibo.add([SinaWeibo::Rule.new( '"new spyro"' )]) assert{ response.response.class == Net::HTTPCreated } ...
Fizziology/sina-weibo-rules
lib/sina-weibo-rules/rule.rb
module SinaWeibo class Rule attr_accessor :value, :tag, :errors def initialize( v , t = nil ) @value = v @tag = t @errors = [] end def as_json(options={}) o = {"query" => value} o.merge!( "tag" => tag ) unless tag.nil? return o end def valid? valid...
Fizziology/sina-weibo-rules
lib/sina-weibo-rules/response.rb
include Forwardable module SinaWeibo class Response extend Forwardable def_delegators :@http_party_response, :response, :request, :body, :headers, :code attr_reader :http_party_response def initialize(http_party_response) @http_party_response = http_party_response end def rules ...
worlduniting/myotherskills.org
app/controllers/dashboard_controller.rb
<filename>app/controllers/dashboard_controller.rb class DashboardController < ApplicationController before_action :authenticate_user! def index @skills = Skill.all end end
worlduniting/myotherskills.org
config/initializers/preferences.rb
# Be sure to restart your server when you modify this file. # All MyOtherSkills preferences are here. MyOtherSkills::Application.config.application_name = "myotherskills.org"
worlduniting/myotherskills.org
test/helpers/skills_helper_test.rb
require 'test_helper' class SkillsHelperTest < ActionView::TestCase end
worlduniting/myotherskills.org
config/routes.rb
MyOtherSkills::Application.routes.draw do resources :skills devise_for :users, :controllers => { :registrations => :registrations } devise_for :admins get '/token' => 'home#token', as: :token get '/admins/manage' => 'admins#manage', as: :manage get '/dashboard' => 'dashboard#index', as: :dashboard ...
worlduniting/myotherskills.org
app/controllers/users_controller.rb
class UsersController < ApplicationController def show @user = User.where(:username => params[:username]).first end end
worlduniting/myotherskills.org
app/views/skills/show.json.jbuilder
<filename>app/views/skills/show.json.jbuilder json.extract! @skill, :id, :name, :experience, :level, :description, :created_at, :updated_at
worlduniting/myotherskills.org
db/migrate/20140319054205_create_skills.rb
class CreateSkills < ActiveRecord::Migration def change create_table :skills do |t| t.string "name" t.integer "experience" t.integer "level" t.text "description" t.datetime "created_at" t.datetime "updated_at" end end end
worlduniting/myotherskills.org
app/controllers/registrations_controller.rb
<gh_stars>0 class RegistrationsController < Devise::RegistrationsController def update @user = User.find(current_user.id) successfully_updated = if needs_password?(@user, params) @user.update_with_password(user_params) else ...
worlduniting/myotherskills.org
db/migrate/20140319021156_add_postal_code_to_users.rb
<filename>db/migrate/20140319021156_add_postal_code_to_users.rb class AddPostalCodeToUsers < ActiveRecord::Migration def change # Postal Code for Geo-location of users add_column :users, :postal_code, :string end end
worlduniting/myotherskills.org
app/controllers/home_controller.rb
class HomeController < ApplicationController before_action :authenticate_user!, only: :token def token end end
worlduniting/myotherskills.org
app/controllers/admins_controller.rb
class AdminsController < ApplicationController before_action :authenticate_admin! def manage end end
nerdgeschoss/pixelpress
lib/pixelpress/renderers/test_renderer.rb
<gh_stars>1-10 class Pixelpress::TestRenderer def render(html) File.binread(File.join(__dir__, "test.pdf")) end end
nerdgeschoss/pixelpress
lib/pixelpress/base.rb
require 'action_controller' require_relative 'renderers/weasyprint_renderer' require_relative 'renderers/test_renderer' require_relative 'instance_invocation' require_relative 'rendering' module Pixelpress class Base < ActionController::Base extend InstanceInvocation include Rendering end end
nerdgeschoss/pixelpress
lib/generators/rspec/templates/printer_spec.rb
<filename>lib/generators/rspec/templates/printer_spec.rb require '<%= File.exists?('spec/rails_helper.rb') ? 'rails_helper' : 'spec_helper' %>' describe <%= class_name %>Printer, pending: true do it "should be tested" do raise "implement your rspec tests" end end
nerdgeschoss/pixelpress
lib/pixelpress/rendering.rb
module Pixelpress module Rendering module ClassMethods attr_writer :default_renderer def default_renderer @default_renderer ||= WeasyPrintRenderer.new end end def self.included(base) base.extend(ClassMethods) end def document @document ||= Document.new rende...
nerdgeschoss/pixelpress
lib/pixelpress/preview.rb
module Pixelpress class Preview def self.all Dir[Rails.root.join('spec', 'printers', 'previews', '**', '*_preview.rb')].map do |file| require_dependency file file.split('printers/previews/').last.sub('.rb', '').classify.constantize.new end end def previews methods - Obje...
nerdgeschoss/pixelpress
spec/lib/generators/test/generator_spec/printer_generator_spec.rb
<gh_stars>1-10 require 'spec_helper' RSpec.describe Pixelpress::Generators::PrinterGenerator do path = File.expand_path('../test_destination', __FILE__) destination path arguments %w(Auth::UserPrinter user_data) before(:each) do prepare_destination allow(Rails).to receive(:root).and_return Pathname.ne...
nerdgeschoss/pixelpress
app/controllers/pixelpress/printers_controller.rb
class Pixelpress::PrintersController < ActionController::Base def index @printers = Pixelpress::Preview.all end def show klass = params[:printer_id] method = params[:id] printer = Pixelpress::Preview.all.map { |e| [e.printer_name, e] }.to_h[klass].send(method) respond_to do |format| for...
nerdgeschoss/pixelpress
lib/pixelpress/fake_file.rb
<gh_stars>1-10 module Pixelpress class FakeFile < StringIO attr_accessor :original_filename, :content_type def initialize(data, options = {}) @original_filename = options[:original_filename] @content_type = options[:content_type] super data end def original_filename @original...
nerdgeschoss/pixelpress
lib/generators/pixelpress/printer/templates/printer.rb
<% module_namespacing do -%> class <%= class_name %>Printer < ApplicationPrinter<% passed_methods.each do |m| %> def <%= m %> #put your code here, if you want :) end<% end %> end <% end -%>