repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
jjyr/minidown | https://github.com/jjyr/minidown/blob/675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a/lib/minidown/elements/block_element.rb | lib/minidown/elements/block_element.rb | module Minidown
class BlockElement < Element
BlockTagRegexp = /\A\s*\>\s*/
def parse
unparsed_lines.unshift content
nodes << self
while(child_line = unparsed_lines.shift) do
block = child_line.sub! BlockTagRegexp, ''
doc.parse_line(child_line)
child = nodes.pop
... | ruby | MIT | 675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a | 2026-01-04T17:48:47.033200Z | false |
jjyr/minidown | https://github.com/jjyr/minidown/blob/675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a/lib/minidown/elements/paragraph_element.rb | lib/minidown/elements/paragraph_element.rb | module Minidown
class ParagraphElement < Element
attr_reader :contents
attr_accessor :extra
ExcludeSchemeRegexp = /\A[^@:]+\z/
StringSymbolRegexp = /"|'/
def initialize *_
super
@contents = [raw_content]
@extra = false
end
def parse
if ParagraphElement === nodes.... | ruby | MIT | 675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a | 2026-01-04T17:48:47.033200Z | false |
jjyr/minidown | https://github.com/jjyr/minidown/blob/675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a/lib/minidown/elements/text_element.rb | lib/minidown/elements/text_element.rb | module Minidown
class TextElement < Element
EscapeChars = %w{# > * + \- ` _ { } ( ) . ! \[ \] ~}
EscapeRegexp = /(?<!\\)\\([#{EscapeChars.join '|'}|\\])/
Regexp = {
tag: /(\\*)<(.+?)(\\*)>/,
quot: /"/,
link: /(?<!\!)\[(.+?)\]\((.+?)\)/,
link_title: /((?<=").+?(?="... | ruby | MIT | 675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a | 2026-01-04T17:48:47.033200Z | false |
jjyr/minidown | https://github.com/jjyr/minidown/blob/675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a/lib/minidown/elements/list_element.rb | lib/minidown/elements/list_element.rb | module Minidown
class ListElement < Element
attr_accessor :p_tag_content, :contents, :task_list, :checked
CheckedBox = '<input type="checkbox" class="task-list-item-checkbox" checked="" disabled="">'.freeze
UnCheckedBox = '<input type="checkbox" class="task-list-item-checkbox" disabled="">'.freeze
de... | ruby | MIT | 675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a | 2026-01-04T17:48:47.033200Z | false |
jjyr/minidown | https://github.com/jjyr/minidown/blob/675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a/lib/minidown/elements/code_block_element.rb | lib/minidown/elements/code_block_element.rb | module Minidown
class CodeBlockElement < Element
def initialize *_
super
@code_block_handler = doc.options[:code_block_handler]
end
def parse
nodes << self
while(line = unparsed_lines.shift) do
case line
when Utils::Regexp[:code_block]
break
... | ruby | MIT | 675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a | 2026-01-04T17:48:47.033200Z | false |
jjyr/minidown | https://github.com/jjyr/minidown/blob/675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a/lib/minidown/elements/line_element.rb | lib/minidown/elements/line_element.rb | module Minidown
class LineElement < Element
attr_accessor :display
def initialize doc, content=nil
super
@display = true
end
def blank?
true
end
def parse
node = nodes.last
@display = (doc.within_block || TextElement === node)
nodes << self
en... | ruby | MIT | 675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a | 2026-01-04T17:48:47.033200Z | false |
jjyr/minidown | https://github.com/jjyr/minidown/blob/675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a/lib/minidown/elements/order_list_element.rb | lib/minidown/elements/order_list_element.rb | module Minidown
class OrderListElement < ListGroupElement
NestRegexp = /\A(\s*)\d+\.\s+(.+)/
ListRegexp = Minidown::Utils::Regexp[:order_list]
def initialize doc, line, indent_level = 0
super doc, line
@children << ListElement.new(doc, content)
@lists = @children.dup
@indent_l... | ruby | MIT | 675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a | 2026-01-04T17:48:47.033200Z | false |
jjyr/minidown | https://github.com/jjyr/minidown/blob/675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a/lib/minidown/elements/unorder_list_element.rb | lib/minidown/elements/unorder_list_element.rb | module Minidown
class UnorderListElement < ListGroupElement
TaskRegexp = /\A\[([ x])\](.+)/
NestRegexp = /\A(\s*)[*\-+]\s+(.+)/
ListRegexp = Minidown::Utils::Regexp[:unorder_list]
def initialize doc, line, indent_level = 0
super doc, line
if content =~ TaskRegexp
@task_ul ||= true... | ruby | MIT | 675e535bf6e559c4a2ae4174fbf1c7a160f8ed5a | 2026-01-04T17:48:47.033200Z | false |
teamcapybara/xpath | https://github.com/teamcapybara/xpath/blob/51839ed643d9f28e3df6913fd8ce63fa9379086c/spec/union_spec.rb | spec/union_spec.rb | # frozen_string_literal: true
require 'spec_helper'
describe XPath::Union do
let(:template) { File.read(File.expand_path('fixtures/simple.html', File.dirname(__FILE__))) }
let(:doc) { Nokogiri::HTML(template) }
describe '#expressions' do
it 'should return the expressions' do
@expr1 = XPath.generate {... | ruby | MIT | 51839ed643d9f28e3df6913fd8ce63fa9379086c | 2026-01-04T17:48:48.612235Z | false |
teamcapybara/xpath | https://github.com/teamcapybara/xpath/blob/51839ed643d9f28e3df6913fd8ce63fa9379086c/spec/xpath_spec.rb | spec/xpath_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'nokogiri'
class Thingy
include XPath
def foo_div
descendant(:div).where(attr(:id) == 'foo')
end
end
describe XPath do
let(:template) { File.read(File.expand_path('fixtures/simple.html', File.dirname(__FILE__))) }
let(:doc) { Nokogiri::HTML(... | ruby | MIT | 51839ed643d9f28e3df6913fd8ce63fa9379086c | 2026-01-04T17:48:48.612235Z | false |
teamcapybara/xpath | https://github.com/teamcapybara/xpath/blob/51839ed643d9f28e3df6913fd8ce63fa9379086c/spec/spec_helper.rb | spec/spec_helper.rb | # frozen_string_literal: true
require 'xpath'
require 'pry'
| ruby | MIT | 51839ed643d9f28e3df6913fd8ce63fa9379086c | 2026-01-04T17:48:48.612235Z | false |
teamcapybara/xpath | https://github.com/teamcapybara/xpath/blob/51839ed643d9f28e3df6913fd8ce63fa9379086c/lib/xpath.rb | lib/xpath.rb | # frozen_string_literal: true
require 'nokogiri'
require 'xpath/dsl'
require 'xpath/expression'
require 'xpath/literal'
require 'xpath/union'
require 'xpath/renderer'
module XPath
extend XPath::DSL
include XPath::DSL
def self.generate
yield(self)
end
end
| ruby | MIT | 51839ed643d9f28e3df6913fd8ce63fa9379086c | 2026-01-04T17:48:48.612235Z | false |
teamcapybara/xpath | https://github.com/teamcapybara/xpath/blob/51839ed643d9f28e3df6913fd8ce63fa9379086c/lib/xpath/version.rb | lib/xpath/version.rb | # frozen_string_literal: true
module XPath
VERSION = '3.2.0'
end
| ruby | MIT | 51839ed643d9f28e3df6913fd8ce63fa9379086c | 2026-01-04T17:48:48.612235Z | false |
teamcapybara/xpath | https://github.com/teamcapybara/xpath/blob/51839ed643d9f28e3df6913fd8ce63fa9379086c/lib/xpath/literal.rb | lib/xpath/literal.rb | # frozen_string_literal: true
module XPath
class Literal
attr_reader :value
def initialize(value)
@value = value
end
end
end
| ruby | MIT | 51839ed643d9f28e3df6913fd8ce63fa9379086c | 2026-01-04T17:48:48.612235Z | false |
teamcapybara/xpath | https://github.com/teamcapybara/xpath/blob/51839ed643d9f28e3df6913fd8ce63fa9379086c/lib/xpath/dsl.rb | lib/xpath/dsl.rb | # frozen_string_literal: true
module XPath
module DSL
def current
Expression.new(:this_node)
end
def descendant(*expressions)
Expression.new(:descendant, current, expressions)
end
def child(*expressions)
Expression.new(:child, current, expressions)
end
def axis(name, ... | ruby | MIT | 51839ed643d9f28e3df6913fd8ce63fa9379086c | 2026-01-04T17:48:48.612235Z | false |
teamcapybara/xpath | https://github.com/teamcapybara/xpath/blob/51839ed643d9f28e3df6913fd8ce63fa9379086c/lib/xpath/union.rb | lib/xpath/union.rb | # frozen_string_literal: true
module XPath
class Union
include Enumerable
attr_reader :expressions
alias_method :arguments, :expressions
def initialize(*expressions)
@expressions = expressions
end
def expression
:union
end
def each(&)
arguments.each(&)
end
... | ruby | MIT | 51839ed643d9f28e3df6913fd8ce63fa9379086c | 2026-01-04T17:48:48.612235Z | false |
teamcapybara/xpath | https://github.com/teamcapybara/xpath/blob/51839ed643d9f28e3df6913fd8ce63fa9379086c/lib/xpath/renderer.rb | lib/xpath/renderer.rb | # frozen_string_literal: true
module XPath
class Renderer
def self.render(node, type)
new(type).render(node)
end
def initialize(type)
@type = type
end
def render(node)
arguments = node.arguments.map { |argument| convert_argument(argument) }
send(node.expression, *argumen... | ruby | MIT | 51839ed643d9f28e3df6913fd8ce63fa9379086c | 2026-01-04T17:48:48.612235Z | false |
teamcapybara/xpath | https://github.com/teamcapybara/xpath/blob/51839ed643d9f28e3df6913fd8ce63fa9379086c/lib/xpath/expression.rb | lib/xpath/expression.rb | # frozen_string_literal: true
module XPath
class Expression
attr_accessor :expression, :arguments
include XPath::DSL
def initialize(expression, *arguments)
@expression = expression
@arguments = arguments
end
def current
self
end
def to_xpath(type = nil)
Rendere... | ruby | MIT | 51839ed643d9f28e3df6913fd8ce63fa9379086c | 2026-01-04T17:48:48.612235Z | false |
lostfilm/books-dl | https://github.com/lostfilm/books-dl/blob/8507e48c2d788c1c8233ba81c6952eaace848f5b/main.rb | main.rb | require_relative './lib/books_dl'
# 如何取得 book_id
# 進入你要下載的書的閱讀頁面,取得網址列中網址
# 例如:
# https://viewer-ebook.books.com.tw/viewer/epub/web/?book_uni_id=E050017049_reflowable_normal
# book_uni_id= 之後的字串就是這本書的 book_id 了
#
book_id = 'E050017049_reflowable_normal'
downloader = BooksDL::Downloader.new(book_id)
downloader.perfo... | ruby | MIT | 8507e48c2d788c1c8233ba81c6952eaace848f5b | 2026-01-04T17:48:51.215079Z | false |
lostfilm/books-dl | https://github.com/lostfilm/books-dl/blob/8507e48c2d788c1c8233ba81c6952eaace848f5b/spec/helpers.rb | spec/helpers.rb | module Helpers
RSPEC_ROOT_PATH = "#{__FILE__.split('/spec/').first}/spec".freeze
def file_fixture(file_name)
file_path = File.join(RSPEC_ROOT_PATH, 'fixtures', 'files', file_name)
File.open(file_path)
end
end
| ruby | MIT | 8507e48c2d788c1c8233ba81c6952eaace848f5b | 2026-01-04T17:48:51.215079Z | false |
lostfilm/books-dl | https://github.com/lostfilm/books-dl/blob/8507e48c2d788c1c8233ba81c6952eaace848f5b/spec/spec_helper.rb | spec/spec_helper.rb | # Load lib
require_relative '../lib/books_dl'
require_relative './helpers'
# This file was generated by the `rspec --init` 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 fil... | ruby | MIT | 8507e48c2d788c1c8233ba81c6952eaace848f5b | 2026-01-04T17:48:51.215079Z | false |
lostfilm/books-dl | https://github.com/lostfilm/books-dl/blob/8507e48c2d788c1c8233ba81c6952eaace848f5b/spec/books_dl/utils_spec.rb | spec/books_dl/utils_spec.rb | describe BooksDL::Utils do
let(:download_token) { file_fixture('download_token.txt').read }
let(:url) { 'https://streaming-ebook.books.com.tw/V1.0/Streaming/book/DD0CB3/952170/OEBPS/content.opf' }
let(:url2) { 'https://streaming-ebook.books.com.tw/V1.0/Streaming/book/DD0CB3/952170/META-INF/container.xml' }
des... | ruby | MIT | 8507e48c2d788c1c8233ba81c6952eaace848f5b | 2026-01-04T17:48:51.215079Z | false |
lostfilm/books-dl | https://github.com/lostfilm/books-dl/blob/8507e48c2d788c1c8233ba81c6952eaace848f5b/lib/books_dl.rb | lib/books_dl.rb | require 'rubygems'
require 'bundler'
require 'json'
require 'digest'
require 'io/console'
require 'ostruct'
Bundler.require(:default)
module BooksDL; end
Dir[File.join(__dir__, 'books_dl', '**', '*.rb')].each(&method(:require))
| ruby | MIT | 8507e48c2d788c1c8233ba81c6952eaace848f5b | 2026-01-04T17:48:51.215079Z | false |
lostfilm/books-dl | https://github.com/lostfilm/books-dl/blob/8507e48c2d788c1c8233ba81c6952eaace848f5b/lib/books_dl/utils.rb | lib/books_dl/utils.rb | module BooksDL
class Utils
def self.hex_to_byte(hex)
return [] unless hex.is_a?(String)
hex.scan(/../).map(&:hex)
end
def self.generate_key(url, download_token)
puts url
file_path = CGI.unescape(url.match(%r|https://(.*?/){3}.*?(?<rest_part>/.+)|)[:rest_part])
md5_chars = D... | ruby | MIT | 8507e48c2d788c1c8233ba81c6952eaace848f5b | 2026-01-04T17:48:51.215079Z | false |
lostfilm/books-dl | https://github.com/lostfilm/books-dl/blob/8507e48c2d788c1c8233ba81c6952eaace848f5b/lib/books_dl/api.rb | lib/books_dl/api.rb | module BooksDL
class API
attr_reader :current_cookie, :book_id, :encoded_token
COOKIE_FILE_NAME = 'cookie.json'.freeze
IMAGE_EXTENSIONS = %w[.bmp .gif .ico .jpeg .jpg .tiff .tif .svg .png .webp].freeze
NO_AUTH_EXTENSIONS = %w[.css .ttc .otf .ttf .eot .woff .woff2].freeze
# API ENDPOINTS
#
... | ruby | MIT | 8507e48c2d788c1c8233ba81c6952eaace848f5b | 2026-01-04T17:48:51.215079Z | false |
lostfilm/books-dl | https://github.com/lostfilm/books-dl/blob/8507e48c2d788c1c8233ba81c6952eaace848f5b/lib/books_dl/base_file.rb | lib/books_dl/base_file.rb | module BooksDL
class BaseFile
attr_reader :path, :content
def initialize(path, content)
@path = path
@content = content
end
end
end | ruby | MIT | 8507e48c2d788c1c8233ba81c6952eaace848f5b | 2026-01-04T17:48:51.215079Z | false |
lostfilm/books-dl | https://github.com/lostfilm/books-dl/blob/8507e48c2d788c1c8233ba81c6952eaace848f5b/lib/books_dl/downloader.rb | lib/books_dl/downloader.rb | require 'zip'
module BooksDL
class Downloader
attr_reader :api, :book, :book_id, :info
def initialize(book_id)
@book_id = book_id
@api = API.new(book_id)
@book = {
root_file_path: nil,
root_file: nil,
files: [
::BooksDL::BaseFile.new('mimetype', 'applicati... | ruby | MIT | 8507e48c2d788c1c8233ba81c6952eaace848f5b | 2026-01-04T17:48:51.215079Z | false |
lostfilm/books-dl | https://github.com/lostfilm/books-dl/blob/8507e48c2d788c1c8233ba81c6952eaace848f5b/lib/books_dl/files/content.rb | lib/books_dl/files/content.rb | module BooksDL
module Files
class Content < ::BooksDL::BaseFile
def file_paths
doc.css('item').map do |item|
::File.join(base_dir, item.attr('href')).to_s
end
end
def title
doc.remove_namespaces!
.css('title')
.first
.text
... | ruby | MIT | 8507e48c2d788c1c8233ba81c6952eaace848f5b | 2026-01-04T17:48:51.215079Z | false |
lostfilm/books-dl | https://github.com/lostfilm/books-dl/blob/8507e48c2d788c1c8233ba81c6952eaace848f5b/lib/books_dl/files/container.rb | lib/books_dl/files/container.rb | module BooksDL
module Files
class Container < ::BooksDL::BaseFile
def root_file_path
doc.css('rootfile').first.attr('full-path')
end
private
def doc
Nokogiri::XML(content)
end
end
end
end | ruby | MIT | 8507e48c2d788c1c8233ba81c6952eaace848f5b | 2026-01-04T17:48:51.215079Z | false |
isaacsanders/omniauth-stripe-connect | https://github.com/isaacsanders/omniauth-stripe-connect/blob/468dd9acaccdbba38a38cdbcdf7f10c17be25e89/spec/spec_helper.rb | spec/spec_helper.rb | require 'rspec'
require 'omniauth-stripe-connect'
| ruby | MIT | 468dd9acaccdbba38a38cdbcdf7f10c17be25e89 | 2026-01-04T17:48:51.752026Z | false |
isaacsanders/omniauth-stripe-connect | https://github.com/isaacsanders/omniauth-stripe-connect/blob/468dd9acaccdbba38a38cdbcdf7f10c17be25e89/spec/omniauth/strategies/stripe_connect_spec.rb | spec/omniauth/strategies/stripe_connect_spec.rb | require 'spec_helper'
describe OmniAuth::Strategies::StripeConnect do
let(:fresh_strategy) { Class.new(OmniAuth::Strategies::StripeConnect) }
before(:each) do
OmniAuth.config.test_mode = true
@old_host = OmniAuth.config.full_host
end
after(:each) do
OmniAuth.config.full_host = @old_host
Omni... | ruby | MIT | 468dd9acaccdbba38a38cdbcdf7f10c17be25e89 | 2026-01-04T17:48:51.752026Z | false |
isaacsanders/omniauth-stripe-connect | https://github.com/isaacsanders/omniauth-stripe-connect/blob/468dd9acaccdbba38a38cdbcdf7f10c17be25e89/lib/omniauth-stripe-connect.rb | lib/omniauth-stripe-connect.rb | require "omniauth-stripe-connect/version"
require 'omniauth/stripe_connect'
| ruby | MIT | 468dd9acaccdbba38a38cdbcdf7f10c17be25e89 | 2026-01-04T17:48:51.752026Z | false |
isaacsanders/omniauth-stripe-connect | https://github.com/isaacsanders/omniauth-stripe-connect/blob/468dd9acaccdbba38a38cdbcdf7f10c17be25e89/lib/omniauth-stripe-connect/version.rb | lib/omniauth-stripe-connect/version.rb | module OmniAuth
module StripeConnect
VERSION = "2.10.1"
end
end
| ruby | MIT | 468dd9acaccdbba38a38cdbcdf7f10c17be25e89 | 2026-01-04T17:48:51.752026Z | false |
isaacsanders/omniauth-stripe-connect | https://github.com/isaacsanders/omniauth-stripe-connect/blob/468dd9acaccdbba38a38cdbcdf7f10c17be25e89/lib/omniauth/stripe_connect.rb | lib/omniauth/stripe_connect.rb | require 'omniauth/strategies/stripe_connect'
| ruby | MIT | 468dd9acaccdbba38a38cdbcdf7f10c17be25e89 | 2026-01-04T17:48:51.752026Z | false |
isaacsanders/omniauth-stripe-connect | https://github.com/isaacsanders/omniauth-stripe-connect/blob/468dd9acaccdbba38a38cdbcdf7f10c17be25e89/lib/omniauth/strategies/stripe_connect.rb | lib/omniauth/strategies/stripe_connect.rb | require 'omniauth/strategies/oauth2'
module OmniAuth
module Strategies
class StripeConnect < OmniAuth::Strategies::OAuth2
option :name, :stripe_connect
option :client_options, {
:site => 'https://connect.stripe.com'
}
option :authorize_options, [:scope, :stripe_landing, :always_... | ruby | MIT | 468dd9acaccdbba38a38cdbcdf7f10c17be25e89 | 2026-01-04T17:48:51.752026Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/spec/spec_helper.rb | spec/spec_helper.rb | require 'simplecov'
SimpleCov.start
require 'bundler'
Bundler.require :default, :development
require 'completely'
require 'completely/cli'
include Completely
# Consistent Colsole output (for rspec_aprovals)
ENV['TTY'] = 'off'
ENV['COLUMNS'] = '80'
ENV['LINES'] = '30'
# Just in case the developer's environment conta... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/spec/completely/completions_spec.rb | spec/completely/completions_spec.rb | describe Completions do
subject { described_class.load path }
let(:path) { "spec/fixtures/#{file}.yaml" }
let(:file) { 'basic' }
describe '::read' do
it 'reads from io' do
io = double :io, read: 'cli: [--help, --version]'
expect(described_class.read(io).config.config).to eq({ 'cli' => %w[--hel... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/spec/completely/integration_spec.rb | spec/completely/integration_spec.rb | describe 'generated script' do
subject { Completions.load "#{fixture}.yaml" }
let(:response) do
Dir.chdir 'spec/fixtures/integration' do
subject.tester.test(compline).sort
end
end
config = YAML.load_file 'spec/completely/integration.yml'
config.each do |fixture, use_cases|
use_cases.each ... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/spec/completely/zsh_spec.rb | spec/completely/zsh_spec.rb | describe 'zsh compatibility' do
subject do
Dir.chdir 'spec/tmp' do
`#{shell} test.sh`.strip
end
end
let(:completions) { Completely::Completions.load 'spec/fixtures/basic.yaml' }
let(:words) { 'completely generate ' }
let(:tester_script) { completions.tester.tester_script words }
let(:shell) {... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/spec/completely/bin_spec.rb | spec/completely/bin_spec.rb | describe 'bin/completely' do
subject { CLI.runner }
it 'shows list of commands' do
expect { subject.run }.to output_approval('cli/commands')
end
context 'when an error occurs' do
it 'displays it nicely' do
expect(`bin/completely preview notfound.yaml 2>&1`).to match_approval('cli/error')
end... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/spec/completely/installer_spec.rb | spec/completely/installer_spec.rb | describe Installer do
subject { described_class.new program: program, script_path: script_path }
let(:leeway) { RUBY_VERSION < '3.2.0' ? 0 : 3 }
let(:program) { 'completely-test' }
let(:script_path) { 'completions.bash' }
let(:targets) { subject.target_directories.map { |dir| "#{dir}/#{program}" } }
let(:i... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/spec/completely/config_spec.rb | spec/completely/config_spec.rb | describe Config do
subject { described_class.load path }
let(:path) { "spec/fixtures/#{file}.yaml" }
let(:file) { 'nested' }
let(:config_string) { 'cli: [--help, --version]' }
let(:config_hash) { { 'cli' => %w[--help --version] } }
describe '::parse' do
it 'loads config from string' do
expect(de... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/spec/completely/tester_spec.rb | spec/completely/tester_spec.rb | describe Tester do
subject { described_class.new script_path: script_path, function_name: function_name }
let(:function_name) { '_cli_completions' }
let(:script_path) { "spec/fixtures/tester/#{fixture}.bash" }
let(:fixture) { 'default' }
let(:compline) { 'cli co' }
before :all do
# Create an up to dat... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/spec/completely/pattern_spec.rb | spec/completely/pattern_spec.rb | describe Pattern do
subject { described_class.new text, completions, function_name }
let(:text) { 'git commit' }
let(:completions) { %w[--message --help <file> <user>] }
let(:function_name) { '_filter' }
describe '#length' do
it 'returns the string length of the pattern text' do
expect(subject.len... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/spec/completely/commands/preview_spec.rb | spec/completely/commands/preview_spec.rb | describe Commands::Preview do
subject { described_class.new }
before { system 'cp lib/completely/templates/sample.yaml completely.yaml' }
after { system 'rm -f completely.yaml' }
context 'with --help' do
it 'shows long usage' do
expect { subject.execute %w[preview --help] }.to output_approval('cli/... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/spec/completely/commands/install_spec.rb | spec/completely/commands/install_spec.rb | describe Commands::Install do
subject { described_class.new }
let(:leeway) { RUBY_VERSION < '3.2.0' ? 0 : 5 }
let :mock_installer do
instance_double Installer,
install: true,
target_path: 'some-target-path',
install_command_string: 'sudo cp source target'
end
... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/spec/completely/commands/generate_spec.rb | spec/completely/commands/generate_spec.rb | describe Commands::Generate do
subject { described_class.new }
before do
reset_tmp_dir
system 'cp lib/completely/templates/sample.yaml completely.yaml'
end
after do
system 'rm -f completely.yaml'
end
context 'with --help' do
it 'shows long usage' do
expect { subject.execute %w[gener... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/spec/completely/commands/init_spec.rb | spec/completely/commands/init_spec.rb | describe Commands::Init do
subject { described_class.new }
before { system 'rm -f completely.yaml' }
after { system 'rm -f completely.yaml' }
let(:sample) { File.read 'lib/completely/templates/sample.yaml' }
let(:sample_nested) { File.read 'lib/completely/templates/sample-nested.yaml' }
context 'with --... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/spec/completely/commands/uninstall_spec.rb | spec/completely/commands/uninstall_spec.rb | describe Commands::Uninstall do
subject { described_class.new }
let(:leeway) { RUBY_VERSION < '3.2.0' ? 0 : 5 }
let :mock_installer do
instance_double Installer,
uninstall: true,
uninstall_command_string: 'rm -f some paths'
end
context 'with --help' do
it 'shows long usage... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/spec/completely/commands/test_spec.rb | spec/completely/commands/test_spec.rb | describe Commands::Test do
subject { described_class.new }
before do
system 'cp lib/completely/templates/sample.yaml completely.yaml'
ENV['COMPLETELY_CONFIG_PATH'] = nil
end
after { system 'rm -f completely.yaml' }
context 'with --help' do
it 'shows long usage' do
expect { subject.execute... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely.rb | lib/completely.rb | require 'completely/exceptions'
require 'completely/config'
require 'completely/pattern'
require 'completely/completions'
require 'completely/tester'
require 'completely/installer'
require 'debug' if ENV['COMPLETELY_DEV']
| ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely/version.rb | lib/completely/version.rb | module Completely
VERSION = '0.7.3'
end
| ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely/exceptions.rb | lib/completely/exceptions.rb | module Completely
class Error < StandardError; end
class InstallError < Error; end
class ParseError < Error; end
end
| ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely/completions.rb | lib/completely/completions.rb | require 'yaml'
require 'erb'
module Completely
class Completions
attr_reader :config
class << self
def load(path, function_name: nil)
new Config.load(path), function_name: function_name
end
def read(io, function_name: nil)
new Config.read(io), function_name: function_name
... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely/installer.rb | lib/completely/installer.rb | module Completely
class Installer
class << self
def from_io(program:, io: nil)
io ||= $stdin
raise InstallError, 'io must respond to #read' unless io.respond_to?(:read)
raise InstallError, 'io is closed' if io.respond_to?(:closed?) && io.closed?
from_string program:, string... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely/cli.rb | lib/completely/cli.rb | require 'mister_bin'
require 'completely/commands/generate'
require 'completely/commands/init'
require 'completely/commands/install'
require 'completely/commands/preview'
require 'completely/commands/test'
require 'completely/commands/uninstall'
require 'completely/version'
module Completely
class CLI
def self.r... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely/pattern.rb | lib/completely/pattern.rb | module Completely
class Pattern
attr_reader :text, :completions, :function_name
def initialize(text, completions, function_name)
@text = text
@completions = completions || []
@function_name = function_name
end
def length
@length ||= text.size
end
def empty?
com... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely/config.rb | lib/completely/config.rb | module Completely
class Config
attr_reader :config, :options
class << self
def parse(str)
new YAML.load(str, aliases: true)
rescue Psych::Exception => e
raise ParseError, "Invalid YAML: #{e.message}"
end
def load(path) = parse(File.read(path))
def read(io) = par... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely/tester.rb | lib/completely/tester.rb | require 'erb'
require 'tempfile'
module Completely
class Tester
attr_reader :script, :script_path, :function_name, :cword, :compline
def initialize(function_name:, script: nil, script_path: nil)
@script = script
@script_path = script_path
@function_name = function_name
end
def tes... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely/commands/test.rb | lib/completely/commands/test.rb | require 'completely/commands/base'
module Completely
module Commands
class Test < Base
summary 'Test completions'
help 'This command can be used to test that your completions script responds with ' \
'the right completions. It works by reading your completely.yaml file, generating ' \
... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely/commands/generate.rb | lib/completely/commands/generate.rb | require 'completely/commands/base'
module Completely
module Commands
class Generate < Base
help 'Generate the bash completion script to file or stdout'
usage 'completely generate [CONFIG_PATH OUTPUT_PATH --function NAME --wrap NAME]'
usage 'completely generate [CONFIG_PATH --install PROGRAM --... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely/commands/uninstall.rb | lib/completely/commands/uninstall.rb | require 'completely/commands/base'
module Completely
module Commands
class Uninstall < Base
summary 'Uninstall a bash completion script'
help <<~HELP
This command will remove the completion script for the specified program from all the bash completion directories.
HELP
usage 'co... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely/commands/preview.rb | lib/completely/commands/preview.rb | require 'completely/commands/base'
module Completely
module Commands
class Preview < Base
help 'Generate the bash completion script to stdout'
usage 'completely preview [CONFIG_PATH --function NAME]'
usage 'completely preview (-h|--help)'
option_function
param_config_path
en... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely/commands/base.rb | lib/completely/commands/base.rb | require 'mister_bin'
module Completely
module Commands
class Base < MisterBin::Command
class << self
def param_config_path
param 'CONFIG_PATH', <<~USAGE
Path to the YAML configuration file [default: completely.yaml].
Can also be set by an environment variable.
... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely/commands/install.rb | lib/completely/commands/install.rb | require 'completely/commands/base'
module Completely
module Commands
class Install < Base
summary 'Install a bash completion script'
help <<~HELP
This command will copy the specified file to one of the bash completion directories.
The target filename will be the program name, and sud... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
bashly-framework/completely | https://github.com/bashly-framework/completely/blob/371d3bc27200bacdb2107d73dba9f719e79a69f2/lib/completely/commands/init.rb | lib/completely/commands/init.rb | require 'completely/commands/base'
module Completely
module Commands
class Init < Base
help 'Create a new sample YAML configuration file'
usage 'completely init [--nested] [CONFIG_PATH]'
usage 'completely init (-h|--help)'
option '-n --nested', 'Generate a nested configuration'
p... | ruby | MIT | 371d3bc27200bacdb2107d73dba9f719e79a69f2 | 2026-01-04T17:48:51.287282Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/concerns/time_in_time_zone.rb | app/concerns/time_in_time_zone.rb | module TimeInTimeZone
extend ActiveSupport::Concern
private
def today
time_now.to_date
end
def time_now
Time.now.in_time_zone(time_zone)
end
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/concerns/hash_lookup_helper.rb | app/concerns/hash_lookup_helper.rb | module HashLookupHelper
extend ActiveSupport::Concern
private
def hash_lookup(hash, *keys)
last_value = hash
keys.each do |key|
return unless last_value
last_value = last_value[key]
end
last_value
end
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/helpers/sites_helper.rb | app/helpers/sites_helper.rb | module SitesHelper
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/helpers/users_helper.rb | app/helpers/users_helper.rb | module UsersHelper
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/helpers/application_helper.rb | app/helpers/application_helper.rb | module ApplicationHelper
def navigation(&block)
content_tag(:nav) do
content_tag(:ul, &block)
end
end
def navigate_to(identifier, body, url, html_options={})
classes = html_options[:class] || []
classes = classes.split(" ") unless classes.is_a?(Array)
classes << "active" if @navigation... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/helpers/pages_helper.rb | app/helpers/pages_helper.rb | module PagesHelper
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/helpers/accounts_helper.rb | app/helpers/accounts_helper.rb | module AccountsHelper
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/helpers/sensors_helper.rb | app/helpers/sensors_helper.rb | module SensorsHelper
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/controllers/sensors_controller.rb | app/controllers/sensors_controller.rb | class SensorsController < ApplicationController
respond_to :html, :except => [:chart]
respond_to :json, :only => [:chart]
navigation :sites
def index
@sensors = site.sensors
respond_with @sensors
end
def show
respond_with sensor
end
def new
@sensor = site.sensors.new
respond_wit... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/controllers/sites_controller.rb | app/controllers/sites_controller.rb | class SitesController < ApplicationController
respond_to :html, :except => [:counters, :chart]
respond_to :json, :only => [:counters, :chart]
navigation :sites
def index
@sites = Site.order(:name)
respond_with @sites
end
def show
respond_with resource
end
def new
respond_with(@site =... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/controllers/users_controller.rb | app/controllers/users_controller.rb | class UsersController < ApplicationController
respond_to :html
navigation :users
def index
@users = User.order(:email)
respond_with @users
end
def show
respond_with resource
end
def new
respond_with(@user = User.new)
end
def create
@user = User.new(params[:user])
if @user... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/controllers/pages_controller.rb | app/controllers/pages_controller.rb | class PagesController < ApplicationController
respond_to :html, :except => [:counters, :chart]
respond_to :json, :only => [:counters, :chart]
def show
respond_with page
rescue ActiveRecord::RecordNotFound
render :not_found
end
def find
uri = Snowfinch::Collector.sanitize_uri(params[:page][:uri... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/controllers/application_controller.rb | app/controllers/application_controller.rb | class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :authenticate_user!
private
def user_root_path
sites_path
end
def navigation(identifier)
@navigation_id = identifier
end
def self.navigation(identifier)
before_filter { navigation(identifier) }
... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/controllers/accounts_controller.rb | app/controllers/accounts_controller.rb | class AccountsController < ApplicationController
respond_to :html
navigation :account
def edit
respond_with user
end
def update
if user.update_with_password(params[:user])
sign_in(user, :bypass => true)
flash.notice = "Your account has been updated."
end
respond_with user, :locat... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/models/page.rb | app/models/page.rb | class Page
include TimeInTimeZone
include HashLookupHelper
delegate :time_zone, :to => :site
delegate :[], :to => :@document
def self.find(site, hash, year=Date.today.year)
document = Mongo.db["page_counts"].find_one(:h => hash, :s => site.bson_id)
if document
new(document)
else
rai... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/models/sensor_host.rb | app/models/sensor_host.rb | class SensorHost < ActiveRecord::Base
belongs_to :sensor
validates_presence_of :host
validates_uniqueness_of :host, :scope => :sensor_id
after_save :sync_with_mongodb
private
def sync_with_mongodb
sensor.send(:sync_with_mongodb)
end
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/models/sensor.rb | app/models/sensor.rb | class Sensor < ActiveRecord::Base
include TimeInTimeZone
include HashLookupHelper
has_many :hosts, :class_name => "SensorHost"
belongs_to :site
accepts_nested_attributes_for :hosts,
:allow_destroy => true,
:reject_if => proc { |attributes| attributes["host"].strip.empty? }
validates_associated :h... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/models/site.rb | app/models/site.rb | class Site < ActiveRecord::Base
include TimeInTimeZone
include HashLookupHelper
has_many :sensors, :dependent => :destroy
validates_presence_of :name, :time_zone
before_create :create_mongo_site
after_rollback :remove_mongo_site
after_destroy :remove_mongo_site
def time_zone_id
ActiveSupport::Ti... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/models/user.rb | app/models/user.rb | class User < ActiveRecord::Base
devise :database_authenticatable, :lockable, :recoverable, :rememberable,
:trackable, :validatable
attr_accessible :email, :password, :password_confirmation, :remember_me
before_validation :generate_password_if_unset, :on => :create
after_create :send_account_inform... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/app/mailers/user_mailer.rb | app/mailers/user_mailer.rb | class UserMailer < ActionMailer::Base
default :from => Snowfinch.configuration[:mailer_sender]
def account_information(user)
@user = user
@host = Snowfinch.configuration[:host]
mail :to => @user.email, :subject => "Account for #{@host}"
end
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/db/seeds.rb | db/seeds.rb | User.create! :email => "user@snowfinch.net", :password => "snowfinch"
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/db/schema.rb | db/schema.rb | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# dat... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/db/migrate/20110410155204_remove_password_salt_from_users.rb | db/migrate/20110410155204_remove_password_salt_from_users.rb | class RemovePasswordSaltFromUsers < ActiveRecord::Migration
def self.up
remove_column :users, :password_salt
end
def self.down
end
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/db/migrate/20110216145846_devise_create_users.rb | db/migrate/20110216145846_devise_create_users.rb | class DeviseCreateUsers < ActiveRecord::Migration
def self.up
create_table(:users) do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
t.encryptable
t.timestamp... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/db/migrate/20110316161329_add_type_and_query_fields_to_sensors.rb | db/migrate/20110316161329_add_type_and_query_fields_to_sensors.rb | class AddTypeAndQueryFieldsToSensors < ActiveRecord::Migration
def self.up
add_column :sensors, :type, :string
add_column :sensors, :uri_query_key, :string
add_column :sensors, :uri_query_value, :string
end
def self.down
remove_column :sensors, :uri_query_value
remove_column :sensors, :uri_qu... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/db/migrate/20110303181824_add_time_zone_to_sites.rb | db/migrate/20110303181824_add_time_zone_to_sites.rb | class AddTimeZoneToSites < ActiveRecord::Migration
def self.up
add_column :sites, :time_zone, :string
end
def self.down
remove_column :sites, :time_zone
end
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/db/migrate/20110228121355_add_token_to_sites.rb | db/migrate/20110228121355_add_token_to_sites.rb | class AddTokenToSites < ActiveRecord::Migration
def self.up
add_column :sites, :token, :string
end
def self.down
remove_column :sites, :token
end
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/db/migrate/20110311114859_create_sensors.rb | db/migrate/20110311114859_create_sensors.rb | class CreateSensors < ActiveRecord::Migration
def self.up
create_table :sensors do |t|
t.string :name
t.integer :site_id
t.timestamps
end
add_index :sensors, :site_id
end
def self.down
drop_table :sensors
end
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/db/migrate/20110316184425_create_sensor_hosts.rb | db/migrate/20110316184425_create_sensor_hosts.rb | class CreateSensorHosts < ActiveRecord::Migration
def self.up
create_table :sensor_hosts do |t|
t.string :host
t.integer :sensor_id
end
add_index :sensor_hosts, :sensor_id
end
def self.down
drop_table :sensor_hosts
end
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/db/migrate/20110219100357_create_sites.rb | db/migrate/20110219100357_create_sites.rb | class CreateSites < ActiveRecord::Migration
def self.up
create_table :sites do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :sites
end
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/autotest/discover.rb | autotest/discover.rb | require "autotest/growl"
Autotest.add_discovery { "rails" }
Autotest.add_discovery { "rspec2" }
Autotest.add_hook :initialize do |at|
at.add_mapping(/^spec\/acceptance\/.*_spec.rb$/) { |f| f }
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/factories.rb | spec/factories.rb | FactoryGirl.define do
sequence :email do |i|
"user-#{i}@snowfinch.net"
end
factory :user do
email
password "123456"
end
factory :site do
name "Snowfinch"
time_zone "Helsinki"
end
factory :sensor do
name "Social Media"
type "host"
site
end
factory :sensor_host do
... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/spec_helper.rb | spec/spec_helper.rb | require "simplecov"
SimpleCov.start do
add_filter "config/initializers"
add_filter "spec/acceptance/support"
end
ENV["RAILS_ENV"] ||= "test"
require File.expand_path("../../config/environment", __FILE__)
require "rspec/rails"
require "shoulda-matchers"
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| requir... | ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
jcxplorer/snowfinch | https://github.com/jcxplorer/snowfinch/blob/ffe6032de2adce64d3bea78cce401e7c9f75b701/spec/helpers/accounts_helper_spec.rb | spec/helpers/accounts_helper_spec.rb | require 'spec_helper'
describe AccountsHelper do
end
| ruby | MIT | ffe6032de2adce64d3bea78cce401e7c9f75b701 | 2026-01-04T17:48:47.586566Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.