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 | socketry/localhost | https://github.com/socketry/localhost | bake/localhost.rb | Ruby | mit | 248 | main | 1,107 | # frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2021-2025, by Samuel Williams.
def initialize(...)
super
require_relative "../lib/localhost"
end
# List all local authorities.
#
# @returns [Array(Hash)] The certificate and key paths, and the expiry date.
def list
Localhost::Authority... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config.ru | Ruby | mit | 248 | main | 399 | # This file is used by Rack-based servers to start the application.
require_relative 'config/environment'
if Rails.env.production? && Rails.configuration.x.app_host
# Redirect to a canonical host
use Rack::CanonicalHost,
Rails.configuration.x.app_host,
cache_control: 'no-cache',
ignore: ->(uri) ... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | Gemfile | Ruby | mit | 248 | main | 5,290 | source 'https://rubygems.org'
ruby file: '.ruby-version'
# Full-stack web application framework. (https://rubyonrails.org)
gem 'rails', '~> 8.1.2'
# Use Vite in Rails and bring joy to your JavaScript experience (https://github.com/ElMassimo/vite_ruby)
gem 'vite_rails'
# The speed of a single-page web application wi... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | Guardfile | Ruby | mit | 248 | main | 2,385 | # A sample Guardfile
# More info at https://github.com/guard/guard#readme
## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
# .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}
## Note: if you are using the `directo... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/routes.rb | Ruby | mit | 248 | main | 7,955 | # == Route Map
#
# Prefix Verb URI Pattern Controller#Action
# rails_health_check GET /up(.:format) ... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/puma.rb | Ruby | mit | 248 | main | 1,922 | # This configuration file will be evaluated by Puma. The top-level methods that
# are invoked here are part of Puma's configuration DSL. For more information
# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html.
#
# Puma starts a configurable number of processes (workers) and each process
# serve... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/ci.rb | Ruby | mit | 248 | main | 928 | # Run using bin/ci
CI.run do
step 'Setup', 'bin/setup --skip-server'
step 'Style: Ruby', 'bin/rubocop'
step 'Style: JavaScript', 'bin/yarn lint'
step 'Style: TypeScript', 'bin/yarn tsc'
step 'Security: Gem audit', 'bin/bundler-audit'
step 'Security: Yarn vulnerability audit', 'bin/yarn npm audit --recurs... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/boot.rb | Ruby | mit | 248 | main | 352 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
require 'bootsnap/setup' # Speed up boot time by caching expensive operations.
# Keyword-argument compatibility for connection_pool must be applied before Rails boots.
require_relative 'initi... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/application.rb | Ruby | mit | 248 | main | 2,041 | require_relative 'boot'
require 'rails'
# Pick the frameworks you want:
require 'active_record/railtie'
# require 'active_storage/engine'
require 'action_controller/railtie'
require 'action_view/railtie'
require 'action_mailer/railtie'
require 'active_job/railtie'
require 'action_cable/engine'
# require 'action_mailbo... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/environments/production.rb | Ruby | mit | 248 | main | 4,456 | require 'active_support/core_ext/integer/time'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.enable_reloading = false
# Eager load code on boot for better performance and memory savings (ignor... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/environments/development.rb | Ruby | mit | 248 | main | 3,687 | require 'active_support/core_ext/integer/time'
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Make code changes take effect immediately without server restart.
config.enable_reloading = true
# Do not eager load code on boot.
config.eager... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/environments/test.rb | Ruby | mit | 248 | main | 2,330 | # The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.application.configure do
# Settings... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/initializers/inflections.rb | Ruby | mit | 248 | main | 649 | # Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflec... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/initializers/rack.rb | Ruby | mit | 248 | main | 1,072 | # Remove 'x-runtime' header
Rails.application.config.middleware.delete(Rack::Runtime)
# Add content_type for some file extension not included in the
# list of defaults: https://github.com/rack/rack/blob/master/lib/rack/mime.rb
Rack::Mime::MIME_TYPES['.webmanifest'] = 'application/manifest+json'
# Enable gzip and brot... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/initializers/connection_pool_kwargs.rb | Ruby | mit | 248 | main | 523 | # connection_pool 3.x expects keyword arguments, but some callers (e.g. ActiveSupport::Cache::RedisCacheStore)
# still pass a positional Hash. Ruby 3.4 no longer converts that implicitly, so patch in support.
unless defined?(ConnectionPoolKeywordCompat)
require 'connection_pool'
module ConnectionPoolKeywordCompat
... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/initializers/content_security_policy.rb | Ruby | mit | 248 | main | 3,648 | # Be sure to restart your server when you modify this file.
# Define an application-wide content security policy.
# See the Securing Rails Applications Guide for more information:
# https://guides.rubyonrails.org/security.html#content-security-policy-header
Rails.application.configure do
config.content_security_pol... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/initializers/wrap_parameters.rb | Ruby | mit | 248 | main | 480 | # Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) { wrap_parameters form... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/initializers/permissions_policy.rb | Ruby | mit | 248 | main | 412 | # Be sure to restart your server when you modify this file.
# Define an application-wide HTTP permissions policy. For further
# information see: https://developers.google.com/web/updates/2018/06/feature-policy
Rails.application.config.permissions_policy do |policy|
policy.camera :none
policy.gyroscope :none
poli... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/initializers/session_store.rb | Ruby | mit | 248 | main | 287 | Rails.application.config.session_store :cookie_store,
key:
"#{Rails.configuration.force_ssl ? '__Host-' : '_'}templatus_session",
secure: Rails.configuration.force_ssl |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/initializers/filter_parameter_logging.rb | Ruby | mit | 248 | main | 469 | # Be sure to restart your server when you modify this file.
# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file.
# Use this to limit dissemination of sensitive information.
# See the ActiveSupport::ParameterFilter documentation for supported notations and behavio... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/initializers/rorvswild.rb | Ruby | mit | 248 | main | 207 | if Rails.configuration.x.rorvswild.api_key
RorVsWild.start(
api_key: Rails.configuration.x.rorvswild.api_key,
deployment: {
revision: Rails.configuration.x.git.commit_version,
},
)
end |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | config/initializers/sidekiq.rb | Ruby | mit | 248 | main | 237 | Sidekiq.configure_client do |config|
config.redis = { url: ENV.fetch('REDIS_URL', 'redis://localhost:6379/2') }
end
Sidekiq.configure_server do |config|
config.redis = { url: ENV.fetch('REDIS_URL', 'redis://localhost:6379/2') }
end |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/rails_helper.rb | Ruby | mit | 248 | main | 3,514 | require 'simplecov'
SimpleCov.start 'rails' do
add_filter 'app/jobs/application_job.rb'
add_filter 'app/mailers/application_mailer.rb'
add_filter 'app/channels/application_cable/connection.rb'
add_filter 'app/channels/application_cable/channel.rb'
add_filter 'app/models/application_record.rb'
end
# This file... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/spec_helper.rb | Ruby | mit | 248 | main | 4,603 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to explicitly require ... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/component_previews/git_version_preview.rb | Ruby | mit | 248 | main | 218 | class GitVersionPreview < ViewComponent::Preview
def with_default
render(
Components::GitVersion.new(
commit_version: 'abc1234',
commit_time: Time.current.utc.to_s,
),
)
end
end |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/component_previews/tabs_preview.rb | Ruby | mit | 248 | main | 233 | class TabsPreview < ViewComponent::Preview
def with_default
render Components::Tabs.new do |c|
c.tab text: 'Foo', href: '/foo'
c.tab text: 'Bar', href: '/bar'
c.tab text: 'Baz', href: '/baz'
end
end
end |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/component_previews/clicks_preview.rb | Ruby | mit | 248 | main | 772 | class ClicksPreview < ViewComponent::Preview
def with_default
render(Components::Clicks.new(clicks: [click1, click2, click3], count: 1))
end
private
def click1
Click.new(
ip: '1.1.1.1',
user_agent: 'Mosaic/0.9',
created_at: 5.minutes.ago,
)
end
def click2
Click.new(
... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/middleware/cloudfront_denier_spec.rb | Ruby | mit | 248 | main | 1,289 | describe CloudfrontDenier do
subject(:middleware) { described_class.new(app, target: host) }
let(:host) { 'https://example.com' }
let(:app) { ->(env) { [200, env, 'OK'] } }
it 'accepts request for asset' do
code, = middleware.call env_for('http://example.com/assets/example.js')
expect(code).to eq(200... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/factories/clicks.rb | Ruby | mit | 248 | main | 427 | # == Schema Information
#
# Table name: clicks
#
# id :bigint not null, primary key
# ip :inet not null
# user_agent :string not null
# created_at :datetime not null
#
FactoryBot.define do
factory :click do
sequence(:created_at) { |n| n.hours.ago }
s... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/models/click_spec.rb | Ruby | mit | 248 | main | 445 | # == Schema Information
#
# Table name: clicks
#
# id :bigint not null, primary key
# ip :inet not null
# user_agent :string not null
# created_at :datetime not null
#
describe Click do
let(:click) { create(:click, ip: '1.2.3.4', user_agent: 'IRB') }
it '... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/channels/clicks_channel_spec.rb | Ruby | mit | 248 | main | 200 | describe ClicksChannel do
it 'successfully subscribes and unsubscribes' do
subscribe
expect(subscription).to be_confirmed
unsubscribe
expect(subscription).to be_confirmed
end
end |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/support/capybara.rb | Ruby | mit | 248 | main | 380 | require 'capybara/rspec'
Capybara.register_driver :my_playwright do |app|
Capybara::Playwright::Driver.new(
app,
browser_type: ENV.fetch('PLAYWRIGHT_BROWSER', 'chromium').to_sym,
headless: ENV['CI'].present? || ENV['PLAYWRIGHT_HEADLESS'].present?,
)
end
RSpec.configure do |config|
config.before(:eac... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/system/basic_spec.rb | Ruby | mit | 248 | main | 637 | describe 'Basic tests' do
it 'can navigate' do
visit root_path
click_on 'About'
expect(page).to have_css('main h1', text: 'About')
click_on 'Home'
expect(page).to have_css('main h1', text: 'Hello')
end
it 'can click' do
visit root_path
expect(page).to have_css('main h1', text: 'Hel... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/requests/deflater_spec.rb | Ruby | mit | 248 | main | 444 | describe 'Rack::Deflater' do
it 'compresses with gzip if requested' do
['gzip', 'deflate, gzip', 'gzip, deflate'].each do |compression_method|
get root_path, headers: { HTTP_ACCEPT_ENCODING: compression_method }
expect(response.headers['Content-Encoding']).to eq('gzip')
end
end
it 'does not ... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/requests/clicks_spec.rb | Ruby | mit | 248 | main | 1,321 | describe 'Clicks' do
describe 'GET /' do
before { create_list(:click, 10) }
it 'lists existing clicks' do
get root_path
expect(response).to have_http_status(:success)
end
end
describe 'POST /clicks' do
let(:user_agent) { 'Netscape Navigator' }
def call(ip)
post clicks_pat... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/components/app_flash/component_spec.rb | Ruby | mit | 248 | main | 375 | describe AppFlash::Component, type: :component do
it 'renders notice' do
result = render_inline(described_class.new(notice: 'All good!'))
expect(result).to have_content('All good!')
end
it 'renders alert' do
result = render_inline(described_class.new(alert: 'Something went wrong!'))
expect(resu... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/components/page_title/component_spec.rb | Ruby | mit | 248 | main | 224 | describe PageTitle::Component, type: :component do
subject(:output) { render_inline(instance) }
let(:instance) { described_class.new('Hello, world!') }
it { is_expected.to have_css('h1', text: 'Hello, world!') }
end |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/components/tabs/component_spec.rb | Ruby | mit | 248 | main | 372 | describe Tabs::Component, type: :component do
subject(:component) { described_class.new }
it 'renders links' do
result =
render_inline(component) do |c|
c.with_tab text: 'One', href: '/1'
c.with_tab text: 'Two', href: '/2'
c.with_tab text: 'Three', href: '/3'
end
expect... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/components/git_version/component_spec.rb | Ruby | mit | 248 | main | 452 | describe GitVersion::Component, type: :component do
subject(:output) { render_inline(instance) }
let(:instance) do
described_class.new commit_version: '1234567',
commit_time: '2021-12-24T18:00:00+01:00'
end
it { is_expected.to have_css('code', text: '1234567') }
it { is_expected.... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | spec/components/about/component_spec.rb | Ruby | mit | 248 | main | 268 | describe About::Component, type: :component do
subject { render_inline(described_class.new) }
it { is_expected.to have_content('Ruby on Rails') }
it { is_expected.to have_content(Rails::VERSION::STRING) }
it { is_expected.to have_link(href: '/sidekiq') }
end |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | db/schema.rb | Ruby | mit | 248 | main | 1,062 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rai... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | db/migrate/20210522144348_create_clicks.rb | Ruby | mit | 248 | main | 239 | class CreateClicks < ActiveRecord::Migration[7.0]
def change
create_table :clicks do |t|
t.inet :ip, null: false
t.string :user_agent, null: false
t.datetime :created_at, precision: 6, null: false
end
end
end |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | lib/tasks/annotate_rb.rake | Ruby | mit | 248 | main | 249 | # This rake task was added by annotate_rb gem.
# Can set `ANNOTATERB_SKIP_ON_DB_TASKS` to be anything to skip this
if Rails.env.development? && ENV['ANNOTATERB_SKIP_ON_DB_TASKS'].nil?
require 'annotate_rb'
AnnotateRb::Core.load_rake_tasks
end |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | app/middleware/cloudfront_denier.rb | Ruby | mit | 248 | main | 493 | # Middleware to deny CloudFront requests to non-assets
# http://ricostacruz.com/til/rails-and-cloudfront
class CloudfrontDenier
def initialize(app, target:)
@app = app
@target = target
end
def call(env)
if cloudfront?(env) && !asset?(env)
[302, { 'Location' => @target }, []]
else
@ap... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | app/components/click/component.rb | Ruby | mit | 248 | main | 213 | class Click::Component < ViewComponent::Base
def initialize(click:, will_animate: false)
super()
@click = click
@will_animate = will_animate
end
private
attr_reader :click, :will_animate
end |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | app/components/app_flash/component.rb | Ruby | mit | 248 | main | 759 | class AppFlash::Component < ViewComponent::Base
def initialize(alert: nil, notice: nil)
super()
@alert = alert
@notice = notice
end
private
attr_reader :alert, :notice
def background_class
base = 'z-50 fixed bottom-0 inset-x-0 border-t-4 p-8 hidden'
if notice
"#{base} bg-green-50... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | app/components/git_version/component.rb | Ruby | mit | 248 | main | 244 | class GitVersion::Component < ViewComponent::Base
def initialize(commit_version:, commit_time:)
super()
@commit_version = commit_version
@commit_time = commit_time
end
private
attr_reader :commit_version, :commit_time
end |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | app/components/tabs/component.rb | Ruby | mit | 248 | main | 699 | class Tabs::Component < ViewComponent::Base
renders_many :tabs, 'TabComponent'
class TabComponent < ViewComponent::Base
def initialize(text:, href:)
super()
@text = text
@href = href
end
def call
link_to text, href, class: css_classes, data: { turbo_action: 'replace' }
end
... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | app/jobs/application_job.rb | Ruby | mit | 248 | main | 272 | class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked
#
# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError
end |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | app/helpers/about_helper.rb | Ruby | mit | 248 | main | 6,779 | module AboutHelper # rubocop:disable Metrics/ModuleLength
FEATURES = [
{
name: 'The backend',
slogan: 'Server side',
items: [
{
name: 'Ruby',
href: 'https://www.ruby-lang.org/',
description:
'A dynamic, open source programming language with a foc... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | app/controllers/application_controller.rb | Ruby | mit | 248 | main | 320 | class ApplicationController < ActionController::Base
def render_flash_update(notice: nil, alert: nil, status: :ok)
render turbo_stream:
turbo_stream.update(
'flash',
render_to_string(AppFlash::Component.new(notice:, alert:)),
),
status:
end
end |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | app/controllers/clicks_controller.rb | Ruby | mit | 248 | main | 636 | class ClicksController < ApplicationController
def index
@clicks = Click.order(created_at: :desc).limit(5).load_async
@clicks_count = Click.count
end
def create
Click.create! user_agent: request.user_agent,
ip: anonymize(request.remote_ip)
render_flash_update notice: t('.success... |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | app/controllers/statics_controller.rb | Ruby | mit | 248 | main | 222 | class StaticsController < ApplicationController
skip_before_action :check_for_lockup, raise: false
layout false
def manifest
expires_in 1.day
respond_to { |format| format.webmanifest { render } }
end
end |
github | templatus/templatus-hotwire | https://github.com/templatus/templatus-hotwire | app/models/click.rb | Ruby | mit | 248 | main | 563 | # == Schema Information
#
# Table name: clicks
#
# id :bigint not null, primary key
# ip :inet not null
# user_agent :string not null
# created_at :datetime not null
#
class Click < ApplicationRecord
validates :ip, presence: true
validates :user_agent, pre... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lastfm.gemspec | Ruby | mit | 248 | master | 883 | # -*- encoding: utf-8 -*-
Gem::Specification.new do |gem|
gem.authors = ["youpy"]
gem.email = ["youpy@buycheapviagraonlinenow.com"]
gem.description = "A ruby interface for Last.fm web services version 2.0"
gem.summary = "A ruby interface for Last.fm web services version 2.0"
gem.homepag... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | Rakefile | Ruby | mit | 248 | master | 234 | #!/usr/bin/env rake
require 'rake'
require "bundler/gem_tasks"
require 'rspec/core'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
task :default => :spec |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm.rb | Ruby | mit | 248 | master | 2,871 | require 'rubygems'
require 'digest/md5'
require 'httparty'
require 'lastfm/util'
require 'lastfm/response'
require 'lastfm/http_request.rb'
require 'lastfm/https_request.rb'
require 'lastfm/method_category/base'
require 'lastfm/method_category/album'
require 'lastfm/method_category/artist'
require 'lastfm/method_categ... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/response.rb | Ruby | mit | 248 | master | 1,020 | require 'rubygems'
require 'xmlsimple'
class Lastfm
class Response
attr_reader :xml
def initialize(body)
# workaround for https://github.com/youpy/ruby-lastfm/issues/83
body = fix_body(body)
@xml = XmlSimple.xml_in(body, 'ForceArray' => ['image', 'tag', 'user', 'event', 'correction'])
... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/util.rb | Ruby | mit | 248 | master | 1,584 | class Lastfm
class Util
def self.force_array(array_or_something)
array_or_something.kind_of?(Array) ? array_or_something : [array_or_something].compact
end
def self.build_options(args, mandatory, optional)
if args.first.is_a?(Hash)
build_options_from_hash(args.first, mandatory || [], ... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/method_category/geo.rb | Ruby | mit | 248 | master | 345 | class Lastfm
module MethodCategory
class Geo < Base
regular_method(
:get_events,
:optional => [
[:location, nil],
[:distance, nil],
[:limit, nil],
[:page, nil]
]
) do |response|
response.xml['events']['event']
end
end
... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/method_category/track.rb | Ruby | mit | 248 | master | 2,519 | class Lastfm
module MethodCategory
class Track < Base
write_method :add_tags, :required => [:artist, :track, :tags]
write_method :remove_tag, :required => [:artist, :track, :tag]
write_method :ban, :required => [:artist, :track]
write_method :love, :required => [:artist, :track]
... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/method_category/tasteometer.rb | Ruby | mit | 248 | master | 315 | class Lastfm
module MethodCategory
class Tasteometer < Base
regular_method(
:compare,
:required => [:type1, :type2, :value1, :value2],
:optional => [
[:limit, nil]
]
) do |response|
response.xml['comparison']['result']
end
end
end
end |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/method_category/radio.rb | Ruby | mit | 248 | master | 418 | class Lastfm
module MethodCategory
class Radio < Base
write_method :tune, :required => [:station]
method_with_authentication :get_playlist do |response|
playlist = response.xml['playlist']
tracklist = playlist['trackList']['track']
unless tracklist.is_a?(Array)
playl... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/method_category/auth.rb | Ruby | mit | 248 | master | 502 | class Lastfm
module MethodCategory
class Auth < Base
method_for_authentication :get_token do |response|
response.xml['token']
end
method_for_authentication(
:get_session,
:required => [:token]
) do |response|
response.xml['session']
end
method_... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/method_category/chart.rb | Ruby | mit | 248 | master | 1,289 | class Lastfm
module MethodCategory
class Chart < Base
regular_method(
:get_hyped_artists,
:optional => [
[:page, nil],
[:limit, nil]
]
) do |response|
response.xml['artists']['artist']
end
regular_method(
:get_hyped_tracks,
... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/method_category/library.rb | Ruby | mit | 248 | master | 623 | class Lastfm
module MethodCategory
class Library < Base
regular_method(
:get_artists,
:required => [:user],
:optional => [
[:limit, nil],
[:page, nil]
]
) do |response|
Util.force_array(response.xml['artists']['artist'])
end
regu... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/method_category/event.rb | Ruby | mit | 248 | master | 217 | class Lastfm
module MethodCategory
class Event < Base
regular_method(
:get_info,
:required => [:event]
) do |response|
response.xml['event'].first
end
end
end
end |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/method_category/album.rb | Ruby | mit | 248 | master | 2,197 | class Lastfm
module MethodCategory
class Album < Base
write_method :add_tags, :required => [:artist, :album, :tags]
write_method :remove_tag, :required => [:artist, :album, :tag]
write_method(
:share,
:required => [:artist, :album, :recipient],
:optional => [
... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/method_category/artist.rb | Ruby | mit | 248 | master | 2,095 | class Lastfm
module MethodCategory
class Artist < Base
regular_method(
:get_top_tracks,
:required => any_params([:artist], [:mbid])
) do |response|
response.xml['toptracks']['track']
end
regular_method(
:get_top_albums,
:required => any_params([:art... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/method_category/tag.rb | Ruby | mit | 248 | master | 1,149 | class Lastfm
module MethodCategory
class Tag < Base
regular_method(
:get_top_artists,
:required => [:tag],
:optional => [
[:limit, nil],
[:page, nil]
]
) do |response|
response.xml['topartists']['artist']
end
regular_method(
... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/method_category/group.rb | Ruby | mit | 248 | master | 324 | class Lastfm
module MethodCategory
class Group < Base
regular_method(
:get_members,
:required => [:group],
:optional => [
[:limit, nil],
[:page, nil]
]
) do |response|
Util.force_array(response.xml['members']['user'])
end
end
end
... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/method_category/user.rb | Ruby | mit | 248 | master | 4,749 | class Lastfm
module MethodCategory
class User < Base
regular_method(
:get_friends,
:required => [:user],
:optional => [
[:recenttracks, nil],
[:limit, nil],
[:page, nil]
]
) do |response|
response.xml['friends']['user']
end
... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | lib/lastfm/method_category/base.rb | Ruby | mit | 248 | master | 2,309 | class Lastfm
class AnyParams
attr_reader :candidates
def initialize(candidates)
@candidates = candidates
end
end
module MethodCategory
class Base
class << self
def any_params(*args)
AnyParams.new(args)
end
def write_method(id, params = {})
... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/util_spec.rb | Ruby | mit | 248 | master | 2,206 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe Lastfm::Util do
subject do
Lastfm::Util
end
describe '.build_options' do
describe 'with array' do
it 'should build options' do
expect(subject.build_options(
['foo', nil],
[:foo],
[[:bar... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/method_category_spec.rb | Ruby | mit | 248 | master | 311 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe 'Lastfm::MethodCategory' do
before do
@lastfm = Lastfm.new('xxx', 'yyy')
end
it 'should have instance of Lastfm' do
expect(Lastfm::MethodCategory::Base.new(@lastfm).instance_eval { @lastfm }).to equal(@lastfm)
end
end |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/spec_helper.rb | Ruby | mit | 248 | master | 682 | require 'lastfm'
RSpec.configure do |config|
def fixture(filename)
File.dirname(__FILE__) + '/fixtures/' + filename
end
def make_response(xml_filename_or_string)
if xml_filename_or_string !~ /</
xml_filename_or_string = open(fixture(xml_filename_or_string + '.xml')).read
end
Lastfm::Respo... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/lastfm_spec.rb | Ruby | mit | 248 | master | 5,427 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Lastfm" do
before { init_lastfm }
describe '.new' do
it 'should instantiate' do
expect(@lastfm).to be_an_instance_of(Lastfm)
end
end
describe '#request' do
it 'should post' do
mock_response = double(HTTParty::... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/response_spec.rb | Ruby | mit | 248 | master | 1,068 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe 'Lastfm::Response' do
before do
@ok = open(fixture('ok.xml')).read
@ng = open(fixture('ng.xml')).read
end
describe '.new' do
it 'should instantiate' do
expect(Lastfm::Response.new(@ok)).to be_an_instance_of(Lastfm::Resp... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/method_specs/tasteometer_spec.rb | Ruby | mit | 248 | master | 847 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe '#tasteometer' do
before { init_lastfm }
it 'should return an instance of Lastfm::Tasteometer' do
expect(@lastfm.tasteometer).to be_an_instance_of(Lastfm::MethodCategory::Tasteometer)
end
describe '#compare' do
it 'should c... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/method_specs/user_spec.rb | Ruby | mit | 248 | master | 13,163 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe '#user' do
before { init_lastfm }
it 'should return an instance of Lastfm::User' do
expect(@lastfm.user).to be_an_instance_of(Lastfm::MethodCategory::User)
end
describe '#get_info' do
context 'with params' do
it 'shou... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/method_specs/album_spec.rb | Ruby | mit | 248 | master | 10,913 | # encoding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe '#album' do
before { init_lastfm }
it 'should return an instance of Lastfm::Album' do
expect(@lastfm.album).to be_an_instance_of(Lastfm::MethodCategory::Album)
end
describe '#add_tags' do
it 'should add ta... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/method_specs/track_spec.rb | Ruby | mit | 248 | master | 11,254 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe '#track' do
before { init_lastfm }
it 'should return an instance of Lastfm::Track' do
expect(@lastfm.track).to be_an_instance_of(Lastfm::MethodCategory::Track)
end
describe '#add_tags' do
it 'should add tags' do
expec... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/method_specs/geo_spec.rb | Ruby | mit | 248 | master | 1,326 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe '#geo' do
before { init_lastfm }
it 'should return an instance of Lastfm::Geo' do
expect(@lastfm.geo).to be_an_instance_of(Lastfm::MethodCategory::Geo)
end
describe '#get_events' do
it 'should get events' do
expect(@l... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/method_specs/chart_spec.rb | Ruby | mit | 248 | master | 2,532 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe '#chart' do
before { init_lastfm }
it 'should return an instance of Lastfm::Chart' do
expect(@lastfm.chart).to be_an_instance_of(Lastfm::MethodCategory::Chart)
end
describe '#get_hyped_artists' do
it 'should get hyped artis... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/method_specs/artist_spec.rb | Ruby | mit | 248 | master | 7,821 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe '#artist' do
before { init_lastfm }
it 'should return an instance of Lastfm::Artist' do
expect(@lastfm.artist).to be_an_instance_of(Lastfm::MethodCategory::Artist)
end
describe '#get_correction' do
it 'should get correction... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/method_specs/group_spec.rb | Ruby | mit | 248 | master | 683 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe '#group' do
before { init_lastfm }
it 'should return an instance of Lastfm::Group' do
expect(@lastfm.group).to be_an_instance_of(Lastfm::MethodCategory::Group)
end
describe '#get_members' do
it 'should get the members\' inf... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/method_specs/tag_spec.rb | Ruby | mit | 248 | master | 3,145 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe '#tag' do
before { init_lastfm }
it 'should return an instance of Lastfm::Tag' do
expect(@lastfm.tag).to be_an_instance_of(Lastfm::MethodCategory::Tag)
end
describe '#get_top_artists' do
it 'should get top artists of some t... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/method_specs/event_spec.rb | Ruby | mit | 248 | master | 505 | describe '#event' do
before { init_lastfm }
it 'should return an instance of Lastfm::Event' do
expect(@lastfm.event).to be_an_instance_of(Lastfm::MethodCategory::Event)
end
describe '#get_info' do
it 'should get info' do
expect(@lastfm).to receive(:request).with('event.getInfo', {
:event... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/method_specs/library_spec.rb | Ruby | mit | 248 | master | 1,221 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe '#library' do
before { init_lastfm }
it 'should return an instance of Lastfm::Library' do
expect(@lastfm.library).to be_an_instance_of(Lastfm::MethodCategory::Library)
end
describe '#get_tracks' do
it 'should get the tracks... |
github | youpy/ruby-lastfm | https://github.com/youpy/ruby-lastfm | spec/method_specs/radio_spec.rb | Ruby | mit | 248 | master | 1,543 | require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe '#radio' do
before { init_lastfm }
it 'should return an instance of Lastfm::Radio' do
expect(@lastfm.radio).to be_an_instance_of(Lastfm::MethodCategory::Radio)
end
describe '#tune' do
it 'should tune' do
expect(@lastf... |
github | myobie/htmldiff | https://github.com/myobie/htmldiff | htmldiff.gemspec | Ruby | mit | 248 | master | 639 | # frozen_string_literal: true
require_relative 'lib/html_diff/version'
Gem::Specification.new do |spec|
spec.name = 'htmldiff'
spec.version = HTMLDiff::VERSION
spec.authors = ['Nathan Herald', 'Johnny Shields']
spec.email = 'nathan@myobie.com'
spec.summary = 'HTML diffs of text'
spec.description = 'Genera... |
github | myobie/htmldiff | https://github.com/myobie/htmldiff | Rakefile | Ruby | mit | 248 | master | 440 | # frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rubygems/package_task'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task default: :spec
gemspec = Gem::Specification.load(File.expand_path('htmldiff.gemspec', __dir__))
Gem::PackageTask.new(gemspec) do |pkg|
pkg.gem_spec = gemsp... |
github | myobie/htmldiff | https://github.com/myobie/htmldiff | spec/spec_helper.rb | Ruby | mit | 248 | master | 481 | # frozen_string_literal: true
require 'bundler/setup'
require 'htmldiff'
RSpec.configure do |config|
config.disable_monkey_patching!
config.expect_with :rspec do |expectations|
expectations.syntax = :expect
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with... |
github | myobie/htmldiff | https://github.com/myobie/htmldiff | spec/html_diff/version_spec.rb | Ruby | mit | 248 | master | 213 | # frozen_string_literal: true
require_relative '../spec_helper'
RSpec.describe 'HTMLDiff::VERSION' do
it 'has a version number' do
expect(HTMLDiff::VERSION).to match(/\A\d+\.\d+\.\d+(?:-.+)?\z/)
end
end |
github | myobie/htmldiff | https://github.com/myobie/htmldiff | spec/html_diff/differ_spec.rb | Ruby | mit | 248 | master | 20,003 | # frozen_string_literal: true
require_relative '../spec_helper'
RSpec.describe HTMLDiff::Differ do
describe '.diff' do
let(:result) { described_class.diff(old_tokens, new_tokens) }
context 'basic case' do # rubocop:disable RSpec/ContextWording
let(:old_tokens) { ['a', ' ', 'word', ' ', 'now', ' ', 'i... |
github | myobie/htmldiff | https://github.com/myobie/htmldiff | spec/html_diff/diff_builder_spec.rb | Ruby | mit | 248 | master | 1,353 | # frozen_string_literal: true
require_relative '../spec_helper'
# rubocop:disable Style/ClassVars
RSpec.describe HTMLDiff::DiffBuilder do
let(:old_string) { 'This is an old string' }
let(:new_string) { 'This is a new string' }
describe '#initialize' do
it 'stores the old and new strings' do
builder =... |
github | myobie/htmldiff | https://github.com/myobie/htmldiff | spec/html_diff/html_formatter_spec.rb | Ruby | mit | 248 | master | 22,929 | # frozen_string_literal: true
require_relative '../spec_helper'
RSpec.describe HTMLDiff::HtmlFormatter do
let(:old_text) { 'The quick red fox jumped over the dog.' }
let(:new_text) { 'The red fox hopped over the lazy dog.' }
let(:example_changes) do
[
['=', 'The ', 'The '],
['-', 'quick ', nil],... |
github | myobie/htmldiff | https://github.com/myobie/htmldiff | spec/html_diff/tokenizer_spec.rb | Ruby | mit | 248 | master | 23,458 | # frozen_string_literal: true
require_relative '../spec_helper'
RSpec.describe HTMLDiff::Tokenizer do
describe '.tokenize' do
context 'with plain text' do
it 'tokenizes simple words' do
tokens = described_class.tokenize('Hello world')
expect(tokens).to eq(['Hello', ' ', 'world'])
end... |
github | myobie/htmldiff | https://github.com/myobie/htmldiff | spec/html_diff/html_diff_spec.rb | Ruby | mit | 248 | master | 20,811 | # frozen_string_literal: true
require_relative '../spec_helper'
RSpec.describe HTMLDiff do
let(:html_format) { { class_replace: 'mod' } }
let(:options) { { html_format: html_format }.compact }
let(:result) { described_class.diff(old_text, new_text, **options) }
describe '.diff' do
context 'when diffing b... |
github | myobie/htmldiff | https://github.com/myobie/htmldiff | lib/html_diff.rb | Ruby | mit | 248 | master | 1,623 | # frozen_string_literal: true
require 'html_diff/tokenizer'
require 'html_diff/differ'
require 'html_diff/html_formatter'
require 'html_diff/version'
require 'html_diff/diff_builder' # @deprecated
# Provides functionality for generating HTML-formatted diffs
# between two text strings.
module HTMLDiff
extend self
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.