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
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
config/initializers/transit_realtime.pb.rb
Ruby
mit
95
master
8,332
module TransitRealtime ::Protobuf::Optionable.inject(self) { ::Google::Protobuf::FileOptions } class FeedMessage < ::Protobuf::Message; end class FeedHeader < ::Protobuf::Message class Incrementality < ::Protobuf::Enum define :FULL_DATASET, 0 define :DIFFERENTIAL, 1 end end class FeedEn...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
app/lib/subway_gtfs_importer.rb
Ruby
mit
95
master
3,157
class SubwayGtfsImporter MTA_URL = "http://web.mta.info/developers/data/nyct/subway/google_transit.zip" COPY_INSTRUCTIONS = [ { table_name: "agencies", file_name: "agency.txt", copy_schema: "mta_id, name, url, timezone, language, phone, created_at, updated_at" }, { table_name: "...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
app/lib/realtime_feed_mapper.rb
Ruby
mit
95
master
1,125
class RealtimeFeedMapper MAPPING = { "1" => [1, "gtfs"], "2" => [1, "gtfs"], "3" => [1, "gtfs"], "4" => [1, "gtfs"], "5" => [1, "gtfs"], "5X" => [1, "gtfs"], "6" => [1, "gtfs"], "6X" => [1, "gtfs"], "7" => [51, "gtfs-7"], "7X" => [51, "gtfs-7"], "GS" => [1, "gtfs"], "A"...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
app/models/stop.rb
Ruby
mit
95
master
916
class Stop < ApplicationRecord validates :mta_id, presence: true, uniqueness: true has_many :stop_times, primary_key: :mta_id, foreign_key: :stop_mta_id has_many :scheduled_trips, through: :stop_times has_many :routes, -> { distinct }, through: :scheduled_trips has_many :stop_time_updates, primary_key: :mta...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
app/models/scheduled_trip.rb
Ruby
mit
95
master
698
class ScheduledTrip < ApplicationRecord validates :mta_id, presence: true, uniqueness: true belongs_to :route, foreign_key: :route_mta_id, primary_key: :mta_id belongs_to :calendar, foreign_key: :service_id, primary_key: :service_id has_many :stop_times, -> { order(:stop_sequence) }, primary_key: :mta...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
app/models/realtime_trip.rb
Ruby
mit
95
master
1,307
class RealtimeTrip < ApplicationRecord MTA_SUB_ID_REGEX = /^(\d{6}_\w{1,2}(?:\.{1,2}[NS])?)/i has_paper_trail on: %i(update destroy), ignore: %i(first_observed_at most_recently_observed_at) validates_presence_of :mta_id, :mta_sub_id, :start_date, :route_mta_id, :train_id, :train_sub_id, :direction, :ori...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
app/models/route.rb
Ruby
mit
95
master
390
class Route < ApplicationRecord validates :mta_id, presence: true, uniqueness: true validates :agency_mta_id, presence: true belongs_to :agency, foreign_key: :agency_mta_id, primary_key: :mta_id belongs_to :realtime_feed has_many :scheduled_trips, primary_key: :mta_id, foreign_key: :route_mta_id has_many ...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
app/models/calendar.rb
Ruby
mit
95
master
266
class Calendar < ApplicationRecord validates :service_id, presence: true, uniqueness: {scope: %i(start_date end_date)} validates :start_date, :end_date, presence: true has_many :scheduled_trips, primary_key: :service_id, foreign_key: :service_id end
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
app/models/alert.rb
Ruby
mit
95
master
314
class Alert < ApplicationRecord validates :realtime_trip_mta_id, :observed_at, :observation_id, presence: true belongs_to :realtime_trip, foreign_key: :realtime_trip_mta_id, primary_key: :mta_id, optional: true belongs_to :observation, class_name: "RealtimeFeedObservation", optional: true end
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
app/models/vehicle_position.rb
Ruby
mit
95
master
450
class VehiclePosition < ApplicationRecord validates :realtime_trip, :observed_at, :observation_id, presence: true belongs_to :realtime_trip belongs_to :stop, foreign_key: :stop_mta_id, primary_key: :mta_id, optional: true belongs_to :observation, class_name: "RealtimeFeedObservation", optional: true scope :...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
app/models/stop_time.rb
Ruby
mit
95
master
303
class StopTime < ApplicationRecord validates :trip_mta_id, presence: true, uniqueness: {scope: :stop_mta_id} validates :stop_mta_id, presence: true belongs_to :scheduled_trip, foreign_key: :trip_mta_id, primary_key: :mta_id belongs_to :stop, foreign_key: :stop_mta_id, primary_key: :mta_id end
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
app/models/realtime_feed.rb
Ruby
mit
95
master
2,204
class RealtimeFeed < ApplicationRecord API_BASE_URL = "https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/nyct%2F" HISTORICAL_DATA_BASE_URL = "https://datamine-history.s3.amazonaws.com" HISTORICAL_DATA_PREFIXES = { 1 => "gtfs", 2 => "gtfs-l" } validates :mta_id, presence: true, uniqueness: true ...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
app/models/shape.rb
Ruby
mit
95
master
212
class Shape < ApplicationRecord validates :mta_id, presence: true, uniqueness: {scope: :sequence} validates :sequence, presence: true belongs_to :trip, foreign_key: :mta_id, primary_key: :shape_mta_id end
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
app/models/stop_time_update.rb
Ruby
mit
95
master
506
class StopTimeUpdate < ApplicationRecord validates :realtime_trip, :stop_mta_id, :observed_at, :observation_id, presence: true belongs_to :realtime_trip belongs_to :stop, foreign_key: :stop_mta_id, primary_key: :mta_id, optional: true belongs_to :observation, class_name: "RealtimeFeedObservation", optional...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
app/models/transfer.rb
Ruby
mit
95
master
394
class Transfer < ApplicationRecord validates :from_stop_mta_id, presence: true, uniqueness: {scope: :to_stop_mta_id} validates :to_stop_mta_id, presence: true belongs_to :from_stop, class_name: "Stop", foreign_key: :from_stop_mta_id, primary_key: :mta_id belongs_to :to_stop, class_nam...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
app/models/realtime_feed_observation.rb
Ruby
mit
95
master
5,806
class RealtimeFeedObservation < ApplicationRecord validates :feed, :observed_at, presence: true belongs_to :feed, class_name: "RealtimeFeed" has_many :stop_time_updates, foreign_key: :observation_id has_many :vehicle_positions, foreign_key: :observation_id has_many :alerts, foreign_key: :observation_id s...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
db/schema.rb
Ruby
mit
95
master
8,868
# 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
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
db/migrate/20171229230608_create_versions.rb
Ruby
mit
95
master
402
class CreateVersions < ActiveRecord::Migration[5.1] def change create_table :versions do |t| t.string :item_type, null: false t.integer :item_id, null: false t.string :event, null: false t.string :whodunnit t.jsonb :object t.jsonb :object_changes t.date...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
db/migrate/20171229230607_create_delayed_jobs.rb
Ruby
mit
95
master
1,306
class CreateDelayedJobs < ActiveRecord::Migration[5.1] def self.up create_table :delayed_jobs, force: true do |table| table.integer :priority, default: 0, null: false # Allows some jobs to jump to the front of the queue table.integer :attempts, default: 0, null: false # Provides for retries, but still...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
db/migrate/20200404140412_add_new_mta_id_to_feeds.rb
Ruby
mit
95
master
899
class AddNewMtaIdToFeeds < ActiveRecord::Migration[5.2] def up rename_column :realtime_feeds, :mta_id, :old_mta_id add_column :realtime_feeds, :mta_id, :string execute <<-SQL UPDATE realtime_feeds SET mta_id = CASE WHEN old_mta_id = 1 THEN 'gtfs' WHEN old_mta_id = 2 THEN 'gtfs...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
db/migrate/20180107173339_create_realtime_tables.rb
Ruby
mit
95
master
2,195
class CreateRealtimeTables < ActiveRecord::Migration[5.1] def change create_table :realtime_trips do |t| t.string :mta_id, null: false t.string :mta_sub_id, null: false t.date :start_date, null: false t.string :route_mta_id, null: false t.string :train_id, null: false t.string ...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
db/migrate/20171229191824_create_realtime_feed_observations.rb
Ruby
mit
95
master
385
class CreateRealtimeFeedObservations < ActiveRecord::Migration[5.1] def change create_table :realtime_feed_observations do |t| t.integer :feed_id, null: false t.timestamp :observed_at, null: false t.jsonb :data t.timestamp :processed_at t.timestamps end add_index :realtime_fe...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
db/migrate/20171229151631_create_gtfs_tables.rb
Ruby
mit
95
master
3,279
class CreateGtfsTables < ActiveRecord::Migration[5.1] def change create_table :agencies do |t| t.text :mta_id, null: false t.text :name t.text :url t.text :timezone t.text :language t.text :phone t.timestamps end add_index :agencies, :mta_id, unique: true cre...
github
toddwschneider/nyc-subway-data
https://github.com/toddwschneider/nyc-subway-data
db/migrate/20171229175709_create_feeds.rb
Ruby
mit
95
master
229
class CreateFeeds < ActiveRecord::Migration[5.1] def change create_table :realtime_feeds do |t| t.integer :mta_id, null: false t.timestamps end add_index :realtime_feeds, :mta_id, unique: true end end
github
garethr/packer-serverspec-example
https://github.com/garethr/packer-serverspec-example
tests/spec/spec_helper.rb
Ruby
mit
95
master
308
require 'serverspec' include SpecInfra::Helper::Exec include SpecInfra::Helper::DetectOS RSpec.configure do |c| if ENV['ASK_SUDO_PASSWORD'] require 'highline/import' c.sudo_password = ask("Enter sudo password: ") { |q| q.echo = false } else c.sudo_password = ENV['SUDO_PASSWORD'] end end
github
baweaver/refactor
https://github.com/baweaver/refactor
refactor.gemspec
Ruby
mit
95
main
1,340
# frozen_string_literal: true require_relative "lib/refactor/version" Gem::Specification.new do |spec| spec.name = "refactor" spec.version = Refactor::VERSION spec.authors = ["Brandon Weaver"] spec.email = ["keystonelemur@gmail.com"] spec.summary = "Ruby refactoring tool" spec.description = "AST-based Ru...
github
baweaver/refactor
https://github.com/baweaver/refactor
Guardfile
Ruby
mit
95
main
346
guard :rspec, cmd: "bundle exec rspec" do require "guard/rspec/dsl" dsl = Guard::RSpec::Dsl.new(self) # RSpec files rspec = dsl.rspec watch(rspec.spec_helper) { rspec.spec_dir } watch(rspec.spec_support) { rspec.spec_dir } watch(rspec.spec_files) # Ruby files ruby = dsl.ruby dsl.watch_spec_file...
github
baweaver/refactor
https://github.com/baweaver/refactor
sandbox/experimental.rb
Ruby
mit
95
main
8,530
# All the stuff I've extracted for the moment until I get it working cleanly # or for release in a later commit. For now this may be interesting for the # sake of reading so I'll leave this in. module Refactor module Util REPL_SOURCE = Regexp.union('(IRB)', '(pry)') def self.extract_block_ast(block) so...
github
baweaver/refactor
https://github.com/baweaver/refactor
spec/spec_helper.rb
Ruby
mit
95
main
371
# frozen_string_literal: true require "refactor" RSpec.configure do |config| # Enable flags like --only-failures and --next-failure config.example_status_persistence_file_path = ".rspec_status" # Disable RSpec exposing methods globally on `Module` and `main` config.disable_monkey_patching! config.expect_w...
github
baweaver/refactor
https://github.com/baweaver/refactor
spec/refactor_spec.rb
Ruby
mit
95
main
3,201
# frozen_string_literal: true RSpec.describe Refactor do let(:shorthand_rule) do Class.new(Refactor::Rule) do def on_block(node) return unless node in [:block, receiver, [[:arg, arg_name]], [:send, [:lvar, ^arg_name], method_name] ] replace(node, "#{receiver.source}(&:#{m...
github
baweaver/refactor
https://github.com/baweaver/refactor
lib/refactor.rb
Ruby
mit
95
main
4,626
# frozen_string_literal: true require_relative 'refactor/version' # Eventually we may consider dropping RuboCop and working more directly # on top of Parser itself require 'rubocop' # Niceties for console output require 'colorized_string' module Refactor # Utilities for working with ASTs module Util def sel...
github
baweaver/refactor
https://github.com/baweaver/refactor
refactor_rules/hash_ref_default_rule.rb
Ruby
mit
95
main
257
class HashRefDefaultRule < Refactor::Rule def on_send(node) return unless node in [:send, [:const, nil, :Hash], :new, [:array | :hash] => reference_value ] replace(node, "Hash.new { |h, k| h[k] = #{reference_value.source} }") end end
github
baweaver/refactor
https://github.com/baweaver/refactor
refactor_rules/shorthand_rule.rb
Ruby
mit
95
main
508
# Inherits from base rule, which provides a lot of utilities # to match and replace with. class ShorthandRule < Refactor::Rule # The code we're trying to work with here is: # # [1, 2, 3].select { |v| v.even? } # # ...and we want to make it into: # # [1, 2, 3].select(&:even?) # def on_block(node)...
github
testdouble/put
https://github.com/testdouble/put
Rakefile
Ruby
mit
95
main
232
require "bundler/gem_tasks" require "rake/testtask" Rake::TestTask.new(:test) do |t| t.libs << "test" t.libs << "lib" t.test_files = FileList["test/**/*_test.rb"] end require "standard/rake" task default: %i[test standard]
github
testdouble/put
https://github.com/testdouble/put
put.gemspec
Ruby
mit
95
main
1,067
require_relative "lib/put/version" Gem::Specification.new do |spec| spec.name = "put" spec.version = Put::VERSION spec.authors = ["Justin Searls"] spec.email = ["searls@gmail.com"] spec.summary = "Put helps you write prioritized, multi-variate sort_by blocks" spec.homepage = "https://github.com/testdouble...
github
testdouble/put
https://github.com/testdouble/put
test/put_test.rb
Ruby
mit
95
main
3,458
require "test_helper" class PutTest < Minitest::Test Golfer = Struct.new(:name, :age, :handicap, :member, keyword_init: true) { def minor? return if age.nil? age < 21 end } def test_put golfers = [ noah = Golfer.new(name: "Noah", age: 13, handicap: 18, member: true), eve = G...
github
testdouble/put
https://github.com/testdouble/put
test/put/debug_test.rb
Ruby
mit
95
main
474
require "test_helper" module Put class DebugTest < Minitest::Test Dingus = Struct.new(:name, keyword_init: true) def setup @subject = Debug.new end def test_sortable_stuff_doesnt_fail dinguses = [Dingus.new(name: "Jerry"), Dingus.new(name: "Justin")] result = @subject.call(dingus...
github
testdouble/put
https://github.com/testdouble/put
test/put/puts_thing/nils_last_test.rb
Ruby
mit
95
main
302
require "test_helper" module Put class PutsThing class NilsLastTest < Minitest::Test def test_the_nils_go_last result = ["B", nil, "A", nil].sort_by { |thing| [Put.nils_last(thing)] } assert_equal ["B", "A", nil, nil], result end end end end
github
testdouble/put
https://github.com/testdouble/put
test/put/puts_thing/nils_first_test.rb
Ruby
mit
95
main
305
require "test_helper" module Put class PutsThing class NilsFirstTest < Minitest::Test def test_the_nils_go_first result = ["B", nil, "A", nil].sort_by { |thing| [Put.nils_first(thing)] } assert_equal [nil, nil, "B", "A"], result end end end end
github
testdouble/put
https://github.com/testdouble/put
test/put/puts_thing/ascending_test.rb
Ruby
mit
95
main
828
require "test_helper" module Put class PutsThing class AscendingTest < Minitest::Test def test_asc_nils_first assert_equal([ Put.asc("B", nils_first: true), Put.asc(nil, nils_first: true), Put.asc("A", nils_first: true), Put.asc(nil, nils_first: true) ...
github
testdouble/put
https://github.com/testdouble/put
test/put/puts_thing/anywhere_test.rb
Ruby
mit
95
main
438
require "test_helper" module Put class PutsThing class AnywhereTest < Minitest::Test def test_it_seems_to_shuffle_stuff stuff = [1, 2, 3, 4, 5] result_1 = stuff.sort_by { |thing| [Put.anywhere] } result_2 = stuff.sort_by { |thing| [Put.anywhere] ...
github
testdouble/put
https://github.com/testdouble/put
lib/put.rb
Ruby
mit
95
main
1,167
require_relative "put/debug" require_relative "put/version" require_relative "put/nil_ext" require_relative "put/puts_thing" require_relative "put/puts_thing/anywhere" require_relative "put/puts_thing/first" require_relative "put/puts_thing/last" require_relative "put/puts_thing/in_order" require_relative "put/puts_thi...
github
testdouble/put
https://github.com/testdouble/put
lib/put/nil_ext.rb
Ruby
mit
95
main
202
module Put module NilExtension def <=>(other) if ::Put::PutsThing === other -(other <=> self) else super end end end ::NilClass.prepend(NilExtension) end
github
testdouble/put
https://github.com/testdouble/put
lib/put/debug.rb
Ruby
mit
95
main
1,894
module Put class Debug Result = Struct.new(:success?, :incomparables, keyword_init: true) Incomparable = Struct.new( :sorting_index, :left, :left_index, :left_value, :right, :right_index, :right_value, keyword_init: true ) { def inspect both_puts_things = left.is_a?(PutsThing) &&...
github
testdouble/put
https://github.com/testdouble/put
lib/put/puts_thing.rb
Ruby
mit
95
main
503
module Put class PutsThing def <=>(other) if value.nil? && (other.nil? || other&.value.nil?) 0 elsif value.nil? nils_first? ? -1 : 1 elsif other.nil? || other&.value.nil? nils_first? ? 1 : -1 elsif other && !other.reverse? value <=> other.value elsif o...
github
testdouble/put
https://github.com/testdouble/put
lib/put/puts_thing/anywhere.rb
Ruby
mit
95
main
223
module Put class PutsThing class Anywhere < PutsThing def initialize(seed) @random = seed.nil? ? Random.new : Random.new(seed) end def value @random.rand end end end end
github
testdouble/put
https://github.com/testdouble/put
lib/put/puts_thing/in_order.rb
Ruby
mit
95
main
263
module Put class PutsThing class InOrder < PutsThing def initialize(value, nils_first:) @value = value @nils_first = nils_first end attr_reader :value def nils_first? @nils_first end end end end
github
testdouble/put
https://github.com/testdouble/put
lib/put/puts_thing/nil_order.rb
Ruby
mit
95
main
240
module Put class PutsThing class NilOrder < PutsThing def initialize(value) @value = value end def value if @value.nil? nil else 0 end end end end end
github
coreyhaines/practice_game_of_life
https://github.com/coreyhaines/practice_game_of_life
Rakefile
Ruby
mit
95
master
1,807
require 'rubygems' require 'rake' begin require 'jeweler' Jeweler::Tasks.new do |gem| gem.name = "practice_game_of_life" gem.summary = %Q{Cucumber features for practicing building game of life simulations} gem.description = %Q{In order to not know when you have a functioning game of life simulator, you...
github
coreyhaines/practice_game_of_life
https://github.com/coreyhaines/practice_game_of_life
Guardfile
Ruby
mit
95
master
438
guard 'rspec', version: 2 do watch(%r{^spec/.+_spec\.rb$}) watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch('spec/spec_helper.rb') { "spec/" } end guard 'cucumber', cli: '--profile guard' do watch(%r{^features/.+\.feature$}) watch(%r{^features/support/.+$}) { 'features' } wa...
github
coreyhaines/practice_game_of_life
https://github.com/coreyhaines/practice_game_of_life
spec/spec_helper.rb
Ruby
mit
95
master
426
$LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'game_of_life' require 'rspec' require 'rspec/autorun' RSpec.configure do |config| # == Mock Framework # # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: # # conf...
github
stve/instapaper
https://github.com/stve/instapaper
instapaper.gemspec
Ruby
mit
95
main
957
lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'instapaper/version' Gem::Specification.new do |spec| spec.add_dependency 'addressable', '~> 2.3' spec.add_dependency 'http', '>= 2', '< 6' spec.add_dependency 'multi_json', '~> 1' spec.add_dependency 'simple...
github
stve/instapaper
https://github.com/stve/instapaper
Gemfile
Ruby
mit
95
main
291
source 'https://rubygems.org' gem 'rake' gem 'yard' gem 'jruby-openssl', platforms: :jruby gem 'json', platforms: :mri_19 group :development do gem 'kramdown' end group :test do gem 'rspec', '~> 3' gem 'rubocop', '>= 0.27' gem 'simplecov' gem 'webmock', '>= 1.22' end gemspec
github
stve/instapaper
https://github.com/stve/instapaper
Rakefile
Ruby
mit
95
main
260
require 'bundler' Bundler::GemHelper.install_tasks require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) task test: :spec require 'rubocop/rake_task' RuboCop::RakeTask.new require 'yard' YARD::Rake::YardocTask.new task default: %i[spec rubocop]
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/error.rb
Ruby
mit
95
main
3,407
module Instapaper # Custom error class for rescuing from all Instapaper errors class Error < StandardError # @return [Integer] attr_reader :code ClientError = Class.new(self) ServerError = Class.new(self) ServiceUnavailableError = Class.new(self) BookmarkError = Class.new(self) FolderEr...
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/bookmark_list.rb
Ruby
mit
95
main
449
require 'instapaper/bookmark' require 'instapaper/highlight' require 'instapaper/user' module Instapaper class BookmarkList include Virtus.value_object values do attribute :user, Instapaper::User attribute :bookmarks, Array[Instapaper::Bookmark] attribute :highlights, Array[Instapaper::Hig...
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/highlight.rb
Ruby
mit
95
main
318
require 'virtus' module Instapaper class Highlight include Virtus.value_object values do attribute :type, String attribute :highlight_id, String attribute :bookmark_id, String attribute :text, String attribute :position, String attribute :time, String end end end
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/client.rb
Ruby
mit
95
main
1,383
require 'instapaper/api' require 'instapaper/http/utils' require 'instapaper/version' module Instapaper # Wrapper for the Instapaper REST API class Client include Instapaper::API include Instapaper::HTTP::Utils attr_accessor :oauth_token, :oauth_token_secret, :consumer_key, :consumer_secret, :proxy ...
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/api.rb
Ruby
mit
95
main
400
require 'instapaper/api/accounts' require 'instapaper/api/bookmarks' require 'instapaper/api/folders' require 'instapaper/api/highlights' require 'instapaper/api/oauth' module Instapaper module API include Instapaper::API::Accounts include Instapaper::API::Bookmarks include Instapaper::API::Folders i...
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/credentials.rb
Ruby
mit
95
main
202
require 'virtus' module Instapaper class Credentials include Virtus.value_object values do attribute :oauth_token, String attribute :oauth_token_secret, String end end end
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/user.rb
Ruby
mit
95
main
275
require 'virtus' module Instapaper class User include Virtus.value_object values do attribute :username, String attribute :user_id, Integer attribute :type, String attribute :subscription_is_active, Axiom::Types::Boolean end end end
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/bookmark.rb
Ruby
mit
95
main
509
require 'virtus' module Instapaper class Bookmark include Virtus.value_object values do attribute :instapaper_hash, String attribute :description, String attribute :bookmark_id, Integer attribute :private_source, String attribute :title, String attribute :url, String ...
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/folder.rb
Ruby
mit
95
main
371
require 'virtus' module Instapaper class Folder include Virtus.value_object values do attribute :title, String attribute :display_title, String attribute :sync_to_mobile, Axiom::Types::Boolean attribute :folder_id, Integer attribute :position, String attribute :type, Stri...
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/http/request.rb
Ruby
mit
95
main
1,314
require 'addressable/uri' require 'http' require 'instapaper/http/headers' require 'instapaper/http/response' module Instapaper module HTTP class Request BASE_URL = 'https://www.instapaper.com' attr_accessor :client, :headers, :options, :path, :request_method, :uri # @param client [Instapaper:...
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/http/qline_parser.rb
Ruby
mit
95
main
231
module Instapaper class QLineParser def self.parse(response) values = response.split('&').map { |part| part.split('=') }.flatten values.unshift('error') if values.length == 1 Hash[*values] end end end
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/http/response.rb
Ruby
mit
95
main
1,616
require 'json' require 'instapaper/error' module Instapaper module HTTP class Response attr_reader :response, :raw_format, :path # TODO: Change this to a keyword argument (needs a major version bump) def initialize(response, path, raw_format = false) # rubocop:disable Style/OptionalBooleanPara...
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/http/headers.rb
Ruby
mit
95
main
1,056
require 'addressable/uri' require 'base64' require 'simple_oauth' module Instapaper module HTTP class Headers def initialize(client, request_method, url, options = {}) @client = client @request_method = request_method.to_sym @uri = Addressable::URI.parse(url) @options = opti...
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/http/utils.rb
Ruby
mit
95
main
2,168
require 'instapaper/http/request' module Instapaper module HTTP module Utils private # @param path [String] # @param options [Hash] # @param klass [Class] def perform_post_with_objects(path, options, klass) perform_request_with_objects(:post, path, options, klass) end...
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/api/oauth.rb
Ruby
mit
95
main
657
require 'instapaper/credentials' require 'instapaper/http/qline_parser' module Instapaper module API # Defines methods related to OAuth module OAuth # Gets an OAuth access token for a user. def access_token(username, password) response = perform_post_with_unparsed_response('/api/1.1/oauth...
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/api/accounts.rb
Ruby
mit
95
main
317
require 'instapaper/user' module Instapaper module API # Defines methods related to accounts module Accounts # Returns the currently logged in user. def verify_credentials perform_post_with_object('/api/1.1/account/verify_credentials', {}, Instapaper::User) end end end end
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/api/folders.rb
Ruby
mit
95
main
1,372
require 'instapaper/folder' module Instapaper module API # Defines methods related to folders module Folders # List the account's user-created folders. # @note This only includes organizational folders and does not include RSS-feed folders or starred-subscription folders def folders ...
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/api/highlights.rb
Ruby
mit
95
main
1,280
require 'instapaper/highlight' module Instapaper module API # Defines methods related to highlights module Highlights # List highlights for a bookmark # @param bookmark_id [String, Integer] def highlights(bookmark_id) perform_get_with_objects("/api/1.1/bookmarks/#{bookmark_id}/highl...
github
stve/instapaper
https://github.com/stve/instapaper
lib/instapaper/api/bookmarks.rb
Ruby
mit
95
main
4,074
require 'instapaper/bookmark' require 'instapaper/bookmark_list' module Instapaper module API # Defines methods related to bookmarks module Bookmarks # Lists the user's unread bookmarks, and can also synchronize reading positions. # @option limit: Optional. A number between 1 and 500, default 25....
github
stve/instapaper
https://github.com/stve/instapaper
spec/spec_helper.rb
Ruby
mit
95
main
627
unless ENV['CI'] require 'simplecov' SimpleCov.start do add_filter '/spec/' end end require 'instapaper' require 'rspec' require 'webmock/rspec' def a_post(path) a_request(:post, Instapaper::HTTP::Request::BASE_URL + path) end def a_get(path) a_request(:get, Instapaper::HTTP::Request::BASE_URL + path) ...
github
stve/instapaper
https://github.com/stve/instapaper
spec/instapaper/error_spec.rb
Ruby
mit
95
main
4,183
require 'spec_helper' describe Instapaper::Error do before do @client = Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', oauth_token: 'AT', oauth_token_secret: 'AS') end describe '#code' do it 'returns the error code' do error = Instapaper::Error.new('execution expired', 123) ...
github
stve/instapaper
https://github.com/stve/instapaper
spec/instapaper/client_spec.rb
Ruby
mit
95
main
632
require 'spec_helper' describe Instapaper::Client do let(:client) { Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', oauth_token: 'OT', oauth_token_secret: 'OS') } describe '#credentials' do it 'returns the credentials as hash' do expect(client.credentials).to be_a Hash end end ...
github
stve/instapaper
https://github.com/stve/instapaper
spec/instapaper/bookmark_list_spec.rb
Ruby
mit
95
main
325
require 'spec_helper' describe Instapaper::BookmarkList do describe '#each' do it 'yields a list of bookmarks' do list = Instapaper::BookmarkList.new(JSON.parse(fixture('bookmarks_list.json').read)) list.each do |bookmark| expect(bookmark).to be_an Instapaper::Bookmark end end end...
github
stve/instapaper
https://github.com/stve/instapaper
spec/instapaper/api/folders_spec.rb
Ruby
mit
95
main
2,557
require 'spec_helper' describe Instapaper::Client::Folders do let(:client) { Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', oauth_token: 'OT', oauth_token_secret: 'OS') } describe '#folders' do before do stub_post('/api/1.1/folders/list') .to_return(body: fixture('folders_list...
github
stve/instapaper
https://github.com/stve/instapaper
spec/instapaper/api/accounts_spec.rb
Ruby
mit
95
main
638
require 'spec_helper' describe Instapaper::Client::Accounts do let(:client) { Instapaper::Client.new } describe '#verify_credentials' do before do stub_post('/api/1.1/account/verify_credentials') .to_return(body: fixture('verify_credentials.json'), headers: {content_type: 'application/json; char...
github
stve/instapaper
https://github.com/stve/instapaper
spec/instapaper/api/oauth_spec.rb
Ruby
mit
95
main
1,238
require 'spec_helper' describe Instapaper::Client::OAuth do let(:client) { Instapaper::Client.new } describe '#token' do before do stub_post('/api/1.1/oauth/access_token') .with(body: {x_auth_username: 'ohai', x_auth_password: 'p455w0rd', x_auth_mode: 'client_auth'}) .to_return(body: fix...
github
stve/instapaper
https://github.com/stve/instapaper
spec/instapaper/api/bookmarks_spec.rb
Ruby
mit
95
main
6,859
require 'spec_helper' describe Instapaper::Client::Bookmarks do let(:client) { Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', oauth_token: 'OT', oauth_token_secret: 'OS') } describe '#bookmarks' do before do stub_post('/api/1.1/bookmarks/list') .to_return(body: fixture('bookma...
github
stve/instapaper
https://github.com/stve/instapaper
spec/instapaper/api/highlights_spec.rb
Ruby
mit
95
main
2,010
require 'spec_helper' describe Instapaper::Client::Highlights do let(:client) { Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', oauth_token: 'OT', oauth_token_secret: 'OS') } describe '#highlights' do before do stub_get('/api/1.1/bookmarks/123/highlights') .to_return(status: 20...
github
stve/instapaper
https://github.com/stve/instapaper
spec/instapaper/http/request_spec.rb
Ruby
mit
95
main
993
require 'spec_helper' describe Instapaper::HTTP::Request do let(:client) { Instapaper::Client.new(consumer_key: 'CK', consumer_secret: 'CS', oauth_token: 'OT', oauth_token_secret: 'OS') } describe 'error handling' do context 'when receiving a non-200 response' do before do stub_post('/api/1.1/fo...
github
stve/instapaper
https://github.com/stve/instapaper
spec/instapaper/http/response_spec.rb
Ruby
mit
95
main
836
require 'spec_helper' class FakeResponse def initialize(body) @body = body end def parse(_) ::JSON.parse(@body) end end describe Instapaper::HTTP::Response do describe '#body' do context 'raw response' do it 'returns the response in raw text' do resp = Instapaper::HTTP::Response.n...
github
stve/instapaper
https://github.com/stve/instapaper
examples/verify_oauth_credentials.rb
Ruby
mit
95
main
357
require 'instapaper' credentials = { consumer_key: 'CONSUMER_KEY', consumer_secret: 'CONSUMER_SECRET', oauth_token: 'OAUTH_TOKEN', oauth_token_secret: 'OAUTH_TOKEN_SECRET', } client = Instapaper::Client.new(credentials) client.verify_credentials # => #<Instapaper::User username="username" user_id=123456 type=...
github
stve/instapaper
https://github.com/stve/instapaper
examples/obtain_a_list_of_folders.rb
Ruby
mit
95
main
391
require 'instapaper' credentials = { consumer_key: 'CONSUMER_KEY', consumer_secret: 'CONSUMER_SECRET', oauth_token: 'OAUTH_TOKEN', oauth_token_secret: 'OAUTH_TOKEN_SECRET', } client = Instapaper::Client.new(credentials) client.folders # => [#<Instapaper::Folder title="Design" display_title="Design" sync_to_mo...
github
stve/instapaper
https://github.com/stve/instapaper
examples/authorization_flow.rb
Ruby
mit
95
main
588
require 'instapaper' credentials = { consumer_key: 'CONSUMER_KEY', consumer_secret: 'CONSUMER_SECRET', } client = Instapaper::Client.new(credentials) token = client.access_token('username', 'password') # => #<Instapaper::Credentials oauth_token="710c838347ae178b4a92c6912e7e72e16c7e42f2" oauth_token_secret="XSXuU7...
github
stve/instapaper
https://github.com/stve/instapaper
examples/obtain_an_access_token.rb
Ruby
mit
95
main
359
require 'instapaper' credentials = { consumer_key: 'CONSUMER_KEY', consumer_secret: 'CONSUMER_SECRET', } client = Instapaper::Client.new(credentials) client.access_token('username', 'password') # => #<Instapaper::Credentials oauth_token="710c838347ae178b4a92c6912e7e72e16c7e42f2" oauth_token_secret="XSXuU7TxBCzbKL...
github
as-cii/terminal-emojify
https://github.com/as-cii/terminal-emojify
terminal-emojify.gemspec
Ruby
mit
95
master
867
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'terminal/emojify/version' Gem::Specification.new do |spec| spec.name = "terminal-emojify" spec.version = Terminal::Emojify::VERSION spec.authors = ["Antonio Scandurra"]...
github
as-cii/terminal-emojify
https://github.com/as-cii/terminal-emojify
lib/terminal/emojify.rb
Ruby
mit
95
master
305
require "terminal/emojify/version" require "terminal/emojify/maybe" require "gemoji" module Terminal module Emojify def self.call(text) text.gsub(/:([\w+-]+):/) do |match| emoji = Maybe.wrap Emoji.find_by_alias($1) (emoji.raw + " ").value || match end end end end
github
as-cii/terminal-emojify
https://github.com/as-cii/terminal-emojify
lib/terminal/emojify/maybe.rb
Ruby
mit
95
master
611
class Maybe def self.wrap(object) if object Some.new(object) else None.new end end def respond_to?(method_name, include_private = false) super || @object.respond_to?(method_name, include_private) end def method_missing(method_name, *arguments, &block) value = nil if @obje...
github
Shopify/active_utils
https://github.com/Shopify/active_utils
Rakefile
Ruby
mit
95
main
681
require 'bundler/gem_tasks' require 'bundler' require 'rake/testtask' Rake::TestTask.new(:test) do |t| t.pattern = 'test/unit/**/*_test.rb' t.libs << 'test' t.verbose = true end desc "Update the built-in CA root certificate file" task :update_cert_file do require 'net/http' require 'uri' cert_uri = URI('...
github
Shopify/active_utils
https://github.com/Shopify/active_utils
active_utils.gemspec
Ruby
mit
95
main
1,076
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "active_utils/version" Gem::Specification.new do |s| s.name = "active_utils" s.version = ActiveUtils::VERSION s.platform = Gem::Platform::RUBY s.authors = ["Shopify"] s.email = ["developers@jadedpixel.com"]...
github
Shopify/active_utils
https://github.com/Shopify/active_utils
lib/active_utils.rb
Ruby
mit
95
main
1,069
require 'active_support' require 'active_support/core_ext/hash/indifferent_access' require 'active_support/core_ext/hash/conversions' require 'active_support/core_ext/class/attribute' require 'active_utils/error' require 'active_utils/version' module ActiveUtils autoload :NetworkConnectionRetries, 'active_utils/ne...
github
Shopify/active_utils
https://github.com/Shopify/active_utils
lib/active_utils/connection.rb
Ruby
mit
95
main
5,038
require 'uri' require 'net/http' require 'net/https' require 'benchmark' module ActiveUtils class Connection include NetworkConnectionRetries MAX_RETRIES = 3 OPEN_TIMEOUT = 60 READ_TIMEOUT = 60 VERIFY_PEER = true # allow using proxy for https calls by pointing to it's certificate # SSL_C...
github
Shopify/active_utils
https://github.com/Shopify/active_utils
lib/active_utils/error.rb
Ruby
mit
95
main
697
module ActiveUtils #:nodoc: class HTTPRequestError < StandardError #:nodoc: end ActiveUtilsError = HTTPRequestError #:nodoc: class ConnectionError < HTTPRequestError # :nodoc: end class RetriableConnectionError < ConnectionError # :nodoc: end class ResponseError < HTTPRequestError # :nodoc: attr...
github
Shopify/active_utils
https://github.com/Shopify/active_utils
lib/active_utils/country.rb
Ruby
mit
95
main
24,378
#!ruby19 # encoding: utf-8 module ActiveUtils #:nodoc: class InvalidCountryCodeError < StandardError end class CountryCodeFormatError < StandardError end class CountryCode attr_reader :value, :format def initialize(value) @value = value.to_s.upcase detect_format end def to_s ...
github
Shopify/active_utils
https://github.com/Shopify/active_utils
lib/active_utils/posts_data.rb
Ruby
mit
95
main
2,456
module ActiveUtils #:nodoc: module PostsData #:nodoc: def self.included(base) base.class_attribute :ssl_strict base.ssl_strict = true base.class_attribute :ssl_version base.ssl_version = nil base.class_attribute :retry_safe base.retry_safe = false base.class_attribut...
github
Shopify/active_utils
https://github.com/Shopify/active_utils
lib/active_utils/requires_parameters.rb
Ruby
mit
95
main
648
module ActiveUtils #:nodoc: module RequiresParameters #:nodoc: def requires!(hash, *params) params.each do |param| if param.is_a?(Array) raise ArgumentError.new("Missing required parameter: #{param.first}") unless hash.has_key?(param.first) valid_options = param[1..-1] ...
github
Shopify/active_utils
https://github.com/Shopify/active_utils
lib/active_utils/currency_code.rb
Ruby
mit
95
main
2,663
module ActiveUtils class InvalidCurrencyCodeError < StandardError end class CurrencyCode ISO_CURRENCIES = [ "AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BOV", "BRL", "BSD", "BTN", "BWP", "BYR", "BYN", "BZD", ...