repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
unindented/unindented-rails
spec/routing/tags_routing_spec.rb
describe TagsController do describe 'routing' do it 'routes `/tags` to #index' do expect(get '/tags/').to route_to('tags#index') end it 'routes `/tags/foobar` to #show' do expect(get '/tags/foobar/').to route_to('tags#show', locator: 'foobar') end end describe 'named routes' do ...
unindented/unindented-rails
app/controllers/contents_controller.rb
class ContentsController < ApplicationController skip_before_action :verify_authenticity_token def show locator = params[:locator] filename = params[:filename] if filename.present? render_file(locator, filename) else render_content(locator) end end private def render_file(...
unindented/unindented-rails
spec/routing/errors_routing_spec.rb
<filename>spec/routing/errors_routing_spec.rb describe ErrorsController do describe 'routing' do it 'routes `/errors/404` to #show' do expect(get '/errors/404/').to route_to( 'errors#show', error: '404') end it 'routes `/errors/500` to #show' do expect(get '/errors/500/').to route_to...
unindented/unindented-rails
app/views/feeds/show.atom.builder
<filename>app/views/feeds/show.atom.builder root_url = absolute_url(nil) feed_url = absolute_url(feed_path(format: :atom, trailing_slash: false)) feed_id = "tag:#{feed_url}" atom_feed(root_url: root_url, url: feed_url, id: feed_id) do |feed| feed.title(@contents.title) feed.subtitle(@contents.subtitle) feed.upd...
unindented/unindented-rails
lib/pygments_processor.rb
require 'htmlentities' require 'nokogiri' require 'pygments' class PygmentsProcessor DEFAULT_LANG = 'text' DEFAULT_OPTS = { elements: ['pre', 'code'], attribute: 'class', pattern: /language-(?<lang>\w+)/, misc: {} } def initialize(opts = {}) @coder = ::HTMLEntities.new @opts ...
unindented/unindented-rails
spec/decorators/content_decorator_spec.rb
describe ContentDecorator do describe '#datetime' do it 'returns the date in long ISO 8601 format' do content = FactoryGirl.build(:content).decorate expect(content.datetime.to_s).to match(/\d{4}-\d{2}-\d{2}T00:00:00\+00:00/) end end describe '#related' do let (:content) { FactoryGirl.bui...
unindented/unindented-rails
spec/controllers/contents_controller_spec.rb
<gh_stars>0 describe ContentsController do describe 'GET show' do let!(:content) { FactoryGirl.create(:content, locator: 'foobar') } context 'with incorrect locator' do it 'has a 404 status code' do get :show, locator: 'bazqux' expect(response.status).to eq(404) end end ...
unindented/unindented-rails
config/environments/test.rb
<reponame>unindented/unindented-rails<filename>config/environments/test.rb Rails.application.configure do config.cache_classes = true config.eager_load = false config.serve_static_assets = true config.static_cache_control = "public, max-age=#{1.hour.to_i}" config.consider_all_requests_local = true...
unindented/unindented-rails
config/application.rb
<reponame>unindented/unindented-rails require File.expand_path('../boot', __FILE__) require 'active_record/railtie' require 'action_controller/railtie' require 'sprockets/railtie' Bundler.require(:default, Rails.env) module Website class Application < Rails::Application config.autoload_paths += %W(#{config.roo...
unindented/unindented-rails
app/controllers/errors_controller.rb
class ErrorsController < ArchivesController def show render params[:error], layout: 'errors' end end
unindented/unindented-rails
spec/lib/pygments_processor_spec.rb
<gh_stars>0 describe PygmentsProcessor do subject do PygmentsProcessor.new(misc: { cssclass: 'highlighted' }) end describe '#process' do it 'highlights a preformatted block' do body = Capybara.string(subject.process(<<-eos <pre> <code class="language-sh">echo 'Foo!'</code> </pre> eos ...
unindented/unindented-rails
db/migrate/20131201000003_create_content_tags.rb
<reponame>unindented/unindented-rails class CreateContentTags < ActiveRecord::Migration def change create_table :content_tags do |t| t.belongs_to :content, null: false, index: true t.belongs_to :tag, null: false, index: true end end end
unindented/unindented-rails
spec/routing/contents_routing_spec.rb
<reponame>unindented/unindented-rails<filename>spec/routing/contents_routing_spec.rb describe ContentsController do describe 'routing' do it 'routes `/about` to #show' do expect(get '/about/').to route_to( 'contents#show', locator: 'about') end it 'routes `/articles/foobar` to #show' do ...
unindented/unindented-rails
config/initializers/secret_token.rb
Rails.application.config.secret_key_base = SecureRandom.hex(30)
unindented/unindented-rails
spec/helpers/twitter_helper_spec.rb
<reponame>unindented/unindented-rails describe TwitterHelper do describe '#twitter_card_meta_tag' do it 'returns a Twitter Card meta tag with the specified name and value' do meta = Capybara.string(helper.twitter_card_meta_tag(:card, :summary)) expect(meta).to have_xpath("//meta[@name='twitter:card']...
unindented/unindented-rails
spec/routing/feeds_routing_spec.rb
describe FeedsController do describe 'routing' do it 'routes `/feed.atom` to #show' do expect(get '/feed.atom').to route_to('feeds#show', format: 'atom') end it 'routes `/feed.tile` to #show' do expect(get '/feed.tile').to route_to('feeds#show', format: 'tile') end end describe 'nam...
unindented/unindented-rails
app/controllers/experiments_controller.rb
<filename>app/controllers/experiments_controller.rb class ExperimentsController < ArchivesController end
unindented/unindented-rails
config/initializers/bullet.rb
if defined? Bullet Bullet.enable = true Bullet.bullet_logger = true Bullet.rails_logger = true end
unindented/unindented-rails
app/decorators/content_decorator.rb
class ContentDecorator < ModelDecorator delegate_all def datetime DateTime.parse(date.to_s) end def color (self.id % 6) + 1 end def related p = self.previous n = self.next pp = p && p.previous nn = n && n.next rel = [pp, p, n, nn].compact rel.slice((rel.length - 1) / 2.0, ...
unindented/unindented-rails
app/decorators/contents_decorator.rb
<reponame>unindented/unindented-rails class ContentsDecorator < CollectionDecorator delegate :current_page, :total_pages, :limit_value def title title_text end def subtitle subtitle_text end def updated first.datetime end def author author_text end def copyright copyright_te...
unindented/unindented-rails
features/step_definitions/javascript_steps.rb
<reponame>unindented/unindented-rails Then(/^I should (not )?see the variable "([^"]*)"(?: with the value "([^"]*)")?$/) do |negate, variable, value| if value.present? script = variable matcher = eq(value) method = negate.present? ? 'to_not' : 'to' else script = "typeof #{variable}" matcher =...
unindented/unindented-rails
db/migrate/20131201000004_create_extensions.rb
class CreateExtensions < ActiveRecord::Migration def change create_table :extensions do |t| t.string :name, null: false t.string :locator, null: false, index: true end end end
unindented/unindented-rails
spec/factories/contents.rb
FactoryGirl.define do factory(:content) do title { Faker::Lorem::words(Random.rand(4) + 4).join(' ') } author { Faker::Name::name } body { Faker::Lorem::paragraphs(Random.rand(5) + 5).join("\n\n") } category { %w{articles experiments}[Random.rand(2)] } date { Date.today - Random.ran...
unindented/unindented-rails
lib/tasks/icons.rake
<filename>lib/tasks/icons.rake<gh_stars>0 require 'icon_generator' namespace :icons do namespace :favicon do desc 'Build favicon in SVG format' task :svg do src = Rails.root.join('app', 'assets', 'images', 'logo_stroked.svg') dst = Rails.root.join('public', 'favicon.svg') FileUtils.cp(src, ...
unindented/unindented-rails
spec/models/content_taggable_spec.rb
describe Content do describe '#tags_list' do let(:tags) do tags = [] tags << FactoryGirl.build(:tag, name: 'Foo') tags << FactoryGirl.build(:tag, name: 'Bar') end it 'returns an empty array when there are no tags' do content = FactoryGirl.build(:content) expect(content.tags...
unindented/unindented-rails
spec/helpers/open_graph_helper_spec.rb
<reponame>unindented/unindented-rails describe OpenGraphHelper do describe '#open_graph_meta_tag' do it 'returns an Open Graph meta tag with the specified name and value' do meta = Capybara.string(helper.open_graph_meta_tag(:type, :website)) expect(meta).to have_xpath("//meta[@property='og:type']", v...
unindented/unindented-rails
lib/tasks/glyphs.rake
<filename>lib/tasks/glyphs.rake<gh_stars>0 namespace :glyphs do desc 'Build all glyphs' task :all do puts %x(fontcustom compile) end end desc 'Alias for glyphs:all' task :glyphs => 'glyphs:all'
unindented/unindented-rails
spec/factories/tags.rb
FactoryGirl.define do sequence :tag_name do |n| "tag#{n}" end factory(:tag) do name { FactoryGirl.generate(:tag_name) } end end
unindented/unindented-rails
app/models/concerns/summarizable.rb
<filename>app/models/concerns/summarizable.rb module Summarizable extend ActiveSupport::Concern included do summarizer = BodySummarizer.new define_method(:summarize_text) { |body_html| summarizer.summarize_text(body_html) } define_method(:summarize_html) { |body_html| summarizer.summarize_html(body_ht...
unindented/unindented-rails
spec/helpers/text_helper_spec.rb
describe TextHelper do describe '#host_text' do it 'returns the host of the site' do allow(SETTINGS).to receive(:host) { 'http://www.foo.com' } expect(helper.host_text).to eq('http://www.foo.com') end end describe '#website_text' do it 'returns the name of the site' do allow(SETTIN...
FrenchKit/UIAutomationClassroom
mock-server/test_run.rb
<reponame>FrenchKit/UIAutomationClassroom class TestRun < ActiveRecord::Base has_many :tracking_events, :dependent => :destroy has_many :mock_responses, :dependent => :destroy end
FrenchKit/UIAutomationClassroom
mock-server/db/migrate/20170717103415_setup.rb
class Setup < ActiveRecord::Migration[5.1] def change create_table :test_runs do |t| t.string :name t.timestamp :started t.timestamp :ended t.timestamps end add_index :test_runs, :name, unique: true create_table :tracking_events do |t| t.text :content ...
FrenchKit/UIAutomationClassroom
mock-server/db/migrate/20170804120735_add_mime_encoding.rb
<filename>mock-server/db/migrate/20170804120735_add_mime_encoding.rb class AddMimeEncoding < ActiveRecord::Migration[5.1] def change add_column :mock_responses, :response_mime_type, :string add_column :mock_responses, :response_encoding, :string end end
FrenchKit/UIAutomationClassroom
mock-server/mock_response.rb
<filename>mock-server/mock_response.rb class MockResponse < ActiveRecord::Base belongs_to :test_run end
FrenchKit/UIAutomationClassroom
mock-server/mock-server.rb
#! /usr/bin/env ruby require 'sinatra/base' require 'json' require 'active_record' require 'thin' require 'base64' require './test_run' require './mock_response' ActiveRecord::Base.establish_connection( :adapter => 'sqlite3', :database => 'mockdb.sqlite3.db', :pool => 30, :timeout => 1000 ) class MockServe...
JDC1492/vg_organizer-project
db/migrate/20201005133035_create_games_table.rb
<reponame>JDC1492/vg_organizer-project<filename>db/migrate/20201005133035_create_games_table.rb<gh_stars>0 class CreateGamesTable < ActiveRecord::Migration[5.2] def change create_table :games do |t| t.string :title t.string :console t.string :genre t.string :description t.boolean :co...
JDC1492/vg_organizer-project
app/controllers/games_controller.rb
<gh_stars>0 class GamesController < ApplicationController get '/games' do redirect_if_not_logged_in @games = current_user.games erb :'games/index' end get '/games/new' do redirect_if_not_logged_in erb :'games/new' end get '/games/:id' do redirect_...
JDC1492/vg_organizer-project
app/controllers/users_controller.rb
<filename>app/controllers/users_controller.rb<gh_stars>0 class UsersController < ApplicationController get '/signup' do @user = User.new(params) erb :'/users/sign_up' end post '/signup' do user = User.new(params) if user.save && user.authenticate(params[:password]) ...
Revolutionary-Games/ThriveDevCenter
ef.rb
<filename>ef.rb #!/usr/bin/env ruby # frozen_string_literal: true # Helper script to run dotnet-ef tool require 'English' require 'optparse' @options = { install: false, update: false, create: nil } SERVER_PROJECT_FILE = 'Server/ThriveDevCenter.Server.csproj' ASP_NET_VERSION_REGEX = /Include="Microsoft\.AspNe...
Revolutionary-Games/ThriveDevCenter
fix_boot_json_hashes.rb
<filename>fix_boot_json_hashes.rb # frozen_string_literal: true require 'json' require 'fileutils' require 'zlib' require 'digest' require 'English' # Fixes all incorrect hashes in a blazor.boot.json file def fix_boot_json_hashes(path_to_boot) data = JSON.parse File.read(path_to_boot) changes = process_hash_help...
Revolutionary-Games/ThriveDevCenter
deploy.rb
<gh_stars>1-10 #!/usr/bin/env ruby # frozen_string_literal: true # ThriveDevCenter deploy require 'English' require 'optparse' require_relative 'fix_boot_json_hashes' @options = { mode: 'staging', # TODO: add running only specific migrations mode migration: 'idempotent', use_migrations: true, use_deploy: ...
abdoutelb/reminder
spec/services/email_notification_spec.rb
<filename>spec/services/email_notification_spec.rb require "rails_helper" describe EmailNotification do describe "#sending email" do it "check output for sending ticket" do EmailNotification.send(Ticket.first).should eql("This ticket task went to <EMAIL>") end end end
abdoutelb/reminder
app/helpers/notify_helper.rb
module NotifyHelper def self.send_ticket(ticket) NotifyHelper::Notification.new().send(ticket) end class Notification RegisterServices = ["EmailNotification"] def send(ticket) RegisterServices.each do |service| Object.const_get(service).send(tick...
abdoutelb/reminder
spec/factories/tickets.rb
FactoryBot.define do factory :ticket do title { Faker::Name.name } description { Faker::Lorem.paragraph } due_date { Time.now } status_id { 0 } progress { Faker::Number.number(2) } user_id { User.first ? User.first.id : create(:user).id } end end
abdoutelb/reminder
app/models/user.rb
<filename>app/models/user.rb class User < ApplicationRecord validates_presence_of :name, :email, :send_due_date_reminder ,:send_due_reminder_interval, :due_date_reminder_time, :time_zone def activate self.update(send_due_date_reminder: true) end def prefered_time self.due_date_rem...
abdoutelb/reminder
app/models/ticket.rb
class Ticket < ApplicationRecord NOT_DELIVED = 0 DELIVED = 1 validates_presence_of :title belongs_to :user after_create do NotifyHelper.send_ticket(self) if self.user.send_due_date_reminder? end def sent self.update(status_id: Ticket::DELIVED) end end
abdoutelb/reminder
app/services/email_notification.rb
class EmailNotification require 'sendgrid-ruby' include SendGrid def self.send(ticket) user = ticket.user sent_at = (user.prefered_time).to_i return "This ticket #{ticket.title} went to #{user.email}" if ENV['RAILS_ENV'] == 'test' puts "This ticket #{ticket.title} went t...
abdoutelb/reminder
db/seeds.rb
<gh_stars>0 # This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings...
abdoutelb/reminder
spec/factories/users.rb
FactoryBot.define do factory :user do name { Faker::Name.name } email { Faker::Internet.email } send_due_reminder_interval { Faker::Number.number(2) } send_due_date_reminder { Faker::Boolean.boolean } due_date_reminder_time { Time.now } time_zone { Faker::Name.name } end end
abdoutelb/reminder
spec/models/user_spec.rb
<reponame>abdoutelb/reminder<filename>spec/models/user_spec.rb require "rails_helper" RSpec.describe User, type: :model do context "#validations" do it { is_expected.to validate_presence_of(:email) } it { is_expected.to validate_presence_of(:name) } it { is_expected.to validate_presence_of(:send_due_dat...
abdoutelb/reminder
db/migrate/20220129124008_add_user_to_tickets.rb
<reponame>abdoutelb/reminder class AddUserToTickets < ActiveRecord::Migration[5.2] def change add_reference :tickets, :user, foreign_key: true end end
abdoutelb/reminder
spec/models/ticket_spec.rb
require "rails_helper" RSpec.describe Ticket, type: :model do context "#validations" do it { is_expected.to validate_presence_of(:title) } end end
alainbloch-scopear/graphql-rails-generators
lib/generators/gql/templates/delete_mutation.rb
module Mutations class <%= prefixed_class_name('Delete') %> < Mutations::BaseMutation field :<%= singular_name %>, Types::<%= name %>Type, null: true argument :id, ID, required: true def resolve(id:) model = <%= class_name %>.find_by(uuid: id) authorize! <%= singular_name %>, to: :destroy? ...
alainbloch-scopear/graphql-rails-generators
lib/generators/gql/templates/policy_file.rb
# frozen_string_literal: true class <%= name %>Policy < ApplicationPolicy relation_scope do |scope| scope end def index? #TODO - Policy goes here end def show? #TODO - policy goes here end def create? #TODO - Policy goes here end def update? #TODO - Policy goes here end d...
alainbloch-scopear/graphql-rails-generators
lib/generators/gql/templates/index_query.rb
# frozen_string_literal: true module Resolvers class <%= name.pluralize %> < Resolvers::BaseResolver type Types::<%= name %>Type, null: false description "Shows <%= name.downcase.pluralize %>" def resolve(id:) authorized_scope(::<%= name %>.all) end end end
alainbloch-scopear/graphql-rails-generators
lib/generators/gql/model_search_base_generator.rb
<reponame>alainbloch-scopear/graphql-rails-generators<gh_stars>0 module Gql class ModelSearchBaseGenerator < Rails::Generators::Base source_root File.expand_path('../templates', __FILE__) class_option :directory, type: :string, default: 'graphql' def generate_model_search_base gem 'search...
alainbloch-scopear/graphql-rails-generators
lib/generators/gql/scaffold_generator.rb
require "rails/generators/named_base" require_relative 'gql_generator_base' module Gql class ScaffoldGenerator < Rails::Generators::NamedBase include GqlGeneratorBase source_root File.expand_path('../templates', __FILE__) desc "Generate create, update and delete generators for a model." class_option...
Promptus/ice_cube
lib/ice_cube/validations/minutely_interval.rb
module IceCube module Validations::MinutelyInterval def interval(interval) @interval = normalized_interval(interval) replace_validations_for(:interval, [Validation.new(@interval)]) clobber_base_validations(:min) self end class Validation attr_reader :interval def i...
Promptus/ice_cube
spec/examples/secondly_rule_spec.rb
<filename>spec/examples/secondly_rule_spec.rb require File.dirname(__FILE__) + '/../spec_helper' module IceCube describe SecondlyRule, 'interval validation' do it 'converts a string integer to an actual int when using the interval method' do rule = Rule.secondly.interval("2") expect(rule.validations_...
Promptus/ice_cube
spec/spec_helper.rb
require "bundler/setup" require 'ice_cube' begin require 'simplecov' SimpleCov.start rescue LoadError # okay end IceCube.compatibility = 12 DAY = Time.utc(2010, 3, 1) WEDNESDAY = Time.utc(2010, 6, 23, 5, 0, 0) WORLD_TIME_ZONES = [ 'America/Anchorage', # -1000 / -0900 'Europe/London', # +0000 / +0100...
Promptus/ice_cube
spec/examples/to_yaml_spec.rb
<filename>spec/examples/to_yaml_spec.rb require File.dirname(__FILE__) + '/../spec_helper' require 'active_support/time' module IceCube describe Schedule, 'to_yaml' do before(:all) { Time.zone = 'Eastern Time (US & Canada)' } [:yearly, :monthly, :weekly, :daily, :hourly, :minutely, :secondly].each do |type...
Promptus/ice_cube
lib/ice_cube/single_occurrence_rule.rb
<reponame>Promptus/ice_cube module IceCube class SingleOccurrenceRule < Rule attr_reader :time def initialize(time) @time = TimeUtil.ensure_time time end # Always terminating def terminating? true end def next_time(t, _, closing_time) unless closing_time && closing_t...
Promptus/ice_cube
spec/examples/rfc_spec.rb
require File.dirname(__FILE__) + '/../spec_helper' describe IceCube::Schedule do it 'should ~ daily for 10 occurrences' do schedule = IceCube::Schedule.new(Time.utc(2010, 9, 2)) schedule.add_recurrence_rule IceCube::Rule.daily.count(10) test_expectations(schedule, {2010 => {9 => [2, 3, 4, 5, 6, 7, 8, 9,...
Promptus/ice_cube
lib/ice_cube/validations/daily_interval.rb
module IceCube module Validations::DailyInterval # Add a new interval validation def interval(interval) @interval = normalized_interval(interval) replace_validations_for(:interval, [Validation.new(@interval)]) clobber_base_validations(:wday, :day) self end class Validation ...
Promptus/ice_cube
lib/ice_cube/version.rb
module IceCube VERSION = '0.16.1' end
nagatea/traQ_webhook-ruby
lib/traq_webhook.rb
require "traq_webhook/version" require "net/http" require "uri" require "openssl" module TraqWebhook class Client attr_accessor :id, :token, :channel_id def initialize yield self if block_given? end def post(message) signature = calc_hmacsha1(self.token, message) uri = URI.parse('...
mislav/twitter
lib/twitter/metadata.rb
require 'twitter/base' module Twitter class Metadata < Twitter::Base lazy_attr_reader :result_type end end
mislav/twitter
spec/twitter/client/trends_spec.rb
require 'helper' describe Twitter::Client do before do @client = Twitter::Client.new end describe "#trends_daily" do before do stub_get("/1/trends/daily.json"). with(:query => {:date => "2010-10-24"}). to_return(:body => fixture("trends_daily.json"), :headers => {:content_type => ...
mislav/twitter
spec/twitter/client/users_spec.rb
<filename>spec/twitter/client/users_spec.rb require 'helper' describe Twitter::Client do before do @client = Twitter::Client.new end describe "#users" do context "with screen names passed" do before do stub_get("/1/users/lookup.json"). with(:query => {:screen_name => "sferik,pen...
mislav/twitter
lib/twitter/error/service_unavailable.rb
require 'twitter/error/server_error' module Twitter # Raised when Twitter returns the HTTP status code 503 class Error::ServiceUnavailable < Twitter::Error::ServerError end end
mislav/twitter
lib/twitter/search_results.rb
require 'twitter/base' module Twitter class SearchResults < Twitter::Base lazy_attr_reader :completed_in, :max_id, :next_page, :page, :query, :refresh_url, :results_per_page, :since_id # @return [Array<Twitter::Status>] def results @results ||= Array(@attrs['results']).map{|status| Twitter::...
mislav/twitter
lib/twitter/error/internal_server_error.rb
require 'twitter/error/server_error' module Twitter # Raised when Twitter returns the HTTP status code 500 class Error::InternalServerError < Twitter::Error::ServerError end end
mislav/twitter
spec/twitter/point_spec.rb
<reponame>mislav/twitter require 'helper' describe Twitter::Point do before do @point = Twitter::Point.new('coordinates' => [-122.399983, 37.788299]) end describe "#==" do it "should return true when coordinates are equal" do other = Twitter::Point.new('coordinates' => [-122.399983, 37.788299]) ...
mislav/twitter
spec/twitter/relationship_spec.rb
<reponame>mislav/twitter<gh_stars>1-10 require 'helper' describe Twitter::Relationship do describe "#source" do it "should return a User when source is set" do source = Twitter::Relationship.new('source' => {}).source source.should be_a Twitter::User end it "should return nil when source is ...
mislav/twitter
lib/twitter/error/forbidden.rb
require 'twitter/error/client_error' module Twitter # Raised when Twitter returns the HTTP status code 403 class Error::Forbidden < Twitter::Error::ClientError end end
mislav/twitter
spec/twitter/client/timelines_spec.rb
require 'helper' describe Twitter::Client do before do @client = Twitter::Client.new end describe "#home_timeline" do before do stub_get("/1/statuses/home_timeline.json"). to_return(:body => fixture("statuses.json"), :headers => {:content_type => "application/json; charset=utf-8"}) en...
mislav/twitter
spec/faraday/request_spec.rb
<reponame>mislav/twitter<gh_stars>1-10 require 'helper' describe Faraday::Request do before(:each) do @oauth = Twitter::Request::TwitterOAuth.new(lambda{|env| env}, Hash.new) @request = {:method => "post", :url => "http://test.com/test.json", :request_headers => {}, :body => {:status => "Test"}} end des...
mislav/twitter
spec/twitter/action_spec.rb
require 'helper' describe Twitter::Action do describe "#created_at" do it "should return a Time when created_at is set" do user = Twitter::User.new('created_at' => "Mon Jul 16 12:59:01 +0000 2007") user.created_at.should be_a Time end it "should return nil when created_at is not set" do ...
mislav/twitter
lib/twitter/entity/user_mention.rb
<gh_stars>1-10 require 'twitter/entity' module Twitter class Entity::UserMention < Twitter::Entity lazy_attr_reader :id, :name, :screen_name end end
mislav/twitter
spec/twitter/client/friends_and_followers_spec.rb
require 'helper' describe Twitter::Client do before do @client = Twitter::Client.new end describe "#follower_ids" do context "with a screen_name passed" do before do stub_get("/1/followers/ids.json"). with(:query => {:cursor => "-1", :screen_name => "sferik"}). to_retu...
mislav/twitter
lib/twitter/error/client_error.rb
require 'twitter/error' module Twitter # Raised when Twitter returns a 4xx HTTP status code class Error::ClientError < Twitter::Error end end
mislav/twitter
spec/twitter/oembed_spec.rb
<filename>spec/twitter/oembed_spec.rb require 'helper' describe Twitter::OEmbed do describe "#author_url" do it "should return the author's url" do oembed = Twitter::OEmbed.new('author_url' => 'https://twitter.com/sferik') oembed.author_url.should == "https://twitter.com/sferik" end it "shou...
mislav/twitter
lib/twitter/follow.rb
<filename>lib/twitter/follow.rb require 'twitter/action' require 'twitter/user' module Twitter class Follow < Twitter::Action lazy_attr_reader :target_objects # A collection of users who followed a user # # @return [Array<Twitter::User>] def sources @sources = Array(@attrs['sources']).map ...
mislav/twitter
spec/twitter/geo_factory_spec.rb
require 'helper' describe Twitter::GeoFactory do describe ".new" do it "should generate a Point" do geo = Twitter::GeoFactory.new('type' => 'Point') geo.should be_a Twitter::Point end it "should generate a Polygon" do geo = Twitter::GeoFactory.new('type' => 'Polygon') geo.should ...
mislav/twitter
lib/twitter/error/enhance_your_calm.rb
require 'twitter/error/client_error' module Twitter # Raised when Twitter returns the HTTP status code 420 class Error::EnhanceYourCalm < Twitter::Error::ClientError # The number of seconds your application should wait before requesting date from the Search API again # # @see http://dev.twitter.com/pag...
mislav/twitter
lib/twitter/entity/url.rb
<gh_stars>1-10 require 'twitter/entity' module Twitter class Entity::Url < Twitter::Entity lazy_attr_reader :display_url, :expanded_url, :url end end
mislav/twitter
lib/twitter/cursor.rb
require 'twitter/core_ext/kernel' module Twitter class Cursor attr_reader :collection attr_accessor :attrs alias :to_hash :attrs # Initializes a new Cursor object # # @param attrs [Hash] # @params method [String, Symbol] The name of the method to return the collection # @params klass...
mislav/twitter
spec/twitter/client/help_spec.rb
<reponame>mislav/twitter<gh_stars>1-10 require 'helper' describe Twitter::Client do before do @client = Twitter::Client.new end describe "#configuration" do before do stub_get("/1/help/configuration.json"). to_return(:body => fixture("configuration.json"), :headers => {:content_type => "a...
mislav/twitter
lib/twitter/place.rb
<gh_stars>1-10 require 'twitter/geo_factory' require 'twitter/identifiable' module Twitter class Place < Twitter::Identifiable lazy_attr_reader :attributes, :country, :full_name, :name, :url, :woeid alias :woe_id :woeid # @param other [Twitter::Place] # @return [Boolean] def ==(other) supe...
mislav/twitter
lib/twitter/relationship.rb
require 'twitter/base' require 'twitter/user' module Twitter class Relationship < Twitter::Base # @return [Twitter::User] def source @source ||= Twitter::User.new(@attrs['source']) unless @attrs['source'].nil? end # @return [Twitter::User] def target @target ||= Twitter::User.new(@a...
mislav/twitter
lib/twitter/size.rb
require 'twitter/base' module Twitter class Size < Twitter::Base lazy_attr_reader :h, :resize, :w alias :height :h alias :width :w # @param other [Twitter::Size] # @return [Boolean] def ==(other) super || (other.class == self.class && other.h == self.h && other.w == self.w) end ...
mislav/twitter
lib/twitter/polygon.rb
require 'twitter/base' module Twitter class Polygon < Twitter::Base lazy_attr_reader :coordinates # @param other [Twitter::Polygon] # @return [Boolean] def ==(other) super || (other.class == self.class && other.coordinates == self.coordinates) end end end
mislav/twitter
lib/twitter/status.rb
<reponame>mislav/twitter require 'twitter/client' require 'twitter/core_ext/hash' require 'twitter/creatable' require 'twitter/entity/hashtag' require 'twitter/entity/url' require 'twitter/entity/user_mention' require 'twitter/geo_factory' require 'twitter/identifiable' require 'twitter/media_factory' require 'twitter/...
mislav/twitter
spec/twitter/polygon_spec.rb
describe Twitter::Polygon do before do @polygon = Twitter::Polygon.new('coordinates' => [[[-122.40348192, 37.77752898], [-122.387436, 37.77752898], [-122.387436, 37.79448597], [-122.40348192, 37.79448597]]]) end describe "#==" do it "should return true when coordinates are equal" do other = Twitte...
mislav/twitter
lib/twitter/error/bad_gateway.rb
require 'twitter/error/server_error' module Twitter # Raised when Twitter returns the HTTP status code 502 class Error::BadGateway < Twitter::Error::ServerError end end
mislav/twitter
lib/twitter/geo_factory.rb
require 'twitter/point' require 'twitter/polygon' module Twitter class GeoFactory # Instantiates a new geo object # # @param attrs [Hash] # @raise [ArgumentError] Error raised when supplied argument is missing a 'type' key. # @return [Twitter::Point, Twitter::Polygon] def self.new(geo={}) ...
mislav/twitter
lib/twitter/user.rb
require 'twitter/authenticatable' require 'twitter/core_ext/hash' require 'twitter/creatable' require 'twitter/identifiable' require 'twitter/status' module Twitter class User < Twitter::Identifiable include Twitter::Authenticatable include Twitter::Creatable lazy_attr_reader :all_replies, :blocking, :ca...
mislav/twitter
spec/twitter/client/notification_spec.rb
require 'helper' describe Twitter::Client do before do @client = Twitter::Client.new end describe "#enable_notifications" do before do stub_post("/1/notifications/follow.json"). with(:body => {:screen_name => "sferik"}). to_return(:body => fixture("sferik.json"), :headers => {:con...
mislav/twitter
spec/twitter/size_spec.rb
<reponame>mislav/twitter<gh_stars>1-10 require 'helper' describe Twitter::Size do describe "#==" do it "should return true when height and width are equal" do size = Twitter::Size.new('h' => 1, 'w' => 1) other = Twitter::Size.new('h' => 1, 'w' => 1) (size == other).should be_true end i...
mislav/twitter
spec/twitter/photo_spec.rb
require 'helper' describe Twitter::Photo do describe "#==" do it "should return true when ids and classes are equal" do photo = Twitter::Photo.new('id' => 1) other = Twitter::Photo.new('id' => 1) (photo == other).should be_true end it "should return false when classes are not equal" do...