repo_name
stringlengths 6
97
| path
stringlengths 3
341
| text
stringlengths 8
1.02M
|
|---|---|---|
Milstein/spinone
|
spec/requests/milestones_spec.rb
|
<reponame>Milstein/spinone
require 'rails_helper'
describe "Milestones", type: :request, vcr: true do
it "milestones" do
get '/milestones'
expect(last_response.status).to eq(200)
meta = json["meta"]
expect(meta["total"]).to eq(8)
expect(json["data"].size).to eq(8)
page = json["data"].first
expect(page["id"]).to eq("38")
expect(page.dig("attributes", "title")).to eq("Public API to manage clients and prefixes")
end
it "open milestones" do
get '/milestones?state=open'
expect(last_response.status).to eq(200)
meta = json["meta"]
expect(meta["total"]).to eq(8)
expect(json["data"].size).to eq(8)
page = json["data"].first
expect(page["id"]).to eq("38")
expect(page.dig("attributes", "title")).to eq("Public API to manage clients and prefixes")
end
it "closed milestones" do
get '/milestones?state=closed'
expect(last_response.status).to eq(200)
meta = json["meta"]
expect(meta["total"]).to eq(24)
expect(json["data"].size).to eq(24)
page = json["data"].first
expect(page["id"]).to eq("27")
expect(page.dig("attributes", "title")).to eq("Upgraded database infrastructure")
end
end
|
Milstein/spinone
|
spec/requests/works_spec.rb
|
<filename>spec/requests/works_spec.rb
require 'rails_helper'
describe "Works", type: :request, vcr: true do
let(:expected_work) { OpenStruct.new(id: "https://handle.test.datacite.org/10.1234/rh5j9bx3gn.1", title: "2018-09-21 07:26:21.58 3 authors public mode (revised)") }
it "works" do
get '/works'
expect(last_response.status).to eq(200)
meta = json["meta"]
expect(meta["data-centers"].size).to eq(15)
expect(meta["data-centers"].first).to eq("count"=>10861, "id"=>"tib.aip", "title"=>"Leibniz-Institut für Astrophysik Potsdam (AIP) An der Sternwarte 16 14482 Potsdam")
expect(meta["registered"].size).to eq(7)
expect(meta["registered"].first).to eq("id"=>"2018", "title"=>"2018", "count"=>23869)
expect(json["data"].size).to eq(25)
work = json["data"].first
expect(work["id"]).to eq("https://handle.test.datacite.org/10.1234/rh5j9bx3gn.1")
expect(work.dig("attributes", "title")).to eq("Title of Mendeley Data Set")
end
it "works with page size" do
get '/works?page[size]=40'
expect(last_response.status).to eq(200)
expect(json["data"].size).to eq(40)
work = json["data"].first
expect(work["id"]).to eq("https://handle.test.datacite.org/10.1234/rh5j9bx3gn.1")
expect(work.dig("attributes", "title")).to eq("Title of Mendeley Data Set")
end
it "works with sample" do
get '/works?sample=10'
expect(last_response.status).to eq(200)
expect(json["data"].size).to eq(10)
work = json["data"].first
expect(work["id"]).to eq("https://handle.test.datacite.org/10.17876/musewide/dr.1/30921")
expect(work.dig("attributes", "title")).to eq("candels-cdfs-30")
end
it "works with sample and sample-group" do
get '/works?sample=1&sample-group=client&page[size]=10'
expect(last_response.status).to eq(200)
expect(json["data"].size).to eq(10)
work = json["data"].first
expect(work["id"]).to eq("https://handle.test.datacite.org/10.17876/musewide/dr.1/30921")
expect(work.dig("attributes", "title")).to eq("candels-cdfs-30")
end
it "works with sample and sample-group limit total to 1000" do
get '/works?sample=50&sample-group=client&page[size]=50'
expect(last_response.status).to eq(200)
expect(json["data"].size).to eq(1000)
work = json["data"].first
expect(work["id"]).to eq("https://handle.test.datacite.org/10.17876/musewide/dr.1/30921")
expect(work.dig("attributes", "title")).to eq("candels-cdfs-30")
end
# it "works with include data-center" do
# get '/works?include=data-center'
# expect(last_response.status).to eq(200)
# expect(json["data"].size).to eq(25)
# work = json["data"].first
# expect(work["id"]).to eq("https://handle.test.datacite.org/10.17863/cam.329")
# expect(work.dig("attributes", "title")).to eq("26-hour storage of a declined liver prior to successful transplantation using ex vivo normothermic perfusion")
# expect(json["included"].size).to eq(4)
# data_center = json["included"].first
# expect(data_center["id"]).to eq("bl.cam")
# expect(data_center.dig("attributes", "title")).to eq("University of Cambridge")
# end
# it "works with include data-center, member and resource-type" do
# get '/works?include=data-center,member,resource-type'
# expect(last_response.status).to eq(200)
# expect(json["data"].size).to eq(25)
# work = json["data"].first
# expect(work["id"]).to eq("https://handle.test.datacite.org/10.17863/cam.329")
# expect(work.dig("attributes", "title")).to eq("26-hour storage of a declined liver prior to successful transplantation using ex vivo normothermic perfusion")
# expect(json["included"].size).to eq(9)
# client = json["included"].last
# expect(client["id"]).to eq("bl.mendeley")
# expect(client.dig("attributes", "title")).to eq("Mendeley Data")
# end
it "works with query" do
get '/works?query=cancer'
expect(last_response.status).to eq(200)
expect(json["data"].size).to eq(25)
work = json["data"].first
expect(work["id"]).to eq("https://handle.test.datacite.org/10.33522/08da-3cnl")
expect(work.dig("attributes", "title")).to eq("Methods for Measuring Cancer Disparities: Using Data Relevant to Healthy People 2010 Cancer-Related Objectives")
end
it "works with query sort by minted" do
get '/works?query=cancer&sort=minted'
expect(last_response.status).to eq(200)
expect(json["data"].size).to eq(25)
work = json["data"].first
expect(work["id"]).to eq("https://handle.test.datacite.org/10.33522/08da-3cnl")
expect(work.dig("attributes", "title")).to eq("Methods for Measuring Cancer Disparities: Using Data Relevant to Healthy People 2010 Cancer-Related Objectives")
end
it "works with query no results" do
get '/works?query=xxxx'
expect(last_response.status).to eq(200)
expect(json["data"].size).to eq(0)
expect(json.dig("meta", "data-centers").size).to eq(0)
end
it "works with query url" do
get '/works?url=*datacite*'
expect(last_response.status).to eq(200)
expect(json["data"].size).to eq(21)
work = json["data"].first
expect(work["id"]).to eq("https://handle.test.datacite.org/10.33540/rry0-5b44")
expect(work.dig("attributes", "title")).to eq("My test title")
expect(work.dig("attributes", "url")).to eq("http://datacommons.cyverse.org/browse/iplant/home/shared/commons_repo/curated/doi-test-full-datacite")
end
it "works with resource-type dataset" do
get '/works?resource-type-id=dataset'
expect(last_response.status).to eq(200)
expect(json.dig("meta", "total")).to eq(18773)
expect(json.dig("meta", "total-pages")).to eq(751)
expect(json["data"].size).to eq(25)
work = json["data"].first
expect(work["id"]).to eq("https://handle.test.datacite.org/10.1234/rh5j9bx3gn.1")
expect(work.dig("attributes", "title")).to eq("Title of Mendeley Data Set")
end
it "works with data-center-id" do
get '/works?data-center-id=bl.mendeley'
expect(last_response.status).to eq(200)
expect(json.dig("meta", "total")).to eq(1052)
expect(json.dig("meta", "total-pages")).to eq(43)
expect(json["data"].size).to eq(25)
work = json["data"].first
expect(work["id"]).to eq(expected_work.id)
expect(work.dig("attributes", "title")).to eq("Title of Mendeley Data Set")
end
it "works with checked date" do
get '/works?checked=2018-03-01'
expect(last_response.status).to eq(200)
expect(json["data"].size).to eq(25)
work = json["data"].first
expect(work["id"]).to eq("https://handle.test.datacite.org/10.1234/rh5j9bx3gn.1")
expect(work.dig("attributes", "title")).to eq("Title of Mendeley Data Set")
end
it "works with resource-type dataset and data-center mendeley" do
get '/works?resource-type-id=dataset&data-center-id=bl.mendeley'
expect(last_response.status).to eq(200)
expect(json.dig("meta", "total")).to eq(1051)
expect(json.dig("meta", "total-pages")).to eq(43)
expect(json["data"].size).to eq(25)
work = json["data"].first
expect(work["id"]).to eq(expected_work.id)
expect(work.dig("attributes", "title")).to eq("Title of Mendeley Data Set")
end
it "related works" do
doi = "10.1016/j.gca.2010.12.008"
get "/works?work-id=#{doi}"
expect(last_response.status).to eq(200)
expect(json["data"].size).to eq(1)
work = json["data"].first
expect(work["id"]).to eq("https://handle.test.datacite.org/10.1594/ieda/100037")
expect(work.dig("attributes", "title")).to eq("LauBasin_TUIM05MV_Mottl")
end
it "work" do
get '/works/10.4124/9f7xnnys8c.5'
expect(last_response.status).to eq(200)
work = json["data"]
expect(work["id"]).to eq("https://handle.test.datacite.org/10.4124/9f7xnnys8c.5")
expect(work.dig("attributes", "title")).to eq("DAT-3025 Maintain file ordering for published datasets - 4")
end
it "work that doesn't exist" do
get '/works/10.1098/rsif.2017.0030'
expect(last_response.status).to eq(404)
errors = json["errors"]
expect(errors.first.dig("title")).to eq("The resource you are looking for doesn't exist.")
end
it "work with + sign in doi" do
get '/works/10.14454/terra+aqua/ceres/cldtyphist_l3.004'
expect(last_response.status).to eq(200)
work = json["data"]
expect(work["id"]).to eq("https://handle.test.datacite.org/10.14454/terra+aqua/ceres/cldtyphist_l3.004")
expect(work.dig("attributes", "title")).to eq("CERES Level 3 Cloud Type Historgram Terra+Aqua HDF file - Edition4")
end
end
|
yagihiro/action-cable-testing
|
test/test_helper.rb
|
<filename>test/test_helper.rb
# frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
begin
require "pry-byebug"
rescue LoadError
end
require "action_cable"
require "action-cable-testing"
require "active_support/testing/autorun"
# Require all the stubs and models
Dir[File.expand_path("stubs/*.rb", __dir__)].each { |file| require file }
# # Set test adapter and logger
ActionCable.server.config.cable = { "adapter" => "test" }
ActionCable.server.config.logger =
ActiveSupport::TaggedLogging.new ActiveSupport::Logger.new(StringIO.new)
|
yagihiro/action-cable-testing
|
spec/generators/test_unit_spec.rb
|
<reponame>yagihiro/action-cable-testing<filename>spec/generators/test_unit_spec.rb
# frozen_string_literal: true
require "spec_helper"
require "generators/test_unit/channel/channel_generator"
describe TestUnit::Generators::ChannelGenerator, type: :generator do
destination File.expand_path("../../../tmp", __FILE__)
let(:args) { ["chat"] }
before do
prepare_destination
run_generator(args)
end
subject { file("test/channels/chat_channel_test.rb") }
it "creates script", :aggregate_failures do
is_expected.to exist
is_expected.to contain("class ChatChannelTest < ActionCable::Channel::TestCase")
end
end
|
yagihiro/action-cable-testing
|
spec/support/helpers.rb
|
<reponame>yagihiro/action-cable-testing
# Copied from rspec-rails
module Helpers
include RSpec::Rails::FeatureCheck
def with_isolated_config
original_config = RSpec.configuration
RSpec.configuration = RSpec::Core::Configuration.new
RSpec::Rails.initialize_configuration(RSpec.configuration)
if defined?(ActionCable)
RSpec.configure do |config|
config.include RSpec::Rails::ChannelExampleGroup, type: :channel
end
end
yield RSpec.configuration
ensure
RSpec.configuration = original_config
end
RSpec.configure { |c| c.include self }
end
|
yagihiro/action-cable-testing
|
lib/generators/test_unit/channel/channel_generator.rb
|
<gh_stars>100-1000
# frozen_string_literal: true
require "rails/generators/test_unit"
module TestUnit # :nodoc:
module Generators # :nodoc:
class ChannelGenerator < Base # :nodoc:
source_root File.expand_path("../templates", __FILE__)
check_class_collision suffix: "ChannelTest"
def create_test_file
template "unit_test.rb.erb", File.join("test/channels", class_path, "#{file_name}_channel_test.rb")
end
end
end
end
|
yagihiro/action-cable-testing
|
spec/rspec/rails/channel_example_group_spec.rb
|
require "spec_helper"
module RSpec::Rails
describe ChannelExampleGroup do
if defined?(ActionCable)
it_behaves_like "an rspec-rails example group mixin", :channel,
'./spec/channels/', '.\\spec\\channels\\'
end
end
end
|
yagihiro/action-cable-testing
|
lib/generators/rspec/channel/channel_generator.rb
|
<reponame>yagihiro/action-cable-testing
# frozen_string_literal: true
require "generators/rspec"
module Rspec
module Generators
# @private
class ChannelGenerator < Base
source_root File.expand_path("../templates", __FILE__)
def create_channel_spec
template "channel_spec.rb.erb", File.join("spec/channels", class_path, "#{file_name}_channel_spec.rb")
end
end
end
end
|
yagihiro/action-cable-testing
|
test/stubs/test_connection.rb
|
# frozen_string_literal: true
require_relative "user"
class TestConnection
attr_reader :identifiers, :logger, :current_user, :server, :transmissions
delegate :pubsub, to: :server
def initialize(user = User.new("lifo"), coder: ActiveSupport::JSON, subscription_adapter: SuccessAdapter)
@coder = coder
@identifiers = [ :current_user ]
@current_user = user
@logger = ActiveSupport::TaggedLogging.new ActiveSupport::Logger.new(StringIO.new)
@server = TestServer.new(subscription_adapter: subscription_adapter)
@transmissions = []
end
def transmit(cable_message)
@transmissions << encode(cable_message)
end
def last_transmission
decode @transmissions.last if @transmissions.any?
end
def decode(websocket_message)
@coder.decode websocket_message
end
def encode(cable_message)
@coder.encode cable_message
end
end
|
yagihiro/action-cable-testing
|
spec/spec_helper.rb
|
<filename>spec/spec_helper.rb
# frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
begin
require "pry-byebug"
rescue LoadError
end
require "action_controller/railtie"
require "action_view/railtie"
require "action_cable"
require "action_cable/testing/rspec"
require "ammeter/init"
# Require all the stubs and models
Dir[File.expand_path("../test/stubs/*.rb", __dir__)].each { |file| require file }
# # Set test adapter and logger
ActionCable.server.config.cable = { "adapter" => "test" }
ActionCable.server.config.logger =
ActiveSupport::TaggedLogging.new ActiveSupport::Logger.new(StringIO.new)
Dir[File.expand_path("support/**/*.rb", __dir__)].each { |f| require f }
RSpec.configure do |config|
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.example_status_persistence_file_path = "tmp/rspec_examples.txt"
config.filter_run :focus
config.run_all_when_everything_filtered = true
config.order = :random
Kernel.srand config.seed
end
|
yagihiro/action-cable-testing
|
action-cable-testing.gemspec
|
# frozen_string_literal: true
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "action_cable/testing/version"
Gem::Specification.new do |spec|
spec.name = "action-cable-testing"
spec.version = ActionCable::Testing::VERSION
spec.authors = ["<NAME>"]
spec.email = ["<EMAIL>"]
spec.summary = "Testing utils for Action Cable"
spec.description = "Testing utils for Action Cable"
spec.homepage = "http://github.com/palkan/action-cable-testing"
spec.license = "MIT"
spec.files = `git ls-files`.split($/).select { |p| p.match(%r{^lib/}) } +
%w(README.md CHANGELOG.md LICENSE.txt)
spec.require_paths = ["lib"]
spec.add_dependency "actioncable", "~> 5.0"
spec.add_development_dependency "bundler", "~> 1.10"
spec.add_development_dependency "cucumber", "~> 3.1.1"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec-rails", "~> 3.5"
spec.add_development_dependency "aruba", "~> 0.14.6"
spec.add_development_dependency "minitest", "~> 5.9"
spec.add_development_dependency "ammeter", "~> 1.1"
spec.add_development_dependency "rubocop", "~> 0.51"
end
|
yagihiro/action-cable-testing
|
lib/action_cable/testing/rspec.rb
|
# frozen_string_literal: true
require "action-cable-testing"
require "rspec/rails"
require "rspec/rails/example/channel_example_group"
require "rspec/rails/matchers/action_cable"
require "rspec/rails/shared_contexts/action_cable"
module RSpec # :nodoc:
module Rails
module FeatureCheck
module_function
def has_action_cable?
defined?(::ActionCable)
end
end
self::DIRECTORY_MAPPINGS[:channel] = %w[spec channels]
end
end
RSpec.configure do |config|
if defined?(ActionCable)
config.include RSpec::Rails::ChannelExampleGroup, type: :channel
end
end
|
yagihiro/action-cable-testing
|
lib/action-cable-testing.rb
|
# frozen_string_literal: true
require "action_cable/testing"
|
yagihiro/action-cable-testing
|
test/test_helper_test.rb
|
# frozen_string_literal: true
require_relative "test_helper"
class BroadcastChannel < ActionCable::Channel::Base
end
class TransmissionsTest < ActionCable::TestCase
def test_assert_broadcasts
assert_nothing_raised do
assert_broadcasts("test", 1) do
ActionCable.server.broadcast "test", "message"
end
end
end
def test_assert_broadcasts_with_no_block
assert_nothing_raised do
ActionCable.server.broadcast "test", "message"
assert_broadcasts "test", 1
end
assert_nothing_raised do
ActionCable.server.broadcast "test", "message 2"
ActionCable.server.broadcast "test", "message 3"
assert_broadcasts "test", 3
end
end
def test_assert_no_broadcasts_with_no_block
assert_nothing_raised do
assert_no_broadcasts "test"
end
end
def test_assert_no_broadcasts
assert_nothing_raised do
assert_no_broadcasts("test") do
ActionCable.server.broadcast "test2", "message"
end
end
end
def test_assert_broadcasts_message_too_few_sent
ActionCable.server.broadcast "test", "hello"
error = assert_raises Minitest::Assertion do
assert_broadcasts("test", 2) do
ActionCable.server.broadcast "test", "world"
end
end
assert_match(/2 .* but 1/, error.message)
end
def test_assert_broadcasts_message_too_many_sent
error = assert_raises Minitest::Assertion do
assert_broadcasts("test", 1) do
ActionCable.server.broadcast "test", "hello"
ActionCable.server.broadcast "test", "world"
end
end
assert_match(/1 .* but 2/, error.message)
end
def test_assert_broadcast_to_object
user = User.new(42)
assert_nothing_raised do
assert_broadcasts user, 1, channel: BroadcastChannel do
BroadcastChannel.broadcast_to user, text: "text"
end
end
end
def test_assert_broadcast_to_object_without_channel
user = User.new(42)
assert_raises ArgumentError do
assert_broadcasts user, 1 do
BroadcastChannel.broadcast_to user, text: "text"
end
end
end
end
class TransmitedDataTest < ActionCable::TestCase
include ActionCable::TestHelper
def test_assert_broadcast_on
assert_nothing_raised do
assert_broadcast_on("test", "message") do
ActionCable.server.broadcast "test", "message"
end
end
end
def test_assert_broadcast_on_with_hash
assert_nothing_raised do
assert_broadcast_on("test", text: "hello") do
ActionCable.server.broadcast "test", text: "hello"
end
end
end
def test_assert_broadcast_on_with_no_block
assert_nothing_raised do
ActionCable.server.broadcast "test", "hello"
assert_broadcast_on "test", "hello"
end
assert_nothing_raised do
ActionCable.server.broadcast "test", "world"
assert_broadcast_on "test", "world"
end
end
def test_assert_broadcast_on_message
ActionCable.server.broadcast "test", "hello"
error = assert_raises Minitest::Assertion do
assert_broadcast_on("test", "world")
end
assert_match(/No messages sent/, error.message)
end
def test_assert_broadcast_on_object
user = User.new(42)
assert_nothing_raised do
assert_broadcast_on user, { text: "text" }, { channel: BroadcastChannel } do
BroadcastChannel.broadcast_to user, text: "text"
end
end
end
def test_assert_broadcast_on_object_without_channel
user = User.new(42)
assert_raises ArgumentError do
assert_broadcast_on user, text: "text" do
BroadcastChannel.broadcast_to user, text: "text"
end
end
end
end
|
yagihiro/action-cable-testing
|
spec/dummy/app/models/broadcaster.rb
|
class Broadcaster; end
|
yagihiro/action-cable-testing
|
lib/action_cable/testing/version.rb
|
# frozen_string_literal: true
module ActionCable
module Testing
VERSION = "0.3.1"
end
end
|
yagihiro/action-cable-testing
|
lib/action_cable/subscription_adapter/test.rb
|
<gh_stars>100-1000
# frozen_string_literal: true
require "action_cable/subscription_adapter/async"
module ActionCable
module SubscriptionAdapter
# == Test adapter for Action Cable
#
# The test adapter should be used only in testing. Along with
# <tt>ActionCable::TestHelper</tt> it makes a great tool to test your Rails application.
#
# To use the test adapter set adapter value to +test+ in your +cable.yml+.
#
# NOTE: Test adapter extends the <tt>ActionCable::SubscriptionsAdapter::Async</tt> adapter,
# so it could be used in system tests too.
class Test < Async
def broadcast(channel, payload)
broadcasts(channel) << payload
super
end
def broadcasts(channel)
channels_data[channel] ||= []
end
def clear_messages(channel)
channels_data[channel] = []
end
def clear
@channels_data = nil
end
private
def channels_data
@channels_data ||= {}
end
end
end
end
|
yagihiro/action-cable-testing
|
spec/dummy/app/channels/chat_channel.rb
|
<filename>spec/dummy/app/channels/chat_channel.rb<gh_stars>100-1000
class ChatChannel < ApplicationCable::Channel
periodically every: 5.seconds do
transmit action: :now, time: Time.now
end
def subscribed
reject unless user_id.present?
@room_id = params[:room_id]
stream_from "chat_#{@room_id}" if @room_id.present?
end
def speak(data)
ActionCable.server.broadcast(
"chat_#{@room_id}", text: data['message'], user_id: user_id
)
end
def leave
@room_id = nil
stop_all_streams
end
end
|
yagihiro/action-cable-testing
|
features/support/env.rb
|
<gh_stars>100-1000
require "aruba/cucumber"
require "fileutils"
Before do
@aruba_timeout_seconds = 30
end
Before do
example_app_dir = "spec/dummy"
aruba_dir = "tmp/aruba"
# Remove the previous aruba workspace.
FileUtils.rm_rf(aruba_dir) if File.exist?(aruba_dir)
FileUtils.cp_r(example_app_dir, aruba_dir)
end
|
yagihiro/action-cable-testing
|
spec/dummy/app/channels/echo_channel.rb
|
<gh_stars>100-1000
class EchoChannel < ApplicationCable::Channel
def subscribed
end
def echo(data)
data.delete("action")
transmit data
end
end
|
yagihiro/action-cable-testing
|
lib/rspec/rails/shared_contexts/action_cable.rb
|
<reponame>yagihiro/action-cable-testing
# frozen_string_literal: true
# Generate contexts to use specific Action Cable adapter:
# - "action_cable:async" (action_cable: :async)
# - "action_cable:inline" (action_cable: :inline)
# - "action_cable:test" (action_cable: :test)
%w[async inline test].each do |adapter|
RSpec.shared_context "action_cable:#{adapter}" do
require "action_cable/subscription_adapter/#{adapter}"
adapter_class = ActionCable::SubscriptionAdapter.const_get(adapter.capitalize)
before do
next if ActionCable.server.pubsub.is_a?(adapter_class)
@__was_pubsub_adapter__ = ActionCable.server.pubsub
adapter = adapter_class.new(ActionCable.server)
ActionCable.server.instance_variable_set(:@pubsub, adapter)
end
after do
next unless instance_variable_defined?(:@__was_pubsub_adapter__)
ActionCable.server.instance_variable_set(:@pubsub, @__was_pubsub_adapter__)
end
end
RSpec.configure do |config|
config.include_context "action_cable:#{adapter}", action_cable: adapter.to_sym
end
end
|
yagihiro/action-cable-testing
|
lib/action_cable/test_helper.rb
|
<gh_stars>0
# frozen_string_literal: true
module ActionCable
# Provides helper methods for testing Action Cable broadcasting
module TestHelper
CHANNEL_NOT_FOUND = ArgumentError.new("Broadcastnig channel can't be infered. Please, specify it with `:channel`")
def before_setup # :nodoc:
server = ActionCable.server
test_adapter = ActionCable::SubscriptionAdapter::Test.new(server)
@old_pubsub_adapter = server.pubsub
server.instance_variable_set(:@pubsub, test_adapter)
super
end
def after_teardown # :nodoc:
super
ActionCable.server.instance_variable_set(:@pubsub, @old_pubsub_adapter)
end
# Asserts that the number of broadcasted messages to the channel matches the given number.
#
# def test_broadcasts
# assert_broadcasts 'messages', 0
# ActionCable.server.broadcast 'messages', { text: 'hello' }
# assert_broadcasts 'messages', 1
# ActionCable.server.broadcast 'messages', { text: 'world' }
# assert_broadcasts 'messages', 2
# end
#
# If a block is passed, that block should cause the specified number of
# messages to be broadcasted.
#
# def test_broadcasts_again
# assert_broadcasts('messages', 1) do
# ActionCable.server.broadcast 'messages', { text: 'hello' }
# end
#
# assert_broadcasts('messages', 2) do
# ActionCable.server.broadcast 'messages', { text: 'hi' }
# ActionCable.server.broadcast 'messages', { text: 'how are you?' }
# end
# end
#
def assert_broadcasts(target, number, channel: nil)
stream = stream(target, channel)
if block_given?
original_count = broadcasts_size(stream)
yield
new_count = broadcasts_size(stream)
assert_equal number, new_count - original_count, "#{number} broadcasts to #{stream} expected, but #{new_count - original_count} were sent"
else
actual_count = broadcasts_size(stream)
assert_equal number, actual_count, "#{number} broadcasts to #{stream} expected, but #{actual_count} were sent"
end
end
# Asserts that no messages have been sent to the channel.
#
# def test_no_broadcasts
# assert_no_broadcasts 'messages'
# ActionCable.server.broadcast 'messages', { text: 'hi' }
# assert_broadcasts 'messages', 1
# end
#
# If a block is passed, that block should not cause any message to be sent.
#
# def test_broadcasts_again
# assert_no_broadcasts 'messages' do
# # No job messages should be sent from this block
# end
# end
#
# Note: This assertion is simply a shortcut for:
#
# assert_broadcasts 'messages', 0, &block
#
def assert_no_broadcasts(target, &block)
assert_broadcasts target, 0, &block
end
# Asserts that the specified message has been sent to the channel.
#
# def test_assert_transmited_message
# ActionCable.server.broadcast 'messages', text: 'hello'
# assert_broadcast_on('messages', text: 'hello')
# end
#
# If a block is passed, that block should cause a message with the specified data to be sent.
#
# def test_assert_broadcast_on_again
# assert_broadcast_on('messages', text: 'hello') do
# ActionCable.server.broadcast 'messages', text: 'hello'
# end
# end
#
def assert_broadcast_on(target, data, channel: nil)
# Encode to JSON and back–we want to use this value to compare
# with decoded JSON.
# Comparing JSON strings doesn't work due to the order if the keys.
serialized_msg =
ActiveSupport::JSON.decode(ActiveSupport::JSON.encode(data))
stream = stream(target, channel)
new_messages = broadcasts(stream)
if block_given?
old_messages = new_messages
clear_messages(stream)
yield
new_messages = broadcasts(stream)
clear_messages(stream)
# Restore all sent messages
(old_messages + new_messages).each { |m| pubsub_adapter.broadcast(stream, m) }
end
message = new_messages.find { |msg| ActiveSupport::JSON.decode(msg) == serialized_msg }
assert message, "No messages sent with #{data} to #{stream}"
end
def pubsub_adapter # :nodoc:
ActionCable.server.pubsub
end
delegate :broadcasts, :clear_messages, to: :pubsub_adapter
private
def broadcasts_size(channel) # :nodoc:
broadcasts(channel).size
end
def stream(target, channel = nil)
return target if target.is_a?(String)
channel ||= @subscription
raise CHANNEL_NOT_FOUND unless channel && channel.respond_to?(:channel_name)
channel.broadcasting_for([channel.channel_name, target])
end
end
end
|
yagihiro/action-cable-testing
|
lib/action_cable/testing.rb
|
# frozen_string_literal: true
require "action_cable/testing/version"
require "action_cable"
module ActionCable
autoload :TestCase
autoload :TestHelper
module Channel
eager_autoload do
autoload :TestCase
end
end
module Connection
eager_autoload do
autoload :TestCase
end
end
module SubscriptionAdapter
autoload :Test
end
end
|
pwim/emoticon
|
lib/emoticon/conversion_table/docomo.rb
|
module Emoticon
module ConversionTable
DOCOMO_SJIS_TO_UNICODE = {
0xF89F=>0xE63E,
0xF8A0=>0xE63F,
0xF8A1=>0xE640,
0xF8A2=>0xE641,
0xF8A3=>0xE642,
0xF8A4=>0xE643,
0xF8A5=>0xE644,
0xF8A6=>0xE645,
0xF8A7=>0xE646,
0xF8A8=>0xE647,
0xF8A9=>0xE648,
0xF8AA=>0xE649,
0xF8AB=>0xE64A,
0xF8AC=>0xE64B,
0xF8AD=>0xE64C,
0xF8AE=>0xE64D,
0xF8AF=>0xE64E,
0xF8B0=>0xE64F,
0xF8B1=>0xE650,
0xF8B2=>0xE651,
0xF8B3=>0xE652,
0xF8B4=>0xE653,
0xF8B5=>0xE654,
0xF8B6=>0xE655,
0xF8B7=>0xE656,
0xF8B8=>0xE657,
0xF8B9=>0xE658,
0xF8BA=>0xE659,
0xF8BB=>0xE65A,
0xF8BC=>0xE65B,
0xF8BD=>0xE65C,
0xF8BE=>0xE65D,
0xF8BF=>0xE65E,
0xF8C0=>0xE65F,
0xF8C1=>0xE660,
0xF8C2=>0xE661,
0xF8C3=>0xE662,
0xF8C4=>0xE663,
0xF8C5=>0xE664,
0xF8C6=>0xE665,
0xF8C7=>0xE666,
0xF8C8=>0xE667,
0xF8C9=>0xE668,
0xF8CA=>0xE669,
0xF8CB=>0xE66A,
0xF8CC=>0xE66B,
0xF8CD=>0xE66C,
0xF8CE=>0xE66D,
0xF8CF=>0xE66E,
0xF8D0=>0xE66F,
0xF8D1=>0xE670,
0xF8D2=>0xE671,
0xF8D3=>0xE672,
0xF8D4=>0xE673,
0xF8D5=>0xE674,
0xF8D6=>0xE675,
0xF8D7=>0xE676,
0xF8D8=>0xE677,
0xF8D9=>0xE678,
0xF8DA=>0xE679,
0xF8DB=>0xE67A,
0xF8DC=>0xE67B,
0xF8DD=>0xE67C,
0xF8DE=>0xE67D,
0xF8DF=>0xE67E,
0xF8E0=>0xE67F,
0xF8E1=>0xE680,
0xF8E2=>0xE681,
0xF8E3=>0xE682,
0xF8E4=>0xE683,
0xF8E5=>0xE684,
0xF8E6=>0xE685,
0xF8E7=>0xE686,
0xF8E8=>0xE687,
0xF8E9=>0xE688,
0xF8EA=>0xE689,
0xF8EB=>0xE68A,
0xF8EC=>0xE68B,
0xF8ED=>0xE68C,
0xF8EE=>0xE68D,
0xF8EF=>0xE68E,
0xF8F0=>0xE68F,
0xF8F1=>0xE690,
0xF8F2=>0xE691,
0xF8F3=>0xE692,
0xF8F4=>0xE693,
0xF8F5=>0xE694,
0xF8F6=>0xE695,
0xF8F7=>0xE696,
0xF8F8=>0xE697,
0xF8F9=>0xE698,
0xF8FA=>0xE699,
0xF8FB=>0xE69A,
0xF8FC=>0xE69B,
0xF940=>0xE69C,
0xF941=>0xE69D,
0xF942=>0xE69E,
0xF943=>0xE69F,
0xF944=>0xE6A0,
0xF945=>0xE6A1,
0xF946=>0xE6A2,
0xF947=>0xE6A3,
0xF948=>0xE6A4,
0xF949=>0xE6A5,
0xF972=>0xE6CE,
0xF973=>0xE6CF,
0xF974=>0xE6D0,
0xF975=>0xE6D1,
0xF976=>0xE6D2,
0xF977=>0xE6D3,
0xF978=>0xE6D4,
0xF979=>0xE6D5,
0xF97A=>0xE6D6,
0xF97B=>0xE6D7,
0xF97C=>0xE6D8,
0xF97D=>0xE6D9,
0xF97E=>0xE6DA,
0xF980=>0xE6DB,
0xF981=>0xE6DC,
0xF982=>0xE6DD,
0xF983=>0xE6DE,
0xF984=>0xE6DF,
0xF985=>0xE6E0,
0xF986=>0xE6E1,
0xF987=>0xE6E2,
0xF988=>0xE6E3,
0xF989=>0xE6E4,
0xF98A=>0xE6E5,
0xF98B=>0xE6E6,
0xF98C=>0xE6E7,
0xF98D=>0xE6E8,
0xF98E=>0xE6E9,
0xF98F=>0xE6EA,
0xF990=>0xE6EB,
0xF9B0=>0xE70B,
0xF991=>0xE6EC,
0xF992=>0xE6ED,
0xF993=>0xE6EE,
0xF994=>0xE6EF,
0xF995=>0xE6F0,
0xF996=>0xE6F1,
0xF997=>0xE6F2,
0xF998=>0xE6F3,
0xF999=>0xE6F4,
0xF99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732,
0xF9D8=>0xE733,
0xF9D9=>0xE734,
0xF9DA=>0xE735,
0xF9DB=>0xE736,
0xF9DC=>0xE737,
0xF9DD=>0xE738,
0xF9DE=>0xE739,
0xF9DF=>0xE73A,
0xF9E0=>0xE73B,
0xF9E1=>0xE73C,
0xF9E2=>0xE73D,
0xF9E3=>0xE73E,
0xF9E4=>0xE73F,
0xF9E5=>0xE740,
0xF9E6=>0xE741,
0xF9E7=>0xE742,
0xF9E8=>0xE743,
0xF9E9=>0xE744,
0xF9EA=>0xE745,
0xF9EB=>0xE746,
0xF9EC=>0xE747,
0xF9ED=>0xE748,
0xF9EE=>0xE749,
0xF9EF=>0xE74A,
0xF9F0=>0xE74B,
0xF9F1=>0xE74C,
0xF9F2=>0xE74D,
0xF9F3=>0xE74E,
0xF9F4=>0xE74F,
0xF9F5=>0xE750,
0xF9F6=>0xE751,
0xF9F7=>0xE752,
0xF9F8=>0xE753,
0xF9F9=>0xE754,
0xF9FA=>0xE755,
0xF9FB=>0xE756,
0xF9FC=>0xE757,
}.freeze
DOCOMO_UNICODE_TO_SJIS = DOCOMO_SJIS_TO_UNICODE.invert.freeze
end
end
|
pwim/emoticon
|
lib/emoticon/transcoder/jphone.rb
|
<filename>lib/emoticon/transcoder/jphone.rb
require File.join(File.dirname(File.dirname(__FILE__)), "transcoder", "softbank")
class Emoticon::Transcoder::Jphone < Emoticon::Transcoder::Softbank
# +str+のなかでWebcodeのSoftBank絵文字を(+0x1000だけシフトして)Unicode数値文字参照に変換した文字列を返す。
def external_to_unicodecr(str)
# SoftBank Webcode
s = str.clone
# 連続したエスケープコードが省略されている場合は切りはなす。
s.gsub!(/\x1b\x24(.)(.+?)\x0f/) do |match|
a = $1
$2.split(//).map{|x| "\x1b\x24#{a}#{x}\x0f"}.join('')
end
# Webcodeを変換
s.gsub(SOFTBANK_WEBCODE_REGEXP) do |match|
unicode = SOFTBANK_WEBCODE_TO_UNICODE[match[2,2]] + 0x1000
unicode ? ("&#x%04x;"%unicode) : match
end
end
end
|
pwim/emoticon
|
lib/emoticon/transcoder/vodafone.rb
|
<gh_stars>1-10
require File.join(File.dirname(File.dirname(__FILE__)), "transcoder", "softbank")
Emoticon::Transcoder::Vodafone = Emoticon::Transcoder::Softbank
|
pwim/emoticon
|
test/emoticon_test.rb
|
<gh_stars>1-10
require File.dirname(__FILE__) + '/test_helper'
require 'emoticon'
class EmoticonTest < Test::Unit::TestCase
def test_transcoder_for_carrier
assert_instance_of(Emoticon::Transcoder::Docomo, Emoticon.transcoder_for_carrier("docomo"))
assert_instance_of(Emoticon::Transcoder::Au, Emoticon.transcoder_for_carrier("au"))
assert_instance_of(Emoticon::Transcoder::Softbank, Emoticon.transcoder_for_carrier("softbank"))
assert_instance_of(Emoticon::Transcoder::Softbank, Emoticon.transcoder_for_carrier("vodafone"))
assert_instance_of(Emoticon::Transcoder::Jphone, Emoticon.transcoder_for_carrier("jphone"))
assert_instance_of(Emoticon::Transcoder::Null, Emoticon.transcoder_for_carrier("emobile"))
assert_instance_of(Emoticon::Transcoder::Null, Emoticon.transcoder_for_carrier("willcom"))
assert_instance_of(Emoticon::Transcoder::Null, Emoticon.transcoder_for_carrier(""))
assert_instance_of(Emoticon::Transcoder::Null, Emoticon.transcoder_for_carrier(nil))
end
end
|
pwim/emoticon
|
test/emoticon/transcoder/au_test.rb
|
<reponame>pwim/emoticon<gh_stars>1-10
require 'test/unit'
require File.dirname(__FILE__) + '/../../test_helper'
require "emoticon/transcoder/au"
class AuTest < Test::Unit::TestCase
def setup
@transcoder = Emoticon::Transcoder::Au.instance
end
def test_internal_to_external
assert_equal "\xf6\x60", @transcoder.internal_to_external(DOCOMO_CR)
assert_equal "\xf6\x60", @transcoder.internal_to_external(DOCOMO_UTF8)
assert_equal "\xf6\xa0", @transcoder.internal_to_external(DOCOMO_DOCOMO_POINT)
assert_equal "\xf6\x60", @transcoder.internal_to_external(AU_CR)
assert_equal "\xf6\x60", @transcoder.internal_to_external(AU_UTF8)
assert_equal "\xf6\x60", @transcoder.internal_to_external(SOFTBANK_CR)
assert_equal "\xf6\x60", @transcoder.internal_to_external(SOFTBANK_UTF8)
end
end
|
pwim/emoticon
|
lib/emoticon/conversion_table/softbank.rb
|
<filename>lib/emoticon/conversion_table/softbank.rb
module Emoticon
module ConversionTable
SOFTBANK_UNICODE_TO_WEBCODE = {
0xE001 => "G!",
0xE002 => "G\"",
0xE003 => "G#",
0xE004 => "G$",
0xE005 => "G%",
0xE006 => "G&",
0xE007 => "G'",
0xE008 => "G(",
0xE009 => "G)",
0xE00A => "G*",
0xE00B => "G+",
0xE00C => "G,",
0xE00D => "G-",
0xE00E => "G.",
0xE00F => "G/",
0xE010 => "G0",
0xE011 => "G1",
0xE012 => "G2",
0xE013 => "G3",
0xE014 => "G4",
0xE015 => "G5",
0xE016 => "G6",
0xE017 => "G7",
0xE018 => "G8",
0xE019 => "G9",
0xE01A => "G:",
0xE01B => "G;",
0xE01C => "G<",
0xE01D => "G=",
0xE01E => "G>",
0xE01F => "G?",
0xE020 => "G@",
0xE021 => "GA",
0xE022 => "GB",
0xE023 => "GC",
0xE024 => "GD",
0xE025 => "GE",
0xE026 => "GF",
0xE027 => "GG",
0xE028 => "GH",
0xE029 => "GI",
0xE02A => "GJ",
0xE02B => "GK",
0xE02C => "GL",
0xE02D => "GM",
0xE02E => "GN",
0xE02F => "GO",
0xE030 => "GP",
0xE031 => "GQ",
0xE032 => "GR",
0xE033 => "GS",
0xE034 => "GT",
0xE035 => "GU",
0xE036 => "GV",
0xE037 => "GW",
0xE038 => "GX",
0xE039 => "GY",
0xE03A => "GZ",
0xE03B => "G[",
0xE03C => "G\\",
0xE03D => "G]",
0xE03E => "G^",
0xE03F => "G_",
0xE040 => "G`",
0xE041 => "Ga",
0xE042 => "Gb",
0xE043 => "Gc",
0xE044 => "Gd",
0xE045 => "Ge",
0xE046 => "Gf",
0xE047 => "Gg",
0xE048 => "Gh",
0xE049 => "Gi",
0xE04A => "Gj",
0xE04B => "Gk",
0xE04C => "Gl",
0xE04D => "Gm",
0xE04E => "Gn",
0xE04F => "Go",
0xE050 => "Gp",
0xE051 => "Gq",
0xE052 => "Gr",
0xE053 => "Gs",
0xE054 => "Gt",
0xE055 => "Gu",
0xE056 => "Gv",
0xE057 => "Gw",
0xE058 => "Gx",
0xE059 => "Gy",
0xE05A => "Gz",
0xE101 => "E!",
0xE102 => "E\"",
0xE103 => "E#",
0xE104 => "E$",
0xE105 => "E%",
0xE106 => "E&",
0xE107 => "E'",
0xE108 => "E(",
0xE109 => "E)",
0xE10A => "E*",
0xE10B => "E+",
0xE10C => "E,",
0xE10D => "E-",
0xE10E => "E.",
0xE10F => "E/",
0xE110 => "E0",
0xE111 => "E1",
0xE112 => "E2",
0xE113 => "E3",
0xE114 => "E4",
0xE115 => "E5",
0xE116 => "E6",
0xE117 => "E7",
0xE118 => "E8",
0xE119 => "E9",
0xE11A => "E:",
0xE11B => "E;",
0xE11C => "E<",
0xE11D => "E=",
0xE11E => "E>",
0xE11F => "E?",
0xE120 => "E@",
0xE121 => "EA",
0xE122 => "EB",
0xE123 => "EC",
0xE124 => "ED",
0xE125 => "EE",
0xE126 => "EF",
0xE127 => "EG",
0xE128 => "EH",
0xE129 => "EI",
0xE12A => "EJ",
0xE12B => "EK",
0xE12C => "EL",
0xE12D => "EM",
0xE12E => "EN",
0xE12F => "EO",
0xE130 => "EP",
0xE131 => "EQ",
0xE132 => "ER",
0xE133 => "ES",
0xE134 => "ET",
0xE135 => "EU",
0xE136 => "EV",
0xE137 => "EW",
0xE138 => "EX",
0xE139 => "EY",
0xE13A => "EZ",
0xE13B => "E[",
0xE13C => "E\\",
0xE13D => "E]",
0xE13E => "E^",
0xE13F => "E_",
0xE140 => "E`",
0xE141 => "Ea",
0xE142 => "Eb",
0xE143 => "Ec",
0xE144 => "Ed",
0xE145 => "Ee",
0xE146 => "Ef",
0xE147 => "Eg",
0xE148 => "Eh",
0xE149 => "Ei",
0xE14A => "Ej",
0xE14B => "Ek",
0xE14C => "El",
0xE14D => "Em",
0xE14E => "En",
0xE14F => "Eo",
0xE150 => "Ep",
0xE151 => "Eq",
0xE152 => "Er",
0xE153 => "Es",
0xE154 => "Et",
0xE155 => "Eu",
0xE156 => "Ev",
0xE157 => "Ew",
0xE158 => "Ex",
0xE159 => "Ey",
0xE15A => "Ez",
0xE201 => "F!",
0xE202 => "F\"",
0xE203 => "F#",
0xE204 => "F$",
0xE205 => "F%",
0xE206 => "F&",
0xE207 => "F'",
0xE208 => "F(",
0xE209 => "F)",
0xE20A => "F*",
0xE20B => "F+",
0xE20C => "F,",
0xE20D => "F-",
0xE20E => "F.",
0xE20F => "F/",
0xE210 => "F0",
0xE211 => "F1",
0xE212 => "F2",
0xE213 => "F3",
0xE214 => "F4",
0xE215 => "F5",
0xE216 => "F6",
0xE217 => "F7",
0xE218 => "F8",
0xE219 => "F9",
0xE21A => "F:",
0xE21B => "F;",
0xE21C => "F<",
0xE21D => "F=",
0xE21E => "F>",
0xE21F => "F?",
0xE220 => "F@",
0xE221 => "FA",
0xE222 => "FB",
0xE223 => "FC",
0xE224 => "FD",
0xE225 => "FE",
0xE226 => "FF",
0xE227 => "FG",
0xE228 => "FH",
0xE229 => "FI",
0xE22A => "FJ",
0xE22B => "FK",
0xE22C => "FL",
0xE22D => "FM",
0xE22E => "FN",
0xE22F => "FO",
0xE230 => "FP",
0xE231 => "FQ",
0xE232 => "FR",
0xE233 => "FS",
0xE234 => "FT",
0xE235 => "FU",
0xE236 => "FV",
0xE237 => "FW",
0xE238 => "FX",
0xE239 => "FY",
0xE23A => "FZ",
0xE23B => "F[",
0xE23C => "F\\",
0xE23D => "F]",
0xE23E => "F^",
0xE23F => "F_",
0xE240 => "F`",
0xE241 => "Fa",
0xE242 => "Fb",
0xE243 => "Fc",
0xE244 => "Fd",
0xE245 => "Fe",
0xE246 => "Ff",
0xE247 => "Fg",
0xE248 => "Fh",
0xE249 => "Fi",
0xE24A => "Fj",
0xE24B => "Fk",
0xE24C => "Fl",
0xE24D => "Fm",
0xE24E => "Fn",
0xE24F => "Fo",
0xE250 => "Fp",
0xE251 => "Fq",
0xE252 => "Fr",
0xE253 => "Fs",
0xE255 => "Fu",
0xE256 => "Fv",
0xE257 => "Fw",
0xE301 => "O!",
0xE302 => "O\"",
0xE303 => "O#",
0xE304 => "O$",
0xE305 => "O%",
0xE306 => "O&",
0xE307 => "O'",
0xE308 => "O(",
0xE309 => "O)",
0xE30A => "O*",
0xE30B => "O+",
0xE30C => "O,",
0xE30D => "O-",
0xE30E => "O.",
0xE30F => "O/",
0xE310 => "O0",
0xE311 => "O1",
0xE312 => "O2",
0xE313 => "O3",
0xE314 => "O4",
0xE315 => "O5",
0xE316 => "O6",
0xE317 => "O7",
0xE318 => "O8",
0xE319 => "O9",
0xE31A => "O:",
0xE31B => "O;",
0xE31C => "O<",
0xE31D => "O=",
0xE31E => "O>",
0xE31F => "O?",
0xE320 => "O@",
0xE321 => "OA",
0xE322 => "OB",
0xE323 => "OC",
0xE324 => "OD",
0xE325 => "OE",
0xE326 => "OF",
0xE327 => "OG",
0xE328 => "OH",
0xE329 => "OI",
0xE32A => "OJ",
0xE32B => "OK",
0xE32C => "OL",
0xE32D => "OM",
0xE32E => "ON",
0xE32F => "OO",
0xE330 => "OP",
0xE331 => "OQ",
0xE332 => "OR",
0xE333 => "OS",
0xE334 => "OT",
0xE335 => "OU",
0xE336 => "OV",
0xE337 => "OW",
0xE338 => "OX",
0xE339 => "OY",
0xE33A => "OZ",
0xE33B => "O[",
0xE33C => "O\\",
0xE33D => "O]",
0xE33E => "O^",
0xE33F => "O_",
0xE340 => "O`",
0xE341 => "Oa",
0xE342 => "Ob",
0xE343 => "Oc",
0xE344 => "Od",
0xE345 => "Oe",
0xE346 => "Of",
0xE347 => "Og",
0xE348 => "Oh",
0xE349 => "Oi",
0xE34A => "Oj",
0xE34B => "Ok",
0xE34C => "Ol",
0xE34D => "Om",
0xE401 => "P!",
0xE402 => "P\"",
0xE403 => "P#",
0xE404 => "P$",
0xE405 => "P%",
0xE406 => "P&",
0xE407 => "P'",
0xE408 => "P(",
0xE409 => "P)",
0xE40A => "P*",
0xE40B => "P+",
0xE40C => "P,",
0xE40D => "P-",
0xE40E => "P.",
0xE40F => "P/",
0xE410 => "P0",
0xE411 => "P1",
0xE412 => "P2",
0xE413 => "P3",
0xE414 => "P4",
0xE415 => "P5",
0xE416 => "P6",
0xE417 => "P7",
0xE418 => "P8",
0xE419 => "P9",
0xE41A => "P:",
0xE41B => "P;",
0xE41C => "P<",
0xE41D => "P=",
0xE41E => "P>",
0xE41F => "P?",
0xE420 => "P@",
0xE421 => "PA",
0xE422 => "PB",
0xE423 => "PC",
0xE424 => "PD",
0xE425 => "PE",
0xE426 => "PF",
0xE427 => "PG",
0xE428 => "PH",
0xE429 => "PI",
0xE42A => "PJ",
0xE42B => "PK",
0xE42C => "PL",
0xE42D => "PM",
0xE42E => "PN",
0xE42F => "PO",
0xE430 => "PP",
0xE431 => "PQ",
0xE432 => "PR",
0xE433 => "PS",
0xE434 => "PT",
0xE435 => "PU",
0xE436 => "PV",
0xE437 => "PW",
0xE438 => "PX",
0xE439 => "PY",
0xE43A => "PZ",
0xE43B => "P[",
0xE43C => "P\\",
0xE43D => "P]",
0xE43E => "P^",
0xE43F => "P_",
0xE440 => "P`",
0xE441 => "Pa",
0xE442 => "Pb",
0xE443 => "Pc",
0xE444 => "Pd",
0xE445 => "Pe",
0xE446 => "Pf",
0xE447 => "Pg",
0xE448 => "Ph",
0xE449 => "Pi",
0xE44A => "Pj",
0xE44B => "Pk",
0xE44C => "Pl",
0xE501 => "Q!",
0xE502 => "Q\"",
0xE503 => "Q#",
0xE504 => "Q$",
0xE505 => "Q%",
0xE506 => "Q&",
0xE507 => "Q'",
0xE508 => "Q(",
0xE509 => "Q)",
0xE50A => "Q*",
0xE50B => "Q+",
0xE50C => "Q,",
0xE50D => "Q-",
0xE50E => "Q.",
0xE50F => "Q/",
0xE510 => "Q0",
0xE511 => "Q1",
0xE512 => "Q2",
0xE513 => "Q3",
0xE514 => "Q4",
0xE515 => "Q5",
0xE516 => "Q6",
0xE517 => "Q7",
0xE518 => "Q8",
0xE519 => "Q9",
0xE51A => "Q:",
0xE51B => "Q;",
0xE51C => "Q<",
0xE51D => "Q=",
0xE51E => "Q>",
0xE51F => "Q?",
0xE520 => "Q@",
0xE521 => "QA",
0xE522 => "QB",
0xE523 => "QC",
0xE524 => "QD",
0xE525 => "QE",
0xE526 => "QF",
0xE527 => "QG",
0xE528 => "QH",
0xE529 => "QI",
0xE52A => "QJ",
0xE52B => "QK",
0xE52C => "QL",
0xE52D => "QM",
0xE52E => "QN",
0xE52F => "QO",
0xE530 => "QP",
0xE531 => "QQ",
0xE532 => "QR",
0xE533 => "QS",
0xE534 => "QT",
0xE535 => "QU",
0xE536 => "QV",
0xE537 => "QW",
}
SOFTBANK_WEBCODE_TO_UNICODE = SOFTBANK_UNICODE_TO_WEBCODE.invert
end
end
|
pwim/emoticon
|
lib/emoticon/transcoder/au.rb
|
require File.join(File.dirname(File.dirname(__FILE__)), "transcoder")
class Emoticon::Transcoder::Au < Emoticon::Transcoder
# +str+ のなかでDoCoMo絵文字をUnicode数値文字参照に置換した文字列を返す。
def external_to_unicodecr(str)
str.gsub(AU_SJIS_REGEXP) do |match|
sjis = match.unpack('n').first
unicode = AU_SJIS_TO_UNICODE[sjis]
unicode ? ("&#x%04x;"%unicode) : match
end
end
private
def to_sjis
true
end
def conversion_table
CONVERSION_TABLE_TO_AU
end
end
|
pwim/emoticon
|
test/test_helper.rb
|
<filename>test/test_helper.rb
require 'test/unit'
$:.unshift File.dirname(__FILE__) + '/../lib'
DOCOMO_CR = ""
DOCOMO_UTF8 = [0xe63e].pack("U")
DOCOMO_DOCOMO_POINT = ""
AU_CR = ""
AU_UTF8 = [0xe488].pack("U")
SOFTBANK_CR = ""
SOFTBANK_UTF8 = [0xf04a].pack("U")
|
pwim/emoticon
|
lib/emoticon.rb
|
Dir.glob(File.join(File.dirname(__FILE__), "emoticon", "transcoder", "*.rb")) do |file|
require "emoticon/transcoder/#{File.basename(file, ".rb")}"
end
module Emoticon
def self.transcoder_for_carrier(carrier)
name = carrier.to_s.capitalize
if !name.empty? && Transcoder.const_defined?(name)
Transcoder.const_get(name).instance
else
Transcoder::Null.instance
end
end
end
|
pwim/emoticon
|
lib/emoticon/transcoder/null.rb
|
require File.join(File.dirname(File.dirname(__FILE__)), "transcoder")
class Emoticon::Transcoder::Null < Emoticon::Transcoder
# 対応する変換メソッドが定義されていない場合は素通し
def external_to_unicodecr(str)
str
end
end
|
pwim/emoticon
|
lib/emoticon/conversion_table/au.rb
|
<gh_stars>1-10
module Emoticon
module ConversionTable
AU_SJIS_TO_UNICODE = {
0xF659=>0xE481,
0xF75E=>0xE542,
0xF65A=>0xE482,
0xF75F=>0xE543,
0xF65B=>0xE483,
0xF760=>0xE544,
0xF748=>0xE52C,
0xF761=>0xE545,
0xF749=>0xE52D,
0xF762=>0xE546,
0xF74A=>0xE52E,
0xF763=>0xE547,
0xF74B=>0xE52F,
0xF764=>0xE548,
0xF74C=>0xE530,
0xF765=>0xE549,
0xF74D=>0xE531,
0xF766=>0xE54A,
0xF74E=>0xE532,
0xF767=>0xE54B,
0xF74F=>0xE533,
0xF768=>0xE54C,
0xF69A=>0xE4C1,
0xF769=>0xE54D,
0xF6EA=>0xE511,
0xF660=>0xE488,
0xF796=>0xE579,
0xF693=>0xE4BA,
0xF65E=>0xE486,
0xF7B1=>0xE594,
0xF65F=>0xE487,
0xF661=>0xE489,
0xF750=>0xE534,
0xF6EB=>0xE512,
0xF751=>0xE535,
0xF77C=>0xE560,
0xF752=>0xE536,
0xF6D3=>0xE4FA,
0xF753=>0xE537,
0xF7B2=>0xE595,
0xF754=>0xE538,
0xF69B=>0xE4C2,
0xF755=>0xE539,
0xF6EC=>0xE513,
0xF756=>0xE53A,
0xF76A=>0xE54E,
0xF757=>0xE53B,
0xF76B=>0xE54F,
0xF797=>0xE57A,
0xF77D=>0xE561,
0xF758=>0xE53C,
0xF798=>0xE57B,
0xF759=>0xE53D,
0xF654=>0xE47C,
0xF75A=>0xE53E,
0xF77E=>0xE562,
0xF75B=>0xE53F,
0xF662=>0xE48A,
0xF75C=>0xE540,
0xF76C=>0xE550,
0xF75D=>0xE541,
0xF76D=>0xE551,
0xF76E=>0xE552,
0xF6EE=>0xE515,
0xF76F=>0xE553,
0xF664=>0xE48C,
0xF69C=>0xE4C3,
0xF694=>0xE4BB,
0xF770=>0xE554,
0xF782=>0xE565,
0xF780=>0xE563,
0xF65C=>0xE484,
0xF6D4=>0xE4FB,
0xF642=>0xE46A,
0xF663=>0xE48B,
0xF783=>0xE566,
0xF771=>0xE555,
0xF784=>0xE567,
0xF772=>0xE556,
0xF785=>0xE568,
0xF6ED=>0xE514,
0xF786=>0xE569,
0xF773=>0xE557,
0xF6EF=>0xE516,
0xF6B8=>0xE4DF,
0xF787=>0xE56A,
0xF640=>0xE468,
0xF676=>0xE49E,
0xF644=>0xE46C,
0xF665=>0xE48D,
0xF64E=>0xE476,
0xF6FA=>0xE521,
0xF6B9=>0xE4E0,
0xF79A=>0xE57D,
0xF7AC=>0xE58F,
0xF6F0=>0xE517,
0xF6D5=>0xE4FC,
0xF79B=>0xE57E,
0xF774=>0xE558,
0xF684=>0xE4AB,
0xF775=>0xE559,
0xF6BD=>0xE4E4,
0xF674=>0xE49C,
0xF79C=>0xE57F,
0xF7AD=>0xE590,
0xF79D=>0xE580,
0xF7B3=>0xE596,
0xF6D7=>0xE4FE,
0xF6D6=>0xE4FD,
0xF778=>0xE55C,
0xF799=>0xE57C,
0xF779=>0xE55D,
0xF776=>0xE55A,
0xF6F1=>0xE518,
0xF777=>0xE55B,
0xF6F2=>0xE519,
0xF790=>0xE573,
0xF788=>0xE56B,
0xF675=>0xE49D,
0xF677=>0xE49F,
0xF781=>0xE564,
0xF79E=>0xE581,
0xF7B4=>0xE597,
0xF6F3=>0xE51A,
0xF68A=>0xE4B1,
0xF686=>0xE4AD,
0xF79F=>0xE582,
0xF78D=>0xE570,
0xF791=>0xE574,
0xF67A=>0xE4A2,
0xF792=>0xE575,
0xF793=>0xE576,
0xF6F4=>0xE51B,
0xF69D=>0xE4C4,
0xF7A0=>0xE583,
0xF7A5=>0xE588,
0xF789=>0xE56C,
0xF7A6=>0xE589,
0xF77A=>0xE55E,
0xF6DA=>0xE501,
0xF6A7=>0xE4CE,
0xF7A7=>0xE58A,
0xF6BA=>0xE4E1,
0xF6F8=>0xE51F,
0xF7A1=>0xE584,
0xF6F9=>0xE520,
0xF77B=>0xE55F,
0xF666=>0xE48E,
0xF78A=>0xE56D,
0xF68C=>0xE4B3,
0xF6F5=>0xE51C,
0xF68D=>0xE4B4,
0xF7A2=>0xE585,
0xF6A1=>0xE4C8,
0xF6D8=>0xE4FF,
0xF7A8=>0xE58B,
0xF6D9=>0xE500,
0xF68E=>0xE4B5,
0xF78B=>0xE56E,
0xF7A9=>0xE58C,
0xF678=>0xE4A0,
0xF7AA=>0xE58D,
0xF6A8=>0xE4CF,
0xF7AB=>0xE58E,
0xF6F6=>0xE51D,
0xF655=>0xE47D,
0xF685=>0xE4AC,
0xF656=>0xE47E,
0xF78C=>0xE56F,
0xF657=>0xE47F,
0xF68B=>0xE4B2,
0xF658=>0xE480,
0xF679=>0xE4A1,
0xF6FB=>0xE522,
0xF7A3=>0xE586,
0xF6FC=>0xE523,
0xF7AE=>0xE591,
0xF740=>0xE524,
0xF7A4=>0xE587,
0xF741=>0xE525,
0xF7AF=>0xE592,
0xF742=>0xE526,
0xF7B0=>0xE593,
0xF743=>0xE527,
0xF6F7=>0xE51E,
0xF744=>0xE528,
0xF745=>0xE529,
0xF643=>0xE46B,
0xF746=>0xE52A,
0xF68F=>0xE4B6,
0xF747=>0xE52B,
0xF690=>0xE4B7,
0xF641=>0xE469,
0xF691=>0xE4B8,
0xF65D=>0xE485,
0xF692=>0xE4B9,
0xF667=>0xE48F,
0xF645=>0xE46D,
0xF668=>0xE490,
0xF695=>0xE4BC,
0xF669=>0xE491,
0xF696=>0xE4BD,
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
0xF3F0=>0xEB2F,
0xF3D2=>0xEB11,
0xF3F1=>0xEB30,
0xF3D3=>0xEB12,
0xF3F2=>0xEB31,
0xF3D4=>0xEB13,
0xF3F3=>0xEB32,
0xF3D5=>0xEB14,
0xF3F4=>0xEB33,
0xF3D6=>0xEB15,
0xF3F5=>0xEB34,
0xF3D7=>0xEB16,
0xF3F6=>0xEB35,
0xF3F7=>0xEB36,
0xF459=>0xEB55,
0xF3F8=>0xEB37,
0xF45A=>0xEB56,
0xF3F9=>0xEB38,
0xF45B=>0xEB57,
0xF3FA=>0xEB39,
0xF45C=>0xEB58,
0xF3FB=>0xEB3A,
0xF45D=>0xEB59,
0xF3FC=>0xEB3B,
0xF45E=>0xEB5A,
0xF440=>0xEB3C,
0xF45F=>0xEB5B,
0xF441=>0xEB3D,
0xF460=>0xEB5C,
0xF442=>0xEB3E,
0xF461=>0xEB5D,
0xF443=>0xEB3F,
0xF462=>0xEB5E,
0xF444=>0xEB40,
0xF463=>0xEB5F,
0xF445=>0xEB41,
0xF464=>0xEB60,
0xF446=>0xEB42,
0xF465=>0xEB61,
0xF447=>0xEB43,
0xF466=>0xEB62,
0xF448=>0xEB44,
0xF467=>0xEB63,
0xF449=>0xEB45,
0xF468=>0xEB64,
0xF44A=>0xEB46,
0xF469=>0xEB65,
0xF44B=>0xEB47,
0xF46A=>0xEB66,
0xF44C=>0xEB48,
0xF46B=>0xEB67,
0xF44D=>0xEB49,
0xF46C=>0xEB68,
0xF44E=>0xEB4A,
0xF46D=>0xEB69,
0xF44F=>0xEB4B,
0xF46E=>0xEB6A,
0xF450=>0xEB4C,
0xF46F=>0xEB6B,
0xF451=>0xEB4D,
0xF470=>0xEB6C,
0xF452=>0xEB4E,
0xF471=>0xEB6D,
0xF453=>0xEB4F,
0xF472=>0xEB6E,
0xF454=>0xEB50,
0xF473=>0xEB6F,
0xF455=>0xEB51,
0xF474=>0xEB70,
0xF456=>0xEB52,
0xF475=>0xEB71,
0xF457=>0xEB53,
0xF476=>0xEB72,
0xF458=>0xEB54,
0xF477=>0xEB73,
0xF478=>0xEB74,
0xF479=>0xEB75,
0xF47A=>0xEB76,
0xF47B=>0xEB77,
0xF47C=>0xEB78,
0xF47D=>0xEB79,
0xF47E=>0xEB7A,
0xF480=>0xEB7B,
0xF481=>0xEB7C,
0xF482=>0xEB7D,
0xF483=>0xEB7E,
0xF484=>0xEB7F,
0xF485=>0xEB80,
0xF486=>0xEB81,
0xF487=>0xEB82,
0xF488=>0xEB83,
0xF489=>0xEB84,
0xF48A=>0xEB85,
0xF48B=>0xEB86,
0xF48C=>0xEB87,
0xF48D=>0xEB88,
}.freeze
AU_UNICODE_TO_SJIS = AU_SJIS_TO_UNICODE.invert.freeze
AU_EMAILJIS_TO_UNICODE = {
0x753A=>0xE481,
0x773F=>0xE542,
0x753B=>0xE482,
0x7740=>0xE543,
0x753C=>0xE483,
0x7741=>0xE544,
0x7729=>0xE52C,
0x7742=>0xE545,
0x772A=>0xE52D,
0x7743=>0xE546,
0x772B=>0xE52E,
0x7744=>0xE547,
0x772C=>0xE52F,
0x7745=>0xE548,
0x772D=>0xE530,
0x7746=>0xE549,
0x772E=>0xE531,
0x7747=>0xE54A,
0x772F=>0xE532,
0x7748=>0xE54B,
0x7730=>0xE533,
0x7749=>0xE54C,
0x757A=>0xE4C1,
0x774A=>0xE54D,
0x766C=>0xE511,
0x7541=>0xE488,
0x7776=>0xE579,
0x7573=>0xE4BA,
0x753F=>0xE486,
0x7833=>0xE594,
0x7540=>0xE487,
0x7542=>0xE489,
0x7731=>0xE534,
0x766D=>0xE512,
0x7732=>0xE535,
0x775D=>0xE560,
0x7733=>0xE536,
0x7655=>0xE4FA,
0x7734=>0xE537,
0x7834=>0xE595,
0x7735=>0xE538,
0x757B=>0xE4C2,
0x7736=>0xE539,
0x766E=>0xE513,
0x7737=>0xE53A,
0x774B=>0xE54E,
0x7738=>0xE53B,
0x774C=>0xE54F,
0x7777=>0xE57A,
0x775E=>0xE561,
0x7739=>0xE53C,
0x7778=>0xE57B,
0x773A=>0xE53D,
0x7535=>0xE47C,
0x773B=>0xE53E,
0x775F=>0xE562,
0x773C=>0xE53F,
0x7543=>0xE48A,
0x773D=>0xE540,
0x774D=>0xE550,
0x773E=>0xE541,
0x774E=>0xE551,
0x774F=>0xE552,
0x7670=>0xE515,
0x7750=>0xE553,
0x7545=>0xE48C,
0x757C=>0xE4C3,
0x7574=>0xE4BB,
0x7751=>0xE554,
0x7762=>0xE565,
0x7760=>0xE563,
0x753D=>0xE484,
0x7656=>0xE4FB,
0x7523=>0xE46A,
0x7544=>0xE48B,
0x7763=>0xE566,
0x7752=>0xE555,
0x7764=>0xE567,
0x7753=>0xE556,
0x7765=>0xE568,
0x766F=>0xE514,
0x7766=>0xE569,
0x7754=>0xE557,
0x7671=>0xE516,
0x763A=>0xE4DF,
0x7767=>0xE56A,
0x7521=>0xE468,
0x7557=>0xE49E,
0x7525=>0xE46C,
0x7546=>0xE48D,
0x752F=>0xE476,
0x767C=>0xE521,
0x763B=>0xE4E0,
0x777A=>0xE57D,
0x782E=>0xE58F,
0x7672=>0xE517,
0x7657=>0xE4FC,
0x777B=>0xE57E,
0x7755=>0xE558,
0x7564=>0xE4AB,
0x7756=>0xE559,
0x763F=>0xE4E4,
0x7555=>0xE49C,
0x777C=>0xE57F,
0x782F=>0xE590,
0x777D=>0xE580,
0x7835=>0xE596,
0x7659=>0xE4FE,
0x7658=>0xE4FD,
0x7759=>0xE55C,
0x7779=>0xE57C,
0x775A=>0xE55D,
0x7757=>0xE55A,
0x7673=>0xE518,
0x7758=>0xE55B,
0x7674=>0xE519,
0x7770=>0xE573,
0x7768=>0xE56B,
0x7556=>0xE49D,
0x7558=>0xE49F,
0x7761=>0xE564,
0x777E=>0xE581,
0x7836=>0xE597,
0x7675=>0xE51A,
0x756A=>0xE4B1,
0x7566=>0xE4AD,
0x7821=>0xE582,
0x776D=>0xE570,
0x7771=>0xE574,
0x755B=>0xE4A2,
0x7772=>0xE575,
0x7773=>0xE576,
0x7676=>0xE51B,
0x757D=>0xE4C4,
0x7822=>0xE583,
0x7827=>0xE588,
0x7769=>0xE56C,
0x7828=>0xE589,
0x775B=>0xE55E,
0x765C=>0xE501,
0x7629=>0xE4CE,
0x7829=>0xE58A,
0x763C=>0xE4E1,
0x767A=>0xE51F,
0x7823=>0xE584,
0x767B=>0xE520,
0x775C=>0xE55F,
0x7547=>0xE48E,
0x776A=>0xE56D,
0x756C=>0xE4B3,
0x7677=>0xE51C,
0x756D=>0xE4B4,
0x7824=>0xE585,
0x7623=>0xE4C8,
0x765A=>0xE4FF,
0x782A=>0xE58B,
0x765B=>0xE500,
0x756E=>0xE4B5,
0x776B=>0xE56E,
0x782B=>0xE58C,
0x7559=>0xE4A0,
0x782C=>0xE58D,
0x762A=>0xE4CF,
0x782D=>0xE58E,
0x7678=>0xE51D,
0x7536=>0xE47D,
0x7565=>0xE4AC,
0x7537=>0xE47E,
0x776C=>0xE56F,
0x7538=>0xE47F,
0x756B=>0xE4B2,
0x7539=>0xE480,
0x755A=>0xE4A1,
0x767D=>0xE522,
0x7825=>0xE586,
0x767E=>0xE523,
0x7830=>0xE591,
0x7721=>0xE524,
0x7826=>0xE587,
0x7722=>0xE525,
0x7831=>0xE592,
0x7723=>0xE526,
0x7832=>0xE593,
0x7724=>0xE527,
0x7679=>0xE51E,
0x7725=>0xE528,
0x7726=>0xE529,
0x7524=>0xE46B,
0x7727=>0xE52A,
0x756F=>0xE4B6,
0x7728=>0xE52B,
0x7570=>0xE4B7,
0x7522=>0xE469,
0x7571=>0xE4B8,
0x753E=>0xE485,
0x7572=>0xE4B9,
0x7548=>0xE48F,
0x7526=>0xE46D,
0x7549=>0xE490,
0x7575=>0xE4BC,
0x754A=>0xE491,
0x7576=>0xE4BD,
0x754B=>0xE492,
0x7577=>0xE4BE,
0x754C=>0xE493,
0x7578=>0xE4BF,
0x754D=>0xE494,
0x7579=>0xE4C0,
0x754E=>0xE495,
0x7527=>0xE46E,
0x754F=>0xE496,
0x7528=>0xE46F,
0x7550=>0xE497,
0x757E=>0xE4C5,
0x7551=>0xE498,
0x7621=>0xE4C6,
0x7552=>0xE499,
0x7622=>0xE4C7,
0x7553=>0xE49A,
0x7624=>0xE4C9,
0x7554=>0xE49B,
0x7625=>0xE4CA,
0x755C=>0xE4A3,
0x7626=>0xE4CB,
0x755D=>0xE4A4,
0x7627=>0xE4CC,
0x755E=>0xE4A5,
0x7628=>0xE4CD,
0x755F=>0xE4A6,
0x762B=>0xE4D0,
0x7560=>0xE4A7,
0x762C=>0xE4D1,
0x7561=>0xE4A8,
0x762D=>0xE4D2,
0x7562=>0xE4A9,
0x762E=>0xE4D3,
0x7563=>0xE4AA,
0x762F=>0xE4D4,
0x776E=>0xE571,
0x7630=>0xE4D5,
0x776F=>0xE572,
0x7631=>0xE4D6,
0x7567=>0xE4AE,
0x7529=>0xE470,
0x7568=>0xE4AF,
0x7632=>0xE4D7,
0x7569=>0xE4B0,
0x7633=>0xE4D8,
0x7634=>0xE4D9,
0x764D=>0xE4F2,
0x7635=>0xE4DA,
0x764E=>0xE4F3,
0x7636=>0xE4DB,
0x764F=>0xE4F4,
0x7637=>0xE4DC,
0x7650=>0xE4F5,
0x7638=>0xE4DD,
0x7651=>0xE4F6,
0x7639=>0xE4DE,
0x7652=>0xE4F7,
0x763D=>0xE4E2,
0x7653=>0xE4F8,
0x763E=>0xE4E3,
0x7654=>0xE4F9,
0x752A=>0xE471,
0x765D=>0xE502,
0x752B=>0xE472,
0x765E=>0xE503,
0x752C=>0xE473,
0x765F=>0xE504,
0x752D=>0xE474,
0x7660=>0xE505,
0x752E=>0xE475,
0x7661=>0xE506,
0x7640=>0xE4E5,
0x7662=>0xE507,
0x7641=>0xE4E6,
0x7663=>0xE508,
0x7642=>0xE4E7,
0x7664=>0xE509,
0x7530=>0xE477,
0x7665=>0xE50A,
0x7531=>0xE478,
0x7666=>0xE50B,
0x7532=>0xE479,
0x7774=>0xE577,
0x7533=>0xE47A,
0x7775=>0xE578,
0x7534=>0xE47B,
0x7667=>0xE50C,
0x7643=>0xE4E8,
0x7668=>0xE50D,
0x7644=>0xE4E9,
0x7669=>0xE50E,
0x7645=>0xE4EA,
0x766A=>0xE50F,
0x7646=>0xE4EB,
0x766B=>0xE510,
0x7647=>0xE4EC,
0x7837=>0xE598,
0x7648=>0xE4ED,
0x7838=>0xE599,
0x7649=>0xE4EE,
0x7839=>0xE59A,
0x764A=>0xE4EF,
0x783A=>0xE59B,
0x764B=>0xE4F0,
0x783B=>0xE59C,
0x764C=>0xE4F1,
0x783C=>0xE59D,
0x783D=>0xE59E,
0x786F=>0xE5BD,
0x783E=>0xE59F,
0x7870=>0xE5BE,
0x783F=>0xE5A0,
0x7871=>0xE5BF,
0x7840=>0xE5A1,
0x7872=>0xE5C0,
0x7841=>0xE5A2,
0x7873=>0xE5C1,
0x7842=>0xE5A3,
0x7874=>0xE5C2,
0x7843=>0xE5A4,
0x7875=>0xE5C3,
0x7844=>0xE5A5,
0x7876=>0xE5C4,
0x7845=>0xE5A6,
0x7877=>0xE5C5,
0x7846=>0xE5A7,
0x7878=>0xE5C6,
0x7847=>0xE5A8,
0x7879=>0xE5C7,
0x7848=>0xE5A9,
0x787A=>0xE5C8,
0x7849=>0xE5AA,
0x787B=>0xE5C9,
0x784A=>0xE5AB,
0x787C=>0xE5CA,
0x784B=>0xE5AC,
0x787D=>0xE5CB,
0x784C=>0xE5AD,
0x787E=>0xE5CC,
0x784D=>0xE5AE,
0x7921=>0xE5CD,
0x784E=>0xE5AF,
0x7922=>0xE5CE,
0x784F=>0xE5B0,
0x7923=>0xE5CF,
0x7850=>0xE5B1,
0x7924=>0xE5D0,
0x7851=>0xE5B2,
0x7925=>0xE5D1,
0x7852=>0xE5B3,
0x7926=>0xE5D2,
0x7853=>0xE5B4,
0x7927=>0xE5D3,
0x7867=>0xE5B5,
0x7928=>0xE5D4,
0x7868=>0xE5B6,
0x7929=>0xE5D5,
0x7869=>0xE5B7,
0x792A=>0xE5D6,
0x786A=>0xE5B8,
0x792B=>0xE5D7,
0x786B=>0xE5B9,
0x792C=>0xE5D8,
0x786C=>0xE5BA,
0x792D=>0xE5D9,
0x786D=>0xE5BB,
0x792E=>0xE5DA,
0x786E=>0xE5BC,
0x792F=>0xE5DB,
0x7930=>0xE5DC,
0x794F=>0xEA9B,
0x7931=>0xE5DD,
0x7950=>0xEA9C,
0x7932=>0xE5DE,
0x7951=>0xEA9D,
0x7933=>0xE5DF,
0x7952=>0xEA9E,
0x7934=>0xEA80,
0x7953=>0xEA9F,
0x7935=>0xEA81,
0x7954=>0xEAA0,
0x7936=>0xEA82,
0x7955=>0xEAA1,
0x7937=>0xEA83,
0x7956=>0xEAA2,
0x7938=>0xEA84,
0x7957=>0xEAA3,
0x7939=>0xEA85,
0x7958=>0xEAA4,
0x793A=>0xEA86,
0x7959=>0xEAA5,
0x793B=>0xEA87,
0x795A=>0xEAA6,
0x793C=>0xEA88,
0x795B=>0xEAA7,
0x793D=>0xEA89,
0x795C=>0xEAA8,
0x793E=>0xEA8A,
0x795D=>0xEAA9,
0x793F=>0xEA8B,
0x795E=>0xEAAA,
0x7940=>0xEA8C,
0x795F=>0xEAAB,
0x7941=>0xEA8D,
0x7960=>0xEAAC,
0x7942=>0xEA8E,
0x7961=>0xEAAD,
0x7943=>0xEA8F,
0x7962=>0xEAAE,
0x7944=>0xEA90,
0x7963=>0xEAAF,
0x7945=>0xEA91,
0x7964=>0xEAB0,
0x7946=>0xEA92,
0x7965=>0xEAB1,
0x7947=>0xEA93,
0x7966=>0xEAB2,
0x7948=>0xEA94,
0x7967=>0xEAB3,
0x7949=>0xEA95,
0x7968=>0xEAB4,
0x794A=>0xEA96,
0x7969=>0xEAB5,
0x794B=>0xEA97,
0x796A=>0xEAB6,
0x794C=>0xEA98,
0x796B=>0xEAB7,
0x794D=>0xEA99,
0x796C=>0xEAB8,
0x794E=>0xEA9A,
0x796D=>0xEAB9,
0x796E=>0xEABA,
0x7A2F=>0xEAD9,
0x796F=>0xEABB,
0x7A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EAFD,
0x7A5F=>0xEB1C,
0x7857=>0xEAFE,
0x7A60=>0xEB1D,
0x7858=>0xEAFF,
0x7A61=>0xEB1E,
0x7859=>0xEB00,
0x7A62=>0xEB1F,
0x785A=>0xEB01,
0x7A63=>0xEB20,
0x785B=>0xEB02,
0x7A64=>0xEB21,
0x785C=>0xEB03,
0x7A65=>0xEB22,
0x785D=>0xEB04,
0x7A66=>0xEB23,
0x785E=>0xEB05,
0x7A67=>0xEB24,
0x785F=>0xEB06,
0x7A68=>0xEB25,
0x7860=>0xEB07,
0x7A69=>0xEB26,
0x7861=>0xEB08,
0x7A6A=>0xEB27,
0x7862=>0xEB09,
0x7A6B=>0xEB28,
0x7863=>0xEB0A,
0x7A6C=>0xEB29,
0x7864=>0xEB0B,
0x7A6D=>0xEB2A,
0x7865=>0xEB0C,
0x7A6E=>0xEB2B,
0x7866=>0xEB0D,
0x7A6F=>0xEB2C,
0x7A51=>0xEB0E,
0x7A70=>0xEB2D,
0x7A52=>0xEB0F,
0x7A71=>0xEB2E,
0x7A53=>0xEB10,
0x7A72=>0xEB2F,
0x7A54=>0xEB11,
0x7A73=>0xEB30,
0x7A55=>0xEB12,
0x7A74=>0xEB31,
0x7A56=>0xEB13,
0x7A75=>0xEB32,
0x7A57=>0xEB14,
0x7A76=>0xEB33,
0x7A58=>0xEB15,
0x7A77=>0xEB34,
0x7A59=>0xEB16,
0x7A78=>0xEB35,
0x7A79=>0xEB36,
0x7B3A=>0xEB55,
0x7A7A=>0xEB37,
0x7B3B=>0xEB56,
0x7A7B=>0xEB38,
0x7B3C=>0xEB57,
0x7A7C=>0xEB39,
0x7B3D=>0xEB58,
0x7A7D=>0xEB3A,
0x7B3E=>0xEB59,
0x7A7E=>0xEB3B,
0x7B3F=>0xEB5A,
0x7B21=>0xEB3C,
0x7B40=>0xEB5B,
0x7B22=>0xEB3D,
0x7B41=>0xEB5C,
0x7B23=>0xEB3E,
0x7B42=>0xEB5D,
0x7B24=>0xEB3F,
0x7B43=>0xEB5E,
0x7B25=>0xEB40,
0x7B44=>0xEB5F,
0x7B26=>0xEB41,
0x7B45=>0xEB60,
0x7B27=>0xEB42,
0x7B46=>0xEB61,
0x7B28=>0xEB43,
0x7B47=>0xEB62,
0x7B29=>0xEB44,
0x7B48=>0xEB63,
0x7B2A=>0xEB45,
0x7B49=>0xEB64,
0x7B2B=>0xEB46,
0x7B4A=>0xEB65,
0x7B2C=>0xEB47,
0x7B4B=>0xEB66,
0x7B2D=>0xEB48,
0x7B4C=>0xEB67,
0x7B2E=>0xEB49,
0x7B4D=>0xEB68,
0x7B2F=>0xEB4A,
0x7B4E=>0xEB69,
0x7B30=>0xEB4B,
0x7B4F=>0xEB6A,
0x7B31=>0xEB4C,
0x7B50=>0xEB6B,
0x7B32=>0xEB4D,
0x7B51=>0xEB6C,
0x7B33=>0xEB4E,
0x7B52=>0xEB6D,
0x7B34=>0xEB4F,
0x7B53=>0xEB6E,
0x7B35=>0xEB50,
0x7B54=>0xEB6F,
0x7B36=>0xEB51,
0x7B55=>0xEB70,
0x7B37=>0xEB52,
0x7B56=>0xEB71,
0x7B38=>0xEB53,
0x7B57=>0xEB72,
0x7B39=>0xEB54,
0x7B58=>0xEB73,
0x7B59=>0xEB74,
0x7B5A=>0xEB75,
0x7B5B=>0xEB76,
0x7B5C=>0xEB77,
0x7B5D=>0xEB78,
0x7B5E=>0xEB79,
0x7B5F=>0xEB7A,
0x7B60=>0xEB7B,
0x7B61=>0xEB7C,
0x7B62=>0xEB7D,
0x7B63=>0xEB7E,
0x7B64=>0xEB7F,
0x7B65=>0xEB80,
0x7B66=>0xEB81,
0x7B67=>0xEB82,
0x7B68=>0xEB83,
0x7B69=>0xEB84,
0x7B6A=>0xEB85,
0x7B6B=>0xEB86,
0x7B6C=>0xEB87,
0x7B6D=>0xEB88,
}.freeze
end
end
|
pwim/emoticon
|
lib/emoticon/transcoder/softbank.rb
|
<filename>lib/emoticon/transcoder/softbank.rb<gh_stars>1-10
require File.join(File.dirname(File.dirname(__FILE__)), "transcoder")
class Emoticon::Transcoder::Softbank < Emoticon::Transcoder
# +str+ のなかでDoCoMo絵文字をUnicode数値文字参照に置換した文字列を返す。
def external_to_unicodecr(str)
# SoftBank Unicode
str.gsub(SOFTBANK_UNICODE_REGEXP) do |match|
unicode = match.unpack('U').first
"&#x%04x;" % (unicode+0x1000)
end
end
private
def to_sjis
true
end
def conversion_table
CONVERSION_TABLE_TO_SOFTBANK
end
end
|
pwim/emoticon
|
lib/emoticon/transcoder.rb
|
require "emoticon/conversion_table"
require 'scanf'
require "kconv"
require "singleton"
module Emoticon
class Transcoder
include Emoticon::ConversionTable
include Singleton
def unicodecr_to_external(str)
str.gsub(/&#x([0-9a-f]{4});/i) do |match|
unicode = $1.scanf("%x").first
if conversion_table
converted = conversion_table[unicode] # キャリア間変換
else
converted = unicode # 変換しない
end
# 携帯側エンコーディングに変換する
case converted
when Integer
# 変換先がUnicodeで指定されている。つまり対応する絵文字がある。
if sjis = UNICODE_TO_SJIS[converted]
[sjis].pack('n')
elsif webcode = SOFTBANK_UNICODE_TO_WEBCODE[converted-0x1000]
"\x1b\x24#{webcode}\x0f"
else
# キャリア変換テーブルに指定されていたUnicodeに対応する
# 携帯側エンコーディングが見つからない(変換テーブルの不備の可能性あり)。
match
end
when String
# 変換先がUnicodeで指定されている。
to_sjis ? Kconv::kconv(converted, Kconv::SJIS, Kconv::UTF8) : converted
when nil
# 変換先が定義されていない。
match
end
end
end
def utf8_to_unicodecr(str)
str.gsub(UTF8_REGEXP) do |match|
"&#x%04x;" % match.unpack('U').first
end
end
def unicodecr_to_utf8(str)
str.gsub(/&#x([0-9a-f]{4});/i) do |match|
unicode = $1.scanf("%x").first
if UNICODE_TO_SJIS[unicode] || SOFTBANK_UNICODE_TO_WEBCODE[unicode-0x1000]
[unicode].pack('U')
else
match
end
end
end
def internal_to_external(s)
unicodecr_to_external(utf8_to_unicodecr(s))
end
private
def to_sjis
false
end
def conversion_table
nil
end
end
end
|
pwim/emoticon
|
test/emoticon/transcoder/docomo_test.rb
|
<reponame>pwim/emoticon<filename>test/emoticon/transcoder/docomo_test.rb
require 'test/unit'
require File.dirname(__FILE__) + '/../../test_helper'
require "emoticon/transcoder/docomo"
class DocomoTest < Test::Unit::TestCase
def setup
@transcoder = Emoticon::Transcoder::Docomo.instance
end
def test_internal_to_external
assert_equal "\xf8\x9f", @transcoder.internal_to_external(DOCOMO_CR)
assert_equal "\xf8\x9f", @transcoder.internal_to_external(DOCOMO_UTF8)
assert_equal "\xf9\x79", @transcoder.internal_to_external(DOCOMO_DOCOMO_POINT)
assert_equal "\xf8\x9f", @transcoder.internal_to_external(AU_CR)
assert_equal "\xf8\x9f", @transcoder.internal_to_external(AU_UTF8)
assert_equal "\xf8\x9f", @transcoder.internal_to_external(SOFTBANK_CR)
assert_equal "\xf8\x9f", @transcoder.internal_to_external(SOFTBANK_UTF8)
end
def test_sjiscr_to_unicodecr
s = @transcoder.sjiscr_to_unicodecr("<P></P>")
assert_equal("<P></P>", s)
end
end
|
pwim/emoticon
|
lib/emoticon/transcoder/docomo.rb
|
<reponame>pwim/emoticon<filename>lib/emoticon/transcoder/docomo.rb
require File.join(File.dirname(File.dirname(__FILE__)), "transcoder")
class Emoticon::Transcoder::Docomo < Emoticon::Transcoder
# +str+ のなかでDoCoMo絵文字をUnicode数値文字参照に置換した文字列を返す。
def external_to_unicodecr(str)
str.gsub(SJIS_REGEXP) do |match|
sjis = match.unpack('n').first
unicode = SJIS_TO_UNICODE[sjis]
unicode ? ("&#x%04x;"%unicode) : match
end
end
def sjiscr_to_unicodecr(s)
s.gsub(/&#([0-9]{5});/i) do |match|
unicode = DOCOMO_SJIS_TO_UNICODE[$1.to_i].to_s(16).upcase
"&#x#{unicode};"
end
end
private
def to_sjis
true
end
def conversion_table
CONVERSION_TABLE_TO_DOCOMO
end
end
|
pwim/emoticon
|
emoticon.gemspec
|
Gem::Specification.new do |s|
s.name = "emoticon"
s.version = "0.0.4"
s.date = "2008-11-12"
s.summary = "Emoticon (emoji) handling for Japanese mobile phones"
s.email = "<EMAIL>"
s.homepage = "http://github.com/pwim/emoticon"
s.description = "Emoticon is a Ruby library for transcoding emoticons across different carriers for Japanese mobile phones. It is derived from Jpmobile, a rails plugin for building mobile sites for Japanese mobiles created by Yohji Shidara"
s.has_rdoc = false
s.authors = ["<NAME>"]
s.files = ["README",
"MIT-LICENSE",
"emoticon.gemspec",
"lib/emoticon.rb",
"lib/emoticon/conversion_table.rb",
"lib/emoticon/transcoder.rb",
"lib/emoticon/conversion_table/au.rb",
"lib/emoticon/conversion_table/docomo.rb",
"lib/emoticon/conversion_table/softbank.rb",
"lib/emoticon/transcoder/au.rb",
"lib/emoticon/transcoder/docomo.rb",
"lib/emoticon/transcoder/jphone.rb",
"lib/emoticon/transcoder/null.rb",
"lib/emoticon/transcoder/softbank.rb",
"lib/emoticon/transcoder/vodafone.rb",
]
s.test_files = ["test/emoticon_test.rb",
"test/test_helper.rb",
"test/emoticon/transcoder/au_test.rb",
"test/emoticon/transcoder/docomo_test.rb",
"test/emoticon/transcoder/jphone_test.rb",
"test/emoticon/transcoder/softbank_test.rb",
"test/emoticon/transcoder/vodafone_test.rb",
]
end
|
pwim/emoticon
|
test/emoticon/transcoder/vodafone_test.rb
|
<filename>test/emoticon/transcoder/vodafone_test.rb
require 'test/unit'
require File.dirname(__FILE__) + '/../../test_helper'
require "emoticon/transcoder/vodafone"
class VodafoneTest < Test::Unit::TestCase
def setup
@transcoder = Emoticon::Transcoder::Vodafone.instance
end
def test_internal_to_external
assert_equal "\e$Gj\x0f", @transcoder.internal_to_external(DOCOMO_CR)
assert_equal "\e$Gj\x0f", @transcoder.internal_to_external(DOCOMO_UTF8)
assert_equal "\e$EO\017", @transcoder.internal_to_external(DOCOMO_DOCOMO_POINT)
assert_equal "\e$Gj\x0f", @transcoder.internal_to_external(AU_CR)
assert_equal "\e$Gj\x0f", @transcoder.internal_to_external(AU_UTF8)
assert_equal "\e$Gj\x0f", @transcoder.internal_to_external(SOFTBANK_CR)
assert_equal "\e$Gj\x0f", @transcoder.internal_to_external(SOFTBANK_UTF8)
end
end
|
teohm/simplecov-html
|
lib/simplecov-html/version.rb
|
module SimpleCov
module Formatter
class HTMLFormatter
VERSION = "0.10.2".freeze
end
end
end
|
michaelakh/igstories
|
app/helpers/application_helper.rb
|
<reponame>michaelakh/igstories
module ApplicationHelper
def active?(page)
current_page?(page) ? 'active' : ''
end
def meta_tag(meta_tag)
#add array type tester before if statement
#test functionality
meta = ''
if meta_tag.kind_of?(Hash) && meta_tag != nil
meta_tag.each do |key,value|
meta += "<meta name='#{key.to_s}' content='#{value}'>\n"
end
else
end
return meta.html_safe
end
end
|
michaelakh/igstories
|
spec/routing/users_routing_spec.rb
|
require "rails_helper"
RSpec.describe UsersController, type: :routing do
describe "routing" do
it "routes to #search" do
expect(:get => "/search").to route_to("users#search")
end
it "routes to #stories" do
expect(:get => "/stories/user").to route_to("users#stories", user:'user')
end
it "routes to #highlights" do
expect(:get => "/user/highlights/10101").to route_to("users#highlights", highlight_id:'10101', user:'user')
end
end
end
|
michaelakh/igstories
|
app/helpers/users_helper.rb
|
<reponame>michaelakh/igstories
module UsersHelper
def time_passed(hours)
days = hours/24
case
when days == 0
return hours == 1 ? "1 hour" : "#{hours} hours"
when days == 1
return "#{days} day"
when days.between?(1,29)
return "#{days} days"
when days.between?(30,58)
return "#{days/30} month"
when days.between?(59,365)
return "#{days/30} months"
when days.between?(365,730)
return "#{(days/365)} year"
when days > 730
return "#{(days/365)} years"
else
end
end
end
|
michaelakh/igstories
|
spec/controllers/messages_controller_spec.rb
|
<reponame>michaelakh/igstories
require 'rails_helper'
RSpec.describe MessagesController, type: :controller do
it "renders the Contact page" do
get :contact
expect(response).to be_success
end
end
|
michaelakh/igstories
|
spec/routing/pages_routing_spec.rb
|
require "rails_helper"
RSpec.describe PagesController, type: :routing do
describe "routing" do
it "routes to #index" do
expect(:get => "/welcome").to route_to("pages#welcome")
end
it "routes to #root" do
expect(:get => "/").to route_to("pages#welcome")
end
end
end
|
michaelakh/igstories
|
spec/routing/messages_routing_spec.rb
|
require "rails_helper"
RSpec.describe MessagesController, type: :routing do
describe "routing" do
it "routes to #contact" do
expect(:get => "/contact").to route_to("messages#contact")
end
end
end
|
michaelakh/igstories
|
spec/models/page_spec.rb
|
require 'rails_helper'
RSpec.describe Page, type: :model do
end
|
michaelakh/igstories
|
spec/controllers/docs_controller_spec.rb
|
<gh_stars>0
require 'rails_helper'
RSpec.describe DocsController, type: :controller do
it "renders the privacy policy page" do
get :privacy_policy
expect(response).to be_success
end
it "renders the cookies policy page" do
get :cookies_policy
expect(response).to be_success
end
it "renders the disclaimer page" do
get :disclaimer
expect(response).to be_success
end
end
|
michaelakh/igstories
|
app/controllers/docs_controller.rb
|
<reponame>michaelakh/igstories
class DocsController < ApplicationController
def privacy_policy
@title = 'Privacy Policy'
end
def cookies_policy
@title = 'Cookies Policy'
end
def disclaimer
@title = 'Disclaimer'
end
end
|
michaelakh/igstories
|
app/controllers/messages_controller.rb
|
class MessagesController < ApplicationController
def contact
@title = 'Contact Me'
end
end
|
michaelakh/igstories
|
app/controllers/users_controller.rb
|
<filename>app/controllers/users_controller.rb
class UsersController < ApplicationController
def index
end
def search
@title = 'Stories Search'
@httprequest = HTTP.get("https://api.storiesig.com/stories/#{params[:q]}")
if @httprequest.status == 200 || @httprequest.status == 400
@response = JSON.parse(@httprequest)
if @response['status'] != 'fail'
@httprequest_highlights = HTTP.get("https://api.storiesig.com/highlights/#{params[:q]}")
@highlights = JSON.parse(@httprequest_highlights)
end
end
end
def stories
@title = 'Stories'
@httprequest = HTTP.get("https://api.storiesig.com/stories/#{params[:user]}")
@response = JSON.parse(@httprequest)
end
def highlights
@title = 'Highlights'
@httprequest_highlights = HTTP.get("https://api.storiesig.com/highlights/#{params[:user]}?highlight=#{params[:highlight_id]}")
@highlights = JSON.parse(@httprequest_highlights)
end
end
|
michaelakh/igstories
|
spec/helpers/users_helper_spec.rb
|
<filename>spec/helpers/users_helper_spec.rb
require 'rails_helper'
RSpec.describe UsersHelper, type: :helper do
describe "time_passed" do
it "returns '1 hour' if 1 is passed in" do
expect(helper.time_passed(1)).to eq "1 hour"
end
it "returns '12 hours' if 12 is passed in" do
expect(helper.time_passed(12)).to eq "12 hours"
end
it "returns '1 day' if a number between 24..47 is passed in" do
expect(helper.time_passed(32)).to eq "1 day"
end
it "returns '5 days' a number between 120..144 is passed in" do
expect(helper.time_passed(137)).to eq "5 days"
end
it "returns '1 month' a number between 730..1460 is passed in" do
expect(helper.time_passed(780)).to eq "1 month"
end
it "returns '4 months' a number between 2920..3650 is passed in" do
expect(helper.time_passed(3000)).to eq "4 months"
end
it "returns '1 year' a number between 8760..17520 is passed in" do
expect(helper.time_passed(9000)).to eq "1 year"
end
it "returns '4 years' a number between 33580..42340 is passed in" do
expect(helper.time_passed(40000)).to eq "4 years"
end
end
end
|
michaelakh/igstories
|
spec/controllers/pages_controller_spec.rb
|
require 'rails_helper'
RSpec.describe PagesController, type: :controller do
describe "GET welcome" do
it "renders the welcome page" do
get :welcome
expect(response).to be_success
end
end
end
|
michaelakh/igstories
|
config/routes.rb
|
Rails.application.routes.draw do
root 'pages#welcome'
#Pages
get 'welcome', to:'pages#welcome'
#Users
get 'search', to:'users#search'
get 'stories/:user', to:'users#stories'
get ':user/highlights/:highlight_id', to:'users#highlights'
#Docs
get 'privacy_policy', to:'docs#privacy_policy'
get 'cookies_policy', to:'docs#cookies_policy'
get 'disclaimer', to:'docs#disclaimer'
#Messages
get 'contact', to:'messages#contact'
end
|
michaelakh/igstories
|
services/page/builder.rb
|
module Page
module Builder
def self.call(params)
end
end
end
|
michaelakh/igstories
|
spec/routing/docs_routing_spec.rb
|
<reponame>michaelakh/igstories
require "rails_helper"
RSpec.describe DocsController, type: :routing do
describe "routing" do
it "routes to #privacy" do
expect(:get => "/privacy_policy").to route_to("docs#privacy_policy")
end
it "routes to #cookies" do
expect(:get => "/cookies_policy").to route_to("docs#cookies_policy")
end
it "routes to #disclaimer" do
expect(:get => "/disclaimer").to route_to("docs#disclaimer")
end
end
end
|
supernini/activerecord-i18n
|
test/activerecord_i18n_test.rb
|
require 'test_helper'
class ActiverecordI18n::Test < ActiveSupport::TestCase
test "get_item allow the default_value to be nil" do
result = ActiverecordI18n.get_item('abc')
assert_equal(result, "")
end
end
|
supernini/activerecord-i18n
|
lib/activerecord_i18n.rb
|
<reponame>supernini/activerecord-i18n<gh_stars>1-10
require 'rails'
require "active_support"
require "activerecord_i18n/railtie"
require "activerecord_i18n/helper"
require "activerecord_i18n/engine" if defined?(Rails)
module ActiverecordI18n
def self.setup
yield self
end
def self.get_translation(key, default_value=nil, current_template=nil)
path = (key[0] == '.' and current_template) ? current_template.virtual_path.gsub('/', '.') + key : key
return ActiverecordI18n.get_item(path, default_value || key)
end
def self.get_item(key, default_value=nil)
translation = ActiverecordI18nTranslation.where(key: key.downcase, locale: I18n.locale).first_or_create()
if !translation.value
translation.value = (default_value || '').gsub('-', ' ')
translation.save
end
return translation.value
end
end
ActiveSupport.on_load(:action_view) do
include ActiverecordI18n::Helper
end
|
supernini/activerecord-i18n
|
lib/activerecord_i18n/engine.rb
|
<reponame>supernini/activerecord-i18n
module ActiverecordI18n
class Engine < ::Rails::Engine
isolate_namespace ActiverecordI18n
end
end
|
supernini/activerecord-i18n
|
lib/activerecord_i18n/helper.rb
|
module ActiverecordI18n
module Helper
def self.ot(key, default_value=nil)
return ActiverecordI18n.get_translation(key, default_value)
end
def ot(key, default_value=nil)
return ActiverecordI18n.get_translation(key, default_value, @current_template || nil)
end
end
end
|
supernini/activerecord-i18n
|
activerecord-i18n.gemspec
|
$:.push File.expand_path("lib", __dir__)
require "activerecord_i18n/version"
Gem::Specification.new do |spec|
spec.name = 'activerecord_i18n'
spec.version = ActiverecordI18n::VERSION
spec.authors = ["<NAME>"]
spec.email = '<EMAIL>'
spec.homepage = "https://github.com/supernini/activerecord-i18n"
spec.summary = "Gem to user i18n in db in place of file. This gem is just simple, no complicated feature"
spec.description = "A simple gem to add a translation mechanic to your existing apps "
spec.license = "MIT"
if spec.respond_to?(:metadata)
spec.metadata["allowed_push_host"] = "https://rubygems.org"
else
raise "RubyGems 2.0 or newer is required to protect against " \
"public gem pushes."
end
spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
spec.add_dependency "rails", '~> 6.0', '> 6.0'
end
|
supernini/activerecord-i18n
|
lib/activerecord_i18n/version.rb
|
module ActiverecordI18n
VERSION = '0.1.4'
end
|
jlongtine/homebrew-tap
|
dagger.rb
|
<filename>dagger.rb<gh_stars>0
# typed: false
# frozen_string_literal: true
# This file was generated by GoReleaser. DO NOT EDIT.
class Dagger < Formula
desc "Dagger is a programmable deployment system."
homepage "https://github.com/dagger/dagger"
version "0.1.0-alpha.27"
bottle :unneeded
on_macos do
if Hardware::CPU.intel?
url "https://dl.dagger.io/dagger/releases/0.1.0-alpha.27/dagger_v0.1.0-alpha.27_darwin_amd64.tar.gz"
sha256 "185f74ffcbcb80e5672ed5054173736fce22018e5f63aaa18cd668ec700b0962"
end
if Hardware::CPU.arm?
url "https://dl.dagger.io/dagger/releases/0.1.0-alpha.27/dagger_v0.1.0-alpha.27_darwin_arm64.tar.gz"
sha256 "fbf8121d5373dd5fef26a23e527387476668031fc7f52deebc22494f1e377b76"
end
end
on_linux do
if Hardware::CPU.intel?
url "https://dl.dagger.io/dagger/releases/0.1.0-alpha.27/dagger_v0.1.0-alpha.27_linux_amd64.tar.gz"
sha256 "771432129c8422298e18be88e611c4b41f8e7ea803f559f3067dcecb6f118abe"
end
if Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
url "https://dl.dagger.io/dagger/releases/0.1.0-alpha.27/dagger_v0.1.0-alpha.27_linux_arm64.tar.gz"
sha256 "21163d50634b3b17f1c9e9c269c090aa924693919d1bdeec7bd503e2f5d38c1a"
end
end
def install
bin.install "dagger"
end
test do
system "#{bin}/dagger version"
end
end
|
Flare576/homebrew-scripts
|
Formula/gac.rb
|
class Gac < Formula
desc "Git Add Commit makes common git tasks easier"
homepage "https://github.com/Flare576/gac"
url "https://github.com/Flare576/gac/archive/refs/tags/v0.4.0.tar.gz"
sha256 "d0c430e958e1cac7adce05c10d781d63ca4843aec654eaf65b3e223686110d5b"
license "MIT"
depends_on "git"
depends_on "node"
def install
bin.install "bin/gac"
end
test do
system "echo", "temp value for formula validation"
end
end
|
Flare576/homebrew-scripts
|
Formula/dvol.rb
|
class Dvol < Formula
include Language::Python::Virtualenv
desc "Docker Volume mapping control; container access made easy!"
homepage "https://github.com/Flare576/dvol"
url "https://files.pythonhosted.org/packages/32/3c/428a5e44b9f407136b8ab277b56a924c5e3012a5d00afda74e30a9a26305/dvol-0.1.0.tar.gz"
sha256 "277c920007067e68a368eab124fb1ca09c794bdccfd4594463a1f3bb8cea26bc"
license "MIT"
head "https://github.com/Flare576/dvol.git"
depends_on "python@3.9"
resource "gitdb" do
url "https://files.pythonhosted.org/packages/34/fe/9265459642ab6e29afe734479f94385870e8702e7f892270ed6e52dd15bf/gitdb-4.0.7.tar.gz"
sha256 "96bf5c08b157a666fec41129e6d327235284cca4c81e92109260f353ba138005"
end
resource "GitPython" do
url "https://files.pythonhosted.org/packages/29/22/3d591875078c1c5e7e11b478616821995053968a74b76043c55448c46381/GitPython-3.1.18.tar.gz"
sha256 "b838a895977b45ab6f0cc926a9045c8d1c44e2b653c1fcc39fe91f42c6e8f05b"
end
resource "jq" do
url "https://files.pythonhosted.org/packages/7f/40/01981da0534839a7c9a0116318f404738c8add70272a45b57478b6a6bf78/jq-1.1.3.tar.gz"
sha256 "f9ec1dfa7f9875b04495f3e08e85ee96f37a3b843e5bca738a3300732865dde7"
end
resource "PyYAML" do
url "https://files.pythonhosted.org/packages/a0/a4/d63f2d7597e1a4b55aa3b4d6c5b029991d3b824b5bd331af8d4ab1ed687d/PyYAML-5.4.1.tar.gz"
sha256 "607774cbba28732bfa802b54baa7484215f530991055bb562efbed5b2f20a45e"
end
resource "smmap" do
url "https://files.pythonhosted.org/packages/dd/d4/2b4f196171674109f0fbb3951b8beab06cd0453c1b247ec0c4556d06648d/smmap-4.0.0.tar.gz"
sha256 "7e65386bd122d45405ddf795637b7f7d2b532e7e401d46bbe3fb49b9986d5182"
end
def install
# ENV.deparallelize # if your formula fails when building in parallel
virtualenv_install_with_resources
end
test do
end
end
|
Flare576/homebrew-scripts
|
Formula/jira-cli.rb
|
class JiraCli < Formula
desc "Go-Jira/jira with Flare customizations. Non-semver version: setup.cookie.config"
homepage "https://github.com/Flare576/jira-cli"
url "https://github.com/Flare576/jira-cli/archive/refs/tags/v3.3.8.tar.gz"
sha256 "3982ab52d9f0bae6bbde3f8d7c7410d232f30a1ec1e3b869a7fb397811dcc248"
license "MIT"
depends_on "node"
depends_on "go-jira"
def install
bin.install "bin/jiracookie"
bin.install "bin/jira-setup"
lib.install ".jira.d"
ohai "Be sure to run 'jira-setup' to link .jira.d!"
end
test do
system "echo", "temp value for formula validation"
end
end
|
Flare576/homebrew-scripts
|
Formula/newScript.rb
|
class Newscript < Formula
desc "Quickly generate script stubs in js, sh, or py"
homepage "https://github.com/Flare576/newScript"
url "https://github.com/Flare576/newScript/archive/refs/tags/v0.0.7.tar.gz"
sha256 "c167ab9a7b399858a17242d0f03c558e6bbef2d521655db8e2cf867e0c3a8b5c"
license "MIT"
depends_on "node"
def install
bin.install "bin/newScript"
bin.install "bin/stubs"
end
test do
system "echo", "temp value for formula validation"
end
end
|
Flare576/homebrew-scripts
|
Formula/switch-theme.rb
|
class SwitchTheme < Formula
desc "Tool for switching themes in vim, tmux, zsh, bat, vsCode, terminals (gnome, mintty, Terminal.app), and whatever else I figure out."
homepage "https://github.com/Flare576/switch-theme"
url "https://github.com/Flare576/switch-theme/archive/refs/tags/v1.1.5.tar.gz"
sha256 "9f49fba12b13f924f2d13fed344820a10ab710817eed54600a9d092ae72daff8"
license "MIT"
resource "pyaml" do
url "https://files.pythonhosted.org/packages/cc/c8/70d6b275de6ab108d9e210d73463e4523b633917e9223a56f8442ce44110/pyaml-21.8.3.tar.gz"
sha256 "a1636d63c476328a07213d0b7111bb63570f1ab8a3eddf60522630250c23d975"
end
def install
bin.install "bin/switch-theme"
bin.install "bin/themeOpenTerminals.scpt"
bin.install "bin/setupGnomeTheme.sh"
bin.install "bin/setupTerminalAppTheme.sh"
bin.install "bin/setupWSLTheme.sh"
lib.install "themes"
lib.install "vim-switch-themes"
system_command 'switch-theme -s'
end
test do
system "echo", "temp value for formula validation"
end
end
|
Flare576/homebrew-scripts
|
Formula/git-clone.rb
|
class GitClone < Formula
desc "Tool for maintaining multiple git accounts across any git system supporting HTTPS."
homepage "https://github.com/Flare576/git-clone"
url "https://github.com/Flare576/git-clone/archive/refs/tags/v0.1.2.tar.gz"
sha256 "de5cc4be237894b7673726e2a4f240db91f875c9d6d4ed22f11b2481627c9377"
license "MIT"
depends_on "git"
def install
bin.install "bin/git-clone" => "clone"
end
test do
system "echo", "temp value for formula validation"
end
end
|
Flare576/homebrew-scripts
|
Formula/vroom.rb
|
<reponame>Flare576/homebrew-scripts<gh_stars>0
class Vroom < Formula
desc "Wrapper for make to help setup/execute standard destroy/setup/run/watch commands"
homepage "https://github.com/Flare576/vroom"
url "https://github.com/Flare576/vroom/archive/refs/tags/v12.0.2.tar.gz"
sha256 "9f8216c53baf98747c7d230be8ff7d01cd13282d99941ec75f31ed4b4b626ade"
license "MIT"
depends_on "make"
def install
bin.install "bin/vroom"
end
test do
system "echo", "temp value for formula validation"
end
end
|
Flare576/homebrew-scripts
|
Formula/monitorjobs.rb
|
class Monitorjobs < Formula
desc ""
homepage "https://github.com/Flare576/monitorjobs"
url "https://github.com/Flare576/monitorjobs/archive/refs/tags/v0.1.1.tar.gz"
sha256 "b47f5f41e55120bb1bff194f5a262fb66f2339991c9a13978d51ca7be50640d9"
license "MIT"
depends_on "jq"
# Don't install a separate version, but it is required that the user is auth'd
# depends_on "awscli"
def install
bin.install "bin/monitorjobs"
end
test do
system "echo", "temp value for formula validation"
end
end
|
JuanjoSalvador/JuanjoPackageManager
|
main.rb
|
require './utils'
require './help'
utils = Utils.new
help = Help.new
case ARGV[0]
when "get"
utils.init()
utils.download(ARGV[1])
when "list"
utils.list()
when "update"
utils.update()
when "help"
help.info()
else
puts "Prueba con el comando help para obtener ayuda"
end
|
JuanjoSalvador/JuanjoPackageManager
|
utils.rb
|
<filename>utils.rb<gh_stars>1-10
require 'rubygems'
require 'git'
require 'yaml'
require 'fileutils'
class Utils
def init()
username = %x[ #{'whoami'} ]
username = username.chomp
jpm_dir = "/home/#{username}/JPM"
if !Dir.exists?(jpm_dir)
FileUtils::mkdir_p jpm_dir
end
end
def download(package)
username = %x[ #{'whoami'} ]
username = username.chomp
path = "/home/#{username}/JPM"
sources = YAML.load_file('sources.yml')
if Dir.exists?("#{path}/#{package}")
puts "ERROR: Ya tienes #{package} en tu directorio de JPM"
else
if sources.include? package
puts "Descargando..."
Git.clone(sources[package][repo], package, :path => path)
puts "Terminado."
else
puts "No se ha encontrado #{package}. Puedes añadirlo con jpm add <paquete>"
end
end
end
def list()
sources = YAML.load_file('sources.yml')
sources = sources.sort
puts "Paquetes disponibles:"
puts ""
sources.each do |s|
puts "* " + s[0] + ": " + s[1]['desc']
end
end
def update()
puts "No disponible aún"
end
end
|
JuanjoSalvador/JuanjoPackageManager
|
help.rb
|
<filename>help.rb
class Help
def info()
puts "AYUDA DE JPM"
puts "En desarrollo"
end
end
|
ZaaLabs/PushButtonEngine
|
script/licenseCheck/checkLicenses.rb
|
require 'ftools'
require 'yaml'
require 'pp'
def validatePath (path, do_exit=false)
if !File.exists? path
puts "[ERROR] \"#{path}\" is not valid"
if(do_exit)
puts "Exiting Script"
exit
end
end
end
def loopThroughDirectory( dirname )
Dir["#{dirname}/**/**"].each do |file|
if(File.directory? file) # If it's a directory
print "Directory: ",file,"\n"
else
@fileTypes.each do |type|
if(type["type"].include? File.extname(file))
#print "File: ",File.basename(file),"\n"
processFile(type, file)
end
end
end
end
end
def processFile(type,file)
print "Processing: #{file}... "
if(File.readlines(file)[0...type["license"].split("\n").length].join.chomp == type["license"].chomp)
#puts "Line matches license: \n#{File.readlines(file)[0...type["license"].split("\n").length]}"
puts "Skipping"
@skipCount += 1
else
puts "Adding license"
#system("open #{file}")
@addCount += 1
end
end
begin
# Load Configuration
@conf = open("./config.yml") {|f| YAML.load(f) }
pp @conf
@rootPath = @conf['srcPath']
@fileTypes = @conf['fileTypes']
puts "Root Path => #{@rootPath}"
validatePath(@rootPath,true)
@addCount = @skipCount = 0
loopThroughDirectory(@rootPath)
puts "#{@addCount} Added, #{@skipCount} Skipped"
#rescue
# print "Something blew up: ",$!, "\n"
end
|
nikolabebic95/LoopsOptimizationTests
|
Ruby/concatenate.rb
|
<filename>Ruby/concatenate.rb
str = ""
File.open("words.txt", "r") do |fh|
while(line = fh.gets) != nil
str.concat(line.strip)
end
end
puts str.length
|
nikolabebic95/LoopsOptimizationTests
|
Ruby/count.rb
|
num = 0
File.open("words.txt", "r") do |fh|
while(line = fh.gets) != nil
num += line.strip.length
end
end
puts num
|
nikolabebic95/LoopsOptimizationTests
|
Ruby/concatenate_optimized.rb
|
<reponame>nikolabebic95/LoopsOptimizationTests<gh_stars>0
str = ""
File.foreach("words.txt") do |line|
str.concat(line.strip)
end
puts str.length
|
nikolabebic95/LoopsOptimizationTests
|
Ruby/count_optimized.rb
|
<gh_stars>0
num = 0
File.foreach("words.txt") do |line|
num += line.strip.length
end
puts num
|
ack43/rocket_cms
|
app/models/menu.rb
|
if RocketCMS.active_record?
class Menu < ActiveRecord::Base
end
end
class Menu
include RocketCMS::Models::Menu
RocketCMS.apply_patches self
rails_admin &RocketCMS.menu_config
end
|
ack43/rocket_cms
|
lib/rocket_cms/models/mongoid/gallery_image.rb
|
module RocketCMS
module Models
module Mongoid
module GalleryImage
extend ActiveSupport::Concern
include ::Mongoid::Paperclip
included do
acts_as_nested_set
scope :sorted, -> { order_by([:lft, :asc]) }
has_mongoid_attached_file :image # need to override
def image_file_name=(val)
return self[:image_file_name] = "" if val == ""
return self[:image_file_name] = nil if val == nil
val = val.to_s
extension = File.extname(val)[1..-1]
file_name = val[0..val.size-extension.size-1]
self[:image_file_name] = "#{file_name.filename_to_slug}.#{extension.filename_to_slug}"
end
end
end
end
end
end
|
ack43/rocket_cms
|
activerecord/rocket_cms_activerecord.gemspec
|
<filename>activerecord/rocket_cms_activerecord.gemspec<gh_stars>0
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
lib = File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rocket_cms/version'
Gem::Specification.new do |spec|
spec.name = 'ack_rocket_cms_activerecord'
spec.version = RocketCMS::VERSION
spec.authors = ['<NAME>', 'glebtv']
spec.email = ["<EMAIL>", '<EMAIL>']
spec.description = %q{AckRocketCMS - RocketCMS fork - ActiveRecord metapackage}
spec.summary = %q{}
spec.homepage = 'https://github.com/ack43/rocket_cms'
spec.license = 'MIT'
spec.files = %w(lib/ack_rocket_cms_activerecord.rb lib/rocket_cms_activerecord.rb)
spec.executables = []
spec.test_files = []
spec.require_paths = ['lib']
spec.add_dependency 'ack_rocket_cms', RocketCMS::VERSION
spec.add_dependency 'awesome_nested_set'
spec.add_dependency 'paperclip'
spec.add_dependency 'paper_trail'
spec.add_dependency 'friendly_id'
spec.add_dependency "validates_lengths_from_database"
spec.add_dependency 'foreigner'
spec.add_dependency 'pg_search'
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'rake'
end
|
ack43/rocket_cms
|
app/models/gallery.rb
|
if RocketCMS.mongoid?
class Gallery
include RocketCMS::Models::Gallery
RocketCMS.apply_patches self
rails_admin &RocketCMS.gallery_config
end
end
|
ack43/rocket_cms
|
lib/rocket_cms/models/gallery.rb
|
<gh_stars>0
module RocketCMS
module Models
module Gallery
extend ActiveSupport::Concern
include RocketCMS::Model
include Enableable
include ManualSlug
include SitemapData
include RocketCMS.orm_specific('Gallery')
included do
has_many :gallery_images
field :name, type: String, localize: RocketCMS.configuration.localize
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
end
end
end
end
|
ack43/rocket_cms
|
lib/rocket_cms/controllers/news.rb
|
<gh_stars>0
module RocketCMS
module Controllers
module News
extend ActiveSupport::Concern
def index
@news = model.enabled.after_now.by_date
unless RocketCMS.config.news_per_page.nil?
@news = @news.page(params[:page])
end
end
def show
@news = model.after_now.find(params[:id])
if @news and @news.text_slug != params[:id]
redirect_to @news, status_code: 301
return true
end
end
private
def model
::News
end
def page_title
if @news.class.name == model.name
@news.page_title
else
super
end
end
end
end
end
|
ack43/rocket_cms
|
lib/rocket_cms.rb
|
unless defined?(RocketCMS) && RocketCMS.respond_to?(:orm) && [:active_record, :mongoid].include?(RocketCMS.orm)
puts "please use ack_rocket_cms_mongoid or ack_rocket_cms_activerecord and not ack_rocket_cms directly"
exit 1
end
require 'rocket_cms/version'
require 'devise'
require 'simple_form'
require 'rocket_cms/simple_form_patch'
require 'glebtv-simple_captcha'
require 'validates_email_format_of'
require 'smart_excerpt'
require 'filename_to_slug'
require 'rails_admin'
require 'rails_admin_nested_set'
require 'rails_admin_toggleable'
# require 'rails_admin_settings'
require 'x-real-ip'
require 'ckeditor'
require 'sitemap_generator'
require 'kaminari'
require 'addressable/uri'
require 'turbolinks'
require 'simple-navigation'
require 'ack_rails_admin_jcrop'
require 'rocket_cms/seo_helpers'
require 'rocket_cms/configuration'
require 'rocket_cms/patch'
require 'rocket_cms/admin'
require 'rocket_cms/elastic_search'
require 'rocket_cms/model'
require 'rocket_cms/rails_admin_menu'
require 'rocket_cms/engine'
require 'rocket_cms/controller'
module RocketCMS
class << self
def mongoid?
RocketCMS.orm == :mongoid
end
def active_record?
RocketCMS.orm == :active_record
end
def model_namespace
"RocketCMS::Models::#{RocketCMS.orm.to_s.camelize}"
end
def orm_specific(name)
"#{model_namespace}::#{name}".constantize
end
end
autoload :Migration, 'rocket_cms/migration'
# module Mongoid
# autoload :Paperclip 'rocket_cms/mongoid/paperlcip'
# end
module Models
autoload :Seo, 'rocket_cms/models/seo'
autoload :Menu, 'rocket_cms/models/menu'
autoload :Page, 'rocket_cms/models/page'
autoload :News, 'rocket_cms/models/news'
autoload :ContactMessage, 'rocket_cms/models/contact_message'
autoload :EmbeddedElement, 'rocket_cms/models/embedded_element'
autoload :EmbeddedGalleryImage, 'rocket_cms/models/embedded_gallery_image'
autoload :GalleryImage, 'rocket_cms/models/gallery_image'
autoload :Gallery, 'rocket_cms/models/gallery'
module Mongoid
autoload :Seo, 'rocket_cms/models/mongoid/seo'
autoload :Menu, 'rocket_cms/models/mongoid/menu'
autoload :Page, 'rocket_cms/models/mongoid/page'
autoload :News, 'rocket_cms/models/mongoid/news'
autoload :ContactMessage, 'rocket_cms/models/mongoid/contact_message'
autoload :EmbeddedElement, 'rocket_cms/models/mongoid/embedded_element'
autoload :EmbeddedGalleryImage, 'rocket_cms/models/mongoid/embedded_gallery_image'
autoload :GalleryImage, 'rocket_cms/models/mongoid/gallery_image'
autoload :Gallery, 'rocket_cms/models/mongoid/gallery'
end
module ActiveRecord
autoload :Seo, 'rocket_cms/models/active_record/seo'
autoload :Menu, 'rocket_cms/models/active_record/menu'
autoload :Page, 'rocket_cms/models/active_record/page'
autoload :News, 'rocket_cms/models/active_record/news'
autoload :ContactMessage, 'rocket_cms/models/active_record/contact_message'
end
end
module Controllers
autoload :Contacts, 'rocket_cms/controllers/contacts'
autoload :News, 'rocket_cms/controllers/news'
autoload :Pages, 'rocket_cms/controllers/pages'
autoload :Search, 'rocket_cms/controllers/search'
end
end
require 'manual_slug'
|
ack43/rocket_cms
|
app/controllers/pages_controller.rb
|
class PagesController < ApplicationController
include RocketCMS::Controllers::Pages
end
|
ack43/rocket_cms
|
lib/rocket_cms/models/active_record/news.rb
|
module RocketCMS
module Models
module ActiveRecord
module News
extend ActiveSupport::Concern
included do
unless RocketCMS.config.news_image_styles.nil?
has_attached_file :image, styles: RocketCMS.config.news_image_styles
end
has_paper_trail
validates_lengths_from_database only: [:name, :title, :content, :excerpt, :h1, :keywords, :robots, :og_title]
scope :after_now, -> { where("time < ?", Time.now) }
scope :by_date, -> { order(time: :desc) }
if RocketCMS.config.localize
translates :name, :excerpt, :content
end
end
end
end
end
end
|
ack43/rocket_cms
|
lib/rocket_cms/elastic_search.rb
|
module RocketCMS::ElasticSearch
extend ActiveSupport::Concern
included do
searchkick(
language: "Russian",
suggest: ["name"],
settings: {
analysis: {
analyzer: {
default_index: {
type: "custom",
tokenizer: "standard",
filter: ["standard", "lowercase", "asciifolding", "searchkick_index_shingle", "searchkick_stemmer", "snowball"]
# https://github.com/imotov/elasticsearch-analysis-morphology
# filter: ["standard", "lowercase", "asciifolding", "searchkick_index_shingle", "searchkick_stemmer", "snowball", "russian_morphology", "english_morphology"]
}
}
}
}
)
def search_data
{
_id: _id,
name: name,
content: SmartExcerpt.strip_tags(content),
}
end
end
end
|
ack43/rocket_cms
|
mongoid/lib/rocket_cms_mongoid.rb
|
require 'mongoid'
require 'glebtv-mongoid-paperclip'
require 'glebtv-mongoid_nested_set'
require 'mongoid-audit'
require 'mongoid_slug'
require 'mongo_session_store-rails4'
require 'rails_admin_settings'
module RocketCMS
def self.orm
:mongoid
end
end
require 'rocket_cms'
|
ack43/rocket_cms
|
lib/rocket_cms/seo_helpers.rb
|
<reponame>ack43/rocket_cms<gh_stars>10-100
module RocketCMS
module SeoHelpers
extend ActiveSupport::Concern
def page_title
title.blank? ? name : title
end
def get_og_title
og_title.blank? ? name : og_title
end
end
end
|
ack43/rocket_cms
|
app/models/concerns/rocket_cms_mongoid_paperclip.rb
|
<reponame>ack43/rocket_cms
module RocketCMSMongoidPaperclip
extend ActiveSupport::Concern
module ClassMethods
def rocket_cms_mongoid_attached_file(name, opts = {})
name = name.to_sym
unless opts.blank?
content_type = opts.delete(:content_type)
jcrop_options = opts.delete(:jcrop_options)
end
has_mongoid_attached_file name, opts
validates_attachment name, content_type: content_type unless content_type.blank?
class_eval <<-EVAL
def #{name}_file_name=(val)
return self[:#{name}_file_name] = "" if val == ""
return self[:#{name}_file_name] = nil if val == nil
val = val.to_s
extension = File.extname(val)[1..-1]
file_name = val[0..val.size-extension.size-1]
self[:#{name}_file_name] = "\#{file_name.filename_to_slug}.\#{extension.filename_to_slug}"
end
EVAL
if jcrop_options
class_eval <<-EVAL
def #{name}_jcrop_options
#{jcrop_options}
end
EVAL
end
end
end
end
|
ack43/rocket_cms
|
lib/rocket_cms/models/contact_message.rb
|
module RocketCMS
module Models
module ContactMessage
extend ActiveSupport::Concern
include RocketCMS::Model
include RocketCMS.orm_specific('ContactMessage')
included do
apply_simple_captcha message: RocketCMS.configuration.contacts_captcha_error_message
validates_email_format_of :email, unless: 'email.blank?'
if RocketCMS.config.contacts_message_required
validates_presence_of :content
end
validate do
if email.blank? && phone.blank?
errors.add(:email, I18n.t('rs.no_contact_info'))
end
end
after_create do
mailer_class.send(mailer_method, self).deliver
end
def mailer_class
ContactMailer
end
def mailer_method
:new_message_email
end
end
end
end
end
|
ack43/rocket_cms
|
lib/generators/rocket_cms/templates/migration_seos.rb
|
<gh_stars>0
class RocketCmsCreateSeos < ActiveRecord::Migration
def change
create_table :seos do |t|
t.boolean :enabled, default: true, null: false
t.integer :seoable_id
t.string :seoable_type
RocketCMS::Migration.seo_fields(t)
t.timestamps
end
add_index :seos, [:seoable_id, :seoable_type], unique: true
end
end
|
ack43/rocket_cms
|
app/controllers/concerns/rs_errors.rb
|
module RsErrors
extend ActiveSupport::Concern
included do
if Rails.env.production? || Rails.env.staging?
rescue_from Exception, with: :render_500
rescue_from ActionController::RoutingError, with: :render_404
rescue_from ActionController::UnknownController, with: :render_404
rescue_from ActionController::MissingFile, with: :render_404
rescue_from AbstractController::ActionNotFound, with: :render_404
if RocketCMS.mongoid?
rescue_from Mongoid::Errors::DocumentNotFound, with: :render_404
rescue_from Mongoid::Errors::InvalidFind, with: :render_404
end
if RocketCMS.active_record?
rescue_from ActiveRecord::RecordNotFound, with: :render_404
end
end
if defined?(CanCan)
rescue_from CanCan::AccessDenied do |exception|
Rails.logger.error "__________________________"
Rails.logger.error "Error 403"
Rails.logger.error (params ? params.inspect : "no params data")
Rails.logger.error (current_user ? current_user.inspect : "no current_user")
unless exception.nil?
Rails.logger.error exception.message
Rails.logger.error exception.backtrace.join("\n")
capture_exception(exception) if defined?(Raven)
end
Rails.logger.error "__________________________"
if !user_signed_in?
#scope = rails_admin? ? main_app : self
#redirect_to scope.new_user_session_path, alert: "Необходимо авторизоваться"
authenticate_user!
else
redirect_to '/', alert: t('rs.errors.access_denied')
end
end
end
rescue_from ActionController::InvalidAuthenticityToken do |exception|
redirect_to '/', alert: t('rs.errors.form_expired')
end
end
private
def render_404(exception = nil)
Rails.logger.error "__________________________"
Rails.logger.error "Error 404"
Rails.logger.error (params ? params.inspect : "no params data")
Rails.logger.error (current_user ? current_user.inspect : "no current_user")
unless exception.nil?
Rails.logger.error exception.message
Rails.logger.error exception.backtrace.join("\n")
capture_exception(exception) if defined?(Raven)
end
Rails.logger.error "__________________________"
render_error(404)
end
def render_500(exception = nil)
Rails.logger.error "__________________________"
Rails.logger.error "Error 500"
Rails.logger.error (params ? params.inspect : "no params data")
Rails.logger.error (current_user ? current_user.inspect : "no current_user")
unless exception.nil?
Rails.logger.error exception.message
Rails.logger.error exception.backtrace.join("\n")
capture_exception(exception) if defined?(Raven)
end
Rails.logger.error "__________________________"
begin
if rails_admin?
render text: t('rs.errors.internal_error_full', klass: exception.class.name, message: exception.message), status: 500
return
end
rescue Exception => e
puts "error while rendering rails admin exception"
puts e.class.name
puts e.message
puts e.backtrace.join("\n")
end
render_error(500)
end
def render_error(code = 500)
render template: "errors/error_#{code}", formats: [:html], handlers: [:slim], layout: RocketCMS.config.error_layout, status: code
end
def rails_admin?
self.is_a?(RailsAdmin::ApplicationController) || self.is_a?(RailsAdmin::MainController)
end
end
|
ack43/rocket_cms
|
lib/rocket_cms/controllers/contacts.rb
|
module RocketCMS
module Controllers
module Contacts
extend ActiveSupport::Concern
def index
@contact_message = ContactMessage.new
after_initialize
end
def new
@contact_message = model.new
after_initialize
end
def create
@contact_message = model.new(message_params)
after_initialize
if RocketCMS.config.contacts_captcha
meth = :save_with_captcha
else
meth = :save
end
if @contact_message.send(meth)
after_create
if request.xhr? && process_ajax
ajax_success
else
redirect_after_done
end
else
render_contacts_error
end
end
def sent
end
private
def render_contacts_error
if request.xhr? && process_ajax
render json: {errors: @contact_message.errors}, status: 422
else
flash.now[:alert] = @contact_message.errors.full_messages.join("\n")
render action: RocketCMS.configuration.recreate_contact_message_action, status: 422
end
end
def process_ajax
true
end
def ajax_success
render json: {ok: true}
end
def redirect_after_done
redirect_to :contacts_sent
end
def after_initialize
# overrideable hook for updating message
end
def after_create
# overrideable hook for updating message
end
def model
ContactMessage
end
def message_params
params.require(:contact_message).permit(RocketCMS.config.contacts_fields.keys + [:name, :email, :phone, :content, :captcha, :captcha_key])
end
end
end
end
|
ack43/rocket_cms
|
lib/rocket_cms/models/active_record/page.rb
|
<gh_stars>0
module RocketCMS
module Models
module ActiveRecord
module Page
extend ActiveSupport::Concern
included do
acts_as_nested_set
has_paper_trail
validates_lengths_from_database only: [:name, :title, :content, :excerpt, :h1, :keywords, :robots, :og_title, :regexp, :redirect, :fullpath]
scope :sorted, -> { order(lft: :asc) }
if RocketCMS.config.localize
translates :name, :content
end
end
end
end
end
end
|
ack43/rocket_cms
|
lib/rocket_cms/models/news.rb
|
module RocketCMS
module Models
module News
extend ActiveSupport::Concern
include RocketCMS::Model
include Seoable
include Enableable
include ManualSlug
include SitemapData
include RocketCMS.orm_specific('News')
if RocketCMS.config.search_enabled
include RocketCMS::ElasticSearch
end
included do
unless RocketCMS.config.news_image_styles.nil?
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
end
validates_presence_of :name
if RocketCMS.config.news_content_required
validates_presence_of :content
end
before_validation do
self.time = Time.now if self.time.blank?
end
scope :recent, ->(count = 5) { enabled.after_now.by_date.limit(count) }
unless RocketCMS.config.news_per_page.nil?
paginates_per RocketCMS.config.news_per_page
end
smart_excerpt :excerpt, :content, RocketCMS.config.news_excerpt
manual_slug :report_slug
RocketCMS.apply_patches self
end
def report_slug
if time.blank?
name
elsif name.blank?
time.strftime('%Y-%m-%d')
else
time.strftime('%Y-%m-%d') + '-' + name[0..20]
end
end
def html5_date
time.strftime('%Y-%m-%d')
end
def format_date
time.strftime(I18n.t('rs.format_time'))
end
end
end
end
|
ack43/rocket_cms
|
app/models/embedded_element.rb
|
<filename>app/models/embedded_element.rb
if RocketCMS.mongoid?
class EmbeddedElement
include RocketCMS::Models::EmbeddedElement
RocketCMS.apply_patches self
# use it in inherited model
#rails_admin &RocketCMS.embedded_image_config
# use it in rails_admin in parent model for sort
# sort_embedded({fields: [:embedded_field_1, :embedded_field_2...]})
# or u need to override rails_admin in inherited model to add sort field
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.