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 | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/template.rb | Ruby | mit | 202 | main | 1,792 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class Template
module Status
PENDING_DELETION = "PENDING_DELETION"
APPROVED = "APPROVED"
PENDING = "PENDING"
REJECTED = "REJECTED"
STATUSES = [PENDING_DELETION, APPROVED, PENDING, REJECTED].freeze
... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/currency.rb | Ruby | mit | 202 | main | 754 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class Currency
# Returns default text if localization fails.
#
# @returns fallback_value [String].
attr_accessor :fallback_value
# Currency code as defined in ISO 4217.
#
# @returns code [String].
at... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/interactive.rb | Ruby | mit | 202 | main | 1,762 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class Interactive
module Type
LIST_MESSAGE = "list"
REPLY_BUTTON = "button"
SINGLE_PRODUCT_MESSAGE = "product"
MULTI_PRODUCT_MESSAGE = "product_list"
end
# Returns the Interactive type of message y... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/parameter_object.rb | Ruby | mit | 202 | main | 4,370 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class ParameterObject
class InvalidType < StandardError
attr_accessor :message
def initialize(type)
@message = "invalid type #{type}. type should be text, currency, date_time, image, document or video"
su... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/media_component.rb | Ruby | mit | 202 | main | 2,253 | # frozen_string_literal: true
# The media used by a component (button, header, body, footer) etc.
module WhatsappSdk
module Resource
class MediaComponent
class InvalidMedia < StandardError
attr_reader :field, :message
def initialize(field, message)
@field = field
@mess... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/button_parameter.rb | Ruby | mit | 202 | main | 1,109 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class ButtonParameter
# Returns the button parameter type.
#
# @returns type [String] Valid options are payload and text.
attr_accessor :type
module Type
TEXT = "text"
PAYLOAD = "payload"
end
... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/phone_number_component.rb | Ruby | mit | 202 | main | 468 | # frozen_string_literal: true
# The media used by a component (button, header, body, footer) etc.
module WhatsappSdk
module Resource
class PhoneNumberComponent
attr_accessor :phone, :wa_id, :type
def initialize(phone:, type:, wa_id:)
@phone = phone
@type = type
@wa_id = wa_i... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/business_account.rb | Ruby | mit | 202 | main | 1,759 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class BusinessAccount
attr_accessor :id, :name, :timezone_id, :message_template_namespace, :account_review_status,
:business_verification_status, :country, :ownership_type, :primary_business_location,
:... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/interactive_action_reply_button.rb | Ruby | mit | 202 | main | 2,004 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class InteractiveActionReplyButton
module Type
REPLY = "reply"
end
# Returns the ActionButton type of message you want to send.
#
# @returns type [String]. Supported Options are reply only.
attr_accessor... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/address.rb | Ruby | mit | 202 | main | 702 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class Address
attr_accessor :street, :city, :state, :zip, :country, :country_code, :type
def initialize(street:, city:, state:, zip:, country:, country_code:, type: AddressType::Home)
@street = street
@city = city
... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/component.rb | Ruby | mit | 202 | main | 2,514 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class Component
class InvalidField < StandardError
attr_reader :field, :message
def initialize(field, message)
@field = field
@message = message
super(message)
end
end
module... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/languages.rb | Ruby | mit | 202 | main | 4,238 | # typed: false
# frozen_string_literal: true
module WhatsappSdk
module Resource
class Languages
AVAILABLE_LANGUAGES = Set.new([
"af", # Afrikaans
"sq", # Albanian
"ar", # Arabic
... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/interactive_body.rb | Ruby | mit | 202 | main | 816 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class InteractiveBody
# Returns Text string if the parameter object type is text.
# For the body interactive, the character limit is 1024 characters.
#
# @returns text [String]
attr_accessor :text
def initialize... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/interactive_header.rb | Ruby | mit | 202 | main | 2,396 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class InteractiveHeader
# Returns the interactive header type.
#
# @returns type [String] Valid options are text, image, document, video.
attr_accessor :type
module Type
TEXT = "text"
IMAGE = "image"
... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/contact_response.rb | Ruby | mit | 202 | main | 241 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class ContactResponse
attr_accessor :wa_id, :input
def initialize(input:, wa_id:)
@input = input
@wa_id = wa_id
end
end
end
end |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/url.rb | Ruby | mit | 202 | main | 306 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class Url
attr_accessor :url, :type
def initialize(url:, type:)
@url = url
@type = type
end
def to_h
{
url: @url,
type: @type
}
end
end
end
end |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/phone_number.rb | Ruby | mit | 202 | main | 2,590 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class PhoneNumber
attr_accessor :id, :verified_name, :display_phone_number, :quality_rating, :is_pin_enabled,
:is_official_business_account, :account_mode, :certificate, :code_verification_status,
:elig... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/date_time.rb | Ruby | mit | 202 | main | 423 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class DateTime
# Returns default text if localization fails.
#
# @returns fallback_value [String].
attr_accessor :fallback_value
def initialize(fallback_value:)
@fallback_value = fallback_value
end
... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/business_profile.rb | Ruby | mit | 202 | main | 1,418 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class BusinessProfile
VERTICAL_VALUES = %w[
UNDEFINED OTHER AUTO BEAUTY APPAREL EDU ENTERTAIN EVENT_PLAN FINANCE GROCERY
GOVT HOTEL HEALTH NONPROFIT PROF_SERVICES RETAIL TRAVEL RESTAURANT NOT_A_BIZ
].freeze
attr_a... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/org.rb | Ruby | mit | 202 | main | 430 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class Org
attr_accessor :company, :department, :title
def initialize(company:, department:, title:)
@company = company
@department = department
@title = title
end
def to_h
{
compan... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/interactive_footer.rb | Ruby | mit | 202 | main | 818 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class InteractiveFooter
# Returns Text string if the parameter object type is text.
# For the body interactive, the character limit is 60 characters.
#
# @returns text [String]
attr_accessor :text
def initialize... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/errors.rb | Ruby | mit | 202 | main | 1,557 | # frozen_string_literal: true
require_relative "../error"
module WhatsappSdk
module Resource
module Errors
class MissingArgumentError < StandardError
attr_reader :message
def initialize(message)
@message = message
super(message)
end
end
class Missi... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/media_types.rb | Ruby | mit | 202 | main | 1,553 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class MediaTypes
# The media types supported by Whatsapp. The list contains all the types defined in the Whatsapp API
# documentation: https://developers.facebook.com/docs/whatsapp/cloud-api/reference/media#supported-media-types
#... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/name.rb | Ruby | mit | 202 | main | 785 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class Name
attr_accessor :formatted_name, :first_name, :last_name, :middle_name, :suffix, :prefix
def initialize(
formatted_name: nil, first_name: nil,
last_name: nil, middle_name: nil, suffix: nil, prefix: nil
)
... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/interactive_action_section_row.rb | Ruby | mit | 202 | main | 2,536 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class InteractiveActionSectionRow
# Returns the ActionSection title you want to send.
#
# @returns title [String]. The character limit is 24 characters.
attr_accessor :title
# Returns the ActionSection description you... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/contact.rb | Ruby | mit | 202 | main | 729 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class Contact
attr_accessor :addresses, :birthday, :emails, :name, :org, :phones, :urls
def initialize(addresses:, birthday:, emails:, name:, org:, phones:, urls:)
@addresses = addresses
@birthday = birthday
@em... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/interactive_action_section.rb | Ruby | mit | 202 | main | 1,629 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class InteractiveActionSection
# Returns the ActionSection title you want to send.
#
# @returns title [String]. The character limit is 24 characters.
attr_accessor :title
# Returns the ActionSection rows you want to s... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/template_analytic.rb | Ruby | mit | 202 | main | 1,750 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class TemplateAnalytic
module Granularity
DAILY = "DAILY"
end
module MetricType
COST = "COST"
CLICKED = "CLICKED"
DELIVERED = "DELIVERED"
READ = "READ"
SENT = "SENT"
# (MM ... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/media.rb | Ruby | mit | 202 | main | 930 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class Media
module Type
AUDIO = 'audio'
DOCUMENT = 'document'
IMAGE = 'image'
VIDEO = 'video'
STICKER = 'sticker'
end
attr_accessor :file_size, :id, :messaging_product, :mime_type, :sha256,... |
github | ignacio-chiazzo/ruby_whatsapp_sdk | https://github.com/ignacio-chiazzo/ruby_whatsapp_sdk | lib/whatsapp_sdk/resource/interactive_action.rb | Ruby | mit | 202 | main | 3,762 | # frozen_string_literal: true
module WhatsappSdk
module Resource
class InteractiveAction
module Type
LIST_MESSAGE = "list_message"
REPLY_BUTTON = "reply_button"
TYPES = [LIST_MESSAGE, REPLY_BUTTON].freeze
def valid?(type)
TYPES.include?(type)
end
en... |
github | dkubb/equalizer | https://github.com/dkubb/equalizer | equalizer.gemspec | Ruby | mit | 202 | master | 1,516 | # frozen_string_literal: true
require_relative "lib/equalizer"
Gem::Specification.new do |spec|
spec.name = "equalizer"
spec.version = Equalizer::VERSION
spec.authors = ["Dan Kubb", "Markus Schirp", "Piotr Solnica", "Erik Berlin"]
spec.email = ["dan.kubb@gmail.com", "mbj@schirp-dso.com", "piotr.solnica@gmail.... |
github | dkubb/equalizer | https://github.com/dkubb/equalizer | Rakefile | Ruby | mit | 202 | master | 1,342 | # frozen_string_literal: true
require "bundler/gem_tasks"
# Override release task to only tag and push to git
# The GitHub Action (push.yml) handles the actual gem push
Rake::Task["release"].clear
desc "Create tag v#{Equalizer::VERSION} and push to GitHub"
task "release", [:remote] => ["build", "release:guard_clean"]... |
github | dkubb/equalizer | https://github.com/dkubb/equalizer | Gemfile | Ruby | mit | 202 | master | 582 | # frozen_string_literal: true
source "https://rubygems.org"
gemspec
group :development, :test do
gem "minitest", ">= 6"
gem "rake", ">= 13.3"
gem "simplecov", ">= 0.22", require: false
# Linting
gem "rubocop", ">= 1.82"
gem "rubocop-minitest", ">= 0.38"
gem "rubocop-performance", ">= 1.26"
gem "rubo... |
github | dkubb/equalizer | https://github.com/dkubb/equalizer | lib/equalizer.rb | Ruby | mit | 202 | master | 5,290 | # frozen_string_literal: true
# Equalizer provides equality, equivalence, hashing, pattern matching, and
# inspection methods for Ruby objects based on specified attributes.
#
# @example Basic usage
# class GeoLocation
# include Equalizer.new(:latitude, :longitude)
#
# attr_reader :latitude, :longitude, :nam... |
github | dkubb/equalizer | https://github.com/dkubb/equalizer | test/equality_test.rb | Ruby | mit | 202 | master | 3,319 | # frozen_string_literal: true
require "test_helper"
class EqualityTest < EqualizerTestCase
def test_equality_with_equal_attributes
assert_equal Point.new(1, 2), Point.new(1, 2)
assert_equal Point.new(1, 2, "a"), Point.new(1, 2, "b")
end
def test_equality_with_different_attributes
refute_equal Point... |
github | dkubb/equalizer | https://github.com/dkubb/equalizer | test/pretty_print_test.rb | Ruby | mit | 202 | master | 2,560 | # frozen_string_literal: true
require "test_helper"
class PrettyPrintTest < EqualizerTestCase
def test_pretty_print_instance_variables
point = Point.new(1, 2, "label")
assert_equal %i[@x @y], point.pretty_print_instance_variables
refute_includes point.pretty_print_instance_variables, :@label
end
d... |
github | dkubb/equalizer | https://github.com/dkubb/equalizer | test/eql_test.rb | Ruby | mit | 202 | master | 1,482 | # frozen_string_literal: true
require "test_helper"
class EqlTest < EqualizerTestCase
def test_eql_with_equal_attributes
assert Point.new(1, 2).eql?(Point.new(1, 2))
refute Point.new(1, 2).eql?(Point.new(9, 9))
end
def test_eql_with_non_equalizer_objects
refute Point.new(1, 2).eql?(nil)
refute ... |
github | dkubb/equalizer | https://github.com/dkubb/equalizer | test/inspect_test.rb | Ruby | mit | 202 | master | 3,084 | # frozen_string_literal: true
require "test_helper"
class InspectTest < EqualizerTestCase
def test_inspect
result = Point.new(1, 2, "label").inspect
assert_match(/\A#<Point:0x[0-9a-f]+ @x=1, @y=2>\z/, result)
refute_match(/@label/, result)
end
def test_inspect_shows_equalizer_attributes
klass ... |
github | dkubb/equalizer | https://github.com/dkubb/equalizer | test/hash_test.rb | Ruby | mit | 202 | master | 1,826 | # frozen_string_literal: true
require "test_helper"
class HashTest < EqualizerTestCase
def test_hash
assert_equal Point.new(1, 2).hash, Point.new(1, 2).hash
refute_equal Point.new(1, 2).hash, Point.new(9, 9).hash
cache = {Point.new(1, 2) => "found"}
assert_equal "found", cache[Point.new(1, 2)]
e... |
github | dkubb/equalizer | https://github.com/dkubb/equalizer | test/deconstruct_test.rb | Ruby | mit | 202 | master | 1,714 | # frozen_string_literal: true
require "test_helper"
class DeconstructTest < EqualizerTestCase
def test_deconstruct
assert_equal [1, 2], Point.new(1, 2).deconstruct
case Point.new(3, 4)
in [x, y] then assert_equal 7, x + y
end
end
def test_deconstruct_keys_with_nil
point = Point.new(1, 2, "... |
github | dkubb/equalizer | https://github.com/dkubb/equalizer | test/test_helper.rb | Ruby | mit | 202 | master | 1,111 | # frozen_string_literal: true
unless ENV["MUTANT"]
require "simplecov"
SimpleCov.start do
enable_coverage :branch
minimum_coverage line: 100, branch: 100
add_filter %r{^/test/}
add_group "Lib", "lib"
end
end
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "equalizer"
if ENV["MUT... |
github | dkubb/equalizer | https://github.com/dkubb/equalizer | test/equalizer_test.rb | Ruby | mit | 202 | master | 2,407 | # frozen_string_literal: true
require "test_helper"
class EqualizerTest < EqualizerTestCase
def test_creates_module_with_descriptive_name
mod = Equalizer.new(:foo, :bar)
assert_kind_of Module, mod
assert_equal "Equalizer(foo, bar)", mod.name
end
def test_equalizer_keys_is_private
klass = Class... |
github | nicotaing/yaml_record | https://github.com/nicotaing/yaml_record | yaml_record.gemspec | Ruby | mit | 202 | master | 1,040 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'yaml_record/version'
Gem::Specification.new do |spec|
spec.name = "yaml_record"
spec.version = YamlRecord::VERSION
spec.authors = ["Nico Taing", "Nathan Esquenazi"]
s... |
github | nicotaing/yaml_record | https://github.com/nicotaing/yaml_record | test/test_helper.rb | Ruby | mit | 202 | master | 441 | require 'minitest/autorun'
require 'shoulda'
require 'yaml_record'
class Minitest::Test
def clean_yaml_record(class_record)
dir = File.dirname(class_record.source)
Dir.mkdir(dir) unless Dir.exists?(dir)
File.open(class_record.source, 'w') {|f| f.write(nil) }
end
# Asserts that the condition is not t... |
github | nicotaing/yaml_record | https://github.com/nicotaing/yaml_record | test/base_test.rb | Ruby | mit | 202 | master | 7,327 | require File.dirname(__FILE__) + '/test_helper'
class YamlObject < YamlRecord::Base
properties :title, :body, :child_ids
source File.dirname(__FILE__) + "/../tmp/yaml_object"
end
class BaseTest < Minitest::Test
def setup
@obj_title = "Simple Title"
@obj_id = "1234"
@obj2_id = "5678"
@obj2_title... |
github | nicotaing/yaml_record | https://github.com/nicotaing/yaml_record | lib/yaml_record.rb | Ruby | mit | 202 | master | 304 | require 'active_support'
require 'active_support/callbacks'
require 'active_support/core_ext/hash'
require 'securerandom'
require 'yaml'
require 'yaml_record/version'
require 'yaml_record/base'
require 'yaml_record/adapters/local_store'
require 'yaml_record/adapters/redis_store'
module YamlRecord
end |
github | nicotaing/yaml_record | https://github.com/nicotaing/yaml_record | lib/yaml_record/base.rb | Ruby | mit | 202 | master | 10,750 | module YamlRecord
class Base
attr_accessor :attributes, :is_created, :is_destroyed
include ActiveSupport::Callbacks
define_callbacks :before_save, :after_save, :before_destroy, :after_destroy, :before_validation, :before_create, :after_create
set_callback :before_create, :before, :set_id!
# Con... |
github | nicotaing/yaml_record | https://github.com/nicotaing/yaml_record | lib/yaml_record/adapters/redis_store.rb | Ruby | mit | 202 | master | 979 | # YAML Adapter for using a redis client store
# YamlRecord::Adapters::RedisStore.new(@redis)
module YamlRecord
module Adapters
class RedisStore
attr_reader :client
# client is an instantiated redis client (i.e Redis::Client.new(...))
def initialize(client)
raise "Please specify a Redis... |
github | nicotaing/yaml_record | https://github.com/nicotaing/yaml_record | lib/yaml_record/adapters/local_store.rb | Ruby | mit | 202 | master | 590 | # YAML Adapter for using a local file store
module YamlRecord
module Adapters
class LocalStore
# Returns YAML File as ruby collection
#
# === Example:
#
# @adapter.read("foo") => [{...}, {...}]
#
def read(source)
YAML.load_file(source)
end
# Write... |
github | rubymotion-community/motion-cocoapods | https://github.com/rubymotion-community/motion-cocoapods | motion-cocoapods.gemspec | Ruby | bsd-2-clause | 202 | master | 901 | # This is just so that the source file can be loaded.
module ::Motion; module Project; class Config
def self.variable(*); end
end; end; end
require 'date'
$:.unshift File.expand_path('../lib', __FILE__)
require 'motion/project/version'
Gem::Specification.new do |spec|
spec.name = 'motion-cocoapods'
spec.... |
github | rubymotion-community/motion-cocoapods | https://github.com/rubymotion-community/motion-cocoapods | Rakefile | Ruby | bsd-2-clause | 202 | master | 559 | require 'bundler/gem_tasks'
desc "Install dependencies needed for development"
task :bootstrap do
sh "git submodule update --init"
sh "bundle install"
end
desc "Run all the specs"
task :spec do
#sh "env COCOAPODS_VERBOSE=1 bundle exec bacon #{FileList['spec/*_spec.rb'].join(' ')}"
FileList['spec/*_spec.rb'].e... |
github | rubymotion-community/motion-cocoapods | https://github.com/rubymotion-community/motion-cocoapods | lib/motion-cocoapods.rb | Ruby | bsd-2-clause | 202 | master | 1,437 | # Copyright (c) 2012, Laurent Sansonetti <lrz@hipbyte.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this... |
github | rubymotion-community/motion-cocoapods | https://github.com/rubymotion-community/motion-cocoapods | lib/motion/project/version.rb | Ruby | bsd-2-clause | 202 | master | 1,445 | # Copyright (c) 2012-2013, Laurent Sansonetti <lrz@hipbyte.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# t... |
github | rubymotion-community/motion-cocoapods | https://github.com/rubymotion-community/motion-cocoapods | lib/motion/project/cocoapods.rb | Ruby | bsd-2-clause | 202 | master | 21,323 | # coding: utf-8
# Copyright (c) 2012-2014, Laurent Sansonetti <lrz@hipbyte.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyrigh... |
github | rubymotion-community/motion-cocoapods | https://github.com/rubymotion-community/motion-cocoapods | spec/spec_helper.rb | Ruby | bsd-2-clause | 202 | master | 936 | require 'rubygems'
require 'bundler/setup'
require 'pathname'
ROOT = Pathname.new(File.expand_path('../../', __FILE__))
$:.unshift(ENV['RUBYMOTION_CHECKOUT'] || "/Library/RubyMotion/lib")
$:.unshift((ROOT + 'lib').to_s)
require 'bacon'
Bacon.summary_at_exit
require 'rake'
require 'motion/project/template/ios'
requ... |
github | rubymotion-community/motion-cocoapods | https://github.com/rubymotion-community/motion-cocoapods | spec/use_frameworks_spec.rb | Ruby | bsd-2-clause | 202 | master | 2,467 | require File.expand_path('../spec_helper', __FILE__)
describe "use_frameworks!" do
extend SpecHelper::TemporaryDirectory
def podfile=(podfile); @podfile = podfile; end
def installer=(installer); @installer = installer; end
before do
unless @ran_install
teardown_temporary_directory
setup_tempo... |
github | rubymotion-community/motion-cocoapods | https://github.com/rubymotion-community/motion-cocoapods | spec/cocoapods_spec.rb | Ruby | bsd-2-clause | 202 | master | 5,341 | require File.expand_path('../spec_helper', __FILE__)
describe "motion-cocoapods" do
extend SpecHelper::TemporaryDirectory
def podfile=(podfile); @podfile = podfile; end
def installer=(installer); @installer = installer; end
before do
unless @ran_install
teardown_temporary_directory
setup_temp... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | instagram-crawler.gemspec | Ruby | mit | 202 | master | 2,020 | lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "instagram_crawler/version"
Gem::Specification.new do |spec|
spec.name = "instagram-crawler"
spec.version = InstagramCrawler::VERSION
spec.authors = ["Leon Ji"]
spec.email = [... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | Gemfile | Ruby | mit | 202 | master | 203 | source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem 'coveralls', require: false
# Specify your gem's dependencies in instagram-crawler.gemspec
gemspec |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | spec/spec_helper.rb | Ruby | mit | 202 | master | 409 | require "bundler/setup"
require "instagram_crawler"
require 'coveralls'
Coveralls.wear!
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.disab... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | spec/instagram_crawler/multi_io_spec.rb | Ruby | mit | 202 | master | 320 | RSpec.describe InstagramCrawler::MultiIO do
subject(:multi_io) { described_class.new(*[STDOUT]) }
it '#pretty_file_text' do
text = "\e[0;96;49m[2016-12-12 12:12]\e[0m leon: 123\n"
pretty_text = multi_io.send(:pretty_file_text, text)
expect(pretty_text).to eq("[2016-12-12 12:12] leon: 123\n")
end
end |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | spec/instagram_crawler/config_spec.rb | Ruby | mit | 202 | master | 864 | RSpec.describe InstagramCrawler::Config do
subject(:config) { described_class }
it '#defaule_url' do
expect(config.default_url).to eq("https://www.instagram.com")
end
it '#user_name=' do
config.user_name = "marvel"
expect(config.user_name).to eq("marvel")
expect(config.base_url).to eq("#{confi... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | spec/instagram_crawler/parser/html_spec.rb | Ruby | mit | 202 | master | 1,714 | RSpec.describe InstagramCrawler::Parser::Html do
subject(:html) { described_class }
path = "spec/instagram_crawler/fixtures"
let(:home_path) { File.read(Pathname("#{path}/marvel_home.html").realpath) }
let(:post_path) { File.read(Pathname("#{path}/marvel_post.html").realpath) }
let(:photo_path) { File.read(... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | spec/instagram_crawler/parser/json_spec.rb | Ruby | mit | 202 | master | 651 | RSpec.describe InstagramCrawler::Parser::Json do
subject(:json) { described_class }
path = "spec/instagram_crawler/fixtures"
let(:api_path) { File.read(Pathname("#{path}/marvel_api.json").realpath) }
it '#parsing' do
allow_any_instance_of(json).to receive(:get_json).and_return(api_path)
allow_any_ins... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | spec/instagram_crawler/parser/args_spec.rb | Ruby | mit | 202 | master | 1,119 | RSpec.describe InstagramCrawler::Parser::Args do
subject(:args) { described_class }
subject(:config) { InstagramCrawler::Config }
context 'when type arguments' do
it 'should get right with short args' do
parsms = ['-u', 'marvel', '-a', '20180101', '-d', '-l', '-P', 'http://example.com', '-p', '1234']
... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | spec/instagram_crawler/errors/arg_error_spec.rb | Ruby | mit | 202 | master | 228 | RSpec.describe InstagramCrawler::Errors::ArgError do
subject(:arg_error) { described_class.new('-u') }
it '#initialize' do
error_message = arg_error.to_s
expect(error_message).to eq("Missing argument: -u")
end
end |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | spec/instagram_crawler/errors/http_error_spec.rb | Ruby | mit | 202 | master | 238 | RSpec.describe InstagramCrawler::Errors::HttpError do
subject(:http_error) { described_class.new("http fail") }
it '#initialize' do
error_message = http_error.to_s
expect(error_message).to eq("HttpError: http fail")
end
end |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | spec/instagram_crawler/errors/env_error_spec.rb | Ruby | mit | 202 | master | 332 | RSpec.describe InstagramCrawler::Errors::EnvError do
subject(:env_error) { described_class.new }
it '#initialize' do
error_message = env_error.to_s
expect(error_message).to eq("Undefined env variable sessionid\nYou should setting env variable 'export sessionid=[your instagram sessionid]' and execute again."... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | lib/instagram_crawler.rb | Ruby | mit | 202 | master | 653 | $LOAD_PATH << File.dirname(__FILE__)
require "optparse"
require "http"
require "nokogiri"
require "logger"
require "colorize"
require "instagram_crawler/version"
require "instagram_crawler/main"
require "instagram_crawler/file"
require "instagram_crawler/logger"
require "instagram_crawler/multi_io"
require "instagra... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | lib/instagram_crawler/logger.rb | Ruby | mit | 202 | master | 704 | module InstagramCrawler
class Logger < ::Logger
class << self
def setting(log)
io = [STDOUT]
io << log_file if log
logger = Logger.new(MultiIO.new(*io))
logger.level = Logger::INFO
logger.formatter = proc do |_severity, _datetime, _progname, msg|
"#{msg}\n"
... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | lib/instagram_crawler/main.rb | Ruby | mit | 202 | master | 907 | module InstagramCrawler
class Main
def self.run
Logger.info text_to_ASCII.light_red
Logger.info "Running instagram-crawler v#{InstagramCrawler::VERSION}\n"
start_time = Time.now
File.mkdir
page_info, user_id = Parser::Html.new(Config.base_url).parsing
Parser::Json.new(page_info... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | lib/instagram_crawler/multi_io.rb | Ruby | mit | 202 | master | 778 | module InstagramCrawler
class MultiIO
def initialize(*targets)
@targets = targets
@shell_colors = {
light_red: '\\e\\[0;91;49m',
light_green: '\\e\\[0;92;49m',
light_yellow: '\\e\\[0;93;49m',
light_blue: '\\e\\[0;94;49m',
light_magenta: '\\e\\[0;95;49m... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | lib/instagram_crawler/config.rb | Ruby | mit | 202 | master | 936 | module InstagramCrawler
class Config
@default_url = "https://www.instagram.com".freeze
class << self
attr_reader :default_url, :user_name, :base_url, :base_path,
:log_path, :after_date, :before_date, :parse_after_date, :parse_before_date
attr_accessor :download, :proxyname
... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | lib/instagram_crawler/file.rb | Ruby | mit | 202 | master | 1,118 | module InstagramCrawler
class File < ::File
class << self
def mkdir
return unless Config.download
Logger.info "Create directory in #{Config.base_path}\n"
FileUtils.mkdir_p(Config.base_path) unless Dir.exist?(Config.base_path)
end
def download(url, dir_name, file_name)
... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | lib/instagram_crawler/errors/env_error.rb | Ruby | mit | 202 | master | 272 | module InstagramCrawler
module Errors
class EnvError < StandardError
def initialize
super("Undefined env variable sessionid\nYou should setting env variable 'export sessionid=[your instagram sessionid]' and execute again.")
end
end
end
end |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | lib/instagram_crawler/parser/json.rb | Ruby | mit | 202 | master | 2,200 | module InstagramCrawler
module Parser
class Json < Base
attr_reader :page_info, :user_id
def initialize(page_info, user_id)
@page_info = page_info
@user_id = user_id
end
def parsing
begin
end_cursor = page_info["end_cursor"][0..-3]
url ... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | lib/instagram_crawler/parser/args.rb | Ruby | mit | 202 | master | 1,816 | module InstagramCrawler
module Parser
class Args
attr_accessor :log
def initialize(args)
@args = args
parse_args
validates_required_args
end
private
def parse_args
opts = OptionParser.new
opts.banner = usage_msg
opts.separator ''
... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | lib/instagram_crawler/parser/html.rb | Ruby | mit | 202 | master | 2,765 | module InstagramCrawler
module Parser
class Html < Base
attr_reader :html
def initialize(url)
@html = get_html(url)
end
def parsing
doc = Nokogiri::HTML(html)
js_data = doc.at_xpath("//script[contains(text(),'window._sharedData')]")
json = JSO... |
github | mgleon08/instagram-crawler | https://github.com/mgleon08/instagram-crawler | lib/instagram_crawler/parser/base.rb | Ruby | mit | 202 | master | 844 | module InstagramCrawler
module Parser
class Base
private
def parse_post(posts, time)
posts.each.with_index(1) do |post, index|
url =
post["node"]["is_video"] ?
post["node"]["video_url"] :
post["node"]["display_url"]
output(time, url)
... |
github | skryukov/skooma | https://github.com/skryukov/skooma | skooma.gemspec | Ruby | mit | 202 | main | 1,080 | # frozen_string_literal: true
require_relative "lib/skooma/version"
Gem::Specification.new do |spec|
spec.name = "skooma"
spec.version = Skooma::VERSION
spec.authors = ["Svyatoslav Kryukov"]
spec.email = ["me@skryukov.dev"]
spec.summary = "Validate API implementations against OpenAPI documents."
spec.des... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma.rb | Ruby | mit | 202 | main | 801 | # frozen_string_literal: true
require "json_skooma"
require "zeitwerk"
require_relative "skooma/inflector"
loader = Zeitwerk::Loader.for_gem
loader.inflector = Skooma::Inflector.new(__FILE__)
# Do not eager load the test helpers
loader.do_not_eager_load(File.join(__dir__, "skooma", "minitest.rb"))
loader.do_not_eag... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/rspec.rb | Ruby | mit | 202 | main | 1,104 | # frozen_string_literal: true
module Skooma
# RSpec matchers for OpenAPI schema validation
# @example
# RSpec.configure do |config|
# # ...
# config.include Skooma::RSpec[Rails.root.join("docs", "openapi.yml")], type: :request
# end
class RSpec < Matchers::Wrapper
module HelperMethods
... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/body_parsers.rb | Ruby | mit | 202 | main | 1,210 | # frozen_string_literal: true
module Skooma
module BodyParsers
class << self
DEFAULT_PARSER = ->(body, **_options) { body }
def [](media_type)
key = normalize_media_type(media_type)
parsers[key] ||
find_suffix_parser(key) ||
find_fallback_parser(key) ||
... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/coverage_store.rb | Ruby | mit | 202 | main | 1,738 | # frozen_string_literal: true
module Skooma
class CoverageStore
DEFAULT_FILE_PATH = File.join(Dir.pwd, "tmp", "skooma_coverage.json")
attr_reader :file_path
def initialize(file_path: DEFAULT_FILE_PATH)
@file_path = file_path
ensure_file_exists
end
def load_data
with_lock("r")... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/instance.rb | Ruby | mit | 202 | main | 3,167 | # frozen_string_literal: true
module Skooma
class Instance < JSONSkooma::JSONNode
module Coercible
def coerce(json)
value = self&.value
return self if value.nil?
case json["type"]
when "integer"
begin
Integer(value, 10)
rescue ArgumentError
... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/env_mapper.rb | Ruby | mit | 202 | main | 1,486 | # frozen_string_literal: true
module Skooma
module EnvMapper
class << self
PLAIN_HEADERS = %w[CONTENT_LENGTH CONTENT_TYPE].freeze
REGEXP_HTTP = /^HTTP_/.freeze
def call(env, response = nil, with_response: true, with_request: true)
result = {
"method" => env["REQUEST_METHOD"].... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/coverage.rb | Ruby | mit | 202 | main | 3,042 | # frozen_string_literal: true
module Skooma
class NoopCoverage
def track_request(*)
end
def report
end
end
class Coverage
class SimpleReport
def initialize(coverage)
@coverage = coverage
end
attr_reader :coverage
def report
puts <<~MSG
Ope... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/inflector.rb | Ruby | mit | 202 | main | 390 | # frozen_string_literal: true
module Skooma
class Inflector < Zeitwerk::GemInflector
STATIC_MAPPING = {
"oas_3_1" => "OAS31",
"openapi" => "OpenAPI",
"rspec" => "RSpec"
}
def camelize(basename, _abspath)
if basename.include?("json_")
super.gsub("Json", "JSON")
else
... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/minitest.rb | Ruby | mit | 202 | main | 1,358 | # frozen_string_literal: true
require "minitest"
module Skooma
# Minitest helpers for OpenAPI schema validation
# @example
# describe TestApp do
# include Skooma::Minitest[Rails.root.join("docs", "openapi.yml")]
# # ...
# end
class Minitest < Matchers::Wrapper
module HelperMethods
... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/output_format.rb | Ruby | mit | 202 | main | 865 | # frozen_string_literal: true
module Skooma
module OutputFormat
class << self
def call(result, **_options)
return {"valid" => true} if result.valid?
node_data(result, true)
end
private
def node_data(node, first = false)
data = {
"instanceLocation" => n... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/matchers/conform_schema.rb | Ruby | mit | 202 | main | 218 | # frozen_string_literal: true
module Skooma
module Matchers
class ConformSchema < ConformResponseSchema
def description
"conform schema with #{@expected} response code"
end
end
end
end |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/matchers/be_valid_document.rb | Ruby | mit | 202 | main | 751 | # frozen_string_literal: true
require "pp"
module Skooma
module Matchers
class BeValidDocument
def matches?(actual)
@actual = actual
return false unless comparable?
@result = @actual.validate
@result.valid?
end
def description
"be a valid OpenAPI docum... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/matchers/wrapper.rb | Ruby | mit | 202 | main | 2,887 | # frozen_string_literal: true
require "pathname"
module Skooma
module Matchers
class Wrapper < Module
TEST_REGISTRY_NAME = "skooma_test_registry"
class << self
alias_method :[], :new
end
module DefaultHelperMethods
def mapped_response(with_response: true, with_request: ... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/matchers/conform_response_schema.rb | Ruby | mit | 202 | main | 1,047 | # frozen_string_literal: true
module Skooma
module Matchers
class ConformResponseSchema < ConformRequestSchema
def initialize(skooma, mapped_response, expected)
super(skooma, mapped_response)
@expected = expected
case expected
when Symbol
@expected_code = Rack::U... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/matchers/conform_request_schema.rb | Ruby | mit | 202 | main | 809 | # frozen_string_literal: true
require "pp"
module Skooma
module Matchers
class ConformRequestSchema
def initialize(skooma, mapped_response)
@skooma = skooma
@schema = skooma.schema
@mapped_response = mapped_response
end
def matches?(*)
@result = @schema.evaluat... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/validators/int_32.rb | Ruby | mit | 202 | main | 398 | # frozen_string_literal: true
module Skooma
module Validators
class Int32 < JSONSkooma::Validators::Base
def self.assert?(instance)
instance.type == "number" && instance == instance.to_i
end
def call(instance)
return if instance.value.bit_length <= 32
raise JSONSkooma:... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/validators/double.rb | Ruby | mit | 202 | main | 329 | # frozen_string_literal: true
module Skooma
module Validators
class Double < JSONSkooma::Validators::Base
self.instance_types = "number"
def call(instance)
return if instance.value.is_a?(::Float)
raise JSONSkooma::Validators::FormatError, "must be a valid double"
end
end
... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/validators/float.rb | Ruby | mit | 202 | main | 327 | # frozen_string_literal: true
module Skooma
module Validators
class Float < JSONSkooma::Validators::Base
self.instance_types = "number"
def call(instance)
return if instance.value.is_a?(::Float)
raise JSONSkooma::Validators::FormatError, "must be a valid float"
end
end
e... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/validators/int_64.rb | Ruby | mit | 202 | main | 398 | # frozen_string_literal: true
module Skooma
module Validators
class Int64 < JSONSkooma::Validators::Base
def self.assert?(instance)
instance.type == "number" && instance == instance.to_i
end
def call(instance)
return if instance.value.bit_length <= 64
raise JSONSkooma:... |
github | skryukov/skooma | https://github.com/skryukov/skooma | lib/skooma/dialects/oas_3_1.rb | Ruby | mit | 202 | main | 1,914 | # frozen_string_literal: true
module Skooma
module Dialects
module OAS31
class << self
def call(registry, **options)
registry.add_source(
"https://spec.openapis.org/oas/3.1/",
JSONSkooma::Sources::Local.new(File.join(DATA_DIR, "oas-3.1").to_s, suffix: ".json")
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.