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
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/query.rb
Ruby
apache-2.0
19
master
3,138
require 'bigdecimal' require 'cmis/query_result' module CMIS class Query # Options: from, page_size def initialize(repository, statement, options = {}) @repository = repository @statement = statement @options = options.symbolize_keys @total = -1 init_options end # Opt...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/policy.rb
Ruby
apache-2.0
19
master
708
module CMIS class Policy < Object attr_reader :policy_text def initialize(raw, repository) super cmis_properties %w( cmis:policyText ) end def apply_to(object, opts = {}) server.execute!({ cmisaction: 'applyPolicy', repositoryId: repository_id, ...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/folder.rb
Ruby
apache-2.0
19
master
2,466
require 'cmis/children' module CMIS class Folder < Object def initialize(raw, repository) super cmis_properties %w( cmis:parentId cmis:path cmis:allowedChildObjectTypeIds ) end def parent(opts = {}) repository.object(parent_id, opts) if parent_id end ...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/utils.rb
Ruby
apache-2.0
19
master
2,514
module CMIS module Utils module_function def build_query_statement(type_id, properties, *queried_properties) QueryStatementBuilder.new(type_id, properties, queried_properties).build end class QueryStatementBuilder def initialize(type_id, properties, queried_properties) @type_id =...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/children.rb
Ruby
apache-2.0
19
master
3,370
require 'bigdecimal' require 'cmis/query_result' module CMIS class Children # Options: from, page_size def initialize(folder, options = {}) @folder = folder @options = options.symbolize_keys init_options end # Options: limit def each_child(options = {}, &block) return en...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/object_factory.rb
Ruby
apache-2.0
19
master
961
module CMIS class ObjectFactory def self.create(raw, repository) case base_type_id(raw) when 'cmis:object' then Object.new(raw, repository) when 'cmis:folder' then Folder.new(raw, repository) when 'cmis:document' then Document.new(raw, repository) when 'cmis:relationship' then Relati...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/object.rb
Ruby
apache-2.0
19
master
4,188
require 'cmis/relationships' module CMIS class Object include Helpers attr_reader :repository attr_reader :properties def initialize(raw, repository) initialize_properties(raw) cmis_properties %w( cmis:objectId cmis:baseTypeId cmis:objectTypeId cmis:secondaryOb...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/property_definition.rb
Ruby
apache-2.0
19
master
554
module CMIS class PropertyDefinition def initialize(hash = {}) @hash = hash.stringify_keys @hash.each_key do |key| self.class.class_eval "def #{key.as_ruby_property};@hash['#{key}'];end" self.class.class_eval "def #{key.as_ruby_property}=(value);@hash['#{key}']=value;end" end ...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/query_result.rb
Ruby
apache-2.0
19
master
360
module CMIS class QueryResult attr_reader :results attr_reader :num_items attr_reader :has_more_items attr_reader :debug_info def initialize(results, num_items, has_more_items, debug_info = nil) @results = results @num_items = num_items @has_more_items = has_more_items @de...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/connection.rb
Ruby
apache-2.0
19
master
2,646
require 'cmis/connection/request_modifier' require 'cmis/connection/response_parser' require 'cmis/version' require 'faraday' require 'faraday_middleware' module CMIS class Connection def initialize(options) message = "option `service_url` must be set" @service_url = options[:service_url] or raise me...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/document.rb
Ruby
apache-2.0
19
master
3,286
module CMIS class Document < Object def initialize(raw, repository) super cmis_properties %w( cmis:isImmutable cmis:isLatestVersion cmis:isMajorVersion cmis:isLatestMajorVersion cmis:isPrivateWorkingCopy cmis:versionLabel cm...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/relationships.rb
Ruby
apache-2.0
19
master
2,673
require 'bigdecimal' require 'cmis/query_result' module CMIS class Relationships # Options: from, page_size def initialize(object, options = {}) @object = object @options = options.symbolize_keys init_options end # Options: limit def each_relationship(options = {}, &block) ...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/server.rb
Ruby
apache-2.0
19
master
1,284
module CMIS class Server def initialize(options = {}) @options = options.symbolize_keys end def connection @connection ||= Connection.new(@options) end def execute!(params = {}, options = {}) params.symbolize_keys! options.symbolize_keys! query = options.fetch(:que...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/helpers.rb
Ruby
apache-2.0
19
master
2,185
module CMIS module Helpers def initialize_properties(raw) @properties = get_properties_map(raw) end def cmis_properties(properties) properties.each do |property_name| method_name = method_name(property_name) self.class.class_eval "def #{method_name};@properties['#{property_nam...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/relationship.rb
Ruby
apache-2.0
19
master
400
module CMIS class Relationship < Object def initialize(raw, repository) super cmis_properties %w( cmis:sourceId cmis:targetId ) end def source(opts = {}) repository.object(source_id, opts) end def target(opts = {}) repository.object(target_id, opts) end def creat...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/type.rb
Ruby
apache-2.0
19
master
3,231
require 'json' module CMIS class Type attr_accessor :repository def initialize(hash, repository) @repository = repository @hash = hash.deep_stringify_keys properties = %w( id localName localNamespace queryName displayName baseId parentId description creatable fileab...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/connection/response_parser.rb
Ruby
apache-2.0
19
master
1,614
require 'faraday' require 'json' module CMIS class Connection class ResponseParser < Faraday::Middleware JSON_CONTENT_TYPE = /\/(x-)?json(;.+?)?$/i.freeze def call(env) response = @app.call(env) response.on_complete do |env| # Remove Authorization header when following re...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
lib/cmis/connection/request_modifier.rb
Ruby
apache-2.0
19
master
1,863
require 'faraday' require 'date' module CMIS class Connection class RequestModifier < Faraday::Middleware def call(env) if env[:body] env[:body].reject! { |_, v| v.nil? } wrap_content(env) massage_properties(env) end @app.call(env) end priv...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
spec/spec_helper.rb
Ruby
apache-2.0
19
master
589
require 'cmis' require 'erb' require 'yaml' module SpecHelpers def server @@server ||= CMIS::Server.new(options['server']) end def repository_id @@repository_id ||= options['repository'] end def repository @@repository ||= server.repository(repository_id) end private def options @@o...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
spec/cmis-ruby/document_spec.rb
Ruby
apache-2.0
19
master
2,828
require 'spec_helper' module CMIS describe Document do context 'when creating a document with content' do it 'has properties and content' do document = repository.new_document document.name = 'apple_document' document.object_type_id = 'cmis:document' document.content = { str...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
spec/cmis-ruby/server_spec.rb
Ruby
apache-2.0
19
master
988
require 'securerandom' require 'spec_helper' module CMIS describe Server do describe '#repositories' do it 'are all Repositories' do server.repositories.each do |r| expect(r).to be_a Repository end end it 'contains the test repository' do repo_array = server.r...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
spec/cmis-ruby/repository_spec.rb
Ruby
apache-2.0
19
master
6,177
require 'spec_helper' module CMIS PRIMARY_BASE_TYPES = [ 'cmis:document', 'cmis:folder', 'cmis:relationship', # 'cmis:policy', 'cmis:item' ] describe Repository do it 'is supported by the library' do expect(repository.cmis_version_supported).to eq('1.1') end it 'has the co...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
spec/cmis-ruby/folder_spec.rb
Ruby
apache-2.0
19
master
2,116
require 'spec_helper' module CMIS describe Folder do describe '#root?' do before do @folder = create_folder end after do @folder.delete end it 'returns true for the root folder' do expect(repository.root.root?).to be true end it 'returns false ...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
spec/cmis-ruby/object_spec.rb
Ruby
apache-2.0
19
master
3,395
require 'spec_helper' module CMIS describe Object do before do @document = create_document end after do @document.delete end describe '#inspect' do REG_EXP = /CMIS::Document\[.*\] @ CMIS::Repository\[.*\] @ CMIS::Server\[.*\]/ it 'displays not too much crap' do ...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
spec/cmis-ruby/query_spec.rb
Ruby
apache-2.0
19
master
1,511
require 'spec_helper' module CMIS describe CMIS::Query do before :all do @folder = create_folder 21.times { create_document } end after :all do @folder.delete_tree end context 'when querying with a limit' do it 'should execute only one query if limit is under 10' do ...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
spec/cmis-ruby/utils_spec.rb
Ruby
apache-2.0
19
master
961
require 'spec_helper' module CMIS describe Utils do describe '#build_query_statement' do def qs(*args) CMIS::Utils.build_query_statement(*args) end it 'builds the correct query statement' do expect(qs('T', {})).to eq 'select * from T' expect(qs('T', foo: 'bar')).to eq "...
github
UP-nxt/cmis-ruby
https://github.com/UP-nxt/cmis-ruby
spec/cmis-ruby/relationship_spec.rb
Ruby
apache-2.0
19
master
2,147
require 'spec_helper' module CMIS describe Relationship do before :all do cleanup_relationships @document = create_document end after :all do @document.delete end context 'when deleting relationships with sourceId and targetId pointing to same document' do before :each d...
github
shoprev/yahoo-api
https://github.com/shoprev/yahoo-api
yahoo-api.gemspec
Ruby
mit
19
master
1,086
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'yahoo/api/version' Gem::Specification.new do |spec| spec.name = "yahoo-api" spec.version = Yahoo::Api::VERSION spec.authors = ["shoprev"] spec.email = ["admin...
github
shoprev/yahoo-api
https://github.com/shoprev/yahoo-api
lib/yahoo/api.rb
Ruby
mit
19
master
764
require "net/http" require "uri" require "cgi" require "json" require 'active_support/core_ext' require "yahoo/api/version" require "yahoo/api/response" require "yahoo/api/request" require "yahoo/api/shopping" require "yahoo/api/auction" require "yahoo/api/news" module Yahoo class Api @@options = {} class...
github
shoprev/yahoo-api
https://github.com/shoprev/yahoo-api
lib/yahoo/api/news.rb
Ruby
mit
19
master
356
module Yahoo class Api class News Topics = "Yahoo::Api::News.topics" class << self # Yahoo News Topics API v2 def topics(opts={}) Yahoo::Request.get("http://news.yahooapis.jp/NewsWebService/V2/topics", Yahoo::Api.merge(opts), "xml") end end en...
github
shoprev/yahoo-api
https://github.com/shoprev/yahoo-api
lib/yahoo/api/auction.rb
Ruby
mit
19
master
3,180
module Yahoo class Api class Auction CategoryTree = "Yahoo::Api::Auction.category_tree" CategoryLeaf = "Yahoo::Api::Auction.category_leaf" SellingList = "Yahoo::Api::Auction.selling_list" Search = "Yahoo::Api::Auction.search" Item = "Yahoo::Api::Auction.item" BidHistory = "Y...
github
shoprev/yahoo-api
https://github.com/shoprev/yahoo-api
lib/yahoo/api/shopping.rb
Ruby
mit
19
master
3,002
module Yahoo class Api class Shopping ItemSearch = "Yahoo::Api::Shopping.item_search" CategoryRanking = "Yahoo::Api::Shopping.category_ranking" CategorySearch = "Yahoo::Api::Shopping.category_search" ItemLookup = "Yahoo::Api::Shopping.item_lookup" QueryRanking = "Yahoo::Api::Shopp...
github
shoprev/yahoo-api
https://github.com/shoprev/yahoo-api
lib/yahoo/api/request.rb
Ruby
mit
19
master
253
module Yahoo class Request def self.get(path,opts,format="json") uri = URI.parse("#{path}?#{opts.map {|k,v|"#{k}=#{CGI.escape(v)}"}.join('&')}") Yahoo::Response.new(Net::HTTP.get_response(uri),format) end end end
github
shoprev/yahoo-api
https://github.com/shoprev/yahoo-api
lib/yahoo/api/response.rb
Ruby
mit
19
master
625
module Yahoo class Response def initialize(response,format) @response =response body = @response.body if format == "json" body = body[9..(body.rindex(")")-1)] if body.include?("callback(") @body = JSON.parse(body) else @body = Hash.from_xml(body) end end...
github
shoprev/yahoo-api
https://github.com/shoprev/yahoo-api
spec/spec_helper.rb
Ruby
mit
19
master
518
# coding: utf-8 require 'webmock/rspec' WebMock.disable_net_connect! require 'vcr' VCR.configure do |c| c.cassette_library_dir = File.expand_path(File.dirname(__FILE__) + '/fixtures') c.hook_into :webmock c.allow_http_connections_when_no_cassette = true end require File.expand_path(File.dirname(__FILE__) + '/...
github
shoprev/yahoo-api
https://github.com/shoprev/yahoo-api
spec/yahoo/auction_spec.rb
Ruby
mit
19
master
4,152
# coding: utf-8 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') share_examples_for 'found items' do context 'code' do it { expect(res.code).to eq 200 } end context 'size' do it { expect(res["ResultSet"]["@attributes"]["totalResultsReturned"].to_i).to be > 0 } end end share_example...
github
shoprev/yahoo-api
https://github.com/shoprev/yahoo-api
spec/yahoo/shopping_spec.rb
Ruby
mit
19
master
8,289
# coding: utf-8 require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') share_examples_for 'found items' do context 'code' do it { expect(res_genre.code).to eq 200 } end context 'size' do it { expect(res_genre["ResultSet"]["totalResultsReturned"].to_i).to be > 0 } end end share_examples_f...
github
shoprev/yahoo-api
https://github.com/shoprev/yahoo-api
example/news.rb
Ruby
mit
19
master
219
require File.expand_path(File.dirname(__FILE__) + '/helper') # Topics API v2 res = Yahoo::Api.get(Yahoo::Api::News::Topics,{:pickupcategory => "sports"}) res["ResultSet"]["Result"].each do |v| p v["Title"] end
github
shoprev/yahoo-api
https://github.com/shoprev/yahoo-api
example/helper.rb
Ruby
mit
19
master
291
require "yaml" require "yahoo/api" config = YAML.load_file(File.dirname(__FILE__)+'/config.yml') Yahoo::Api.configure do |options| options[:appid] = config['appid'] # options[:affiliate_type] = config['affiliate_type'] # options[:affiliate_id] = config['affiliate_id'] end
github
shoprev/yahoo-api
https://github.com/shoprev/yahoo-api
example/shopping.rb
Ruby
mit
19
master
2,301
require File.expand_path(File.dirname(__FILE__) + '/helper') # Item Search API v1 res = Yahoo::Api.get(Yahoo::Api::Shopping::ItemSearch,{:category_id => "13457"}) res["ResultSet"]["totalResultsReturned"].times do |i| p res["ResultSet"]["0"]["Result"]["#{i}"]["Code"] end res["ResultSet"]["0"]["Result"].each do |i,v| ...
github
shoprev/yahoo-api
https://github.com/shoprev/yahoo-api
example/auction.rb
Ruby
mit
19
master
1,591
require File.expand_path(File.dirname(__FILE__) + '/helper') # Category Tree API v2 res = Yahoo::Api.get(Yahoo::Api::Auction::CategoryTree,{:category => "0"}) res["ResultSet"]["Result"]["ChildCategory"].each do |v| p v["CategoryId"] end # Category Leaf API v2 res = Yahoo::Api.get(Yahoo::Api::Auction::CategoryLeaf,{...
github
wallace/yamldiff
https://github.com/wallace/yamldiff
yamldiff.gemspec
Ruby
mit
19
master
1,035
# -*- encoding: utf-8 -*- require File.expand_path('../lib/yamldiff/version', __FILE__) Gem::Specification.new do |gem| gem.authors = ["Jonathan R. Wallace"] gem.email = ["jonathan.wallace@gmail.com"] gem.description = %q{Shows the difference yaml keys} gem.summary = %q{Yamldiff will tell...
github
wallace/yamldiff
https://github.com/wallace/yamldiff
spec/lib/yamldiff_error_spec.rb
Ruby
mit
19
master
1,188
require "spec_helper" describe YamldiffKeyError, "#to_s" do subject(:key_error) { YamldiffKeyError.new('key', ['root', 'namespace']) } it "outputs human readable text" do expect(key_error.to_s).to eql "Missing key: root.namespace.key" end end describe YamldiffKeyValueTypeError, "#to_s" do subject(:key_va...
github
wallace/yamldiff
https://github.com/wallace/yamldiff
spec/lib/yamldiff_spec.rb
Ruby
mit
19
master
4,147
require "spec_helper" describe Yamldiff do subject { Yamldiff } describe ".compare_hashes" do it "should be empty for equal hashes" do expect(subject.compare_hashes({ a: 1 }, { a: 1 })).to be_empty end it "should be empty for nested hashes" do first = { a: { b: 2 } } second = { a: ...
github
wallace/yamldiff
https://github.com/wallace/yamldiff
lib/yamldiff/yamldiff_error.rb
Ruby
mit
19
master
677
class YamldiffError attr_reader :key, :context def initialize(key, context) @key = key @context = context end def path (@context + [@key]).join('.') end end class YamldiffKeyError < YamldiffError def to_s "Missing key: #{path}" end end class YamldiffKeyValueTypeError < YamldiffError ...
github
wallace/yamldiff
https://github.com/wallace/yamldiff
lib/yamldiff/yamldiff.rb
Ruby
mit
19
master
1,309
class Yamldiff class << self # Compare the two yaml files def diff_yaml(first, second, errors_for = {}) primary = YAML.load(ERB.new(File.read(first)).result) secondary = YAML.load(ERB.new(File.read(second)).result) errors_for[second] = compare_hashes(primary, secondary) ...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/Gemfile
Ruby
mit
19
master
2,271
#source 'https://rubygems.org' if ENV['RUBYTAOBAO'] source 'http://ruby.taobao.org' else source 'https://rubygems.org' end gem "http" gem "rake" gem 'monadic' gem "excon" gem "json" gem 'annotate', '~> 2.6.6' gem 'rufus-scheduler' gem 'figaro' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem '...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/Guardfile
Ruby
mit
19
master
4,605
# 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 features) ## Uncomment to clear the screen before every task # clearing :on ## Guard internally checks for changes in the Guardfi...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/spec/spec_helper.rb
Ruby
mit
19
master
4,267
# This file was generated by the `rails generate rspec:install` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause # this file to always be loaded, without a need to explicitly require ...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/spec/rails_helper.rb
Ruby
mit
19
master
2,326
# This file is copied to spec/ when you run 'rails generate rspec:install' ENV['RAILS_ENV'] ||= 'test' require 'spec_helper' require File.expand_path('../../config/environment', __FILE__) require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! # Requires supporting ruby f...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/spec/factories/proxy_domains.rb
Ruby
mit
19
master
1,167
# == Schema Information # # Table name: proxy_domains # # id :integer not null, primary key # proxy :string(255) # domain :string(255) # proxy_type :string(255) default("http") # succ_ratio :float(24) default(0.0) # succ :integer default(0) # total ...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/spec/factories/items.rb
Ruby
mit
19
master
256
# == Schema Information # # Table name: items # # id :integer not null, primary key # created_at :datetime not null # updated_at :datetime not null # FactoryGirl.define do factory :item do hello "what" end end
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/spec/controllers/proxy_domain_controller_spec.rb
Ruby
mit
19
master
1,977
require 'rails_helper' RSpec.describe ProxyDomainController, type: :controller do describe "GET #get_proxy" do it "get proxy correct" do high_proxy = create(:high_proxy) middle_proxy = create(:middle_proxy) low_proxy = create(:low_proxy) get 'get_proxy' expect(JSON.parse(response.b...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/spec/controllers/proxy_controller_spec.rb
Ruby
mit
19
master
698
require 'rails_helper' RSpec.describe ProxyController, type: :controller do describe "POST #add_proxy" do before do end it "add us http proxy succ" do post :add_proxy, proxy_url: "http://75.126.26.180:80" expect(ProxyDomain.first.country).to eq "US" post :add_proxy, proxy_url: "http://...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/spec/supports/factory_girl.rb
Ruby
mit
19
master
607
# RSpec # spec/support/factory_girl.rb RSpec.configure do |config| config.include FactoryGirl::Syntax::Methods end # Test::Unit class Test::Unit::TestCase include FactoryGirl::Syntax::Methods end # Cucumber World(FactoryGirl::Syntax::Methods) # Spinach class Spinach::FeatureSteps include FactoryGirl::Syntax::M...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/spec/supports/helper.rb
Ruby
mit
19
master
209
def check_json(json_str, key, expected) unless json_str.kind_of?(JSON) json_str = JSON.parse(json_str) end result = json_str[key.to_sym] || json_str[key.to_s] expect(result).to be(expected) end
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/app/controllers/people_controller.rb
Ruby
mit
19
master
1,837
class PeopleController < ApplicationController before_action :set_person, only: [:show, :edit, :update, :destroy] # GET /people # GET /people.json def index @people = Person.all end # GET /people/1 # GET /people/1.json def show end # GET /people/new def new @person = Person.new end ...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/app/controllers/entries_controller.rb
Ruby
mit
19
master
201
class EntriesController < ApplicationController def sign_in @name = params[:visitor_name] if !@name.blank? then @entry = Entry.create({:name => @name}) end @entries = Entry.all end end
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/app/controllers/application_controller.rb
Ruby
mit
19
master
249
class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. #protect_from_forgery with: :exception #protect_from_forgery with: :null_session end
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/app/controllers/proxy_domain_controller.rb
Ruby
mit
19
master
1,481
class ProxyDomainController < ApplicationController after_action :print_result def print_result end def proxy_domains @proxy_domains = ProxyDomain.all respond_to do |format| format.json { render :json => @proxy_domains } end end def get_domain(url) #todo return "zillow.com" en...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/app/controllers/proxy_controller.rb
Ruby
mit
19
master
4,527
require 'uri' class ProxyController < ApplicationController def proxys @proxys = Proxy.all return render :json => {:data => @proxys}, :callback => params[:callback] end def add_proxy_api api_link = params[:proxyApi] begin #r = (HTTP).via(host, port).get(params[:...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/app/models/person.rb
Ruby
mit
19
master
253
# == Schema Information # # Table name: people # # id :integer not null, primary key # name :string(255) # created_at :datetime not null # updated_at :datetime not null # class Person < ActiveRecord::Base end
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/app/models/proxy_domain.rb
Ruby
mit
19
master
842
# == Schema Information # # Table name: proxy_domains # # id :integer not null, primary key # proxy :string(255) # domain :string(255) # proxy_type :string(255) default("http") # succ_ratio :float(24) default(0.0) # succ :integer default(0) # total ...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/app/models/entry.rb
Ruby
mit
19
master
277
# == Schema Information # # Table name: entries # # id :integer not null, primary key # name :string(255) # created_at :datetime not null # updated_at :datetime not null # class Entry < ActiveRecord::Base #attr_accessible :name end
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/app/models/proxy.rb
Ruby
mit
19
master
541
# == Schema Information # # Table name: proxies # # id :integer not null, primary key # proxy :string(255) # banned :boolean default(FALSE) # banned_time :datetime # proxy_type :string(255) default("http") # succ_ratio :float(24) default(0.0) # succ :int...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/test/controllers/people_controller_test.rb
Ruby
mit
19
master
1,025
require 'test_helper' class PeopleControllerTest < ActionController::TestCase setup do @person = people(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:people) end test "should get new" do get :new assert_response :success end te...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/test/models/proxy_test.rb
Ruby
mit
19
master
595
# == Schema Information # # Table name: proxies # # id :integer not null, primary key # proxy :string(255) # banned :boolean default(FALSE) # banned_time :datetime # proxy_type :string(255) default("http") # succ_ratio :float(24) default(0.0) # succ :int...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/test/models/proxy_domain_test.rb
Ruby
mit
19
master
659
# == Schema Information # # Table name: proxy_domains # # id :integer not null, primary key # proxy :string(255) # domain :string(255) # proxy_type :string(255) default("http") # succ_ratio :float(24) default(0.0) # succ :integer default(0) # total ...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/test/models/entry_test.rb
Ruby
mit
19
master
335
# == Schema Information # # Table name: entries # # id :integer not null, primary key # name :string(255) # created_at :datetime not null # updated_at :datetime not null # require 'test_helper' class EntryTest < ActiveSupport::TestCase # test "the truth" do # assert tr...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/test/models/person_test.rb
Ruby
mit
19
master
335
# == Schema Information # # Table name: people # # id :integer not null, primary key # name :string(255) # created_at :datetime not null # updated_at :datetime not null # require 'test_helper' class PersonTest < ActiveSupport::TestCase # test "the truth" do # assert tr...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/config/routes.rb
Ruby
mit
19
master
2,354
Rails.application.routes.draw do get 'proxy_domain/index' resources :people get 'entries/sign_in' post 'entries/sign_in' get 'proxys' => 'proxy#proxys' post 'add_proxy' => 'proxy#add_proxy' get 'add_proxy' => 'proxy#add_proxy' #get 'get_proxy' => 'proxy#get_proxy' get 'get_proxy' => 'proxy_domain#g...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/config/application.rb
Ruby
mit
19
master
1,118
require File.expand_path('../boot', __FILE__) require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module ProxyManage class Application < Rails::Application # Settings in config/environments/* take p...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/config/deploy.rb
Ruby
mit
19
master
2,882
require 'mina/bundler' require 'mina/rails' require 'mina/git' # require 'mina/rbenv' # for rbenv support. (http://rbenv.org) # require 'mina/rvm' # for rvm support. (http://rvm.io) # Basic settings: # domain - The hostname to SSH to. # deploy_to - Path to deploy into. # repository - Git repo to c...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/config/environments/development.rb
Ruby
mit
19
master
2,086
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web serv...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/db/schema.rb
Ruby
mit
19
master
2,949
# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative sou...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/db/migrate/20150416092261_change_column_default.rb
Ruby
mit
19
master
549
class ChangeColumnDefault < ActiveRecord::Migration def change change_column_default :proxies, :succ, 0 change_column_default :proxies, :total, 0 change_column_default :proxies, :succ_ratio, 0.0 change_column_default :proxies, :banned, false change_column_default :proxies, :proxy_type, 'http' ...
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/db/migrate/20150416062648_create_proxy_domains.rb
Ruby
mit
19
master
296
class CreateProxyDomains < ActiveRecord::Migration def change create_table :proxy_domains do |t| t.string :proxy t.string :domain t.string :proxy_type t.float :succ_ratio t.integer :succ t.integer :total t.timestamps null: false end end end
github
seaify/ipool
https://github.com/seaify/ipool
proxy-backend/db/migrate/20150416062846_create_proxies.rb
Ruby
mit
19
master
316
class CreateProxies < ActiveRecord::Migration def change create_table :proxies do |t| t.string :proxy t.boolean :banned t.datetime :banned_time t.string :proxy_type t.float :succ_ratio t.integer :succ t.integer :total t.timestamps null: false end end end
github
seaify/ipool
https://github.com/seaify/ipool
config/deploy.rb
Ruby
mit
19
master
2,896
require 'mina/bundler' require 'mina/rails' require 'mina/git' # require 'mina/rbenv' # for rbenv support. (http://rbenv.org) # require 'mina/rvm' # for rvm support. (http://rvm.io) # Basic settings: # domain - The hostname to SSH to. # deploy_to - Path to deploy into. # repository - Git repo to c...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
Guardfile
Ruby
mit
19
master
299
# A sample Guardfile # More info at https://github.com/guard/guard#readme guard :rspec do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec" } watch(%r{^spec/support/(.+)\.rb$}) { "spec" } end
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
stressfactor.gemspec
Ruby
mit
19
master
1,091
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'stressfactor/version' Gem::Specification.new do |spec| spec.name = "stressfactor" spec.version = Stressfactor::VERSION spec.authors = ["Andrew Hao"] spec.email ...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
lib/stressfactor.rb
Ruby
mit
19
master
421
require "gpx" require "stressfactor/interval" require "stressfactor/gpx_loader" require "stressfactor/stress_calculator" require "stressfactor/average_pace_accumulator" require "stressfactor/pace_calculator" require "stressfactor/pace_strategy" require "stressfactor/grade_adjusted_pace_strategy" require "stressfactor/r...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
lib/stressfactor/grade_adjusted_pace_strategy.rb
Ruby
mit
19
master
877
# Inspired by the work CTM Davies' research, as discussed by the Strava # blog: http://engineering.strava.com/improving-grade-adjusted-pace/ module Stressfactor class GradeAdjustedPaceStrategy < PaceStrategy attr_accessor :interval def self.calculate_for_interval(interval) observed_pace = interval.time...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
lib/stressfactor/raw_pace_strategy.rb
Ruby
mit
19
master
354
# Take the exact average over all paces over the set of # run intervals. module Stressfactor class RawPaceStrategy < PaceStrategy def self.calculate_for_interval(interval) interval.time(units: :minutes) / interval.distance end def calculate AveragePaceAccumulator.new(intervals).average_pace(...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
lib/stressfactor/average_pace_accumulator.rb
Ruby
mit
19
master
678
module Stressfactor class AveragePaceAccumulator attr_accessor :intervals def initialize(intervals) @intervals = intervals end def average_pace(strategy: :raw) strategy_klass = strategy == :raw ? RawPaceStrategy : GradeAdjustedPaceStrategy intervals.inject(0) do |acc, interval| ...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
lib/stressfactor/stress_calculator.rb
Ruby
mit
19
master
694
# Implements the actual TSS algorithm. module Stressfactor class StressCalculator attr_reader :threshold_pace, :loader def initialize(threshold_pace: threshold_pace, loader: loader) @threshold_pace = threshold_pace @loader = loader end def calculate (total_time * normalized_graded_...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
lib/stressfactor/interval.rb
Ruby
mit
19
master
839
module Stressfactor class Interval attr_accessor :start_point, :end_point def initialize(start_point, end_point) @start_point = start_point @end_point = end_point end # time in seconds def time(options={}) delta = end_point.time - start_point.time delta /= 60.0 if options...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
lib/stressfactor/gpx_loader.rb
Ruby
mit
19
master
775
module Stressfactor class GpxLoader attr_reader :gpx def initialize(gpx_file_path) @gpx = GPX::GPXFile.new(gpx_file: gpx_file_path) end # units: seconds def total_time intervals.inject(0) do |acc, i| acc + i.time end end # An array of instantaneous pace times i...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
lib/stressfactor/pace_calculator.rb
Ruby
mit
19
master
454
require "ostruct" module Stressfactor class PaceCalculator attr_accessor :gpx_loader def initialize(gpx_loader) @gpx_loader = gpx_loader end def calculate(strategy: :grade_adjusted, units: :metric) pace = AveragePaceAccumulator.new(intervals).average_pace(strategy: strategy) pace ...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
scripts/analyze_sample_gpx.rb
Ruby
mit
19
master
204
require_relative "../lib/stressfactor" require "pry" file = GPX::GPXFile.new(:gpx_file => "examples/data/sample.gpx") pc = Stressfactor::PaceCalculator.new(file) pace = pc.calculate puts pace binding.pry
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
spec/spec_helper.rb
Ruby
mit
19
master
4,268
require_relative "../lib/stressfactor.rb" # This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rspec` file contains `--require spec_helper` which will cause this # file to always be loaded, without a ...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
spec/stressfactor/grade_adjusted_pace_strategy_spec.rb
Ruby
mit
19
master
1,297
require "spec_helper" describe Stressfactor::GradeAdjustedPaceStrategy do let(:end_time) { Time.now } let(:p1) do GPX::TrackPoint.new( :lat => 37.7985474, :lon => -122.2554386, :elevation => 10.0, :time => end_time - 10 ) end let(:p2) do GPX::TrackPoint.new( :lat => 37...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
spec/stressfactor/gpx_loader_spec.rb
Ruby
mit
19
master
1,289
require "spec_helper" describe Stressfactor::GpxLoader do let(:intervals) do [Stressfactor::Interval.new(p1, p2), Stressfactor::Interval.new(p2, p3)] end let(:end_time) { Time.now } let(:p1) do GPX::TrackPoint.new( :lat => 37.7985474, :lon => -122.2554386, :elevation => 10.0, ...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
spec/stressfactor/stress_calculator_spec.rb
Ruby
mit
19
master
1,228
require "spec_helper" describe Stressfactor::StressCalculator do # use 5k pace # 19min / 5k = 3.8 m/km let(:threshold_pace) { 3.8 } let(:gpx) { "gpx file" } let(:normalized_graded_pace) { 3.0 } let(:total_time) { 3600 } let(:loader) { double('loader', :total_time => total_time) } #Stressfactor::GpxLoader...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
spec/stressfactor/pace_calculator_spec.rb
Ruby
mit
19
master
1,801
require "spec_helper" describe Stressfactor::PaceCalculator do let(:gpx_loader) { double("loader", intervals: intervals) } let(:intervals) do [Stressfactor::Interval.new(p1, p2), Stressfactor::Interval.new(p2, p3)] end let(:end_time) { Time.now } let(:p1) do GPX::TrackPoint.new( :lat => 37...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
spec/stressfactor/interval_spec.rb
Ruby
mit
19
master
1,499
require "spec_helper" describe Stressfactor::Interval do subject { described_class.new(p1, p2) } let(:t1) { Time.now } let(:t2) { t1 + 3 } let(:t3) { t1 + 6 } let(:p1) { GPX::TrackPoint.new(:time => t1, :lat => 0.00001, :lon => 0.00001, :elevation => 10) } let(:p2) { GPX::TrackPoint.new(:time => t2, :lat =...
github
andrewhao/stressfactor
https://github.com/andrewhao/stressfactor
spec/stressfactor/raw_pace_strategy_spec.rb
Ruby
mit
19
master
997
require "spec_helper" describe Stressfactor::RawPaceStrategy do let(:points) { [p1, p2, p3] } let(:end_time) { Time.now } let(:p1) do GPX::TrackPoint.new( :lat => 37.7985474, :lon => -122.2554386, :elevation => 10.0, :time => end_time - 10 ) end let(:p2) do GPX::TrackPoin...
github
sbraford/rbet
https://github.com/sbraford/rbet
Rakefile
Ruby
mit
19
master
933
require 'rake' require 'rake/testtask' require 'rake/clean' require 'rake/gempackagetask' require 'rake/rdoctask' ET_PACKAGE='rbetmailer' ET_VERSION='0.0.1' Rake::TestTask.new do |t| t.test_files = FileList["test/*_test.rb"] t.verbose = true end Rake::RDocTask.new do |rdoc| rdoc.rdoc_dir = 'doc/rdoc' rdoc.op...
github
sbraford/rbet
https://github.com/sbraford/rbet
examples/help.rb
Ruby
mit
19
master
357
$:.unshift File.join(File.dirname(__FILE__), "..", "lib") require 'et' $et_user = ENV['ET_USER'] $et_pass = ENV['ET_PASS'] $et_uri="https://www.exacttarget.com/api/integrate.asp?qf=xml" if !$et_user or !$et_pass STDERR.puts "You must set the environment variables ET_USER and ET_PASS. e.g. export ET_USER='tester'; e...
github
sbraford/rbet
https://github.com/sbraford/rbet
examples/subscribe.rb
Ruby
mit
19
master
854
require File.join(File.dirname(__FILE__),'help.rb') subscriber = ET::Subscriber.new($et_uri, $et_user, $et_pass, :debug_output => $stderr) list = ET::List.new($et_uri, $et_user, $et_pass,:debug_output => $stderr) list_id = list.all.first id = subscriber.add( 'tester555@testsomething.com', 1149947, :keywords => ['hell...