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 | jferris/effigy | https://github.com/jferris/effigy | features/step_definitions/rails_steps.rb | Ruby | mit | 206 | master | 1,168 | When /^I generate a new rails app$/ do
run_simple 'rails new testapp ' \
'--skip-git ' \
'--skip-bundle ' \
'--skip-sprockets ' \
'--skip-test-unit ' \
'--skip-javascript'
cd 'testapp'
end
When /^I add "([^"]*)" from this project as a dependency$/ do |gem_name|
append_to_file('Gemfile', %{\ng... |
github | jferris/effigy | https://github.com/jferris/effigy | features/support/rails_server.rb | Ruby | mit | 206 | master | 1,778 | require 'net/http'
# Starts a Rails application server in a fork and waits for it to be responsive
class RailsServer
HOST = 'localhost'.freeze
class << self
attr_accessor :instance
end
def self.start(port = nil)
self.instance = new(port)
self.instance.start
end
def self.stop
self.instanc... |
github | jferris/effigy | https://github.com/jferris/effigy | spec/spec_helper.rb | Ruby | mit | 206 | master | 388 | require 'rspec'
require 'rails/all'
require 'ammeter/init'
PROJECT_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')).freeze
RAILS_ROOT = File.join(PROJECT_ROOT, 'tmp', 'rails_root')
$: << File.join(PROJECT_ROOT, 'lib')
Dir[File.join(PROJECT_ROOT, 'spec', 'support', '**', '*.rb')].each { |file| require... |
github | jferris/effigy | https://github.com/jferris/effigy | spec/support/have_selector.rb | Ruby | mit | 206 | master | 1,455 | module Matchers
class HaveSelector
def initialize(selector, attrs)
@selector = selector
@attrs = attrs
@contents = attrs.delete(:contents)
end
def matches?(xml)
@xml = xml.to_s
verify_element_present! &&
verify_contents! &&
verify_attrs!
end
... |
github | jferris/effigy | https://github.com/jferris/effigy | spec/effigy/example_element_transformer_spec.rb | Ruby | mit | 206 | master | 1,057 | require 'spec_helper'
require 'effigy/example_element_transformer'
require 'effigy/view'
describe Effigy::ExampleElementTransformer do
it "should replace all selected elements with a clone for each item in a collection" do
view = Effigy::View.new
class << view
def transform
elements = select('e... |
github | jferris/effigy | https://github.com/jferris/effigy | spec/effigy/nokogiri_ext_spec.rb | Ruby | mit | 206 | master | 964 | require 'spec_helper'
require 'effigy/nokogiri_ext'
describe Nokogiri::XML::Node do
it "should merge the given attributes" do
html = %{<node one="abc" two="def" />}
document = Nokogiri::HTML.parse(html)
node = document.at("//node")
node.merge!('two' => '2', :three => '3')
result = document.to_h... |
github | jferris/effigy | https://github.com/jferris/effigy | spec/effigy/selection_spec.rb | Ruby | mit | 206 | master | 994 | require 'spec_helper'
require 'effigy/selection'
module Effigy
describe Selection do
%w(text).each do |method|
it "should delegate #{method} to its view" do
view = stub('a view')
selector = '.findme'
arguments = [1, 2, 3]
view.should_receive(method).with(selector, *arguments... |
github | jferris/effigy | https://github.com/jferris/effigy | spec/effigy/view_spec.rb | Ruby | mit | 206 | master | 7,842 | require 'spec_helper'
require 'effigy/view'
module Effigy
describe View do
it "should replace element text" do
template = %{<test>
<element one="abc">something</element>
<element two="abc">else</element>
</test>}
view = Effigy::View.new
... |
github | jferris/effigy | https://github.com/jferris/effigy | spec/effigy/class_list_spec.rb | Ruby | mit | 206 | master | 2,441 | require 'spec_helper'
require 'effigy/class_list'
describe Effigy::ClassList do
it "should add a class name to an element with one existing class name" do
element = Nokogiri::XML.parse(%{<test class="original"/>}).at("//test")
class_list = Effigy::ClassList.new(element)
class_list.add %w(another)
el... |
github | jferris/effigy | https://github.com/jferris/effigy | spec/effigy/core_ext/object_spec.rb | Ruby | mit | 206 | master | 252 | require 'spec_helper'
require 'effigy/core_ext/object'
describe Object do
it "should return itself as the key of an effigy attribute hash" do
key = :key
value = :value
key.to_effigy_attributes(value).should == { key => value }
end
end |
github | jferris/effigy | https://github.com/jferris/effigy | spec/effigy/core_ext/hash_spec.rb | Ruby | mit | 206 | master | 214 | require 'spec_helper'
require 'effigy/core_ext/hash'
describe Hash do
it "should return itself as an attribute hash" do
hash = { :key => :value }
hash.to_effigy_attributes(nil).should == hash
end
end |
github | jferris/effigy | https://github.com/jferris/effigy | spec/generators/effigy/view/view_generator_spec.rb | Ruby | mit | 206 | master | 1,415 | require 'spec_helper'
require 'generators/effigy/view/view_generator'
describe Effigy::Generators::ViewGenerator do
destination File.join(PROJECT_ROOT, 'tmp')
before { prepare_destination }
it 'generates an action view and template with the given name' do
run_generator %w(users create)
view = file('app... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | harmonious_dictionary.gemspec | Ruby | mit | 206 | master | 983 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "harmonious_dictionary/version"
Gem::Specification.new do |s|
s.name = "harmonious_dictionary"
s.version = HarmoniousDictionary::VERSION
s.authors = ["Stephen Kong"]
s.email = ["wear63659220@gmail.com"]
s.home... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | lib/harmonious_dictionary.rb | Ruby | mit | 206 | master | 1,326 | # encoding: utf-8
require "harmonious_dictionary/rseg"
require "harmonious_dictionary/version"
require "harmonious_dictionary/model_additions"
require "harmonious_dictionary/railtie" if defined? Rails
module HarmoniousDictionary
def self.clean?(input, model = nil)
results = HarmoniousDictionary::Rseg.segmen... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | lib/generators/harmonious_dictionary/setup/setup_generator.rb | Ruby | mit | 206 | master | 615 | require "rails/generators"
module HarmoniousDictionary
module Generators
class SetupGenerator < ::Rails::Generators::Base
desc "This generator creates necessary at config/harmonious_dictionary"
source_root File.expand_path("../templates", __FILE__)
def generate_setup
#copy_file "remo... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | lib/tasks/generate_dictionary.rake | Ruby | mit | 206 | master | 1,769 | require 'yaml'
namespace :harmonious_dictionary do
desc "generate harmonious dictionary for use"
task :generate => :environment do
chinese_dictionary_path = File.join(Rails.root, 'config','harmonious_dictionary','chinese_dictionary.txt')
english_dictionary_path = File.join(Rails.root, 'config','harmonious_... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | lib/harmonious_dictionary/rseg.rb | Ruby | mit | 206 | master | 4,682 | # encoding: utf-8
require 'singleton'
require 'net/http'
require 'yaml'
require File.join(File.dirname(__FILE__), 'engines/engine')
require File.join(File.dirname(__FILE__), 'engines/dict')
require File.join(File.dirname(__FILE__), 'engines/english')
require File.join(File.dirname(__FILE__), 'filters/fullwidth')
req... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | lib/harmonious_dictionary/app.rb | Ruby | mit | 206 | master | 413 | require 'sinatra/base'
module HarmoniousDictionary
class App < Sinatra::Base
set :root, File.dirname(__FILE__) + "/.."
set :app_file, __FILE__
post '/segment' do
@input = params[:input]
@result = HarmoniousDictionary::Rseg.segment(@input).join(' ')
end
post '/seg' do
@input ... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | lib/harmonious_dictionary/model_additions.rb | Ruby | mit | 206 | master | 706 | # encoding: utf-8
module HarmoniousDictionary
module ModelAdditions
def validate_harmonious_of(attr_names, option = {})
configuration = {message:'不能含有敏感词'}
library = option.values[0].to_s
configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash)
validates_each attr_names do |mod... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | lib/harmonious_dictionary/railtie.rb | Ruby | mit | 206 | master | 592 | module HarmoniousDictionary
class Railtie < Rails::Railtie
# config.harmonious_dictionary = ActiveSupport::OrderedOptions.new
# config.harmonious_dictionary.use_remote_server = false
# config.after_initialize do
# if config.harmonious_dictionary.use_remote_server
# Rseg.instance.load_remote_... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | lib/harmonious_dictionary/filters/fullwidth.rb | Ruby | mit | 206 | master | 1,376 | # encoding: utf-8
module RsegFilter
class Fullwidth
@@fullwidth_chars = {'1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8',
'9' => '9', '0' => '0', 'a' => 'a', 'b' => 'b', 'c' => 'c', 'd' => 'd', 'e' => 'e', 'f' => 'f',
'g... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | lib/harmonious_dictionary/filters/symbol.rb | Ruby | mit | 206 | master | 735 | # encoding: utf-8
require 'set'
module RsegFilter
class Symbol
@@separators = Set.new ['`', '[', ']', '、', '=', '‘', ';', '。', '|', '?', '》',
'《', ':', '“', '{', '}', ')', '(', '*', '…', '#', '!',
'~', '’', '”', '〕', '〈', '〉', '「', '」', '『', '』', '〖', '〗',
... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | lib/harmonious_dictionary/filters/conjunction.rb | Ruby | mit | 206 | master | 328 | # encoding: utf-8
require 'set'
module RsegFilter
class Conjunction
@@conjunctions = Set.new %W(给 的 说 对 在 和 是 被 最 所 那 由 这 有 将 你 会 与 他 为 不 没 很 了 啊 哦 呵 把 去 从)
def self.filter(char)
@@conjunctions.include?(char) ? :conjunction : char
end
end
end |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | lib/harmonious_dictionary/engines/engine.rb | Ruby | mit | 206 | master | 296 | module HarmoniousDictionary
module RsegEngine
class Engine
def initialize
@running = true
end
def stop
@running = false
end
def run
@running = true
end
def running?
@running
end
end
end
end |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | lib/harmonious_dictionary/engines/dict.rb | Ruby | mit | 206 | master | 961 | module HarmoniousDictionary
module RsegEngine
class Dict < Engine
def initialize(&block)
@dict_path = block.call
@word = ''
super
end
def dictionary
@@root
end
def process(char)
@root ||= load_dict(@dict_path)
@node ||= @root
... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | lib/harmonious_dictionary/engines/english.rb | Ruby | mit | 206 | master | 528 | require 'set'
module HarmoniousDictionary
module RsegEngine
LETTER_SYMBOLS = Set.new ('a'..'z').to_a + ('A'..'Z').to_a
class English < Engine
def initialize
@word = ''
super
end
def process(char)
match = false
word = nil
if LETTER_SYMBOLS... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | benchmark/benchmark.rb | Ruby | mit | 206 | master | 1,067 | require 'rubygems'
require 'benchmark'
# 测试前现在本地建立词库索引
# 如需独立服务,测试前请先把切词服务起起来 bin/rseg_server
require_relative "../lib/harmonious_dictionary"
module Rails
def self.root
File.join File.dirname(__FILE__),'../'
end
def self.env
'test'
end
end
%w(100 1000 10000).each do |word_count|
puts "\n --#{wor... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | spec/harmonious_dictionary_spec.rb | Ruby | mit | 206 | master | 2,039 | # encoding: utf-8
require 'spec_helper'
describe HarmoniousDictionary do
describe 'local' do
describe 'segment' do
it 'should return harmonious word for sentence' do
HarmoniousDictionary.harmonious_words('戴秉国在中国').should == ['戴秉国']
end
it 'should return harmonious word for sentence u... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | spec/spec_helper.rb | Ruby | mit | 206 | master | 335 | require 'rubygems'
require 'rails'
require 'active_model'
require 'active_record'
require 'harmonious_dictionary'
RSpec.configure do |config|
config.color_enabled = true
config.formatter = 'documentation'
end
module Rails
def self.root
File.join File.dirname(__FILE__),'../'
end
def self.env
't... |
github | wear/harmonious_dictionary | https://github.com/wear/harmonious_dictionary | spec/model_additions_spec.rb | Ruby | mit | 206 | master | 1,752 | # encoding: utf-8
require 'spec_helper'
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
ActiveRecord::Schema.define(:version => 1) do
create_table :posts do |t|
t.string :title
t.text :body
t.text :note
end
end
class Post < ActiveRecord::Base
extend Harmo... |
github | DocSpring/libreconv | https://github.com/DocSpring/libreconv | libreconv.gemspec | Ruby | mit | 206 | master | 1,180 | # encoding: UTF-8
# frozen_string_literal: true
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'libreconv/version'
Gem::Specification.new do |spec|
spec.name = 'libreconv'
spec.version = Libreconv::VERSION
spec.authors = ['Richard ... |
github | DocSpring/libreconv | https://github.com/DocSpring/libreconv | spec/libreconv_spec.rb | Ruby | mit | 206 | master | 420 | # frozen_string_literal: true
RSpec.describe Libreconv do
it 'has a version number' do
expect(Libreconv::VERSION).to be_truthy
end
describe '.convert' do
it 'converts an office file to the specified target pdf' do
create_tmpfile(['', '.pdf']) do |target_file|
described_class.convert(fixtur... |
github | DocSpring/libreconv | https://github.com/DocSpring/libreconv | spec/spec_helper.rb | Ruby | mit | 206 | master | 955 | # frozen_string_literal: true
require 'bundler/setup'
require 'libreconv'
require 'webmock/rspec'
module Helpers
FILE_TYPES = %w[docx doc pptx ppt xlsx xls].map(&:to_sym).freeze
# @return [String]
def fixture_path(*paths)
File.join(File.expand_path('../fixtures', __FILE__), *paths)
end
# @return [Str... |
github | DocSpring/libreconv | https://github.com/DocSpring/libreconv | spec/libreconv/converter_check_url_spec.rb | Ruby | mit | 206 | master | 1,344 | # frozen_string_literal: true
RSpec.describe Libreconv::Converter do
let(:converter) { described_class.new fixture_file, '/', fixture_path('soffice') }
describe '#check_valid_url' do
it 'returns false for non-HTTP url' do
expect(converter.send(:check_valid_url, 'ftp://test.com/')).to eq false
end
... |
github | DocSpring/libreconv | https://github.com/DocSpring/libreconv | spec/libreconv/converter_convert_spec.rb | Ruby | mit | 206 | master | 725 | # frozen_string_literal: true
RSpec.describe Libreconv::Converter do
describe '#convert' do
it 'converts a file to the specified target html' do
create_tmpfile(['', '.html']) do |target_file|
described_class.new(fixture_file, target_file, nil, 'html').convert
expect(File.size?(target_file)... |
github | DocSpring/libreconv | https://github.com/DocSpring/libreconv | spec/libreconv/converter_spec.rb | Ruby | mit | 206 | master | 1,041 | # frozen_string_literal: true
RSpec.describe Libreconv::Converter do
describe '.new' do
it 'raises error if soffice command does not exists' do
expect do
described_class.new fixture_file, '/target', '/Whatever/soffice'
end.to raise_error(IOError, /\bCan't find .*\bExecutable\b/i)
end
... |
github | DocSpring/libreconv | https://github.com/DocSpring/libreconv | spec/libreconv/converter_file_uri_spec.rb | Ruby | mit | 206 | master | 749 | # encoding: UTF-8
# frozen_string_literal: true
RSpec.describe Libreconv::Converter do
let :converter do
described_class.new fixture_file, '/target', fixture_path('soffice')
end
describe '#build_file_uri' do
it 'converts a file path to file URI' do
url = converter.send(:build_file_uri, File.join(D... |
github | DocSpring/libreconv | https://github.com/DocSpring/libreconv | spec/libreconv/converter_convert_url_spec.rb | Ruby | mit | 206 | master | 1,115 | # frozen_string_literal: true
RSpec.describe Libreconv::Converter do
describe '#convert' do
it 'raises error when URL cannot be loaded' do
stub_request(:head, url = 'http://s3.amazonaws.com/libreconv-test/docx.docx')
# Error: source file could not be loaded
expect do
described_class.ne... |
github | DocSpring/libreconv | https://github.com/DocSpring/libreconv | lib/libreconv.rb | Ruby | mit | 206 | master | 6,366 | # frozen_string_literal: true
require 'libreconv/version'
require 'uri'
require 'net/http'
require 'tmpdir'
require 'securerandom'
require 'open3'
# Convert office documents using LibreOffice / OpenOffice to one of their supported formats.
module Libreconv
class ConversionFailedError < StandardError; end
# @para... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | Gemfile | Ruby | mit | 206 | master | 608 | source "http://rubygems.org"
# Declare your gem's dependencies in dynamic_sitemaps.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
# jquery-rails is used by the dummy application
gem "jquery-rails"
#... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | dynamic_sitemaps.gemspec | Ruby | mit | 206 | master | 1,098 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'dynamic_sitemaps/version'
Gem::Specification.new do |gem|
gem.name = "dynamic_sitemaps"
gem.version = DynamicSitemaps::VERSION
gem.authors = ["Lasse Bunk"]
... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | test/dynamic_sitemaps_test.rb | Ruby | mit | 206 | master | 1,596 | require 'test_helper'
class DynamicSitemapsTest < ActiveSupport::TestCase
setup do
DynamicSitemaps.reset!
end
test "defaults" do
assert_equal Rails.root.join("public").to_s, DynamicSitemaps.path
assert_equal "sitemaps", DynamicSitemaps.folder
assert_equal "sitemap.xml", DynamicSitemaps.index_fil... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | test/test_helper.rb | Ruby | mit | 206 | master | 497 | # Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require "rails/test_help"
require "webmock/test_unit"
Rails.backtrace_cleaner.remove_silencers!
# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
#... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | test/pinger_test.rb | Ruby | mit | 206 | master | 2,770 | require 'test_helper'
class PingerTest < ActiveSupport::TestCase
setup do
DynamicSitemaps.reset!
end
test "pinging search engines" do
stub_request :get, /^http:\/\/www\.google\.com\/webmasters\/sitemaps\/ping\?sitemap=.*/
stub_request :get, /^http:\/\/www\.bing\.com\/webmaster\/ping\.aspx\?siteMap=.... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | test/generator_test.rb | Ruby | mit | 206 | master | 14,135 | require "test_helper"
require "nokogiri"
require "timecop"
class GeneratorTest < ActiveSupport::TestCase
setup do
Timecop.freeze Time.new(2013, 7, 10, 13, 46, 23, "+10:00")
FileUtils.rm_rf Rails.root.join("public", "sitemaps")
DynamicSitemaps.reset!
end
teardown do
Timecop.return
end
test "... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | test/dummy/db/schema.rb | Ruby | mit | 206 | master | 1,050 | # encoding: UTF-8
# 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 sou... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | test/dummy/config/application.rb | Ruby | mit | 206 | master | 2,565 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require
require "dynamic_sitemaps"
module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initiali... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | test/dummy/config/initializers/secret_token.rb | Ruby | mit | 206 | master | 496 | # Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | lib/dynamic_sitemaps.rb | Ruby | mit | 206 | master | 3,765 | require "dynamic_sitemaps/rails/engine"
require "dynamic_sitemaps/sitemap"
require "dynamic_sitemaps/generator"
require "dynamic_sitemaps/sitemap_generator"
require "dynamic_sitemaps/index_generator"
require "dynamic_sitemaps/sitemap_result"
require "dynamic_sitemaps/pinger"
require "dynamic_sitemaps/logger"
module Dy... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | lib/dynamic_sitemaps/sitemap.rb | Ruby | mit | 206 | master | 898 | module DynamicSitemaps
class Sitemap
attr_reader :name, :collection, :block, :host, :folder, :protocol
# Initializes a sitemap object.
#
# Sitemap.new(:site) do
# url root_url
# end
def initialize(*args, &block)
if args.first.is_a?(Symbol)
@name = args.shift
e... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | lib/dynamic_sitemaps/generator.rb | Ruby | mit | 206 | master | 3,870 | module DynamicSitemaps
class Generator
# Generates the sitemap(s) and index based on the configuration file specified in DynamicSitemaps.config_path.
# If you supply a block, that block is evaluated instead of the configuration file.
def generate(&block)
create_temp_dir
if block
instan... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | lib/dynamic_sitemaps/pinger.rb | Ruby | mit | 206 | master | 1,087 | module DynamicSitemaps
class Pinger
class << self
def ping_search_engines_with(sitemap_urls)
sitemap_urls = [sitemap_urls] unless sitemap_urls.is_a?(Array)
if sitemap_urls.any? && ping_for_environment?(Rails.env)
Logger.info "Pinging search engines..."
sitemap_urls.each... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | lib/dynamic_sitemaps/sitemap_result.rb | Ruby | mit | 206 | master | 400 | # Contains the result of a sitemap generation
module DynamicSitemaps
class SitemapResult
attr_reader :sitemap, :files
def initialize(sitemap, files)
@sitemap = sitemap
@files = files
end
def name
sitemap.name
end
def host
sitemap.host
end
def folder
s... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | lib/dynamic_sitemaps/sitemap_generator.rb | Ruby | mit | 206 | master | 3,250 | module DynamicSitemaps
class SitemapGenerator
attr_reader :sitemap
attr_writer :counter, :page
def initialize(sitemap)
unless self.class.included_modules.include?(Rails.application.routes.url_helpers)
self.class.send :include, Rails.application.routes.url_helpers
end
@sitemap = ... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | lib/dynamic_sitemaps/logger.rb | Ruby | mit | 206 | master | 406 | module DynamicSitemaps
class Logger
class << self
def info(message)
show message
Rails.logger.info message
end
def warn(message)
show message
Rails.logger.warn message
end
# Shows the message using puts unless testing.
def show(message)
... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | lib/dynamic_sitemaps/index_generator.rb | Ruby | mit | 206 | master | 1,460 | module DynamicSitemaps
class IndexGenerator
attr_reader :sitemaps # Array of sitemap results
# Initialize the class with an array of SitemapResult
def initialize(sitemaps)
@sitemaps = sitemaps
end
def generate
sitemaps.group_by(&:folder).each do |folder, sitemaps|
index_path ... |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | lib/dynamic_sitemaps/tasks/sitemap.rake | Ruby | mit | 206 | master | 283 | namespace :sitemap do
task :generate => :environment do
start_time = Time.now
DynamicSitemaps::Logger.info "Generating sitemap..."
DynamicSitemaps.generate_sitemap
DynamicSitemaps::Logger.info "Done generating sitemap in #{Time.now - start_time} seconds."
end
end |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | lib/generators/dynamic_sitemaps/install_generator.rb | Ruby | mit | 206 | master | 226 | module DynamicSitemaps
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
def create_config
copy_file "config.rb", "config/sitemap.rb"
end
end
end |
github | lassebunk/dynamic_sitemaps | https://github.com/lassebunk/dynamic_sitemaps | lib/generators/dynamic_sitemaps/templates/config.rb | Ruby | mit | 206 | master | 1,361 | # Change this to your host. See the readme at https://github.com/lassebunk/dynamic_sitemaps
# for examples of multiple hosts and folders.
host "www.example.com"
protocol "http"
sitemap :site do
url root_url, last_mod: Time.now, change_freq: "daily", priority: 1.0
end
# You can have multiple sitemaps like the above ... |
github | maccman/hermes | https://github.com/maccman/hermes | Rakefile | Ruby | mit | 206 | master | 271 | #!/usr/bin/env rake
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Hermes::Application.load_tasks |
github | maccman/hermes | https://github.com/maccman/hermes | Gemfile | Ruby | mit | 206 | master | 748 | source 'https://rubygems.org'
gem 'rails', '3.2.0.rc1'
gem 'thin'
group :assets do
gem 'coffee-rails', '~> 3.2.0'
gem 'uglifier', '>= 1.0.3'
gem 'stylus'
gem 'spine-rails', :git => 'git://github.com/maccman/spine-rails.git'
gem 'eco'
end
gem 'jquery-rails'
gem 'omniauth'
gem 'omniauth-twitter'
gem 'omniaut... |
github | maccman/hermes | https://github.com/maccman/hermes | test/test_helper.rb | Ruby | mit | 206 | master | 524 | ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'factory_girl'
require Rails.root.join('test', 'factories')
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You... |
github | maccman/hermes | https://github.com/maccman/hermes | test/factories.rb | Ruby | mit | 206 | master | 449 | FactoryGirl.define do
sequence :uid do |n|
"#{n}"
end
sequence :email do |n|
"person#{n}@example.com"
end
sequence :handle do |n|
"@#{n}"
end
factory :user do
uid
email
handle
end
factory :conversation do
user
to_users {|c| [c.association(:user)] }
end
... |
github | maccman/hermes | https://github.com/maccman/hermes | test/functional/emails_controller_test.rb | Ruby | mit | 206 | master | 429 | require 'test_helper'
class EmailsControllerTest < ActionController::TestCase
test "creates messages" do
headers = {}
text = "An awesome message"
post :create, to: 'maccman@example.com',
from: 'mike@example.com',
headers: headers, text: text
... |
github | maccman/hermes | https://github.com/maccman/hermes | test/functional/messages_controller_test.rb | Ruby | mit | 206 | master | 866 | require 'test_helper'
class MessagesControllerTest < ActionController::TestCase
setup do
@message = FactoryGirl.create(:message)
@controller.stubs(:keepsafe).returns(true)
@current_user = FactoryGirl.create(:user)
@controller.stubs(:current_user).returns(@current_user)
end
test "should get ... |
github | maccman/hermes | https://github.com/maccman/hermes | app/observers/juggernaut_observer.rb | Ruby | mit | 206 | master | 332 | module JuggernautObserver extend self
def publish(type, record, options = {})
data = {
type: type,
id: record.id,
model: record.class.name,
record: record
}
Juggernaut.publish(
"/observer/#{record.user_id}",
data,
options
)
rescue Errno::ECONNREFUSE... |
github | maccman/hermes | https://github.com/maccman/hermes | app/controllers/app_controller.rb | Ruby | mit | 206 | master | 230 | class AppController < ApplicationController
before_filter :require_user
def index
@config_json = ({juggernaut: Rails.config.juggernaut}).to_json
@user_json = current_user.to_json(methods: :autocomplete)
end
end |
github | maccman/hermes | https://github.com/maccman/hermes | app/controllers/emails_controller.rb | Ruby | mit | 206 | master | 1,220 | require 'mail'
class EmailsController < ApplicationController
skip_before_filter :verify_authenticity_token
def create
mail = params[:headers] && Mail.new(params[:headers])
from = params[:from]
to = params[:to] || params[:recipient] || ""
cc = params[:cc]
bcc = pa... |
github | maccman/hermes | https://github.com/maccman/hermes | app/controllers/messages_controller.rb | Ruby | mit | 206 | master | 1,742 | class MessagesController < ApplicationController
before_filter :require_user
before_filter :find_message, :only => [:show, :update, :destroy]
# GET /messages.json
def index
@messages = Message.for_user(current_user).latest_last
@messages = @messages.paginate(:page => params[:page], :per_page => 30)
... |
github | maccman/hermes | https://github.com/maccman/hermes | app/controllers/application_controller.rb | Ruby | mit | 206 | master | 1,471 | class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :login_with_access_token
protected
def login_with_access_token
if params[:access_token].present?
self.current_user = User.find_by_access_token(params[:access_token])
end
end
def cur... |
github | maccman/hermes | https://github.com/maccman/hermes | app/controllers/conversations_controller.rb | Ruby | mit | 206 | master | 1,860 | class ConversationsController < ApplicationController
before_filter :require_user
before_filter :find_converation, :only => [:show, :update]
# GET /conversations.json
def index
@conversations = Conversation.for_user(current_user).latest
@conversations = @conversations.paginate(:page => params[:page],... |
github | maccman/hermes | https://github.com/maccman/hermes | app/controllers/authorize_controller.rb | Ruby | mit | 206 | master | 518 | class AuthorizeController < ApplicationController
before_filter :require_user, :only => :google
def google
self.current_user.link_google!(
request.env["omniauth.auth"]
)
redirect_to "/"
end
def create
self.current_user = User.authorize_twitter!(
request.env["omniauth.auth"]
)
... |
github | maccman/hermes | https://github.com/maccman/hermes | app/models/attachment.rb | Ruby | mit | 206 | master | 1,747 | class Attachment < ActiveRecord::Base
belongs_to :message
class FileUploader < CarrierWave::Uploader::Base
# Include RMagick or ImageScience support:
include CarrierWave::RMagick
# include CarrierWave::ImageScience
# Choose what kind of storage to use for this uploader:
# storage :file
sto... |
github | maccman/hermes | https://github.com/maccman/hermes | app/models/user.rb | Ruby | mit | 206 | master | 3,396 | class User < ActiveRecord::Base
has_many :conversations
has_many :friends, :through => :conversations, :source => :to_users
validates_uniqueness_of :uid, :allow_blank => true
validates_presence_of :handle, :unless => :email?
validates_presence_of :email, :unless => :handle?
before_create :create_ac... |
github | maccman/hermes | https://github.com/maccman/hermes | app/models/conversation.rb | Ruby | mit | 206 | master | 2,455 | class Conversation < ActiveRecord::Base
belongs_to :user
has_many :conversation_users
has_many :to_users, :through => :conversation_users, :source => :user
has_many :messages
before_save :set_defaults
validates_presence_of :user_id
validates_length_of :to_users, :within => 1..20, :on => :create
... |
github | maccman/hermes | https://github.com/maccman/hermes | app/models/message.rb | Ruby | mit | 206 | master | 3,717 | require 'mail'
require 'rails_autolink'
class Message < ActiveRecord::Base
include ActionView::Helpers::TextHelper
include ActionView::Helpers::UrlHelper
belongs_to :conversation
belongs_to :user
belongs_to :from_user, :class_name => "User"
validates_presence_of :from_user, :conversation, :user, :bod... |
github | maccman/hermes | https://github.com/maccman/hermes | app/mailers/user_mailer.rb | Ruby | mit | 206 | master | 815 | class UserMailer < ActionMailer::Base
default from: "notify@#{Rails.config.domain}"
def send_message(to_user, message)
@to_user = to_user
@from_user = message.from_user
@message = message
@conversation = message.conversation
previous_msgs = @conversation.messages.latest_firs... |
github | maccman/hermes | https://github.com/maccman/hermes | lib/mail_body.rb | Ruby | mit | 206 | master | 492 | module MailBody extend self
def strip(body)
return if body.blank?
body = body && body.split(/^-----Original Message-----/, 2)[0]
body = body && body.split(/^________________________________/, 2)[0]
body = body && body.split(/^On .+ wrote:(\n|\r\n)/, 2)[0]
body = body && body.split(/^---? ?(\n|\r\n... |
github | maccman/hermes | https://github.com/maccman/hermes | lib/gravatar.rb | Ruby | mit | 206 | master | 428 | require 'digest/md5'
require 'cgi'
module Gravatar extend self
DEFAULT = "http://robohash.org/%s.png?size=80x80&bgset=1"
def make(email)
return unless email
email = email.downcase
hash = Digest::MD5.hexdigest(email)
default = CGI.escape(DEFAULT % hash)
"http://www.gravatar.com/avat... |
github | maccman/hermes | https://github.com/maccman/hermes | lib/mail_activity.rb | Ruby | mit | 206 | master | 753 | module MailActivity extend self
FROM_EMAIL_PATTERNS = [
/not?-?reply/,
/\+activity/,
/amazon.com/,
/facebookmail.com/,
/linkedin.com/,
/foursquare.com/,
/postmaster.twitter.com/,
/info@meetup.com/,
/friendfeed.com/,
/calendar-notification@google.com/,
/support@plancast.com/... |
github | maccman/hermes | https://github.com/maccman/hermes | lib/user_extractor.rb | Ruby | mit | 206 | master | 737 | require 'user'
require 'mail'
require 'twitter'
module UserExtractor extend self
def extract_handle(str)
Twitter::Extractor.extract_mentioned_screen_names(str)[0]
end
def extract_mail(str)
address = Mail::Address.new(str)
address.domain && address
end
def extract(array)
if array.is_a?(S... |
github | maccman/hermes | https://github.com/maccman/hermes | lib/dm_sender.rb | Ruby | mit | 206 | master | 781 | module DMSender extend self
extend ActionView::Helpers::TextHelper
extend ActionDispatch::Routing::UrlFor
include Rails.application.routes.url_helpers
default_url_options[:host] = Rails.config.domain
def send_message(to_user, message)
conversation = message.conversation
conversation_url = url_for(
... |
github | maccman/hermes | https://github.com/maccman/hermes | lib/google.rb | Ruby | mit | 206 | master | 1,155 | module Google
class Contact
attr_reader :name, :emails, :email
def initialize(result)
@name = result["title"]
@name = @name["$t"].blank? ? nil : @name["$t"]
raw_emails = result["gd$email"] || []
@emails = raw_emails.map {|e| e["address"] }
@email = r... |
github | maccman/hermes | https://github.com/maccman/hermes | db/schema.rb | Ruby | mit | 206 | master | 2,581 | # encoding: UTF-8
# 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 sou... |
github | maccman/hermes | https://github.com/maccman/hermes | db/seeds.rb | Ruby | mit | 206 | master | 549 | user1 = User.create(uid: "2006261", handle: "maccman", name: "Alex MacCaw", email: "maccman@gmail.com", twitter_token: "blank")
user2 = User.create(uid: "734903", handle: "mjackson", name: "Michael Jackson", email: "mjijackson@gmail.com", twitter_token: "blank")
message = Message.new
message.body = "Hello World"
messa... |
github | maccman/hermes | https://github.com/maccman/hermes | db/migrate/20120101195314_create_conversations.rb | Ruby | mit | 206 | master | 203 | class CreateConversations < ActiveRecord::Migration
def change
create_table :conversations do |t|
t.string :uid
t.boolean :read, :default => false
t.timestamps
end
end
end |
github | maccman/hermes | https://github.com/maccman/hermes | db/migrate/20120102170041_create_conversation_users.rb | Ruby | mit | 206 | master | 208 | class CreateConversationUsers < ActiveRecord::Migration
def change
create_table :conversation_users do |t|
t.integer :conversation_id
t.integer :user_id
t.timestamps
end
end
end |
github | maccman/hermes | https://github.com/maccman/hermes | db/migrate/20120101190943_create_messages.rb | Ruby | mit | 206 | master | 262 | class CreateMessages < ActiveRecord::Migration
def change
create_table :messages do |t|
t.text :subject
t.text :body
t.datetime :sent_at
t.integer :conversation_id
t.integer :from_user_id
t.timestamps
end
end
end |
github | maccman/hermes | https://github.com/maccman/hermes | db/migrate/20120124033720_make_starred_activity_defaults.rb | Ruby | mit | 206 | master | 203 | class MakeStarredActivityDefaults < ActiveRecord::Migration
def up
change_column_default :messages, :starred, false
change_column_default :messages, :activity, false
end
def down
end
end |
github | maccman/hermes | https://github.com/maccman/hermes | db/migrate/20120101195725_create_users.rb | Ruby | mit | 206 | master | 327 | class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :email
t.string :uid
t.string :handle
t.string :twitter_token
t.string :twitter_secret
t.string :name
t.string :avatar_url
t.text :description
t.timestamps
end
... |
github | maccman/hermes | https://github.com/maccman/hermes | config/application.rb | Ruby | mit | 206 | master | 2,684 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.requi... |
github | maccman/hermes | https://github.com/maccman/hermes | config/routes.rb | Ruby | mit | 206 | master | 2,339 | Hermes::Application.routes.draw do
resources :messages
resources :conversations do
collection do
get 'activity'
get 'starred'
get 'between'
end
end
resources :emails
root :to => 'app#index'
match '/auth/google' => redirect('/auth/google_oauth2')
match '/auth/twitter/cal... |
github | maccman/hermes | https://github.com/maccman/hermes | config/initializers/session_store.rb | Ruby | mit | 206 | master | 410 | # Be sure to restart your server when you modify this file.
Hermes::Application.config.session_store :cookie_store, key: '_carrier_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rails ge... |
github | maccman/hermes | https://github.com/maccman/hermes | config/initializers/carrierwave.rb | Ruby | mit | 206 | master | 370 | CarrierWave.configure do |config|
config.cache_dir = Rails.root.join("tmp", "uploads")
config.root = Rails.root.join("tmp")
config.fog_credentials = {
:provider => "AWS",
:aws_access_key_id => ENV["S3_KEY"],
:aws_secret_access_key => ENV["S3_SECRET"],
}
config.fog_directo... |
github | maccman/hermes | https://github.com/maccman/hermes | config/initializers/omniauth.rb | Ruby | mit | 206 | master | 401 | Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, ENV["TWITTER_CONSUMER_KEY"], ENV["TWITTER_CONSUMER_SECRET"]
provider :google_oauth2, ENV["GOOGLE_KEY"], ENV["GOOGLE_SECRET"], access_type: "", scope: "userinfo.email,userinfo.profile,https://www.google.com/m8/feeds"
on_failure do |env... |
github | maccman/hermes | https://github.com/maccman/hermes | config/initializers/config.rb | Ruby | mit | 206 | master | 810 | # Rails 3 Config
#
# In: config/application.yml
#
# development:
# github:
# key: test
# secret: verysecret-dev
# production:
# github:
# key: test
# secret: verysecret-dev
#
# Usage:
# Rails.config.github.key
# Rails.config.github.secret?
module Rails
class Config < Active... |
github | maccman/hermes | https://github.com/maccman/hermes | config/initializers/secret_token.rb | Ruby | mit | 206 | master | 497 | # Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... |
github | maccman/hermes | https://github.com/maccman/hermes | config/environments/development.rb | Ruby | mit | 206 | master | 1,372 | Hermes::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web ser... |
github | maccman/hermes | https://github.com/maccman/hermes | config/environments/production.rb | Ruby | mit | 206 | master | 2,779 | Hermes::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_... |
github | maccman/hermes | https://github.com/maccman/hermes | config/environments/test.rb | Ruby | mit | 206 | master | 1,525 | Hermes::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# 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 sui... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.