repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
martinhristov90/packer-consul
test/integration/consul/controls/consul_directory.rb
control 'consul_directory' do title 'consul_directory_check' desc 'Checks if Consul directory is created and has the right permissions' describe directory('/etc/consul.d/') do it { should exist } its('owner') { should eq 'consul' } its('mode') { should cmp '0755' } end end ...
martinhristov90/packer-consul
test/integration/consul/controls/consul_systemd.rb
<filename>test/integration/consul/controls/consul_systemd.rb control 'consul_systemd' do title 'consul_check_systemd' desc 'Checks if Consul is installed as Systemd service' describe systemd_service('consul') do it { should be_installed } it { should_not be_enabled } it { should...
martinhristov90/packer-consul
test/integration/consul/controls/consul_install.rb
control 'consul_install' do title 'consul_install_check' desc 'Checks if Consul is installed' describe command('consul') do it { should exist } end describe command('consul-template') do it { should exist } end describe command('envconsul') do it { should exist...
martinhristov90/packer-consul
test/integration/consul/controls/consul_user.rb
control 'consul_user' do title 'consul_user_check' desc 'Checks if user consul is available' describe group('consul') do it { should exist } end describe user('consul') do it { should exist } its('shell') { should eq '/bin/false' } its('group') { should eq 'consul...
remore/yarv-prof
yarv-prof.gemspec
<gh_stars>0 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'yarv-prof/version' Gem::Specification.new do |s| s.name = 'yarv-prof' s.version = YarvProf::VERSION s.homepage = 'https://github.com/remore/yarv-prof' s.authors = '<NAME>(@remore)' s.email...
remore/yarv-prof
lib/yarv-prof.rb
<filename>lib/yarv-prof.rb<gh_stars>0 require 'yarv-prof/version' require 'tempfile' class YarvProf class << self def start(clock: :wall, out:'/tmp/yarv-prof/', opt:'-x bufsize=20m') at_exit do Process.kill(:TERM, @pid) if !@pid.nil? FileUtils.remove_entry @file.path if File.exists?(@file.p...
remore/yarv-prof
lib/yarv-prof/version.rb
<reponame>remore/yarv-prof<filename>lib/yarv-prof/version.rb class YarvProf VERSION = "0.1.1" end
stevenspiel/formbuilder-js-rails
lib/formbuilder/formbuilder-js-rails.rb
<gh_stars>0 require "formbuilder/js/rails/version" module Formbuilder module Js module Rails # Your code goes here... end end end
stevenspiel/formbuilder-js-rails
lib/formbuilder/js/rails/version.rb
<filename>lib/formbuilder/js/rails/version.rb module Formbuilder module Js module Rails VERSION = "0.0.2" end end end
camptocamp/vagrant-debian-package
test/unit/vagrant/registry_test.rb
require File.expand_path("../../base", __FILE__) describe Vagrant::Registry do let(:instance) { described_class.new } it "should return nil for nonexistent items" do instance.get("foo").should be_nil end it "should register a simple key/value" do instance.register("foo") { "value" } instance.get(...
camptocamp/vagrant-debian-package
lib/vagrant/plugin/v2/plugin.rb
<filename>lib/vagrant/plugin/v2/plugin.rb<gh_stars>0 require "set" require "log4r" require "vagrant/plugin/v2/components" module Vagrant module Plugin module V2 # This is the superclass for all V2 plugins. class Plugin # Special marker that can be used for action hooks that matches ...
camptocamp/vagrant-debian-package
lib/vagrant/guest.rb
require "log4r" module Vagrant # This class handles guest-OS specific interactions with a machine. # It is primarily responsible for detecting the proper guest OS # implementation and then delegating capabilities. # # Vagrant has many tasks which require specific guest OS knowledge. # These are implemented...
camptocamp/vagrant-debian-package
plugins/providers/virtualbox/action/prepare_nfs_settings.rb
module VagrantPlugins module ProviderVirtualBox module Action class PrepareNFSSettings def initialize(app,env) @app = app @logger = Log4r::Logger.new("vagrant::action::vm::nfs") end def call(env) @app.call(env) using_nfs = false env...
camptocamp/vagrant-debian-package
test/unit/vagrant/plugin/v2/manager_test.rb
require File.expand_path("../../../../base", __FILE__) describe Vagrant::Plugin::V2::Manager do include_context "unit" let(:instance) { described_class.new } def plugin p = Class.new(Vagrant.plugin("2")) yield p p end describe "#action_hooks" do it "should contain globally registered hooks...
camptocamp/vagrant-debian-package
plugins/hosts/linux/plugin.rb
require "vagrant" module VagrantPlugins module HostLinux class Plugin < Vagrant.plugin("2") name "Linux host" description "Linux host support." host("linux") do require File.expand_path("../host", __FILE__) Host end end end end
camptocamp/vagrant-debian-package
plugins/provisioners/shell/provisioner.rb
require "pathname" require "tempfile" require "vagrant/util/downloader" module VagrantPlugins module Shell class Provisioner < Vagrant.plugin("2", :provisioner) def provision args = "" args = " #{config.args}" if config.args command = "chmod +x #{config.upload_path} && #{config.upl...
camptocamp/vagrant-debian-package
plugins/hosts/fedora/host.rb
<filename>plugins/hosts/fedora/host.rb require "pathname" require "vagrant" require Vagrant.source_root.join("plugins/hosts/linux/host") module VagrantPlugins module HostFedora class Host < VagrantPlugins::HostLinux::Host def self.match? release_file = Pathname.new("/etc/redhat-release") ...
camptocamp/vagrant-debian-package
plugins/guests/arch/cap/configure_networks.rb
<reponame>camptocamp/vagrant-debian-package require "tempfile" require "vagrant/util/template_renderer" module VagrantPlugins module GuestArch module Cap class ConfigureNetworks include Vagrant::Util def self.configure_networks(machine, networks) networks.each do |network| ...
camptocamp/vagrant-debian-package
lib/vagrant/action/builtin/wait_for_communicator.rb
<reponame>camptocamp/vagrant-debian-package module Vagrant module Action module Builtin # This waits for the communicator to be ready for a set amount of # time. class WaitForCommunicator def initialize(app, env, states=nil) @app = app @states = states end ...
camptocamp/vagrant-debian-package
lib/vagrant/util/which.rb
require "vagrant/util/platform" module Vagrant module Util class Which # Cross-platform way of finding an executable in the PATH. # # which('ruby') #=> /usr/bin/ruby # # This code is adapted from the following post by mislav: # http://stackoverflow.com/questions/2108727/wh...
camptocamp/vagrant-debian-package
plugins/providers/virtualbox/action/export.rb
require "fileutils" module VagrantPlugins module ProviderVirtualBox module Action class Export attr_reader :temp_dir def initialize(app, env) @app = app end def call(env) @env = env raise Vagrant::Errors::VMPowerOffToPackage if \ ...
camptocamp/vagrant-debian-package
test/unit/vagrant/action/runner_test.rb
<gh_stars>1-10 require File.expand_path("../../../base", __FILE__) describe Vagrant::Action::Runner do let(:instance) { described_class.new } it "should raise an error if an invalid callable is given" do expect { instance.run(7) }.to raise_error(ArgumentError, /must be a callable/) end it "should be able...
camptocamp/vagrant-debian-package
plugins/guests/debian/cap/change_host_name.rb
module VagrantPlugins module GuestDebian module Cap class ChangeHostName def self.change_host_name(machine, name) machine.communicate.tap do |comm| # Get the current hostname # if existing fqdn setup improperly, this returns just hostname old = '' ...
camptocamp/vagrant-debian-package
lib/vagrant/hosts.rb
<gh_stars>1-10 require 'log4r' module Vagrant module Hosts # This method detects the correct host based on the `match?` methods # implemented in the registered hosts. # # @param [Hash] registry Hash mapping key to host class def self.detect(registry) logger = Log4r::Logger.new("vagrant::hos...
camptocamp/vagrant-debian-package
lib/vagrant/action/builtin/box_add.rb
<gh_stars>0 require "log4r" require "vagrant/util/downloader" require "vagrant/util/platform" module Vagrant module Action module Builtin # This middleware will download a remote box and add it to the # given box collection. class BoxAdd def initialize(app, env) @app = app...
camptocamp/vagrant-debian-package
plugins/guests/solaris11/cap/mount_virtualbox_shared_folder.rb
<gh_stars>0 # A general Vagrant system implementation for "solaris 11". # # Contributed by <NAME> <<EMAIL>> module VagrantPlugins module GuestSolaris11 module Cap class MountVirtualBoxSharedFolder def self.mount_virtualbox_shared_folder(machine, name, guestpath, options) # These are just ...
camptocamp/vagrant-debian-package
lib/vagrant/plugin/v2/components.rb
module Vagrant module Plugin module V2 # This is the container class for the components of a single plugin. # This allows us to separate the plugin class which defines the # components, and the actual container of those components. This # removes a bit of state overhead from the plugin cla...
camptocamp/vagrant-debian-package
test/unit/vagrant/config_test.rb
require File.expand_path("../../base", __FILE__) describe Vagrant::Config do it "should not execute the proc on configuration" do described_class.run do raise Exception, "Failure." end end it "should capture calls to `Vagrant.configure`" do receiver = double() procs = described_class.capt...
camptocamp/vagrant-debian-package
plugins/hosts/gentoo/host.rb
<reponame>camptocamp/vagrant-debian-package<filename>plugins/hosts/gentoo/host.rb require "vagrant" require Vagrant.source_root.join("plugins/hosts/linux/host") module VagrantPlugins module HostGentoo class Host < VagrantPlugins::HostLinux::Host def self.match? return File.exists?("/etc/gentoo-rel...
camptocamp/vagrant-debian-package
test/unit/vagrant/machine_test.rb
require "pathname" require File.expand_path("../../base", __FILE__) describe Vagrant::Machine do include_context "unit" let(:name) { "foo" } let(:provider) { double("provider") } let(:provider_cls) do obj = double("provider_cls") obj.stub(:new => provider) obj end let(:provider_config) { ...
camptocamp/vagrant-debian-package
plugins/commands/help/command.rb
require 'optparse' module VagrantPlugins module CommandHelp class Command < Vagrant.plugin("2", :command) def execute return @env.cli([]) if @argv.empty? @env.cli([@argv[0], "-h"]) end end end end
camptocamp/vagrant-debian-package
plugins/commands/destroy/command.rb
module VagrantPlugins module CommandDestroy class Command < Vagrant.plugin("2", :command) def execute options = {} options[:force] = false opts = OptionParser.new do |o| o.banner = "Usage: vagrant destroy [vm-name]" o.separator "" o.on("-f", "--force",...
camptocamp/vagrant-debian-package
plugins/kernel_v2/config/vagrant.rb
require "vagrant" module VagrantPlugins module Kernel_V2 class VagrantConfig < Vagrant.plugin("2", :config) attr_accessor :host def to_s "Vagrant" end end end end
camptocamp/vagrant-debian-package
lib/vagrant/action/builtin/provision.rb
<reponame>camptocamp/vagrant-debian-package<filename>lib/vagrant/action/builtin/provision.rb<gh_stars>0 require "log4r" require_relative "mixin_provisioners" module Vagrant module Action module Builtin # This class will run the configured provisioners against the # machine. # # This acti...
camptocamp/vagrant-debian-package
lib/vagrant/util/downloader.rb
<gh_stars>0 require "log4r" require "vagrant/util/busy" require "vagrant/util/subprocess" module Vagrant module Util # This class downloads files using various protocols by subprocessing # to cURL. cURL is a much more capable and complete download tool than # a hand-rolled Ruby library, so we defer to i...
camptocamp/vagrant-debian-package
plugins/guests/ubuntu/cap/mount_nfs.rb
<gh_stars>1-10 require Vagrant.source_root.join("plugins/guests/linux/cap/mount_nfs") module VagrantPlugins module GuestUbuntu module Cap class MountNFS < GuestLinux::Cap::MountNFS def self.mount_nfs_folder(machine, ip, folders) super # Emit an upstart events if upstart is avai...
camptocamp/vagrant-debian-package
plugins/hosts/slackware/host.rb
<filename>plugins/hosts/slackware/host.rb<gh_stars>1-10 require "vagrant" require Vagrant.source_root.join("plugins/hosts/linux/host") module VagrantPlugins module HostSlackware class Host < VagrantPlugins::HostLinux::Host def self.match? return File.exists?("/etc/slackware-release") || Dir.glob("...
camptocamp/vagrant-debian-package
plugins/guests/ubuntu/cap/mount_virtualbox_shared_folder.rb
<reponame>camptocamp/vagrant-debian-package<gh_stars>0 require Vagrant.source_root.join("plugins/guests/linux/cap/mount_virtualbox_shared_folder") module VagrantPlugins module GuestUbuntu module Cap class MountVirtualBoxSharedFolder < GuestLinux::Cap::MountVirtualBoxSharedFolder def self.mount_virt...
camptocamp/vagrant-debian-package
plugins/commands/plugin/action/bundler_check.rb
<gh_stars>1-10 module VagrantPlugins module CommandPlugin module Action class BundlerCheck def initialize(app, env) @app = app end def call(env) # Bundler sets up its own custom gem load paths such that our # own gems are never loaded. Therefore, give a...
camptocamp/vagrant-debian-package
lib/vagrant/action/builtin/ssh_run.rb
require "log4r" module Vagrant module Action module Builtin # This class will run a single command on the remote machine and will # mirror the output to the UI. The resulting exit status of the command # will exist in the `:ssh_run_exit_status` key in the environment. class SSHRun ...
camptocamp/vagrant-debian-package
plugins/kernel_v2/config/nfs.rb
require "vagrant" module VagrantPlugins module Kernel_V2 class NFSConfig < Vagrant.plugin("2", :config) attr_accessor :map_uid attr_accessor :map_gid def to_s "NFS" end end end end
camptocamp/vagrant-debian-package
plugins/commands/plugin/command/base.rb
module VagrantPlugins module CommandPlugin module Command class Base < Vagrant.plugin("2", :command) # This is a helper for executing an action sequence with the proper # environment hash setup so that the plugin specific helpers are # in. # # @param [Object] callable...
camptocamp/vagrant-debian-package
plugins/hosts/bsd/plugin.rb
<reponame>camptocamp/vagrant-debian-package require "vagrant" module VagrantPlugins module HostBSD class Plugin < Vagrant.plugin("2") name "BSD host" description "BSD host support." host("bsd") do require File.expand_path("../host", __FILE__) Host end end end end
camptocamp/vagrant-debian-package
lib/vagrant/plugin.rb
<filename>lib/vagrant/plugin.rb module Vagrant module Plugin autoload :V1, "vagrant/plugin/v1" autoload :V2, "vagrant/plugin/v2" end end
camptocamp/vagrant-debian-package
plugins/commands/plugin/plugin.rb
<filename>plugins/commands/plugin/plugin.rb require "vagrant" module VagrantPlugins module CommandPlugin class Plugin < Vagrant.plugin("2") name "plugin command" description <<-DESC This command helps manage and install plugins within the Vagrant environment. DESC command("plugin")...
camptocamp/vagrant-debian-package
plugins/providers/virtualbox/action/set_name.rb
require "log4r" module VagrantPlugins module ProviderVirtualBox module Action class SetName def initialize(app, env) @logger = Log4r::Logger.new("vagrant::action::vm::setname") @app = app end def call(env) name = env[:machine].provider_config.name ...
camptocamp/vagrant-debian-package
plugins/hosts/arch/host.rb
require "vagrant" require Vagrant.source_root.join("plugins/hosts/linux/host") module VagrantPlugins module HostArch class Host < VagrantPlugins::HostLinux::Host def self.match? File.exist?("/etc/arch-release") end def self.nfs? # HostLinux checks for nfsd which returns false ...
camptocamp/vagrant-debian-package
test/unit/base.rb
<reponame>camptocamp/vagrant-debian-package require "rubygems" require "rspec/autorun" # Require Vagrant itself so we can reference the proper # classes to test. require "vagrant" # Add the test directory to the load path $:.unshift File.expand_path("../../", __FILE__) # Load in helpers require "support/tempdir" req...
camptocamp/vagrant-debian-package
plugins/provisioners/puppet/config/puppet_server.rb
module VagrantPlugins module Puppet module Config class PuppetServer < Vagrant.plugin("2", :config) attr_accessor :puppet_server attr_accessor :puppet_node attr_accessor :options attr_accessor :facter def facter; @facter ||= {}; end def puppet_server; @puppet...
camptocamp/vagrant-debian-package
lib/vagrant/plugin/v2/host.rb
module Vagrant module Plugin module V2 # Base class for a host in Vagrant. A host class contains functionality # that is specific to a specific OS that is running Vagrant. This # abstraction is done becauase there is some host-specific logic that # Vagrant must do in some cases. clas...
camptocamp/vagrant-debian-package
plugins/provisioners/salt/errors.rb
<filename>plugins/provisioners/salt/errors.rb require "vagrant" module VagrantPlugins module Salt module Errors class SaltError < Vagrant::Errors::VagrantError error_namespace("salt") end end end end
camptocamp/vagrant-debian-package
plugins/guests/freebsd/cap/configure_networks.rb
require "tempfile" require "vagrant/util/template_renderer" module VagrantPlugins module GuestFreeBSD module Cap class ConfigureNetworks include Vagrant::Util def self.configure_networks(machine, networks) # Remove any previous network additions to the configuration file. ...
camptocamp/vagrant-debian-package
plugins/hosts/opensuse/plugin.rb
require "vagrant" module VagrantPlugins module HostOpenSUSE class Plugin < Vagrant.plugin("2") name "OpenSUSE host" description "OpenSUSE host support." host("opensuse") do require File.expand_path("../host", __FILE__) Host end end end end
camptocamp/vagrant-debian-package
plugins/hosts/slackware/plugin.rb
require "vagrant" module VagrantPlugins module HostSlackware class Plugin < Vagrant.plugin("2") name "Slackware host" description "Slackware and derivertives host support." host("slackware") do require File.expand_path("../host", __FILE__) Host end end end end
camptocamp/vagrant-debian-package
plugins/commands/box/command/remove.rb
require 'optparse' module VagrantPlugins module CommandBox module Command class Remove < Vagrant.plugin("2", :command) def execute opts = OptionParser.new do |o| o.banner = "Usage: vagrant box remove <name> <provider>" end # Parse the options arg...
camptocamp/vagrant-debian-package
plugins/guests/freebsd/guest.rb
<gh_stars>1-10 require 'vagrant/util/template_renderer' module VagrantPlugins module GuestFreeBSD # A general Vagrant system implementation for "freebsd". # # Contributed by <NAME> <<EMAIL>> class Guest < Vagrant.plugin("2", :guest) def detect?(machine) machine.communicate.test("uname -...
camptocamp/vagrant-debian-package
test/unit/vagrant/plugin/v2/components_test.rb
require File.expand_path("../../../../base", __FILE__) require "vagrant/registry" describe Vagrant::Plugin::V2::Components do let(:instance) { described_class.new } describe "configs" do it "should have configs" do instance.configs.should be_kind_of(Hash) end it "should default the values to r...
camptocamp/vagrant-debian-package
plugins/guests/debian/plugin.rb
require "vagrant" module VagrantPlugins module GuestDebian class Plugin < Vagrant.plugin("2") name "Debian guest" description "Debian guest support." guest("debian", "linux") do require File.expand_path("../guest", __FILE__) Guest end guest_capability("debian", "co...
RiotGames/unicorn
definitions/unicorn_config.rb
<reponame>RiotGames/unicorn<gh_stars>1-10 # # Author:: <NAME> <<EMAIL>> # Cookbook Name:: unicorn # Definition:: unicorn_config # # Copyright 2009, Opscode, 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...
ryanfox1985/formtastic
lib/formtastic/actions/input_action.rb
<filename>lib/formtastic/actions/input_action.rb module Formtastic module Actions # Outputs an `<input type="submit">` or `<input type="reset">` wrapped in the standard `<li>` # wrapper. This the default for `:submit` and `:reset` actions, but `:as => :button` is also # available as an alternative. # # @ex...
ryanfox1985/formtastic
spec/util_spec.rb
<reponame>ryanfox1985/formtastic # encoding: utf-8 require 'spec_helper' RSpec.describe 'Formtastic::Util' do describe '.deprecated_version_of_rails?' do subject { Formtastic::Util.deprecated_version_of_rails? } context '4.1.0' do before { allow(Formtastic::Util).to receive(:rails_version) { "4.1.0"...
ryanfox1985/formtastic
spec/inputs/with_options_spec.rb
# encoding: utf-8 require 'spec_helper' RSpec.describe 'string input' do include FormtasticSpecHelper before do @output_buffer = '' mock_everything end describe "with_options and :wrapper_html" do before do concat(semantic_form_for(@new_post) do |builder| builder.with_options :wrap...
ryanfox1985/formtastic
lib/formtastic/deprecation.rb
<filename>lib/formtastic/deprecation.rb require 'active_support/deprecation' module Formtastic Deprecation = ActiveSupport::Deprecation end
ryanfox1985/formtastic
lib/formtastic/actions/buttonish.rb
module Formtastic module Actions module Buttonish def supported_methods [:submit, :reset] end def extra_button_html_options { :type => method } end end end end
ryanfox1985/formtastic
lib/formtastic/inputs/base/datetime_pickerish.rb
module Formtastic module Inputs module Base module DatetimePickerish include Base::Placeholder def html_input_type raise NotImplementedError end def default_size raise NotImplementedError end def value raise...
ryanfox1985/formtastic
lib/formtastic/inputs/date_select_input.rb
module Formtastic module Inputs # Outputs a series of select boxes for the fragments that make up a date (year, month, day). # # @see Formtastic::Inputs::Base::Timeish Timeish module for documentation of date, time and datetime input options. class DateSelectInput include Base include Bas...
ryanfox1985/formtastic
lib/formtastic/inputs/datalist_input.rb
module Formtastic module Inputs # Outputs a label and a text field, along with a datalist tag # datalist tag provides a list of options which drives a simple autocomplete # on the text field. This is a HTML5 feature, more info can be found at # {https://developer.mozilla.org/en/docs/Web/HTML/Element/d...
ryanfox1985/formtastic
spec/action_class_finder_spec.rb
<reponame>ryanfox1985/formtastic<filename>spec/action_class_finder_spec.rb # encoding: utf-8 require 'spec_helper' require 'formtastic/action_class_finder' RSpec.describe Formtastic::ActionClassFinder do include FormtasticSpecHelper it_behaves_like 'Specialized Class Finder' do let(:default) { Formtastic::Act...
ryanfox1985/formtastic
lib/formtastic/input_class_finder.rb
<reponame>ryanfox1985/formtastic module Formtastic # Uses the {Formtastic::NamespacedClassFinder} to look up input class names. # # See {Formtastic::FormBuilder#namespaced_input_class} for details. # class InputClassFinder < NamespacedClassFinder # @param builder [FormBuilder] def initialize(builder...
ryanfox1985/formtastic
lib/formtastic/util.rb
<gh_stars>1-10 # encoding: utf-8 module Formtastic # @private module Util extend self def deprecated_version_of_rails? match?(rails_version, "< #{minimum_version_of_rails}") end def minimum_version_of_rails "4.1.0" end def rails_version ::Rails::VERSION::STRING end ...
ryanfox1985/formtastic
lib/formtastic/inputs/base/naming.rb
module Formtastic module Inputs module Base module Naming def as self.class.name.split("::")[-1].underscore.gsub(/_input$/, '') end def sanitized_object_name object_name.to_s.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "") end def sanitized_meth...
ryanfox1985/formtastic
lib/formtastic/inputs/base/timeish.rb
<filename>lib/formtastic/inputs/base/timeish.rb module Formtastic module Inputs module Base # Timeish inputs (`:date_select`, `:datetime_select`, `:time_select`) are similar to the Rails date and time # helpers (`date_select`, `datetime_select`, `time_select`), rendering a series of `<select>` ...
ryanfox1985/formtastic
lib/formtastic/version.rb
module Formtastic VERSION = "3.2.0.pre" end
ryanfox1985/formtastic
lib/formtastic/inputs/base/database.rb
<gh_stars>1-10 module Formtastic module Inputs module Base module Database def column if object.respond_to?(:column_for_attribute) # Remove deprecation wrapper & review after Rails 5.0 ships ActiveSupport::Deprecation.silence do object.column_...
ryanfox1985/formtastic
lib/formtastic/inputs/base/fileish.rb
<reponame>ryanfox1985/formtastic module Formtastic module Inputs module Base module Fileish def file? @file ||= begin # TODO return true if self.is_a?(Formtastic::Inputs::FileInput::Woo) object && object.respond_to?(method) && builder.file_methods.any? { |m| ...
ryanfox1985/formtastic
spec/generators/formtastic/input/input_generator_spec.rb
<gh_stars>1-10 require 'spec_helper' require 'generators/formtastic/input/input_generator' RSpec.describe Formtastic::InputGenerator do include FormtasticSpecHelper destination File.expand_path("../../../../../tmp", __FILE__) before do prepare_destination end after do FileUtils.rm_rf(File.expand_...
ryanfox1985/formtastic
spec/inputs/base/validations_spec.rb
<gh_stars>0 require 'fast_spec_helper' require 'inputs/base/validations' class MyInput include Formtastic::Inputs::Base::Validations end RSpec.describe MyInput do let(:builder) { double } let(:template) { double } let(:model_class) { double } let(:model) { double(:class => model_class) } let(:model_name) ...
ryanfox1985/formtastic
spec/inputs/hidden_input_spec.rb
<gh_stars>1-10 # encoding: utf-8 require 'spec_helper' RSpec.describe 'hidden input' do include FormtasticSpecHelper before do @output_buffer = '' mock_everything concat(semantic_form_for(@new_post) do |builder| concat(builder.input(:secret, :as => :hidden)) concat(builder.input(:pub...
ryanfox1985/formtastic
spec/fast_spec_helper.rb
# encoding: utf-8 $LOAD_PATH << 'lib/formtastic' require 'active_support/all' require 'localized_string' require 'inputs' require 'helpers' class MyInput include Formtastic::Inputs::Base end I18n.enforce_available_locales = false if I18n.respond_to?(:enforce_available_locales)
ryanfox1985/formtastic
lib/formtastic/helpers/input_helper.rb
# -*- coding: utf-8 -*- module Formtastic module Helpers # {#input} is used to render all content (labels, form widgets, error messages, hints, etc) for # a single form input (or field), usually representing a single method or attribute on the # form's object or model. # # The content is wrapped ...
ryanfox1985/formtastic
spec/input_class_finder_spec.rb
# encoding: utf-8 require 'spec_helper' require 'formtastic/input_class_finder' RSpec.describe Formtastic::InputClassFinder do it_behaves_like 'Specialized Class Finder' do let(:default) { Formtastic::Inputs } let(:namespaces_setting) { :input_namespaces } end end
ryanfox1985/formtastic
lib/formtastic/action_class_finder.rb
module Formtastic # Uses the {NamespacedClassFinder} to look up action class names. # # See {Formtastic::Helpers::ActionHelper#namespaced_action_class} for details. # class ActionClassFinder < NamespacedClassFinder # @param builder [FormBuilder] def initialize(builder) super builder.action_nam...
ryanfox1985/formtastic
lib/generators/formtastic/form/form_generator.rb
<reponame>ryanfox1985/formtastic # encoding: utf-8 module Formtastic # Generates a Formtastic form partial based on an existing model. It will not overwrite existing # files without confirmation. # # @example # !!!shell # $ rails generate formtastic:form Post # @example Copy the partial code to the past...
ryanfox1985/formtastic
spec/actions/generic_action_spec.rb
# encoding: utf-8 require 'spec_helper' RSpec.describe 'InputAction::Base' do # Most basic Action class to test Base class ::GenericAction include ::Formtastic::Actions::Base def supported_methods [:submit, :reset, :cancel] end def to_html wrapper do builder.submit(...
ryanfox1985/formtastic
sample/config.ru
module Rack module Formtastic class Samples def initialize(app) @app = app end def call(env) @status, @headers, @body = @app.call(env) @env = env @body = '' if favicon? @body = static_file if !favicon? && static_file? @body = styl...
ryanfox1985/formtastic
spec/support/specialized_class_finder_shared_example.rb
<reponame>ryanfox1985/formtastic # encoding: utf-8 # RSpec.shared_examples 'Specialized Class Finder' do let(:builder) { Formtastic::FormBuilder.allocate } subject(:finder) { described_class.new(builder) } context 'by default' do it 'includes Object and the default namespaces' do expect(finder.namespac...
ryanfox1985/formtastic
spec/builder/error_proc_spec.rb
# encoding: utf-8 require 'spec_helper' RSpec.describe 'Rails field_error_proc' do include FormtasticSpecHelper before do @output_buffer = '' mock_everything end it "should not be overridden globally for all form builders" do current_field_error_proc = ::ActionView::Base.field_error_proc se...
matthijsgroen/game-of-geese
lib/gosu-formatter/listeners/pawn_listener.rb
# tell gosu when pawn is moved module PawnListener attr_accessor :formatter_listener def location=(_value) super.tap { formatter_listener.update } end end
matthijsgroen/game-of-geese
spec/models/rules/well_spec.rb
require 'spec_helper' describe Rules::Well do let(:game) { Game.new } let(:board) { Board.new 40 } let(:die) { FixedDie.new 5 } let(:pawn) { Pawn.new color: :blue } let(:person) { Person.new age: 8 } before do game.board = board game.die = die game.join person, pawn end it 'moves the p...
matthijsgroen/game-of-geese
features/support/helpers/game_helpers.rb
# Helper methods to ease setting up the game module GameHelpers def add_player(game, attributes) person_attributes = attributes.select { |k| [:name, :age].include? k } pawn_attributes = attributes.select { |k| [:color].include? k } person = Person.new person_attributes pawn = Pawn.new(pawn_attributes...
matthijsgroen/game-of-geese
app/models/rules/well.rb
require_relative './base' module Rules # It locks the player in place class Well < Base def leave_space(pawn, die_value) pawn.location += die_value if die_value == 6 end end end
matthijsgroen/game-of-geese
app/models/roles/player_circle.rb
# This role represents a circle of players, # positioned clock-wise module PlayerCircle def start # the youngest player may start sort { |a, b| a.age <=> b.age }.first end def next_after(player) player == last ? first : at(index(player) + 1) end def next_after_with_skipping(player) loop do ...
matthijsgroen/game-of-geese
spec/models/rules/skip_turn_spec.rb
<filename>spec/models/rules/skip_turn_spec.rb require 'spec_helper' describe Rules::SkipTurn do let(:game) { Game.new } let(:board) { Board.new 40 } let(:die) { FixedDie.new 5 } let(:pawn) { Pawn.new color: :blue } let(:person) { Person.new age: 8 } let(:second_person) { Person.new age: 9 } let(:third_...
matthijsgroen/game-of-geese
lib/gosu-formatter/remote_client.rb
<filename>lib/gosu-formatter/remote_client.rb<gh_stars>0 require_relative '../../app/models/board' require_relative '../../app/models/die' require_relative '../../app/models/game' require_relative '../../app/models/pawn' require_relative '../../app/models/person' require_relative '../../app/models/roles/player_circle' ...
matthijsgroen/game-of-geese
lib/gosu-formatter/space_generator.rb
<gh_stars>0 # Generates locations for spaces on the Game of Goose board class SpaceGenerator DIRECTIONS = [:right, :down, :left, :up] def initialize(max_x, max_y, row_spacing:, cell_spacing:) @row_spacing = row_spacing @cell_spacing = cell_spacing set_boundaries(max_x, max_y) @spaces = [] @dire...
matthijsgroen/game-of-geese
spec/models/rules/goto_space_spec.rb
<reponame>matthijsgroen/game-of-geese require 'spec_helper' describe Rules::GotoSpace do let(:game) { Game.new } let(:board) { Board.new 40 } let(:die) { FixedDie.new 5 } let(:pawn) { Pawn.new color: :blue } let(:person) { Person.new age: 8 } before do game.board = board game.die = die game...
matthijsgroen/game-of-geese
app/models/roles/board_pawn.rb
# A pawn that can move across a game board module BoardPawn attr_accessor :location attr_accessor :board end
matthijsgroen/game-of-geese
app/models/rules/skip_turn.rb
require_relative './base' module Rules # Brings the player to a new location class SkipTurn < Base def initialize(amount_turns_to_skip) @amount_turns_to_skip = amount_turns_to_skip @turns_skipped = 0 end def allowed_to_roll? @turns_skipped += 1 @turns_skipped > @amount_turns_to...
matthijsgroen/game-of-geese
lib/gosu-formatter/renderers/board_renderer.rb
<reponame>matthijsgroen/game-of-geese # Renders the game board class BoardRenderer def initialize(window) @window = window @font = Gosu::Font.new(@window, Gosu.default_font_name, 20) @rule_images = [] @default_image = Gosu::Image.new(@window, image_path('default'), true) add_images_by_description...
matthijsgroen/game-of-geese
spec/models/rules/roll_again_spec.rb
<reponame>matthijsgroen/game-of-geese<filename>spec/models/rules/roll_again_spec.rb require 'spec_helper' describe Rules::RollAgain do let(:game) { Game.new } let(:board) { Board.new 40 } let(:die) { FixedDie.new 5 } let(:pawn) { Pawn.new color: :blue } let(:person) { Person.new age: 8 } let(:other_perso...