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
jashkenas/quakespotter
https://github.com/jashkenas/quakespotter
Quakespotter.app/lib/hpricot.rb
Ruby
mit
19
master
1,081
# == About hpricot.rb # # All of Hpricot's various part are loaded when you use <tt>require 'hpricot'</tt>. # # * hpricot_scan: the scanner (a C extension for Ruby) which turns an HTML stream into tokens. # * hpricot/parse.rb: uses the scanner to sort through tokens and give you back a complete document object. # * hpr...
github
jashkenas/quakespotter
https://github.com/jashkenas/quakespotter
Quakespotter.app/lib/quakespotter.rb
Ruby
mit
19
master
4,119
$LOAD_PATH << 'vendor/hpricot/lib' require 'open-uri' require 'vendor/hpricot/lib/hpricot' require 'lib/globe' require 'lib/scraper' require 'lib/quake' require 'lib/overlay' require 'lib/control_strip' require 'lib/status' require 'lib/tweet' require 'lib/map' class WorldWide < Processing::App load_library 'openg...
github
jashkenas/quakespotter
https://github.com/jashkenas/quakespotter
Quakespotter.app/lib/ruby-processing/app.rb
Ruby
mit
19
master
16,754
# This class is a thin wrapper around Processing's PApplet. # Most of the code here is for interfacing with Swing, # web applets, going fullscreen and so on. require 'java' module Processing # Conditionally load core.jar require "#{RP5_ROOT}/lib/core/core.jar" unless Processing.online? || Processing.embedded? ...
github
jashkenas/quakespotter
https://github.com/jashkenas/quakespotter
Quakespotter.app/lib/ruby-processing/runner.rb
Ruby
mit
19
master
5,431
require 'ostruct' require 'fileutils' module Processing # Utility class to handle the different commands that the 'rp5' command # offers. Able to run, watch, live, create, app, applet, and unpack class Runner HELP_MESSAGE = <<-EOS Ruby-Processing is a little shim between Processing and JRuby...
github
jashkenas/quakespotter
https://github.com/jashkenas/quakespotter
Quakespotter.app/lib/ruby-processing/exporters/base_exporter.rb
Ruby
mit
19
master
4,718
require 'fileutils' require 'erb' module Processing # This base exporter implements some of the common # code-munging needed to generate apps and applets. class BaseExporter include FileUtils DEFAULT_DIMENSIONS = {'width' => '100', 'height' => '100'} DEFAULT_DESCRIPTION = '' NECESSARY_FO...
github
jashkenas/quakespotter
https://github.com/jashkenas/quakespotter
Quakespotter.app/lib/ruby-processing/exporters/applet_exporter.rb
Ruby
mit
19
master
2,511
module Processing # A utility class to export Ruby-Processing sketches as applets # that can be viewed online. class AppletExporter < BaseExporter USAGE = <<-EOS The applet generator will generate a web-ready applet for you. Usage: script/applet <path_to_sketch> Example: script/apple...
github
jashkenas/quakespotter
https://github.com/jashkenas/quakespotter
Quakespotter.app/lib/ruby-processing/exporters/application_exporter.rb
Ruby
mit
19
master
2,979
module Processing # A utility class to export Ruby-Processing sketches as # Mac/Win/Nix Applications. class ApplicationExporter < BaseExporter USAGE = <<-EOS The application exporter will generate a Mac application for you. Usage: script/application <path_to_sketch> Example: scri...
github
jashkenas/quakespotter
https://github.com/jashkenas/quakespotter
Quakespotter.app/lib/ruby-processing/exporters/creator.rb
Ruby
mit
19
master
1,735
module Processing # This class creates blank sketches, with the boilerplate filled in. class Creator < BaseExporter ALL_DIGITS = /\A\d+\Z/ # Create a blank sketch, given a path. def create!(path, args, bare) usage path main_file = File.basename(path, ".rb") # Check to make...
github
jashkenas/quakespotter
https://github.com/jashkenas/quakespotter
Quakespotter.app/lib/ruby-processing/runners/live.rb
Ruby
mit
19
master
306
# An IRB shell for live coding. # This flavor will either load up empty Ruby-Processing, # or will start with your sketch. require "#{File.dirname(__FILE__)}/base.rb" Processing.load_and_run_sketch ARGV.clear # So that IRB doesn't try to load them as files. require 'irb' IRB.setup(__FILE__) IRB.start
github
jashkenas/quakespotter
https://github.com/jashkenas/quakespotter
Quakespotter.app/lib/ruby-processing/runners/watch.rb
Ruby
mit
19
master
4,071
require "#{File.dirname(__FILE__)}/base.rb" module Processing # A sketch loader, observer, and reloader, to tighten # the feedback between code and effect. class Watcher # Sic a new Processing::Watcher on the sketch def initialize @file = SKETCH_PATH @time = Time.now # Doesn'...
github
jashkenas/quakespotter
https://github.com/jashkenas/quakespotter
Quakespotter.app/lib/ruby-processing/runners/run.rb
Ruby
mit
19
master
229
# TODO: this is crud. Windows applets are having serious # trouble with absolute paths. root = defined?(JRUBY_APPLET) ? 'ruby-processing/runners' : File.dirname(__FILE__) require "#{root}/base.rb" Processing.load_and_run_sketch
github
jashkenas/quakespotter
https://github.com/jashkenas/quakespotter
Quakespotter.app/lib/ruby-processing/runners/base.rb
Ruby
mit
19
master
1,761
$LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../../") SKETCH_PATH = ARGV.shift SKETCH_ROOT = File.dirname(SKETCH_PATH) unless defined? SKETCH_ROOT require 'ruby-processing' require 'ruby-processing/app' module Processing # For use with "bare" sketches that don't want to define a class or methods ...
github
jashkenas/quakespotter
https://github.com/jashkenas/quakespotter
Quakespotter.app/lib/ruby-processing/helpers/string.rb
Ruby
mit
19
master
780
class String #:nodoc: def titleize self.underscore.humanize.gsub(/\b([a-z])/) { $1.capitalize } end def humanize() self.gsub(/_id$/, "").gsub(/_/, " ").capitalize end def camelize(first_letter_in_uppercase = true) if first_letter_in_uppercase self.gsub(/\/(.?)/) { "::" + $1.upcase }...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
hasoffers.gemspec
Ruby
mit
19
master
995
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "hasoffers/version" Gem::Specification.new do |s| s.name = "hasoffers" s.version = Hasoffers::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Luke Ludwig"] s.email = ["luke.ludwig@sportngin.com"] s...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
test/affiliate_billing_test.rb
Ruby
mit
19
master
1,514
require File.dirname(__FILE__) + '/test_helper' class AffiliateBillingTest < Test::Unit::TestCase def test_find_invoice_stats response = HasOffers::AffiliateBilling.find_invoice_stats('affiliate_id' => 1, 'start_date' => "06/23/10", 'end_date' => "07/23/10") assert_success response end def test_find_al...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
test/offer_test.rb
Ruby
mit
19
master
773
require File.dirname(__FILE__) + '/test_helper' class OfferTest < Test::Unit::TestCase def good_params { 'name' => 'Test', 'description' => 'Test', 'advertiser_id' => '1', 'offer_url' => 'test', 'preview_url' => 'test', 'protocol' => 'https', 'status' => 'active', ...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
test/conversion_test.rb
Ruby
mit
19
master
562
require File.dirname(__FILE__) + '/test_helper' class ConversionTest < Test::Unit::TestCase def good_params {'affiliate_id' => '1', 'offer_id' => '1', 'payout' => '10.50', 'revenue' => '5.75'} end def test_create response = HasOffers::Conversion.create(good_params) assert_success response end ...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
test/has_offers_model_test.rb
Ruby
mit
19
master
762
require File.expand_path(File.dirname(__FILE__) + '/test_helper') require 'has_offers_model' class DummyModel include ActiveModel::Validations include HasOffersModel has_offers_model "Affiliate" end class HasOffersModelTest < Test::Unit::TestCase def create_model DummyModel.new end def failed_respon...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
test/advertiser_test.rb
Ruby
mit
19
master
650
require File.dirname(__FILE__) + '/test_helper' class AdvertiserTest < Test::Unit::TestCase def test_find_all response = HasOffers::Advertiser.find_all assert_success response end def good_params { 'company' => 'Dominoes', 'address1' => '100 1st St.', 'city' => 'Minneapolis', 'co...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
test/base_test.rb
Ruby
mit
19
master
253
require File.dirname(__FILE__) + '/test_helper' class AdvertiserTest < Test::Unit::TestCase def test_set_base_uri new_uri = "http://example.com" HasOffers::Base.base_uri = new_uri assert_equal new_uri, HasOffers::Base.base_uri end end
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
test/affiliate_test.rb
Ruby
mit
19
master
1,017
require File.dirname(__FILE__) + '/test_helper' class AffiliateTest < Test::Unit::TestCase def good_params {'company' => 'Hockey Organization', 'address1' => '100 East 1st St.', 'city' => 'Minneapolis', 'country' => 'USA', 'zipcode' => '55431', 'region' => 'MN', 'phone' => '123-123...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
test/report_test.rb
Ruby
mit
19
master
565
require File.dirname(__FILE__) + '/test_helper' class ReportTest < Test::Unit::TestCase def test_get_stats response = HasOffers::Report.get_stats( 'fields' => ['Stat.clicks'], 'filters' => ['Stat.affiliate_id' => ['values' => 1, 'conditional' => 'EQUAL_TO']] ) assert_success response end ...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
test/test_helper.rb
Ruby
mit
19
master
230
require "test/unit" require "rubygems" require "active_model" require 'active_support/all' require "hasoffers" def assert_success(response) assert response.success?, "Failed with error messages: #{response.error_messages}" end
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
lib/has_offers_model.rb
Ruby
mit
19
master
1,744
module HasOffersModel def self.included(klass) klass.extend ClassMethods end module ClassMethods # requires that your model has the column has_offer_id # requires that you implement the method has_offers_params within your model def has_offers_model(has_offers_class_name) has_offers_clas...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
lib/hasoffers.rb
Ruby
mit
19
master
486
require 'yaml' require 'net/http' require 'net/https' require 'yajl' require 'crack' # loading base classes which other models depend on directory = File.expand_path(File.dirname(__FILE__)) require File.join(directory, "hasoffers", "response") require File.join(directory, "hasoffers", "dummy_response") require File.jo...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
lib/hasoffers/base.rb
Ruby
mit
19
master
3,343
module HasOffers class Base @@base_uri = 'https://api.hasoffers.com/Api' @@api_mode = ((defined?(Rails) and Rails.env.production?) or ENV['HAS_OFFERS_LIVE'] == '1') ? :live : :test @@default_params = nil class << self def base_uri=(uri) @@base_uri = uri end def base_uri ...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
lib/hasoffers/dummy_response.rb
Ruby
mit
19
master
4,036
module HasOffers class DummyResponse class << self def response_for(target, method, params) body = self.send("response_for_#{target.downcase}_#{method.downcase}", params) DummyResponse.new(200, 'Ok', body, {}) end # Assume return_object is set for simplicity which means j...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
lib/hasoffers/response.rb
Ruby
mit
19
master
2,396
module HasOffers class Response attr_reader :test, :body, :http_status_code, :http_message, :http_headers def success? @http_status_code.to_s == '200' and status == 1 end def test? @test end def status @body['response']['status'] end # allows specific api calls to...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
lib/hasoffers/affiliate.rb
Ruby
mit
19
master
627
module HasOffers class Affiliate < Base Target = 'Affiliate' class << self def create(data, return_object = false) requires!(data, %w[company address1 city country zipcode phone]) if data['country'] == 'US' or data['country'] == 'CA' requires!(data, 'region') end ...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
lib/hasoffers/affiliate_billing.rb
Ruby
mit
19
master
2,108
module HasOffers class AffiliateBilling < Base Target = 'AffiliateBilling' class << self # Jon Phenow @ 06/13/12 # Switched this to use POST because of some weird issues with sending # from behind a proxy def find_invoice_stats(params) requires!(params, %w[affiliate_id end_...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
lib/hasoffers/offer.rb
Ruby
mit
19
master
556
module HasOffers class Offer < Base Target = 'Offer' class << self def create(data, return_object = false) requires!(data, %w[name description advertiser_id offer_url preview_url protocol status expiration_date]) params = build_data data, return_object post_request(Target, ...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
lib/hasoffers/advertiser.rb
Ruby
mit
19
master
611
module HasOffers class Advertiser < Base Target = 'Advertiser' class << self def find_all(params = {}) post_request(Target, 'findAll', params) end def create(data, return_object = false) requires!(data, %w[company address1 city country zipcode phone]) params = bu...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
lib/hasoffers/report.rb
Ruby
mit
19
master
1,111
module HasOffers class Report < Base Target = 'Report' class << self # Jon Phenow @ 06/13/12 # Switched this to use POST because of some weird issues with sending # from behind a proxy def get_stats(params) requires!(params, %w[fields]) response = post_request(Targe...
github
sportnginlegacy/hasoffers
https://github.com/sportnginlegacy/hasoffers
lib/hasoffers/conversion.rb
Ruby
mit
19
master
623
module HasOffers class Conversion < Base Target = 'Conversion' class << self # number is number of conversions to create. Defaults to 1 on has offers side def create(data, number = nil) requires!(data, %w[affiliate_id offer_id payout revenue]) params = build_data data ...
github
Irio/skooby
https://github.com/Irio/skooby
skooby.gemspec
Ruby
mit
19
master
1,082
# -*- encoding: utf-8 -*- lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'skooby/version' Gem::Specification.new do |gem| gem.name = "skooby" gem.version = Skooby::VERSION gem.authors = ["Irio Irineu Musskopf Junior"] gem.email ...
github
Irio/skooby
https://github.com/Irio/skooby
lib/skooby/request.rb
Ruby
mit
19
master
255
module Skooby class Request include HTTParty base_uri 'skoob.com.br' def post(path, options = {}) self.class.post(path, options).body end def get(path, options = {}) self.class.get(path, options).body end end end
github
Irio/skooby
https://github.com/Irio/skooby
lib/skooby/book.rb
Ruby
mit
19
master
1,125
require 'nokogiri' module Skooby class Book attr_reader :id, :title, :author, :rating, :votes def initialize(params = {}) @id = params[:id] @title = params[:title] @author = params[:author] @rating = params[:rating] @votes = params[:votes] end def url ...
github
Irio/skooby
https://github.com/Irio/skooby
lib/skooby/search.rb
Ruby
mit
19
master
846
require 'nokogiri' module Skooby class Search def book(query) opts = { body: { data: { Busca: { tipo: "livro", tag: query } } } } page = Request.new.post('/livro/lista/', opts) parse_result(page) end private def parse_result(page_body) doc = Nokogiri::HTML(page_body) if...
github
Irio/skooby
https://github.com/Irio/skooby
lib/skooby/review.rb
Ruby
mit
19
master
298
module Skooby class Review attr_accessor :author, :title, :text def initialize(params = {}) @author = params[:author] if params.has_key?(:author) @title = params[:title] if params.has_key?(:title) @text = params[:text] if params.has_key?(:text) end end end
github
Irio/skooby
https://github.com/Irio/skooby
lib/skooby/reviews_parser.rb
Ruby
mit
19
master
1,029
module Skooby class ReviewsParser def initialize(book_id) @book_id = book_id end def url Request.base_uri + path end def last_reviews(page = 1) page_body = Request.new.get(path(page)) doc = Nokogiri::HTML.parse(page_body) doc.css('#corpo > div > [id^="resenha"]').ma...
github
Irio/skooby
https://github.com/Irio/skooby
test/unit/test_search.rb
Ruby
mit
19
master
1,569
require_relative '../helper' class TestSearch < MiniTest::Unit::TestCase def subject Skooby::Search.new end def test_book_method_returns_a_collection_of_Skooby_Book_instances_when_find_more_than_one_book result = nil VCR.use_cassette('search_movie_multiple_results') do result = subject.book('H...
github
Irio/skooby
https://github.com/Irio/skooby
test/unit/test_reviews_parser.rb
Ruby
mit
19
master
1,603
require_relative '../helper' class TestReviewsParser < MiniTest::Unit::TestCase def subject Skooby::ReviewsParser.new(108) end def test_url_method_should_return_a_valid_url URI.parse(subject.url) end def test_reviews_method_returns_a_collection_of_Skooby_Review_instances result = nil VCR.us...
github
Irio/skooby
https://github.com/Irio/skooby
test/unit/test_review.rb
Ruby
mit
19
master
555
require_relative '../helper' class TestReview < MiniTest::Unit::TestCase def test_initialization_of_attributes subject = Skooby::Review.new(author: 'Irio') assert_equal 'Irio', subject.author, 'should allow initialization of author' subject = Skooby::Review.new(title: 'Lipsum') assert_equal 'Lipsum',...
github
Irio/skooby
https://github.com/Irio/skooby
test/unit/test_book.rb
Ruby
mit
19
master
4,219
require_relative '../helper' class TestBook < MiniTest::Unit::TestCase def test_initialization_of_attributes subject = Skooby::Book.new(id: 108) assert_equal 108, subject.id, 'should allow initialization of id' subject = Skooby::Book.new(title: 'Harry Potter e a Pedra Filosofal') assert_equal 'Harry ...
github
Irio/skooby
https://github.com/Irio/skooby
test/unit/test_request.rb
Ruby
mit
19
master
594
require_relative '../helper' class TestRequest < MiniTest::Unit::TestCase def test_defines_skoobs_base_uri assert_equal 'http://skoob.com.br', Skooby::Request.base_uri end def test_post_method_delegates_itself_to_a_class_method Skooby::Request.expects(:post).with('/', bla: :foo). returns(stub('res...
github
danielfone/as_csv
https://github.com/danielfone/as_csv
as_csv.gemspec
Ruby
mit
19
master
864
# -*- encoding: utf-8 -*- require File.expand_path '../lib/as_csv/version', __FILE__ Gem::Specification.new do |gem| gem.name = "as_csv" gem.version = AsCSV::VERSION gem.authors = ["Daniel Fone"] gem.email = %w[daniel@fone.net.nz] gem.description = %q{Instant CSV support for Ra...
github
danielfone/as_csv
https://github.com/danielfone/as_csv
spec/spec_helper.rb
Ruby
mit
19
master
282
require 'simplecov' SimpleCov.start # Requires supporting ruby files with custom matchers and macros, etc, # in spec/support/ and its subdirectories. Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } RSpec.configure do |config| config.order = "random" end
github
danielfone/as_csv
https://github.com/danielfone/as_csv
spec/rails_helper.rb
Ruby
mit
19
master
806
require 'spec_helper' # Configure Rails Environment ENV["RAILS_ENV"] = "test" # require File.expand_path("../dummy/config/environment.rb", __FILE__) require File.expand_path("../support/test_rails_app.rb", __FILE__) require 'rspec/rails' Rails.backtrace_cleaner.remove_silencers! RSpec.configure do |config| # If...
github
danielfone/as_csv
https://github.com/danielfone/as_csv
spec/lib/csv_builder_spec.rb
Ruby
mit
19
master
1,778
require 'spec_helper' require 'as_csv/csv_builder' describe AsCSV::CSVBuilder do subject(:builder) { described_class.new records, options } let(:records) { nil } let(:options) { Hash.new } describe '#to_csv' do subject { builder.to_csv } context 'with single record' do let(:records) do ...
github
danielfone/as_csv
https://github.com/danielfone/as_csv
spec/controllers/render_widgets_controller_spec.rb
Ruby
mit
19
master
1,273
require 'rails_helper' RSpec.describe RenderWidgetsController do before do Widget.create! [ { :name => "widget-1", :description => 'widget-description-1', :code => 1001 }, { :name => "widget-2", :description => 'widget-description-2', :code => 1002 }, { :name => "widget-3", :description => 'wid...
github
danielfone/as_csv
https://github.com/danielfone/as_csv
spec/models/widget_spec.rb
Ruby
mit
19
master
1,754
require 'rails_helper' describe Widget do it { should respond_to :to_csv } it { should respond_to :as_csv } describe 'dummy' do subject(:dummy_widget) { Widget.new :name => "widget-name", :description => 'widget-description', :code => 1234 } describe :to_csv do subject { dummy_widget.to_csv } ...
github
danielfone/as_csv
https://github.com/danielfone/as_csv
spec/models/active_model_spec.rb
Ruby
mit
19
master
249
require 'rails_helper' class Serializable include ActiveModel::Serialization end class NonSerializable; end describe Serializable do it { should respond_to :as_csv } end describe NonSerializable do it { should_not respond_to :as_csv } end
github
danielfone/as_csv
https://github.com/danielfone/as_csv
spec/models/widget_with_options_spec.rb
Ruby
mit
19
master
634
require 'rails_helper' describe WidgetWithOptions do subject(:widget) { WidgetWithOptions.new :name => 'widget-name', :code => 1234 } describe :to_csv do subject { widget.to_csv(options) } context 'with style = :full' do let(:options) { {:style => :full} } it do should == <<-CSV.strip...
github
danielfone/as_csv
https://github.com/danielfone/as_csv
spec/support/test_rails_app.rb
Ruby
mit
19
master
1,393
# # This single file defines an entire Rails app, which is used for testing # require 'action_controller/railtie' require 'active_record/railtie' require 'as_csv' # Configure in-memory db ENV['DATABASE_URL'] = 'sqlite3::memory:' # A minimal test rails application class TestRailsApp < Rails::Application config.eager...
github
danielfone/as_csv
https://github.com/danielfone/as_csv
spec/core_ext/array_spec.rb
Ruby
mit
19
master
766
require 'spec_helper' require 'as_csv/core_ext/array' describe Array do subject(:array) do [ double(:foo, :as_csv => {:header => '1'}), double(:foo, :as_csv => {:header => '2'}), double(:foo, :as_csv => {:header1 => '3'}), ] end describe '#to_csv' do subject { array.to_csv } i...
github
danielfone/as_csv
https://github.com/danielfone/as_csv
lib/as_csv/railtie.rb
Ruby
mit
19
master
866
require 'as_csv/active_model/serialization/csv' # Use the Railtie to hook into the Rails initialization process module AsCsv class Railtie < Rails::Railtie initializer "as_csv" do # Include the CSV serialization module into ActiveRecord::Base and # ActiveModel::Serialization ActiveSupport.on_...
github
danielfone/as_csv
https://github.com/danielfone/as_csv
lib/as_csv/csv_builder.rb
Ruby
mit
19
master
1,301
require 'csv' module AsCSV class CSVBuilder attr_reader :records, :options, :csv_options def initialize(records, options={}) @records = Array(records) @options = options @csv_options = options.delete(:csv_options) || {} validate end def to_csv rows.collect { |row| CSV....
github
danielfone/as_csv
https://github.com/danielfone/as_csv
lib/as_csv/active_model/serialization/csv.rb
Ruby
mit
19
master
289
require 'as_csv/csv_builder' module AsCSV module ActiveModel module Serialization module CSV def as_csv(options={}) attributes end def to_csv(*args) AsCSV::CSVBuilder.new(self, *args).to_csv end end end end end
github
danielfone/as_csv
https://github.com/danielfone/as_csv
lib/as_csv/core_ext/array.rb
Ruby
mit
19
master
419
require 'csv' require 'as_csv/csv_builder' class Array def to_csv_with_builder(opts={}) use_csv_builder? and csv_builder(opts).to_csv or to_csv_without_builder end alias_method :to_csv_without_builder, :to_csv alias_method :to_csv, :to_csv_with_builder private def use_csv_builder? any? { |e| e.re...
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
Rakefile
Ruby
mit
19
master
260
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) TwitterGreatRss::Application.load_tasks
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
Gemfile
Ruby
mit
19
master
1,105
source 'https://rubygems.org' ruby '2.5.9' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.2.0' gem 'slim' # Use Uglifier as compressor for JavaScript assets gem 'uglifier'#, '>= 1.3.0' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyr...
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
db/schema.rb
Ruby
mit
19
master
1,175
# 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 source for your # dat...
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
db/migrate/20140216143921_create_users.rb
Ruby
mit
19
master
314
class CreateUsers < ActiveRecord::Migration[5.2] def change create_table :users do |t| t.string :twitter_id t.string :twitter_access_token t.string :twitter_access_secret t.string :url_id_hash t.timestamps t.index :twitter_id t.index :url_id_hash end end end
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
app/controllers/feed_controller.rb
Ruby
mit
19
master
1,803
class FeedController < ApplicationController TWEET_COUNT = 200 before_action :prepare_twitter_client def home res = @client.home(TWEET_COUNT) render_error and return if res.error @tweets = Tweet.tweets_from_hash_list(res.body) render_rss end def user res = @client.user(params[:name], T...
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
app/controllers/main_controller.rb
Ruby
mit
19
master
203
class MainController < ApplicationController before_action :set_user def index end private def set_user if session[:user_id] @user = User.find(session[:user_id]) end end end
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
app/controllers/auth_controller.rb
Ruby
mit
19
master
1,276
require 'oauth_twitter' class AuthController < ApplicationController def auth token = request_token session[:request_token] = token.token session[:request_token_secret] = token.secret redirect_to token.authorize_url end def callback @access_token = nil begin @access_token = oauth_t...
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
app/models/tweet.rb
Ruby
mit
19
master
708
class Tweet class << self def tweets_from_hash_list(hash_list) hash_list.map{|tweet_hash| Tweet.new(tweet_hash) } end end def initialize(tweet_hash) @hash = tweet_hash Rails.logger.debug @hash end def markupped_text MarkupTweet::markup_tweet(@hash) end def screen_name @has...
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
app/helpers/application_helper.rb
Ruby
mit
19
master
266
module ApplicationHelper def bookmarklet_escape(js) # output_safety string to raw string String.new(js) .gsub(/^\s+/, '') .gsub(/\s+$/, '') .gsub("\n", '') .gsub('%', '%25') .gsub(" ", '%20') .gsub('"', '%22') end end
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
lib/oauth_twitter.rb
Ruby
mit
19
master
765
require 'oauth' require 'json' class OAuthTwitter SITE_URL = 'https://api.twitter.com' def request_token(hash) self.consumer.get_request_token(hash) end def access_token(request_token, request_token_secret, oauth_token, oauth_verifier) request_token = OAuth::RequestToken.new(self.consumer, request_to...
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
lib/twitter_client.rb
Ruby
mit
19
master
1,819
require 'oauth' require 'oauth_twitter' require 'uri' class TwitterClient def initialize(access_token, access_secret) @access_token = OAuth::AccessToken.new(OAuthTwitter.new.consumer, access_token, access_secret) end def home(count) get_and_json_parse(home_sub_url(count)) end def user(name, count) ...
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
lib/markup_tweet.rb
Ruby
mit
19
master
2,592
class MarkupTweet class << self def markup_tweet(tweet) text = tweet['full_text'] entities = tweet['entities'] extended_entities = tweet['extended_entities'] text = MarkupTweet::markup_media(text, entities, extended_entities) text = MarkupTweet::markup_urls(text, tweet) text = ...
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
config/routes.rb
Ruby
mit
19
master
369
Rails.application.routes.draw do root 'main#index' scope :auth do get 'auth' => 'auth#auth' get 'callback' => 'auth#callback' get 'logout' => 'auth#logout' end scope :feed do get 'home' => 'feed#home' get 'user' => 'feed#user' get 'user/fav' => 'feed#user_fav' get 'list' => 'feed#l...
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
config/application.rb
Ruby
mit
19
master
1,163
require File.expand_path('../boot', __FILE__) #require 'rails/all' # Include each railties manually, excluding `active_storage/engine` %w( active_record/railtie action_controller/railtie action_view/railtie action_mailer/railtie active_job/railtie action_cable/engine rails/test_unit/railtie sprockets/...
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
config/environments/production.rb
Ruby
mit
19
master
3,948
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web serve...
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
config/environments/test.rb
Ruby
mit
19
master
1,877
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suit...
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
config/environments/development.rb
Ruby
mit
19
master
2,177
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
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
config/initializers/secret_token.rb
Ruby
mit
19
master
669
# Be sure to restart your server when you modify this file. # Your secret key is used for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to diction...
github
yayugu/twitter-great-rss
https://github.com/yayugu/twitter-great-rss
config/initializers/new_framework_defaults.rb
Ruby
mit
19
master
1,119
# Be sure to restart your server when you modify this file. # # This file contains migration options to ease your Rails 5.0 upgrade. # # Once upgraded flip defaults one by one to migrate to the new default. # # Read the Guide for Upgrading Ruby on Rails for more info on each option. #Rails.application.config.action_co...
github
shioimm/trace_header
https://github.com/shioimm/trace_header
trace_header.gemspec
Ruby
mit
19
master
1,168
lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "trace_header/version" Gem::Specification.new do |spec| spec.name = "trace_header" spec.version = TraceHeader::VERSION spec.authors = ["Misaki Shioi"] spec.email = ["shioi.mm@...
github
shioimm/trace_header
https://github.com/shioimm/trace_header
lib/trace_header.rb
Ruby
mit
19
master
1,182
require 'active_support/core_ext' require_relative 'trace_header/description' require_relative 'trace_header/result' require_relative 'trace_header/version' class TraceHeader include Describable def initialize(app) @app = app @datas = [] @fixed_app = nil end def call(env) tracer.ena...
github
shioimm/trace_header
https://github.com/shioimm/trace_header
lib/trace_header/result.rb
Ruby
mit
19
master
1,049
class TraceHeader class Result attr_reader :target_app def initialize(target_app, datas) @target_app = target_app @target_hash = datas.find { |data| data[:middleware].eql?(target_app.class) } @inner_hash = datas[datas.index(@target_hash) + 1] end def new_headers headers(new...
github
shioimm/trace_header
https://github.com/shioimm/trace_header
lib/trace_header/description.rb
Ruby
mit
19
master
1,159
class TraceHeader module Describable MAXIMUM_LENGTH = 50 def output(result) puts description(result) end private def description(result) <<~"TEXT" ---------------------------------------------------- TraceHeader printing... [Target Middleware] ...
github
shioimm/trace_header
https://github.com/shioimm/trace_header
spec/trace_header_spec.rb
Ruby
mit
19
master
2,223
# frozen_string_literal: true require_relative './spec_helper' require_relative './support/dummy/sample_app' require_relative './support/dummy/new_header_middleware' require_relative './support/dummy/changed_header_middleware' RSpec.describe TraceHeader do it 'has a version number' do expect(TraceHeader::VERSIO...
github
shioimm/trace_header
https://github.com/shioimm/trace_header
spec/support/dummy/changed_header_middleware.rb
Ruby
mit
19
master
233
class ChangedHeaderMiddleware def initialize(app) @app = app end def call(env) status, header, body = @app.call(env) if header.key?('Foo') header['Foo'] = 'Baz' end [status, header, body] end end
github
shioimm/trace_header
https://github.com/shioimm/trace_header
spec/support/dummy/new_header_middleware.rb
Ruby
mit
19
master
204
class NewHeaderMiddleware def initialize(app) @app = app end def call(env) status, header, body = @app.call(env) header.merge!({ 'Foo' =>'Bar' }) [status, header, body] end end
github
ruby/rbs_json_schema
https://github.com/ruby/rbs_json_schema
rbs_json_schema.gemspec
Ruby
mit
19
main
1,367
require_relative 'lib/rbs_json_schema/version' Gem::Specification.new do |spec| spec.name = "rbs_json_schema" spec.version = RBSJsonSchema::VERSION spec.authors = ["Soutaro Matsumoto"] spec.email = ["matsumoto@soutaro.com"] spec.summary = %q{Generate RBS type definitions f...
github
ruby/rbs_json_schema
https://github.com/ruby/rbs_json_schema
test/cli_test.rb
Ruby
mit
19
main
9,251
require "test_helper" class CLITest < Minitest::Test include TestHelper include RBSJsonSchema RBS_PATH = Pathname(Gem::Specification.find_by_name("rbs", RBS::VERSION).gem_dir).realpath SCHEMA_PATH = RBS_PATH + "schema" def stdout @stdout ||= StringIO.new end def stderr @stderr ||= StringIO.ne...
github
ruby/rbs_json_schema
https://github.com/ruby/rbs_json_schema
test/generator_test.rb
Ruby
mit
19
main
1,283
require "test_helper" class GeneratorTest < Minitest::Test include TestHelper include RBSJsonSchema def output @output ||= "" end def stdout @stdout ||= StringIO.new end def stderr @stderr ||= StringIO.new end def generator @generator ||= Generator.new( stringify_keys: fals...
github
ruby/rbs_json_schema
https://github.com/ruby/rbs_json_schema
lib/rbs_json_schema.rb
Ruby
mit
19
main
298
require "uri" require "json" require "rbs" require "active_support/core_ext/string/inflections" require "rbs_json_schema/version" require "rbs_json_schema/generator" require "rbs_json_schema/validation_error" module RBSJsonSchema class Error < StandardError; end # Your code goes here... end
github
ruby/rbs_json_schema
https://github.com/ruby/rbs_json_schema
lib/rbs_json_schema/cli.rb
Ruby
mit
19
main
1,585
require "optparse" module RBSJsonSchema class CLI attr_reader :stdout attr_reader :stderr def initialize(stdout:, stderr:) @stdout = stdout @stderr = stderr @options = {} end def run(args) OptionParser.new do |opts| opts.banner = <<~USAGE Usage: rbs_json_...
github
ruby/rbs_json_schema
https://github.com/ruby/rbs_json_schema
lib/rbs_json_schema/generator.rb
Ruby
mit
19
main
10,726
module RBSJsonSchema class Generator attr_reader :stringify_keys attr_reader :output attr_reader :stdout attr_reader :stderr attr_reader :path_decls attr_reader :generated_schemas Alias = RBS::AST::Declarations::Alias def initialize(stringify_keys:, output:, stdout:, stderr:) @...
github
mikhailvs/rack-fluentd-logger
https://github.com/mikhailvs/rack-fluentd-logger
rack-fluentd-logger.gemspec
Ruby
mit
19
master
855
# frozen_string_literal: true lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'rack/fluentd_logger_version' Gem::Specification.new do |s| s.name = 'rack-fluentd-logger' s.version = Rack::FluentdLogger::VERSION s.authors = ['Mikhail Slyusarev'] s.email =...
github
mikhailvs/rack-fluentd-logger
https://github.com/mikhailvs/rack-fluentd-logger
lib/rack/fluentd_logger.rb
Ruby
mit
19
master
2,418
# frozen_string_literal: true require 'English' require 'fluent-logger' require 'concurrent' require 'json' module Rack class FluentdLogger class << self attr_reader :logger, :json_parser, :preprocessor def configure( name: ENV['FLUENTD_NAME'], host: ENV['FLUENTD_HOST'], por...
github
mikhailvs/rack-fluentd-logger
https://github.com/mikhailvs/rack-fluentd-logger
spec/spec_helper.rb
Ruby
mit
19
master
374
# frozen_string_literal: true require 'rack-fluentd-logger' RSpec.configure do |config| config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end config.mock_with :rspec do |mocks| mocks.verify_partial_doubles = true end config.shared_...
github
dwillis/hulse
https://github.com/dwillis/hulse
hulse.gemspec
Ruby
mit
19
master
1,332
# coding: utf-8 lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'hulse/version' Gem::Specification.new do |spec| spec.name = "hulse" spec.version = Hulse::VERSION spec.authors = ["Derek Willis"] spec.email = ["dwillis@gmail.com...
github
dwillis/hulse
https://github.com/dwillis/hulse
lib/hulse.rb
Ruby
mit
19
master
2,094
require 'httparty' require 'oj' require 'nokogiri' require 'htmlentities' require 'memoist' require 'rest-client' require "hulse/version" require "hulse/bill" require "hulse/record" require "hulse/amendment" require "hulse/communication" require "hulse/committee_report" require "hulse/house_vote" require "hulse/house_m...
github
dwillis/hulse
https://github.com/dwillis/hulse
lib/hulse/house_committee.rb
Ruby
mit
19
master
2,178
module Hulse class HouseCommittee attr_reader :url, :name, :code, :members, :republicans, :democrats, :subcommittees def initialize(params={}) params.each_pair do |k,v| instance_variable_set("@#{k}", v) end end def self.fetch(url) doc = HTTParty.get(url) Nokogiri::HT...
github
dwillis/hulse
https://github.com/dwillis/hulse
lib/hulse/senate_vote.rb
Ruby
mit
19
master
4,283
module Hulse class SenateVote attr_reader :congress, :session, :year, :vote_number, :vote_timestamp, :updated_at, :vote_question_text, :vote_document_text, :vote_result_text, :question, :vote_title, :majority_requirement, :vote_result, :document, :amendment, :vote_count, :tie_breaker, :members, :vote_dat...
github
dwillis/hulse
https://github.com/dwillis/hulse
lib/hulse/communication.rb
Ruby
mit
19
master
3,097
module Hulse class Communication attr_reader :id, :date, :committee, :url, :text, :requirement, :requirement_url def initialize(params={}) params.each_pair do |k,v| instance_variable_set("@#{k}", v) end end def to_s id end def self.presidential(page=1) comms...
github
dwillis/hulse
https://github.com/dwillis/hulse
lib/hulse/committee_report.rb
Ruby
mit
19
master
2,182
module Hulse class CommitteeReport attr_reader :congress, :chamber, :title, :url, :number, :committee, :committee_code, :bill, :bill_url, :text, :pdf_url def self.fetch(url) doc = RestClient.get(url) Nokogiri::HTML(doc.body) end def initialize(params={}) params.each_pair do |k,v| ...