repo_name
stringlengths
6
97
path
stringlengths
3
341
text
stringlengths
8
1.02M
mislav/twitter
lib/twitter/authenticatable.rb
<reponame>mislav/twitter<gh_stars>1-10 module Twitter module Authenticatable # Credentials hash # # @return [Hash] def credentials { :consumer_key => consumer_key, :consumer_secret => consumer_secret, :token => oauth_token, :token_secret => oauth_token_secret, ...
mislav/twitter
spec/twitter/base_spec.rb
require 'helper' describe Twitter::Base do before do @base = Twitter::Base.new('id' => 1) end describe "#[]" do it "should be able to call methods using [] with symbol" do @base[:object_id].should be_an Integer end it "should be able to call methods using [] with string" do @base['o...
mislav/twitter
lib/twitter/action.rb
<filename>lib/twitter/action.rb require 'twitter/base' require 'twitter/creatable' module Twitter class Action < Twitter::Base include Twitter::Creatable lazy_attr_reader :max_position, :min_position end end
mislav/twitter
spec/twitter/client_spec.rb
<gh_stars>1-10 require 'helper' describe Twitter::Client do before do @keys = Twitter::Config::VALID_OPTIONS_KEYS end context "with module configuration" do before do Twitter.configure do |config| @keys.each do |key| config.send("#{key}=", key) end end end ...
mislav/twitter
lib/twitter/point.rb
<gh_stars>1-10 require 'twitter/base' module Twitter class Point < Twitter::Base lazy_attr_reader :coordinates # @param other [Twitter::Point] # @return [Boolean] def ==(other) super || (other.class == self.class && other.coordinates == self.coordinates) end # @return [Integer] de...
mislav/twitter
spec/twitter/client/accounts_spec.rb
require 'helper' describe Twitter::Client do before do @client = Twitter::Client.new end describe "#rate_limit_status" do before do stub_get("/1/account/rate_limit_status.json"). to_return(:body => fixture("rate_limit_status.json"), :headers => {:content_type => "application/json; charset...
mislav/twitter
lib/twitter/entity/hashtag.rb
<filename>lib/twitter/entity/hashtag.rb<gh_stars>1-10 require 'twitter/entity' module Twitter class Entity::Hashtag < Twitter::Entity lazy_attr_reader :text end end
mislav/twitter
lib/twitter/config.rb
<reponame>mislav/twitter<gh_stars>1-10 require 'twitter/version' module Twitter # Defines constants and methods related to configuration module Config # The HTTP connection adapter that will be used to connect if none is set DEFAULT_ADAPTER = :net_http # The Faraday connection options if none is set ...
mislav/twitter
lib/twitter/language.rb
require 'twitter/base' module Twitter class Language < Twitter::Base lazy_attr_reader :code, :name, :status end end
mislav/twitter
lib/twitter/client.rb
require 'twitter/action_factory' require 'twitter/authenticatable' require 'twitter/config' require 'twitter/configuration' require 'twitter/connection' require 'twitter/core_ext/enumerable' require 'twitter/core_ext/hash' require 'twitter/cursor' require 'twitter/direct_message' require 'twitter/error/forbidden' requi...
mislav/twitter
lib/twitter/list.rb
require 'twitter/creatable' require 'twitter/identifiable' require 'twitter/user' module Twitter class List < Twitter::Identifiable include Twitter::Creatable lazy_attr_reader :description, :following, :full_name, :member_count, :mode, :name, :slug, :subscriber_count, :uri alias :following? :follow...
mislav/twitter
lib/twitter/mention.rb
<filename>lib/twitter/mention.rb require 'twitter/action' require 'twitter/status' require 'twitter/user' module Twitter class Mention < Twitter::Action # A collection of users who mentioned a user # # @return [Array<Twitter::User>] def sources @sources = Array(@attrs['sources']).map do |user|...
mislav/twitter
lib/twitter/oembed.rb
require 'twitter/identifiable' module Twitter class OEmbed < Twitter::Identifiable lazy_attr_reader :author_name,:author_url, :cache_age, :height, :html, :provider_name, :provider_url, :type, :width, :url, :version end end
mislav/twitter
lib/twitter/trend.rb
require 'twitter/base' module Twitter class Trend < Twitter::Base lazy_attr_reader :events, :name, :promoted_content, :query, :url # @param other [Twitter::Trend] # @return [Boolean] def ==(other) super || (other.class == self.class && other.name == self.name) end end end
mislav/twitter
spec/twitter/media_factory_spec.rb
<gh_stars>1-10 require 'helper' describe Twitter::MediaFactory do describe ".new" do it "should generate a Photo" do media = Twitter::MediaFactory.new('type' => 'photo') media.should be_a Twitter::Photo end it "should raise an ArgumentError when type is not specified" do lambda do ...
mislav/twitter
lib/twitter/action_factory.rb
<filename>lib/twitter/action_factory.rb require 'twitter/favorite' require 'twitter/follow' require 'twitter/inflector' require 'twitter/list_member_added' require 'twitter/mention' require 'twitter/reply' require 'twitter/retweet' module Twitter class ActionFactory extend Twitter::Inflector # Instantiates ...
mislav/twitter
spec/twitter/saved_search_spec.rb
require 'helper' describe Twitter::SavedSearch do describe "#==" do it "should return true when ids and classes are equal" do saved_search = Twitter::SavedSearch.new('id' => 1) other = Twitter::SavedSearch.new('id' => 1) (saved_search == other).should be_true end it "should return fals...
mislav/twitter
spec/twitter/action_factory_spec.rb
require 'helper' describe Twitter::ActionFactory do describe ".new" do it "should generate a Favorite" do action = Twitter::ActionFactory.new('action' => 'favorite') action.should be_a Twitter::Favorite end it "should generate a Follow" do action = Twitter::ActionFactory.new('action' =...
mislav/twitter
spec/twitter/favorite_spec.rb
<reponame>mislav/twitter<filename>spec/twitter/favorite_spec.rb require 'helper' describe Twitter::Favorite do describe "#sources" do it "should return a collection of users who favorited a status" do sources = Twitter::Favorite.new('sources' => [{}]).sources sources.should be_an Array sources...
mislav/twitter
lib/twitter/error/not_acceptable.rb
require 'twitter/error/client_error' module Twitter # Raised when Twitter returns the HTTP status code 406 class Error::NotAcceptable < Twitter::Error::ClientError end end
mislav/twitter
spec/twitter/status_spec.rb
require 'helper' describe Twitter::Status do before do @old_stderr = $stderr $stderr = StringIO.new end after do $stderr = @old_stderr end describe "#==" do it "should return true when ids and classes are equal" do status = Twitter::Status.new('id' => 1) other = Twitter::Status...
mislav/twitter
spec/twitter/mention_spec.rb
require 'helper' describe Twitter::Mention do describe "#sources" do it "should return a collection of users who mentioned a user" do sources = Twitter::Mention.new('sources' => [{}]).sources sources.should be_an Array sources.first.should be_a Twitter::User end it "should be empty whe...
mislav/twitter
lib/twitter/response/raise_server_error.rb
require 'faraday' require 'twitter/error/bad_gateway' require 'twitter/error/internal_server_error' require 'twitter/error/service_unavailable' module Twitter module Response class RaiseServerError < Faraday::Response::Middleware def on_complete(env) case env[:status].to_i when 500 ...
mislav/twitter
lib/twitter/base.rb
<reponame>mislav/twitter require 'twitter/identity_map' module Twitter class Base attr_accessor :attrs alias :to_hash :attrs @@identity_map = IdentityMap.new # Define methods that retrieve the value from an initialized instance variable Hash, using the attribute as a key # # @overload self....
mislav/twitter
lib/twitter/request/oauth.rb
<reponame>mislav/twitter require 'faraday' require 'simple_oauth' module Twitter module Request class TwitterOAuth < Faraday::Middleware def call(env) params = env[:body] || {} signature_params = params params.each do |key, value| signature_params = {} if value.respond_to...
mislav/twitter
lib/twitter/request/gateway.rb
require 'faraday' module Twitter module Request class Gateway < Faraday::Middleware def call(env) url = env[:url].dup url.host = @gateway env[:url] = url @app.call(env) end def initialize(app, gateway) @app, @gateway = app, gateway end end ...
mislav/twitter
lib/twitter/media_factory.rb
<gh_stars>1-10 require 'twitter/photo' module Twitter class MediaFactory # Instantiates a new media object # # @param attrs [Hash] # @raise [ArgumentError] Error raised when supplied argument is missing a 'type' key. # @return [Twitter::Photo] def self.new(media={}) type = media.delete...
mislav/twitter
spec/twitter/place_spec.rb
<reponame>mislav/twitter require 'helper' describe Twitter::Place do describe "#==" do it "should return true when ids and classes are equal" do place = Twitter::Place.new('id' => 1) other = Twitter::Place.new('id' => 1) (place == other).should be_true end it "should return false when ...
mislav/twitter
lib/twitter/error/not_found.rb
require 'twitter/error/client_error' module Twitter # Raised when Twitter returns the HTTP status code 404 class Error::NotFound < Twitter::Error::ClientError end end
mislav/twitter
spec/twitter/list_spec.rb
require 'helper' describe Twitter::List do describe "#==" do it "should return true when ids and classes are equal" do list = Twitter::List.new('id' => 1) other = Twitter::List.new('id' => 1) (list == other).should be_true end it "should return false when classes are not equal" do ...
mislav/twitter
spec/twitter/connection_spec.rb
require 'helper' describe Twitter::Connection do subject do client = Twitter::Client.new client.class_eval{ public *Twitter::Connection.private_instance_methods } client end describe "#connection" do let(:endpoint){ URI.parse("https://api.tweeter.com") } it "returns a Faraday connection" do...
mislav/twitter
lib/twitter/error/bad_request.rb
require 'twitter/error/client_error' module Twitter # Raised when Twitter returns the HTTP status code 400 class Error::BadRequest < Twitter::Error::ClientError end end
mislav/twitter
lib/twitter/photo.rb
<reponame>mislav/twitter<gh_stars>1-10 require 'twitter/identifiable' require 'twitter/size' module Twitter class Photo < Twitter::Identifiable lazy_attr_reader :display_url, :expanded_url, :indices, :media_url, :media_url_https, :url # @param other [Twitter::Photo] # @return [Boolean] def ==(...
mislav/twitter
lib/twitter/inflector.rb
<reponame>mislav/twitter<gh_stars>1-10 module Twitter module Inflector # Converts a snake_case string to CamelCase # # @params string [String] # @return [String] def camelize(string) string.split('_').map(&:capitalize).join end end end
mislav/twitter
spec/twitter/client/direct_messages_spec.rb
require 'helper' describe Twitter::Client do before do @client = Twitter::Client.new end describe "#direct_messages" do before do stub_get("/1/direct_messages.json"). to_return(:body => fixture("direct_messages.json"), :headers => {:content_type => "application/json; charset=utf-8"}) ...
mislav/twitter
spec/twitter/trend_spec.rb
require 'helper' describe Twitter::Trend do before do @trend = Twitter::Trend.new('name' => '#sevenwordsaftersex') end describe "#==" do it "should return true when names are equal" do other = Twitter::Trend.new('name' => '#sevenwordsaftersex') (@trend == other).should be_true end i...
mislav/twitter
spec/twitter/client/activity_spec.rb
<reponame>mislav/twitter<filename>spec/twitter/client/activity_spec.rb require 'helper' describe Twitter::Client do before do @client = Twitter::Client.new end describe "#about_me" do before do stub_get("/i/activity/about_me.json"). to_return(:body => fixture("about_me.json"), :headers =>...
mislav/twitter
twitter.gemspec
<reponame>mislav/twitter # encoding: utf-8 require File.expand_path('../lib/twitter/version', __FILE__) Gem::Specification.new do |gem| gem.add_dependency 'faraday', '~> 0.8' gem.add_dependency 'multi_json', '~> 1.3' gem.add_dependency 'simple_oauth', '~> 0.1.6' gem.add_development_dependency 'json' gem.add_...
mislav/twitter
spec/twitter/direct_message_spec.rb
<filename>spec/twitter/direct_message_spec.rb require 'helper' describe Twitter::DirectMessage do describe "#==" do it "should return true when ids and classes are equal" do direct_message = Twitter::DirectMessage.new('id' => 1) other = Twitter::DirectMessage.new('id' => 1) (direct_message == ...
mislav/twitter
spec/twitter/client/suggested_users_spec.rb
<gh_stars>1-10 require 'helper' describe Twitter::Client do before do @client = Twitter::Client.new end describe "#suggestions" do context "with a category slug passed" do before do stub_get("/1/users/suggestions/art-design.json"). to_return(:body => fixture("category.json"), :h...
mislav/twitter
lib/twitter/error.rb
module Twitter # Custom error class for rescuing from all Twitter errors class Error < StandardError attr_reader :http_headers # Initializes a new Error object # # @param message [String] # @param http_headers [Hash] # @return [Twitter::Error] def initialize(message, http_headers) ...
mislav/twitter
spec/twitter/cursor_spec.rb
<filename>spec/twitter/cursor_spec.rb<gh_stars>1-10 require 'helper' describe Twitter::Cursor do describe "#first?" do context "when previous cursor equals zero" do before do @cursor = Twitter::Cursor.new({'previous_cursor' => 0}, 'ids') end it "should return true" do @cursor.f...
mislav/twitter
lib/twitter/error/unauthorized.rb
require 'twitter/error/client_error' module Twitter # Raised when Twitter returns the HTTP status code 401 class Error::Unauthorized < Twitter::Error::ClientError end end
mislav/twitter
lib/twitter/saved_search.rb
require 'twitter/creatable' require 'twitter/identifiable' module Twitter class SavedSearch < Twitter::Identifiable include Twitter::Creatable lazy_attr_reader :name, :position, :query # @param other [Twitter::SavedSearch] # @return [Boolean] def ==(other) super || (other.class == self.cla...
mislav/twitter
spec/twitter/settings_spec.rb
require 'helper' describe Twitter::Settings do describe "#trend_location" do it "should return a Twitter::Place when set" do place = Twitter::Settings.new('trend_location' => [{'countryCode' => 'US', 'name' => 'San Francisco', 'country' => 'United States', 'placeType' => {'name' => 'Town', 'code' => 7}, '...
mislav/twitter
spec/twitter/client/favorites_spec.rb
<gh_stars>1-10 require 'helper' describe Twitter::Client do before do @client = Twitter::Client.new end describe "#favorites" do context "with a screen name passed" do before do stub_get("/1/favorites/sferik.json"). to_return(:body => fixture("favorites.json"), :headers => {:con...
mislav/twitter
spec/twitter/client/tweets_spec.rb
<gh_stars>1-10 require 'helper' describe Twitter::Client do before do @client = Twitter::Client.new end describe "#retweeters_of" do context "with ids_only passed" do before do stub_get("/1/statuses/27467028175/retweeted_by/ids.json"). to_return(:body => fixture("ids.json"), :he...
mislav/twitter
lib/twitter/identifiable.rb
require 'twitter/base' module Twitter class Identifiable < Base def self.new(attrs={}) @@identity_map[self] ||= {} attrs['id'] && @@identity_map[self][attrs['id']] ? @@identity_map[self][attrs['id']].update(attrs) : super(attrs) end # Initializes a new object # # @param attrs [Hash]...
mislav/twitter
spec/twitter/client/local_trends_spec.rb
<gh_stars>1-10 require 'helper' describe Twitter::Client do before do @client = Twitter::Client.new end describe "#local_trends" do context "with woeid passed" do before do stub_get("/1/trends/2487956.json"). to_return(:body => fixture("matching_trends.json"), :headers => {:cont...
mislav/twitter
lib/twitter/suggestion.rb
require 'twitter/base' require 'twitter/user' module Twitter class Suggestion < Twitter::Base lazy_attr_reader :name, :size, :slug # @param other [Twitter::Suggestion] # @return [Boolean] def ==(other) super || (other.class == self.class && other.slug == self.slug) end # @return [Arra...
mislav/twitter
spec/twitter/user_spec.rb
require 'helper' describe Twitter::User do describe "#==" do it "should return true when ids and classes are equal" do user = Twitter::User.new('id' => 1) other = Twitter::User.new('id' => 1) (user == other).should be_true end it "should return false when classes are not equal" do ...
mislav/twitter
lib/twitter/connection.rb
require 'faraday' require 'twitter/core_ext/hash' require 'twitter/request/gateway' require 'twitter/request/multipart_with_file' require 'twitter/request/oauth' require 'twitter/response/parse_json' require 'twitter/response/raise_client_error' require 'twitter/response/raise_server_error' module Twitter module Con...
mislav/twitter
lib/twitter/list_member_added.rb
<gh_stars>1-10 require 'twitter/action' require 'twitter/list' require 'twitter/user' module Twitter class ListMemberAdded < Twitter::Action lazy_attr_reader :target_objects # A collection of users who added a user to a list # # @return [Array<Twitter::User>] def sources @sources = Array(@...
mislav/twitter
lib/twitter/response/raise_client_error.rb
require 'faraday' require 'twitter/error/bad_request' require 'twitter/error/enhance_your_calm' require 'twitter/error/forbidden' require 'twitter/error/not_acceptable' require 'twitter/error/not_found' require 'twitter/error/unauthorized' module Twitter module Response class RaiseClientError < Faraday::Response...
mislav/twitter
spec/twitter/search_results_spec.rb
require 'helper' describe Twitter::SearchResults do describe "#results" do it "should contain twitter status objects" do search_results = Twitter::SearchResults.new('results' => [{'text' => 'tweet!'}]) search_results.results.should be_a Array search_results.results.first.should be_a Twitter::S...
mislav/twitter
lib/twitter/settings.rb
require 'twitter/base' require 'twitter/place' module Twitter class Settings < Twitter::Base lazy_attr_reader :always_use_https, :discoverable_by_email, :geo_enabled, :language, :protected, :screen_name, :show_all_inline_media, :sleep_time, :time_zone alias :protected? :protected # @return [...
mislav/twitter
lib/twitter/reply.rb
require 'twitter/action' require 'twitter/status' require 'twitter/user' module Twitter class Reply < Twitter::Action # A collection of users who replies to a user # # @return [Array<Twitter::User>] def sources @sources = Array(@attrs['sources']).map do |user| Twitter::User.new(user) ...
mislav/twitter
spec/twitter/suggestion_spec.rb
require 'helper' describe Twitter::Suggestion do before do @suggestion = Twitter::Suggestion.new('slug' => 'art-design') end describe "#==" do it "should return true when slugs are equal" do other = Twitter::Suggestion.new('slug' => 'art-design') (@suggestion == other).should be_true en...
fnando/botkit
lib/botkit/runner.rb
<gh_stars>1-10 # frozen_string_literal: true module Botkit class Runner attr_reader :bot, :polling def initialize(bot, polling: 1) @bot = bot @polling = polling end def call loop do tick break if bot.halt? sleep(polling) end end private def...
fnando/botkit
lib/botkit/message.rb
# frozen_string_literal: true module Botkit class Message attr_reader :text, :command, :raw, :options, :channel_id, :id def initialize( text:, raw: {}, channel_id: nil, command: nil, options: {}, id: nil ) @text = text @command = command @raw = raw ...
fnando/botkit
test/test_helper.rb
# frozen_string_literal: true require "simplecov" SimpleCov.start require "bundler/setup" require "botkit" require "minitest/utils" require "minitest/autorun" require_relative "./support/fake_bot"
fnando/botkit
lib/botkit.rb
<gh_stars>1-10 # frozen_string_literal: true module Botkit require "aitch" require "signal" require "botkit/version" require "botkit/runner" require "botkit/message" require "botkit/bot" def self.run(bot, **kwargs) Runner.new(bot, **kwargs).call end end
fnando/botkit
test/support/fake_bot.rb
<reponame>fnando/botkit # frozen_string_literal: true class FakeBot < Botkit::Bot def halt? true end def call end end
fnando/botkit
lib/botkit/bot.rb
<filename>lib/botkit/bot.rb<gh_stars>1-10 # frozen_string_literal: true module Botkit class Bot include Signal # When setting `bot.halt = true`, the bot will be halted # after the current loop. attr_writer :halt def initialize @halt = false end # Detect if bot should halt himself...
fnando/botkit
test/botkit_test.rb
<filename>test/botkit_test.rb # frozen_string_literal: true require "test_helper" class BotkitTest < Minitest::Test test "reports failures back to the bot instance" do error = StandardError.new("Failure") bot = FakeBot.new bot.expects(:report_exception).with(error) bot.stubs(:call).raises(error) ...
Shopify/money
lib/rubocop/cop/money/missing_currency.rb
<reponame>Shopify/money<gh_stars>100-1000 # frozen_string_literal: true module RuboCop module Cop module Money class MissingCurrency < Cop # `Money.new()` without a currency argument cannot guarantee correctness: # - no error raised for cross-currency computation (e.g. 5 CAD + 5 USD) ...
Shopify/money
spec/rubocop_helper.rb
<filename>spec/rubocop_helper.rb<gh_stars>100-1000 # frozen_string_literal: true require_relative 'spec_helper' require 'rubocop' require 'rubocop/rspec/support' RSpec.configure do |config| config.include RuboCop::RSpec::ExpectOffense end
Shopify/money
spec/rubocop/cop/money/missing_currency_spec.rb
# frozen_string_literal: true require_relative '../../../rubocop_helper' require 'rubocop/cop/money/missing_currency' RSpec.describe RuboCop::Cop::Money::MissingCurrency do subject(:cop) { described_class.new(config) } let(:config) { RuboCop::Config.new } context 'with default configuration' do it 'regist...
Shopify/money
spec/spec_helper.rb
<filename>spec/spec_helper.rb # frozen_string_literal: true require 'simplecov' SimpleCov.minimum_coverage 100 SimpleCov.start do add_filter "/spec/" end $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'rspec' require 'pry-byebug' require 'databa...
Shopify/money
spec/config_spec.rb
<reponame>Shopify/money<gh_stars>100-1000 # frozen_string_literal: true require 'spec_helper' RSpec.describe "Money::Config" do describe 'legacy_deprecations' do it "respects the default currency" do configure(default_currency: 'USD', legacy_deprecations: true) do expect(Money.default_currency).to ...
Shopify/money
lib/money/rails/job_argument_serializer.rb
# frozen_string_literal: true class Money module Rails class JobArgumentSerializer < ::ActiveJob::Serializers::ObjectSerializer def serialize(money) super("value" => money.value, "currency" => money.currency.iso_code) end def deserialize(hash) Money.new(hash["value"], hash["cur...
Shopify/money
lib/money.rb
<filename>lib/money.rb # frozen_string_literal: true require_relative 'money/version' require_relative 'money/money_parser' require_relative 'money/helpers' require_relative 'money/currency' require_relative 'money/null_currency' require_relative 'money/allocator' require_relative 'money/config' require_relative 'money...
Shopify/money
lib/money/config.rb
# frozen_string_literal: true class Money class Config attr_accessor :parser, :default_currency, :legacy_json_format, :legacy_deprecations def legacy_default_currency! @default_currency ||= Money::NULL_CURRENCY end def legacy_deprecations! @legacy_deprecations = true end def le...
Shopify/money
lib/money/version.rb
<filename>lib/money/version.rb # frozen_string_literal: true class Money VERSION = "1.0.0.pre" end
Shopify/money
spec/rails/job_argument_serializer_spec.rb
<filename>spec/rails/job_argument_serializer_spec.rb # frozen_string_literal: true require "rails_spec_helper" RSpec.describe Money::Rails::JobArgumentSerializer do it "roundtrip a Money argument returns the same object" do job = MoneyTestJob.new(value: Money.new(10.21, "BRL")) serialized_job = job.seriali...
Shopify/money
spec/money_spec.rb
<filename>spec/money_spec.rb # frozen_string_literal: true require 'spec_helper' require 'yaml' RSpec.describe "Money" do let (:money) { Money.new(1) } let (:amount_money) { Money.new(1.23, 'USD') } let (:non_fractional_money) { Money.new(1, 'JPY') } let (:zero_money) { Money.new(0) } it "has a version" do ...
Shopify/money
lib/rubocop/cop/money.rb
<filename>lib/rubocop/cop/money.rb<gh_stars>100-1000 # frozen_string_literal: true require 'rubocop/cop/money/missing_currency' require 'rubocop/cop/money/zero_money'
Shopify/money
lib/money/currency/loader.rb
# frozen_string_literal: true require 'yaml' class Money class Currency module Loader class << self def load_currencies currency_data_path = File.expand_path("../../../../config", __FILE__) currencies = {} currencies.merge! YAML.load_file("#{currency_data_path}/curren...
Shopify/money
lib/money/null_currency.rb
<reponame>Shopify/money # frozen_string_literal: true class Money # A placeholder currency for instances where no actual currency is available, # as defined by ISO4217. You should rarely, if ever, need to use this # directly. It's here mostly for backwards compatibility and for that reason # behaves like a doll...
Shopify/money
spec/rubocop/cop/money/zero_money_spec.rb
# frozen_string_literal: true require_relative '../../../rubocop_helper' require 'rubocop/cop/money/zero_money' RSpec.describe RuboCop::Cop::Money::ZeroMoney do subject(:cop) { described_class.new(config) } let(:config) { RuboCop::Config.new } context 'with default configuration' do it 'registers an offen...
Shopify/money
lib/money/money.rb
<filename>lib/money/money.rb # frozen_string_literal: true require 'forwardable' class Money include Comparable extend Forwardable NULL_CURRENCY = NullCurrency.new.freeze attr_reader :value, :currency def_delegators :@value, :zero?, :nonzero?, :positive?, :negative?, :to_i, :to_f, :hash class << self ...
Shopify/money
spec/money_column_spec.rb
<filename>spec/money_column_spec.rb # frozen_string_literal: true require 'spec_helper' class MoneyRecord < ActiveRecord::Base RATE = 1.17 before_validation do self.price_usd = Money.new(self["price"] * RATE, 'USD') if self["price"] end money_column :price, currency_column: 'currency' money_column :prix,...
Shopify/money
spec/allocator_spec.rb
# frozen_string_literal: true require 'spec_helper' RSpec.describe "Allocator" do describe "allocate"do specify "#allocate takes no action when one gets all" do expect(new_allocator(5).allocate([1])).to eq([Money.new(5)]) end specify "#allocate does not lose pennies" do moneys = new_allocato...
Shopify/money
lib/rubocop/cop/money/zero_money.rb
<reponame>Shopify/money # frozen_string_literal: true module RuboCop module Cop module Money class ZeroMoney < Cop # `Money.zero` and it's alias `empty`, with or without currency # argument is removed in favour of the more explicit Money.new # syntax. Supplying it with a real curren...
Shopify/money
spec/rails_spec_helper.rb
# frozen_string_literal: true require "active_job" require_relative "spec_helper" Money::Railtie.initializers.each(&:run) class MoneyTestJob < ActiveJob::Base def perform(_params) end end
Shopify/money
lib/money/railtie.rb
# frozen_string_literal: true class Money class Railtie < Rails::Railtie initializer "shopify-money.setup_active_job_serializer" do ActiveSupport.on_load :active_job do require_relative "rails/job_argument_serializer" ActiveJob::Serializers.add_serializers ::Money::Rails::JobArgumentSeriali...
arca0/bulmatown
lib/bulmatown/version.rb
<reponame>arca0/bulmatown<filename>lib/bulmatown/version.rb # frozen_string_literal: true module Bulmatown VERSION = "1.0.7" end
arca0/bulmatown
bridgetown.automation.rb
<reponame>arca0/bulmatown<filename>bridgetown.automation.rb # Thanks to https://github.com/ParamagicDev for a bunch of the smarts in this # automation :) add_bridgetown_plugin "bulmatown" add_bridgetown_plugin "bridgetown-quick-search" # 0.15 bug! :( can't use this: #add_yarn_for_gem "bulmatown" gem_version = (`bund...
gildas/fluent-plugin-bunyan
lib/fluent/plugin/parser_bunyan.rb
<reponame>gildas/fluent-plugin-bunyan<gh_stars>0 # # Copyright 2020- <NAME> # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requi...
gildas/fluent-plugin-bunyan
fluent-plugin-bunyan.gemspec
lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) Gem::Specification.new do |spec| spec.name = "fluent-plugin-bunyan" #spec.version = Fluent::Plugin::BunyanParser.new.version spec.version = "0.0.5" spec.authors = ["<NAME>"] spec.email = ["<EMAIL>"] spe...
gildas/fluent-plugin-bunyan
test/plugin/test_parser_bunyan.rb
require "helper" require "fluent/plugin/parser_bunyan.rb" class BunyanParserTest < Test::Unit::TestCase setup do Fluent::Test.setup end CONFIG = %[ pattern apache ] sub_test_case "parse" do test "can parse simple entry" do driver = create_driver(CONFIG) text = '{"hostname":"hellowor...
concord-consortium/secure-samesite-cookies
lib/rack/secure_samesite_cookies/version.rb
<filename>lib/rack/secure_samesite_cookies/version.rb module Rack class SecureSamesiteCookies VERSION = "1.0.2" end end
concord-consortium/secure-samesite-cookies
spec/lib/rack/secure_samesite_cookies_spec.rb
require_relative "../../spec_helper" def cookie_from_response(response=last_response) Hash[response.header["Set-Cookie"].lines.map { |line| cookie = Rack::Test::Cookie.new(line.chomp) [cookie.name, line.chomp] }]["foo"] end describe "Rack::SecureSiteSiteCookies" do include Rack::Test::Methods let(:ra...
concord-consortium/secure-samesite-cookies
lib/rack/secure_samesite_cookies/railtie.rb
<reponame>concord-consortium/secure-samesite-cookies module Rack class SecureSamesiteCookies class Railtie < ::Rails::Railtie initializer "rack-secure_samesite_cookies.configure_rails_initialization" do |app| app.config.middleware.insert_after(Rack::Runtime, Rack::SecureSiteSiteCookies) end ...
concord-consortium/secure-samesite-cookies
lib/rack/secure_samesite_cookies.rb
require "rack/secure_samesite_cookies/version" require 'rack/secure_samesite_cookies/railtie' if defined?(Rails::Railtie) module Rack class SecureSiteSiteCookies COOKIE_SEPARATOR = "\n".freeze def initialize(app) @app = app end def call(env) status, headers, body = @app.call(env) ...
concord-consortium/secure-samesite-cookies
spec/spec_helper.rb
require "minitest/spec" require "minitest/autorun" require "rack/test" require "rack/secure_samesite_cookies"
sharex-admin/token-profile
format.rb
require "eth" require "json" workdir = Dir.pwd Dir.each_child("erc20") do |file| next if file == "$template.json" || !file.end_with?("json") puts "processing file:#{file}" fullpath = "#{workdir}/erc20/#{file}" begin json = JSON.parse IO.read(fullpath) rescue => e puts e.message exit false end ...
PikachuEXE/memcached_cloud_gem
spec/spec_helper.rb
$LOAD_PATH.unshift(File.dirname(__FILE__)) $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) require 'rubygems' require 'bundler' Bundler.setup :default, :test
PikachuEXE/memcached_cloud_gem
memcached_cloud.gemspec
lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "memcached_cloud/version" Gem::Specification.new do |spec| spec.name = "memcached_cloud" spec.version = MemcachedCloud::VERSION spec.summary = "Compatibility gem for using memcached libraries...
PikachuEXE/memcached_cloud_gem
lib/memcached_cloud.rb
<gh_stars>0 require 'memcached_cloud/version' module MemcachedCloud extend self def setup { "MEMCACHEDCLOUD_SERVERS" => "MEMCACHE_SERVERS", "MEMCACHEDCLOUD_USERNAME" => "MEMCACHE_USERNAME", "MEMCACHEDCLOUD_PASSWORD" => "<PASSWORD>", }.each do |key, value| ENV[value] = ENV[key] if E...