source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
solutious/rudy
https://github.com/solutious/rudy
lib/rudy/cli/aws/ec2/keypairs.rb
Ruby
mit
88
master
1,231
module Rudy; module CLI; module AWS; module EC2; class Keypairs < Rudy::CLI::CommandBase def create_keypairs_valid? raise Drydock::ArgError.new('name', @alias) unless @argv.name true end def create_keypairs kp = execute_action { Rudy::AWS::EC2::Keypairs.create(@argv.name) } ...
github
solutious/rudy
https://github.com/solutious/rudy
lib/rudy/cli/aws/sdb/select.rb
Ruby
mit
88
master
454
module Rudy; module CLI; module AWS; module SDB; class Select < Rudy::CLI::CommandBase def query_valid? raise "No select query supplied" if @argv.empty? true end def query @sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region) results = @sd...
github
solutious/rudy
https://github.com/solutious/rudy
lib/rudy/cli/aws/sdb/objects.rb
Ruby
mit
88
master
978
module Rudy; module CLI; module AWS; module SDB; class Objects < Rudy::CLI::CommandBase def objects_valid? raise "Usage: rudy-sdb objects DOMAIN" if @argv.empty? true end def objects @sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region) ...
github
solutious/rudy
https://github.com/solutious/rudy
lib/rudy/cli/aws/sdb/domains.rb
Ruby
mit
88
master
966
module Rudy; module CLI; module AWS; module SDB; class Domains < Rudy::CLI::CommandBase def domains @sdb = Rudy::AWS::SDB.new(@@global.accesskey, @@global.secretkey, @@global.region) domains = @sdb.list_domains puts domains puts "No domains" if domains.nil? || domains.empty? ...
github
solutious/rudy
https://github.com/solutious/rudy
lib/rudy/cli/aws/s3/buckets.rb
Ruby
mit
88
master
1,184
module Rudy; module CLI; module AWS; module S3; class Buckets < Rudy::CLI::CommandBase def buckets raise "No bucket name supplied" if !@argv.name && @option.list s3 = Rudy::AWS::S3.new(@@global.accesskey, @@global.secretkey, @@global.region) unless @option.list (s3.list_buc...
github
solutious/rudy
https://github.com/solutious/rudy
lib/rudy/cli/aws/s3/store.rb
Ruby
mit
88
master
452
module Rudy; module CLI; module AWS; module S3; class Store < Rudy::CLI::CommandBase def store_valid? raise "No path specified" unless @argv.path raise "No bucket specified" unless @option.bucket true end def store s3 = Rudy::AWS::S3.new(@@global.accesskey, @@global.secret...
github
solutious/rudy
https://github.com/solutious/rudy
examples/windows.rb
Ruby
mit
88
master
2,061
# Rudy Windows Machines # # This configuration is used to # test windows instance support. defaults do color true environment :test role :windows zone :'eu-west-1b' bucket 'rudy-ami-eu' end machines do region :'us-east-1' do ami 'ami-de4daab7' # Amazon Windows Server 2003 (US) size...
github
solutious/rudy
https://github.com/solutious/rudy
examples/solaris.rb
Ruby
mit
88
master
532
# Rudy Solaris Machines # # This configuration is used to # test solaris instance support. defaults do color true environment :test role :solaris end machines do region :'us-east-1' do ami 'ami-8f30d1e6' # OpenSolaris 2009.06 32-bit (US) end region :'eu-west-1' do ami 'ami-2381a95...
github
solutious/rudy
https://github.com/solutious/rudy
examples/spot_instances.rb
Ruby
mit
88
master
2,341
machines do env :stage do ami 'ami-e348af8a' # Alestic Debian 5.0, 32-bit (US) # Changing to spot pricing causes Rudy to aquire your instances via a "spot request" # to EC2, as opposed to asking EC2 to boot your instances directly (so-called "on # demand" instances). Consequently, the f...
github
solutious/rudy
https://github.com/solutious/rudy
examples/authorize.rb
Ruby
mit
88
master
308
machines do env :stage do user :jira ami 'ami-e348af8a' # Alestic Debian 5.0, 32-bit (US) end end routines do setup do # NOTE: This fails b/c it's trying to login as jira rather than root. adduser :jira authorize :jira end end
github
solutious/rudy
https://github.com/solutious/rudy
examples/gem-test.rb
Ruby
mit
88
master
2,065
# Rudy Gem Test # # This configuration is used to # test installing the Rudy gem. defaults do color true environment :test role :rudy end machines do region :'us-east-1' do ami 'ami-e348af8a' # Alestic Debian 5.0, 32-bit (US) end env :test do role :rudy do user :root end ...
github
revans/Ti
https://github.com/revans/Ti
Rakefile
Ruby
mit
87
master
886
require 'rubygems' require 'bundler' begin Bundler.setup(: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 'rake' require 'time' require 'rake/testtask' Rake::TestTask.new(:test) do |test|...
github
revans/Ti
https://github.com/revans/Ti
ti.gemspec
Ruby
mit
87
master
1,879
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "ti/version" Gem::Specification.new do |s| s.name = %q{ti} s.version = '0.2.0' s.platform = Gem::Platform::RUBY s.authors = ["Robert R Evans", "Julius Francisco", "Wynn Netherland", "Rupak Ganguly"] s.dat...
github
revans/Ti
https://github.com/revans/Ti
Guardfile
Ruby
mit
87
master
201
guard 'rspec', :cli => "--color --format documentation" do watch(%r{^spec/.+_spec\.rb}) watch(%r{^cli/(.+)\.rb}) { |m| "spec/cli/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } end
github
revans/Ti
https://github.com/revans/Ti
lib/ti.rb
Ruby
mit
87
master
1,080
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) require 'rubygems' require 'pathname' require 'fileutils' require 'rbconfig' require 'colored' require 'rocco' require 'thor' require 'erubis' require 'nokogiri' module Ti ROOT_PATH...
github
revans/Ti
https://github.com/revans/Ti
lib/ti/utils.rb
Ruby
mit
87
master
2,432
module Ti module Utils def create_new_file(name, file=nil) log "Creating #{name}" contents = file.nil? ? '' : File.read(file) unless File.file?(location.join(name)) File.open(location.join(name), 'w') { |f| f.write(contents) } end end def get_app_name config = File...
github
revans/Ti
https://github.com/revans/Ti
lib/ti/cli.rb
Ruby
mit
87
master
3,122
module Ti class CLI < Thor include Utils STATUS_TYPES = {:success => 0, :general_error => 1, :not_supported => 3, :not_found => 4, :incorrect_usage => 64, } no_tasks { def cli_e...
github
revans/Ti
https://github.com/revans/Ti
lib/ti/config.rb
Ruby
mit
87
master
665
require 'nokogiri' module Ti class Config attr_accessor :id, :name, :version, :publisher, :url, :description, :copyright def parse(filename) xml = File.open(filename) doc = Nokogiri::XML(xml) xml.close # parse into properties @id = doc.xpath('ti:app/id').text ...
github
revans/Ti
https://github.com/revans/Ti
lib/ti/compiler/sass_scripts.rb
Ruby
mit
87
master
414
require 'sass' module Ti module Compiler class SASSScripts class << self include ::Ti::Utils # def compile(contents, compile_to_location) def compile system "sass --compass -C -t expand app/#{underscore(get_app_name)}/stylesheets/app.sass > Resources/app.jss" log...
github
revans/Ti
https://github.com/revans/Ti
lib/ti/compiler/coffee_scripts.rb
Ruby
mit
87
master
1,245
require 'coffee_script' module Ti module Compiler class CoffeeScripts class << self include ::Ti::Utils def compile_all! coffeefile = File.read(base_location.join('Coffeefile')).split("\n").compact.delete_if { |l| l.include?("#") } files = coffeefile.colle...
github
revans/Ti
https://github.com/revans/Ti
lib/ti/generate/project.rb
Ruby
mit
87
master
3,863
require 'session' module Ti module Generate class Project class << self attr_accessor :project_name, :device_platform, :app_id include ::Ti::Utils # Ti::Generate::Project.create('demo', 'org.codewranglers.demo', 'ipad') def create(name, id, platform='iphone') @proj...
github
revans/Ti
https://github.com/revans/Ti
lib/ti/generate/view.rb
Ruby
mit
87
master
1,718
module Ti module Generate class View class << self include ::Ti::Utils def create(name, context={}) create_view_template(name, context) end def create_view_template(name, context) log "Creating #{name} view using a template." app...
github
revans/Ti
https://github.com/revans/Ti
lib/ti/generate/controller.rb
Ruby
mit
87
master
1,268
module Ti module Generate class Controller class << self include ::Ti::Utils def create(name, context={}) create_controller_file(name, context) end def create_controller_file(name, context) log "Creating #{name} controller using a templa...
github
revans/Ti
https://github.com/revans/Ti
lib/ti/generate/model.rb
Ruby
mit
87
master
778
module Ti module Generate class Model class << self include ::Ti::Utils def create(name) create_model_file(name) end def create_model_file(name) log "Creating a new model file named #{name}." model_directory = "app/#{underscore(...
github
revans/Ti
https://github.com/revans/Ti
lib/ti/builder/titanium.rb
Ruby
mit
87
master
914
module Ti module Builder class Titanium class << self require 'rake' include ::Ti::Utils # TODO: This should be loaded properly load 'config/config.rb' include Config def build(platform) log "Building with Titanium... DEVICE_TYPE: #{platform}" ...
github
revans/Ti
https://github.com/revans/Ti
lib/ti/templates/rakefile
Ruby
mit
87
master
2,464
require 'rubygems' require 'colored' require File.join(File.dirname(__FILE__), 'config.rb') include Config task :default => ["build:iphone"] namespace :project do desc "Get project information" task :info do puts "#{PROJECT_NAME} at version #{PROJECT_VERSION}." puts " App ID: #{APP_ID}." puts " App Na...
github
revans/Ti
https://github.com/revans/Ti
spec/spec_helper.rb
Ruby
mit
87
master
967
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib', 'ti')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'rspec' require 'ti' require 'stringio' require 'config' RSpec.configure do |config| def capture_with_status(stream) exit_status = 0 begin stream = stream.to_s eval "$#{str...
github
revans/Ti
https://github.com/revans/Ti
spec/cli/command_spec.rb
Ruby
mit
87
master
7,415
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "Ti Generator Commands" do context "Help command:" do context "ti help" do it "should display the basic help for the CLI" do response, status = capture_with_status(:stdout){ Ti::CLI.start(['help']) } status.should...
github
revans/Ti
https://github.com/revans/Ti
spec/ti/logger_spec.rb
Ruby
mit
87
master
724
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "The Logger" do before(:each) do @stdout_orig = $stdout $stdout = StringIO.new @stderr_orig = $stderr $stderr = StringIO.new end context "Reporting an error" do it "should output a formatted m...
github
revans/Ti
https://github.com/revans/Ti
spec/ti/utils_spec.rb
Ruby
mit
87
master
4,073
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "The utilities" do before(:each) do class Klass class << self include ::Ti::Utils end end end it "should return the base location" do Klass.base_location.should == Pathname.new(Dir.pwd) end ...
github
revans/Ti
https://github.com/revans/Ti
spec/ti/generators/model_spec.rb
Ruby
mit
87
master
780
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe "Creating of a model" do before(:all) do ::Ti::Generate::Project.create('dailyfocus', 'org.codewranglers.demo', 'ipad') end context "Creating a model file and its spec" do before(:all) do # ::Ti::Generate::Model.c...
github
revans/Ti
https://github.com/revans/Ti
spec/ti/generators/project_spec.rb
Ruby
mit
87
master
3,639
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe "Creating of a new Ti Project" do before(:all) do ::Ti::Generate::Project.create('dailyfocus', 'org.codewranglers.demo', 'ipad') end context "Directories should be created" do it "should have created the project" do ...
github
revans/Ti
https://github.com/revans/Ti
spec/ti/generators/view_spec.rb
Ruby
mit
87
master
780
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe "Creating of a view file" do before(:each) do ::Ti::Generate::Project.create('dailyfocus', 'org.codewranglers.demo', 'ipad') end context "Creating a view file and its spec" do before(:all) do # system("cd dailyfocus...
github
revans/Ti
https://github.com/revans/Ti
spec/lib/config_spec.rb
Ruby
mit
87
master
1,054
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe "Ti Config" do context "Reading the Ti app config file (tiapp.xml)" do before (:all) do @config = Ti::Config.new @config.parse(fixture_file(:config, 'tiapp.xml')) end it "should be able to get the id" do @conf...
github
Netflix/restful-jsonapi
https://github.com/Netflix/restful-jsonapi
restful-jsonapi.gemspec
Ruby
mit
88
master
1,106
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'restful/jsonapi/version' Gem::Specification.new do |spec| spec.name = "restful-jsonapi" spec.version = Restful::Jsonapi::VERSION spec.authors = ["Zach Wentz", "Ryan Joh...
github
Netflix/restful-jsonapi
https://github.com/Netflix/restful-jsonapi
lib/restful/jsonapi.rb
Ruby
mit
88
master
282
require "restful/jsonapi/version" require 'restful/jsonapi/railtie' if defined?(Rails) require 'restful/jsonapi/restify_param' require 'restful/jsonapi/serializable_errors' require 'restful/jsonapi/active_model_serializer' module Restful module Jsonapi # Good job! end end
github
Netflix/restful-jsonapi
https://github.com/Netflix/restful-jsonapi
lib/restful/jsonapi/restify_param.rb
Ruby
mit
88
master
3,115
module Restful module Jsonapi module RestifyParam extend ActiveSupport::Concern def restify_param(param_key) ActionController::Parameters.new(param_key => restify_data(param_key)) end private def restify_data(param_key, value = params) if value == params ...
github
Netflix/restful-jsonapi
https://github.com/Netflix/restful-jsonapi
lib/restful/jsonapi/serializable_errors.rb
Ruby
mit
88
master
439
module Restful module Jsonapi module SerializableErrors extend ActiveSupport::Concern def serializable_errors(object) prefix = object.class.to_s.demodulize.underscore errors = object.errors.to_hash.each_with_object([]) do |(k, v), array| v.each do |msg| array.pu...
github
Netflix/restful-jsonapi
https://github.com/Netflix/restful-jsonapi
lib/restful/jsonapi/railtie.rb
Ruby
mit
88
master
547
module Restful module Jsonapi class Railtie < Rails::Railtie initializer "restful-jsonapi.action_controller" do ActiveSupport.on_load(:action_controller) do include Restful::Jsonapi::RestifyParam include Restful::Jsonapi::SerializableErrors end end initialize...
github
Netflix/restful-jsonapi
https://github.com/Netflix/restful-jsonapi
lib/restful/jsonapi/active_model_serializer.rb
Ruby
mit
88
master
248
module Restful module Jsonapi module ActiveModelSerializer extend ActiveSupport::Concern included do def type object.class.model_name.name.demodulize.pluralize.underscore end end end end end
github
platanus/pincers
https://github.com/platanus/pincers
Guardfile
Ruby
mit
88
master
1,692
watch(%r{^spec/.+_spec\.rb$}) # A sample Guardfile # More info at https://github.com/guard/guard#readme ## Uncomment and set this to only include directories you want to watch # directories %w(app lib config test spec feature) ## Uncomment to clear the screen before every task # clearing :on ## Make Guard exit when ...
github
platanus/pincers
https://github.com/platanus/pincers
pincers.gemspec
Ruby
mit
88
master
1,543
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'pincers/version' Gem::Specification.new do |spec| spec.name = "pincers" spec.description = "Web automation DSL on top of webdriver and nokogiri" spec.version = Pincers::VER...
github
platanus/pincers
https://github.com/platanus/pincers
Rakefile
Ruby
mit
88
master
252
require 'rspec/core/rake_task' require "bundler/gem_tasks" # Default directory to look in is `/specs` # Run with `rake spec` RSpec::Core::RakeTask.new(:spec) do |task| task.rspec_opts = ['--color', '--format', 'nested'] end task :default => :spec
github
platanus/pincers
https://github.com/platanus/pincers
spec/spec_helper.rb
Ruby
mit
88
master
871
require 'pry' require 'pincers' require 'webmock/rspec' Dir[File.expand_path("../support/*.rb", __FILE__)].each { |f| require f } Dir[File.expand_path("../macros/*.rb", __FILE__)].each { |f| require f } FIXTURE_PATH = File.expand_path('../fixtures', __FILE__) SERVER_PORT = 9292 RSpec.configure do |config| config.f...
github
platanus/pincers
https://github.com/platanus/pincers
spec/macros/support_jquery_selectors.rb
Ruby
mit
88
master
1,097
module Macros def it_should_support_jquery_selectors describe "search" do it { expect(pincers.search('.bikes li:first').count).to eq 1 } it { expect(pincers.search('.bikes li:odd').count).to eq 2 } it { expect(pincers.search('.bikes li:even').count).to eq 1 } it { expect(pincers.search('....
github
platanus/pincers
https://github.com/platanus/pincers
spec/macros/handle_frames_in_example.rb
Ruby
mit
88
master
1,326
module Macros def it_should_properly_handle_frames_in_example describe "goto" do it "should switch to selected frame when called on a search context" do pincers.search('#the-frame').goto expect(pincers.text).to include('This is the frame content') end it "should switch to desir...
github
platanus/pincers
https://github.com/platanus/pincers
spec/macros/read_the_example.rb
Ruby
mit
88
master
2,834
module Macros def it_should_properly_read_the_example describe "search" do it { expect(pincers.search(tag: 'label').first.text).to eq 'Name:' } it { expect(pincers.search(content: 'Email').first.tag).to eq 'label' } it { expect(pincers.search(content: 'fo').first[:id]).to eq 'option' } it...
github
platanus/pincers
https://github.com/platanus/pincers
spec/macros/handle_dynamic_markup.rb
Ruby
mit
88
master
1,062
module Macros def it_should_properly_handle_dynamic_markup context "when navigating dynamic content" do before { pincers.goto "http://localhost:#{SERVER_PORT}/dynamic.html" } describe "wait(:present)" do it "should wait for content to be present" do expect { pincers.search('#half-...
github
platanus/pincers
https://github.com/platanus/pincers
spec/macros/enter_data_in_example.rb
Ruby
mit
88
master
3,137
module Macros def it_should_properly_enter_data_in_example let(:text_input) { pincers.search('#name') } let(:textarea_input) { pincers.search('#message') } let(:select_input) { pincers.search('#category') } let(:checkbox_input) { pincers.search('#option') } let(:checkbox_input_checked) { pincers....
github
platanus/pincers
https://github.com/platanus/pincers
spec/macros/navigate_through_example.rb
Ruby
mit
88
master
784
module Macros def it_should_properly_navigate_through_example describe 'goto' do it "should switch to the provided url" do pincers.goto("http://localhost:#{SERVER_PORT}/frame.html") expect(pincers.text).to include('This is the frame content') end end describe 'click' do ...
github
platanus/pincers
https://github.com/platanus/pincers
spec/macros/perform_raw_requests.rb
Ruby
mit
88
master
2,136
module Macros def it_should_perform_raw_requests(_merge_support=true) describe 'download' do it "should retrieve the resouce pointed by the element" do expect(pincers.search('#download').download.content).to eq 'Some text' end it "should fail if element does not point to a resource" do...
github
platanus/pincers
https://github.com/platanus/pincers
spec/support/chrome_helpers.rb
Ruby
mit
88
master
628
# frozen_string_literal: true module ChromeHelpers def build_chrome_headless_driver(width = 1410, heigth = 768) chrome_bin = ENV.fetch('GOOGLE_CHROME_BIN', '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome') opts = Selenium::WebDriver::Chrome::Options.new(detach: false,...
github
platanus/pincers
https://github.com/platanus/pincers
spec/support/webserver.rb
Ruby
mit
88
master
1,520
require 'rubygems' require 'rack' module Pincers module Test class Server def call(env) @root = FIXTURE_PATH path = Rack::Utils.unescape(env['PATH_INFO']) path += 'index.html' if path == '/' file = File.join(@root, path) if File.exists?(file) [ 200, {"Cont...
github
platanus/pincers
https://github.com/platanus/pincers
spec/lib/factory_spec.rb
Ruby
mit
88
master
595
require 'spec_helper' describe 'Pincers::Factory' do describe 'for_webdriver' do it "should close connection automatically if block is given" do temp = Pincers.for_webdriver build_chrome_headless_driver do |pincers| expect { pincers.url }.not_to raise_error pincers end expect...
github
platanus/pincers
https://github.com/platanus/pincers
spec/lib/nokogiri/backend_spec.rb
Ruby
mit
88
master
271
require 'spec_helper' describe 'Pincers::Nokogiri::Backend' do let!(:example) { ::Nokogiri::HTML File.read "#{FIXTURE_PATH}/index.html" } let(:pincers) { Pincers.for_nokogiri example } it_should_properly_read_the_example it_should_support_jquery_selectors end
github
platanus/pincers
https://github.com/platanus/pincers
spec/lib/chenso/browsing_context_spec.rb
Ruby
mit
88
master
3,726
require "spec_helper" require "pincers/chenso/browsing_context" require "pincers/chenso/browsing_state" describe "Pincers::Chenso::BrowsingContext" do let(:client) { :dummy } let(:service) { Pincers::Chenso::BrowsingContext.new client } 6.times do |i| let("fake_request_#{i}") do double('Request', { ...
github
platanus/pincers
https://github.com/platanus/pincers
spec/lib/chenso/backend_spec.rb
Ruby
mit
88
master
392
require 'spec_helper' describe 'Pincers::Chenso::Backend' do let!(:pincers) { Pincers.for_chenso } before { pincers.goto "http://localhost:#{SERVER_PORT}/index.html" } it_should_properly_read_the_example it_should_properly_navigate_through_example it_should_properly_enter_data_in_example it_should...
github
platanus/pincers
https://github.com/platanus/pincers
spec/lib/webdriver/backend_spec.rb
Ruby
mit
88
master
1,340
require 'spec_helper' require 'selenium-webdriver' describe 'Pincers::Webdriver::Backend' do before(:context) { @driver = Pincers.for_webdriver(build_chrome_headless_driver, wait_timeout: 2.0).document } before { @driver.switch_to.default_content @driver.get "http://localhost:#{SERVER_PORT}/index.h...
github
platanus/pincers
https://github.com/platanus/pincers
spec/lib/http/utils_spec.rb
Ruby
mit
88
master
1,028
require "spec_helper" require "pincers/http/utils" describe Pincers::Http::Utils do let(:srv) { described_class } describe 'encode_urlencoded' do it { expect(srv.encode_urlencoded({})).to eq("") } it { expect(srv.encode_urlencoded({ foo: 'bar' })).to eq("foo=bar") } it { expect(srv.encode_urlencoded(...
github
platanus/pincers
https://github.com/platanus/pincers
spec/lib/http/client_spec.rb
Ruby
mit
88
master
5,009
require 'spec_helper' require 'pincers/http/client' describe Pincers::Http::Client do before { stub_request(:any, "foo.bar").to_return(:body => "helloworld", headers: { 'Set-Cookie' => 'foo=bar' }) stub_request(:get, "foo.bar").with(:query => {"foo" => "bar"}) stub_request(:get, "foo.bar/relative") ...
github
platanus/pincers
https://github.com/platanus/pincers
spec/lib/http/cookie_jar_spec.rb
Ruby
mit
88
master
2,521
require 'spec_helper' require 'pincers/http/cookie_jar' describe Pincers::Http::CookieJar do let(:jar) { described_class.new } let(:base_uri) { URI.parse "http://crabfarm.io" } let(:internal_uri) { URI.parse "http://crabfarm.io/demo/" } let(:subdomain_uri) { URI.parse "http://blog.crabfarm.io" } let(:simila...
github
platanus/pincers
https://github.com/platanus/pincers
spec/lib/core/root_context_spec.rb
Ruby
mit
88
master
12,003
require 'spec_helper' describe 'Pincers::Core::RootContext' do let!(:backend) do be = double('Pincers::Core::BaseBackend') allow(be).to receive(:javascript_enabled?) { true } allow(be).to receive(:document) { 'not a real document' } allow(be).to receive(:document_root) ...
github
platanus/pincers
https://github.com/platanus/pincers
spec/lib/core/helpers/form_spec.rb
Ruby
mit
88
master
3,653
require 'spec_helper' require 'pincers/core/base_backend' require 'pincers/core/helpers/form' describe Pincers::Core::Helpers::Form do let!(:backend) do be = Class.new(Pincers::Core::BaseBackend).new allow(be).to receive(:search_by_xpath) { |el, sel| el[:childs] } allow(be).to receive(:extrac...
github
platanus/pincers
https://github.com/platanus/pincers
spec/lib/css/parser_spec.rb
Ruby
mit
88
master
656
require "spec_helper" require "pincers/css/parser" describe Pincers::CSS::Parser do let(:parser) { described_class } describe "is_extended?" do it { expect(parser.new('hello:contains(\'world\')').is_extended?).to be true } it { expect(parser.new('hello:contains').is_extended?).to be true } it { expe...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers.rb
Ruby
mit
88
master
358
require "nokogiri" require "forwardable" require "pincers/version" require "pincers/errors" require 'pincers/core/root_context' require "pincers/factory" require "pincers/support/configuration" module Pincers extend Factory @@config = Support::Configuration.new def self.config @@config end def self.co...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/errors.rb
Ruby
mit
88
master
1,418
module Pincers class Error < StandardError; end class ConfigurationError < Error; end class MissingFeatureError < Error attr_reader :feature def initialize(_feature) @feature = _feature super "This backend does not provide '#{_feature}'" end end class ContextError < Error a...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/factory.rb
Ruby
mit
88
master
789
module Pincers module Factory def for_webdriver(_driver=nil, _options={}, &_block) require 'pincers/webdriver/factory' if _driver.is_a? Hash _options = _driver _driver = nil end _options[:driver] = _driver || config.webdriver_bridge context = Webdriver::Factory.ne...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/http/utils.rb
Ruby
mit
88
master
1,093
require 'uri' module Pincers::Http module Utils extend self FORM_URLENCODED = 'application/x-www-form-urlencoded' FORM_MULTIPART = 'multipart/form-data' URI_PARSER = URI::Parser.new(:UNRESERVED => URI::REGEXP::PATTERN::UNRESERVED + '|') def encode_urlencoded(_pairs) _pairs = hash_to_pairs...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/http/errors.rb
Ruby
mit
88
master
541
module Pincers::Http class RequestError < StandardError extend Forwardable def_delegators :@response, :code, :uri, :content attr_reader :response def initialize(_response) @response = _response super _response.message end end class EncodingNotSupported < StandardError def i...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/http/cookie_jar.rb
Ruby
mit
88
master
4,280
require 'pincers/http/cookie' require 'pincers/http/utils' module Pincers::Http class CookieJar BAD_VALUE_CHARS = /([\x00-\x20\x7F",;\\])/ # RFC 6265 - 4.1.1 attr_reader :cookies def initialize(_cookies=nil) @cookies = _cookies || [] end def copy self.class.new @cookies.clone ...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/http/client.rb
Ruby
mit
88
master
3,838
require 'forwardable' require 'net/http' require 'pincers/http/utils' require 'pincers/http/session' require 'pincers/http/request' require 'pincers/http/errors' module Pincers::Http class Client extend Forwardable def self.build_from_options(_options = {}) session = Session.new session.proxy =...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/http/response.rb
Ruby
mit
88
master
387
module Pincers::Http class Response attr_reader :uri, :response def initialize(_uri, _response) @response = _response @uri = _uri end def code @response.code end def message @response.message end def content_type @response['Content-Type'] || 'text/pla...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/http/session.rb
Ruby
mit
88
master
3,447
require 'pincers/http/errors' require 'pincers/http/cookie_jar' require 'pincers/http/response' module Pincers::Http class Session DEFAULT_HEADERS = { 'Accept' => '*/*', 'Cache-Control' => 'no-cache' } attr_reader :cookie_jar, :headers attr_accessor :proxy_addr, :proxy_port, :proxy_user...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/http/request.rb
Ruby
mit
88
master
1,779
module Pincers::Http class Request attr_accessor :method, :uri, :data, :headers def initialize(_method, _uri) @method = _method @uri = _uri @headers = {} @data = nil end def url @uri.to_s end def native_type case @method when :get then Net::HTTP::G...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/http/cookie.rb
Ruby
mit
88
master
518
module Pincers::Http class Cookie attr_reader :name, :value, :domain, :path, :expires, :secure def initialize(_name, _value, _domain, _path=nil, _expires=nil, _secure=nil) @name = _name @value = _value @domain = _domain.gsub(/^\./,'').downcase # RFC 6265 5.2.3 @path = valid_path?(_pa...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/support/xpath_builder.rb
Ruby
mit
88
master
1,651
module Pincers::Support class XPathBuilder def initialize(_options={}) @parts = [] by_tag _options.delete(:tag) if _options.key? :tag by_content _options.delete(:content) if _options.key? :content if _options.key? :class _options.delete(:class).split(' ').each { |c| by_class c } ...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/support/configuration.rb
Ruby
mit
88
master
695
module Pincers::Support class Configuration class Option < Struct.new(:name, :type, :text); end FIELDS = [ [:wait_timeout, 10.0], [:wait_interval, 0.2], [:advanced_mode, false], # webdriver defaults [:webdriver_bridge, :firefox], [:webdriver_options, {}] ]; FIEL...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/extension/labs.rb
Ruby
mit
88
master
462
module Pincers::Extension module Labs def readonly(&_block) nk_root = Pincers.for_nokogiri to_html # nk_root = Pincers.for_chenso http_client # nk_root.backend.push_document current_url, to_html unless root? nk_root = nk_root.search('body > *') # nokogiri will inject valid html ...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/extension/actions.rb
Ruby
mit
88
master
1,270
module Pincers::Extension module Actions def set(_value=true, _options={}) if _value.is_a? Hash _options = _value _value = true end case input_mode when :text wait :enabled set_text _value.to_s when :select wait :enabled return set_s...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/extension/queries.rb
Ruby
mit
88
master
1,301
module Pincers::Extension module Queries TEXT_INPUTS = ['text', 'email', 'number', 'email', 'color', 'password', 'search', 'tel', 'url'] def id self[:id] end def value case input_mode when :checkbox, :radio if checked? then self[:value] else nil end else self...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/nokogiri/backend.rb
Ruby
mit
88
master
3,954
require 'pincers/core/base_backend' module Pincers::Nokogiri class Backend < Pincers::Core::BaseBackend # This is a small bool properties subset, I believe its enough for scrapping. # For information of where to find the full list: http://stackoverflow.com/questions/706384/boolean-html-attributes BOOL_...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/nokogiri/factory.rb
Ruby
mit
88
master
449
require "pincers/core/base_factory" require "pincers/nokogiri/backend" module Pincers::Nokogiri class Factory < Pincers::Core::BaseFactory def load_backend(_options) document = _options.delete(:document) unless document.is_a? ::Nokogiri::HTML::Document document = ::Nokogiri::HTML document, ...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/css/parser.rb
Ruby
mit
88
master
604
require 'pincers/css/xpath_visitor' module Pincers::CSS class Parser IS_EXTENDED_RGX = /:(contains|has|first|last|even|odd|eq|gt|lt|button|checkbox|file|image|password|radio|reset|submit|text|selected|checked)([^\w\-]|$)/ attr_reader :selector def is_extended? IS_EXTENDED_RGX === selector e...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/css/xpath_visitor.rb
Ruby
mit
88
master
1,939
module Pincers::CSS class XPathVisitor < ::Nokogiri::CSS::XPathVisitor # jQuery extended functions and classes def visit_function_contains(_node) # override nokofiri impl to search in value attribute too "(contains(., #{_node.value[1]}) or contains(@value, #{_node.value[1]}))" end def visit_...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/webdriver/factory.rb
Ruby
mit
88
master
2,764
require 'pincers/core/base_factory' require 'pincers/webdriver/backend' module Pincers::Webdriver class Factory < Pincers::Core::BaseFactory DEFAULT_SETUP = { page_timeout: 60000 } def load_backend(_options) driver = _options.delete(:driver) unless driver.is_a? Selenium::WebDriver::D...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/webdriver/backend.rb
Ruby
mit
88
master
5,562
require 'selenium-webdriver' require 'pincers/core/base_backend' require 'pincers/webdriver/http_document' require 'pincers/http/client' require 'pincers/http/cookie' module Pincers::Webdriver class Backend < Pincers::Core::BaseBackend DOM_PROPERTIES = [:selected, :disabled, :checked, :value, :required] at...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/webdriver/http_document.rb
Ruby
mit
88
master
319
require 'pincers/http/utils' module Pincers::Webdriver class HttpDocument def initialize(_backend) @backend = _backend end def uri Pincers::Http::Utils.parse_uri @backend.document_url end def content_type 'text/html' end def content @backend end end end
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/core/base_backend.rb
Ruby
mit
88
master
3,088
module Pincers::Core class BaseBackend def javascript_enabled? false end def document ensure_implementation :document end def document_root ensure_implementation :document_root end def document_url ensure_implementation :document_url end def document_t...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/core/root_context.rb
Ruby
mit
88
master
2,792
require 'pincers/core/cookies' require 'pincers/core/search_context' require 'pincers/http/utils' module Pincers::Core class RootContext < SearchContext attr_reader :config def initialize(_backend, _config={}) super nil, nil, nil @backend = _backend @config = Pincers.config.values.merge _...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/core/base_factory.rb
Ruby
mit
88
master
699
module Pincers::Core class BaseFactory def self.new_context(_options) self.new(_options).new_context end def initialize(_options) @context_options = extract_context_options _options @backend_options = _options end def new_context backend = load_backend @backend_options ...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/core/search_context.rb
Ruby
mit
88
master
6,936
require 'pincers/core/helpers/query' require 'pincers/core/replicas/link' require 'pincers/core/replicas/form' require 'pincers/extension/queries' require 'pincers/extension/actions' require 'pincers/extension/labs' module Pincers::Core class SearchContext include Enumerable extend Forwardable include Pi...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/core/cookies.rb
Ruby
mit
88
master
240
require 'ostruct' module Pincers::Core class Cookies include Enumerable def initialize(_backend) @backend = _backend end def each @backend.fetch_cookies.each { |c| yield OpenStruct.new c } end end end
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/core/helpers/form.rb
Ruby
mit
88
master
2,698
require 'pincers/http/utils' module Pincers::Core::Helpers class Form attr_reader :backend def initialize(_backend, _form_element, _trigger_element = nil) @backend = _backend @form = _form_element @trigger = _trigger_element @force_multipart = false end def action @a...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/core/helpers/query.rb
Ruby
mit
88
master
1,810
require 'pincers/css/parser' require 'pincers/support/xpath_builder' module Pincers::Core::Helpers class Query def self.build_from_options(_backend, _selector, _options = {}, &_block) limit = _options.delete(:limit) lang = :xpath exp = nil if _selector parser = Pincers::CSS::Par...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/core/replicas/link.rb
Ruby
mit
88
master
395
require 'pincers/http/utils' module Pincers::Core::Replicas class Link attr_reader :ref def initialize(_backend, _element) @backend = _backend @ref = Pincers::Http::Utils.parse_uri _backend.extract_element_attribute(_element, :href) end def fetch(_http_client=nil) client = _http_...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/core/replicas/form.rb
Ruby
mit
88
master
1,046
require 'pincers/core/helpers/form' module Pincers::Core::Replicas class Form def initialize(_backend, _element) @backend = _backend @form = Pincers::Core::Helpers::Form.new(_backend, _element) @pairs = @form.inputs end def set(_name, _value, _replace = true) _name = _name.to_s ...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/chenso/html_page_request.rb
Ruby
mit
88
master
1,260
require 'pincers/http/utils' require 'pincers/chenso/browsing_state' module Pincers::Chenso class HtmlPageRequest DEFAULT_HEADERS = { 'Accept' => 'text/html,application/xhtml+xml,application/xml', 'Cache-Control' => 'no-cache' } def initialize(_url, _method=:get, _data=nil, _encoding=nil) ...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/chenso/backend.rb
Ruby
mit
88
master
4,315
require 'pincers/nokogiri/backend' require 'pincers/chenso/browsing_manager' require 'pincers/chenso/html_page_request' require 'pincers/chenso/html_form_request' require 'pincers/chenso/html_page_cache' require 'pincers/core/helpers/form' module Pincers::Chenso class Backend < Pincers::Nokogiri::Backend attr_r...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/chenso/html_page_cache.rb
Ruby
mit
88
master
331
require 'pincers/chenso/browsing_state' module Pincers::Chenso class HtmlPageCache def initialize(_uri, _content) @uri = _uri @content = _content end def fix_uri(_current_state) # nothing end def execute(_client) BrowsingState.new @uri, ::Nokogiri::HTML(@content) en...
github
platanus/pincers
https://github.com/platanus/pincers
lib/pincers/chenso/factory.rb
Ruby
mit
88
master
625
require 'pincers/core/base_factory' require 'pincers/chenso/backend' require 'pincers/http/client' module Pincers::Chenso class Factory < Pincers::Core::BaseFactory def load_backend(_options) _options[:headers] = default_headers(_options).merge! _options.fetch(:headers, {}) client = Pincers::Http::C...