source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
nofxx/georuby
https://github.com/nofxx/georuby
bench.rb
Ruby
mit
243
master
959
# # Just for fun, benchmarking Pure Ruby GeoRuby against RGeo. # # !/usr/bin/env ruby require 'benchmark' require 'geo_ruby' require 'rgeo' COUNT = 100_000 fac = RGeo::Cartesian.factory def t(text) puts "\n\n#{' ' * (53 - text.size)}#{text}\n" end t 'Point.new!' Benchmark.bmbm do |x| x.report('Georuby') { COUN...
github
nofxx/georuby
https://github.com/nofxx/georuby
Rakefile
Ruby
mit
243
master
744
require 'bundler' Bundler.setup require 'rspec' require 'rspec/core/rake_task' $LOAD_PATH.unshift File.expand_path('../lib', __FILE__) require 'geo_ruby/version' desc 'Builds the gem' task gem: :build task :build do system 'gem build georuby.gemspec' Dir.mkdir('pkg') unless Dir.exist?('pkg') system "mv georuby...
github
nofxx/georuby
https://github.com/nofxx/georuby
Gemfile
Ruby
mit
243
master
233
source 'https://rubygems.org' gem 'rake' group :test do gem 'dbf' gem 'json' gem 'nokogiri' gem 'rspec' gem 'guard' gem 'guard-rspec' gem 'guard-rubocop' if ENV['CI'] gem 'coveralls', require: false end end
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby.rb
Ruby
mit
243
master
344
# $:.unshift(File.dirname(__FILE__)) #unless # $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) require 'geo_ruby/simple_features' # Require if you need # require 'geo_ruby/shp4r/shp' # require 'geo_ruby/gpx4r/gpx' # require 'geo_ruby/geojson' # require 'geo_ruby/georss' #...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/gpx.rb
Ruby
mit
243
master
3,278
require 'nokogiri' module GeoRuby module Gpx4r # An interface to GPX files class GpxFile attr_reader :record_count, :file_root #:xmin, :ymin, :xmax, :ymax, :zmin, :zmax, :mmin, :mmax, :file_length include Enumerable # Opens a GPX file. Both "abc.shp" and "abc" are accepted. def init...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/simple_features.rb
Ruby
mit
243
master
396
module GeoRuby module SimpleFeatures %w( geometry circle envelope geometry_collection geometry_factory helper line_string linear_ring multi_line_string multi_point multi_polygon point polygon ).each do |rel_file| require File....
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/kml.rb
Ruby
mit
243
master
2,755
require 'rexml/parsers/pullparser' module GeoRuby class KmlParser ELEMENT_MAP = { # "Point" => SimpleFeatures::Point, # we don't need to map points. they are done automatically by the coordinate parsing 'LineString' => SimpleFeatures::LineString, 'LinearRing' => SimpleFeatures::LinearRing, ...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/geojson.rb
Ruby
mit
243
master
4,004
# GeoJSON parser based on the v1.0 spec at http://geojson.org/geojson-spec.html require 'rubygems' begin require 'json' rescue LoadError puts "You've loaded GeoRuby GeoJSON Support." puts "Please install any 'json' provider gem. `gem install json`" end module GeoRuby # Raised when an error in the GeoJSON strin...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/georss.rb
Ruby
mit
243
master
5,831
module GeoRuby # Raised when an error in the GeoRSS string is detected class GeorssFormatError < StandardError end # Contains tags possibly found on GeoRss Simple geometries class GeorssTags < Struct.new(:featuretypetag, :relationshiptag, :elev, :floor, :radius) end # Par...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/shp4r/dbf.rb
Ruby
mit
243
master
929
# Uses the dbf lib, Copyright 2006 Keith Morrison (http://infused.org) # Modified to work as external gem now require 'rubygems' begin require 'dbf' rescue LoadError puts "You've loaded GeoRuby SHP Support." puts "Please install the gem 'dbf' to use it. `gem install dbf`" end module GeoRuby # Ruby .shp files ...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/shp4r/shp.rb
Ruby
mit
243
master
27,324
require 'date' require 'fileutils' unless defined?(FileUtils) module GeoRuby module Shp4r # Enumerates all the types of SHP geometries. # The MULTIPATCH one is the only one not currently supported by Geo_ruby. module ShpType NULL_SHAPE = 0 POINT = 1 POLYLINE = 3 POLYGON = 5 ...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/ewk/ewkb_parser.rb
Ruby
mit
243
master
5,959
module GeoRuby module SimpleFeatures # Raised when an error in the EWKB string is detected class EWKBFormatError < StandardError end # Parses EWKB strings and notifies of events (such as the beginning of the definition of geometry, the value of the SRID...) the factory passed as argument to the const...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/ewk/ewkt_parser.rb
Ruby
mit
243
master
9,246
require 'strscan' module GeoRuby module SimpleFeatures # Raised when an error in the EWKT string is detected class EWKTFormatError < StandardError end # Parses EWKT strings and notifies of events (such as the beginning of the definition of geometry, the value of the SRID...) the factory passed as ar...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/simple_features/polygon.rb
Ruby
mit
243
master
5,952
require 'geo_ruby/simple_features/geometry' module GeoRuby module SimpleFeatures # Represents a polygon as an array of linear rings (see LinearRing). # No check is performed regarding the validity of the geometries # forming the polygon. class Polygon < Geometry # the list of rings forming the ...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/simple_features/multi_point.rb
Ruby
mit
243
master
1,563
require 'geo_ruby/simple_features/geometry_collection' module GeoRuby module SimpleFeatures # Represents a group of points (see Point). class MultiPoint < GeometryCollection def initialize(srid = DEFAULT_SRID, with_z = false, with_m = false) super(srid, with_z, with_m) end def bina...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/simple_features/envelope.rb
Ruby
mit
243
master
6,922
module GeoRuby module SimpleFeatures # Contains the bounding box of a geometry class Envelope attr_accessor :lower_corner, :upper_corner attr_accessor :srid, :with_z, :zoom # Creates a enw Envelope with +lower_corner+ as the first element # of the corners array and +upper_corner+ as t...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/simple_features/geometry_factory.rb
Ruby
mit
243
master
2,374
module GeoRuby module SimpleFeatures # Creates a new geometry according to constructions # received from a parser, for example EWKBParser. class GeometryFactory # the built geometry attr_reader :geometry def initialize @geometry = nil @geometry_stack = [] end ...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/simple_features/multi_line_string.rb
Ruby
mit
243
master
1,813
require 'geo_ruby/simple_features/geometry_collection' module GeoRuby module SimpleFeatures # Represents a group of line strings (see LineString). class MultiLineString < GeometryCollection def initialize(srid = DEFAULT_SRID, _with_z = false, _with_m = false) super(srid) end def bi...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/simple_features/geometry.rb
Ruby
mit
243
master
8,231
module GeoRuby #:nodoc: module SimpleFeatures # Default SRID DEFAULT_SRID = 4326 unless defined? DEFAULT_SRID # Root of all geometric data classes. # Objects of class Geometry should not be instantiated. class Geometry # SRID of the geometry attr_reader :srid # writer defined below ...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/simple_features/geometry_collection.rb
Ruby
mit
243
master
4,566
require 'geo_ruby/simple_features/geometry' module GeoRuby module SimpleFeatures # Represents a collection of arbitrary geometries class GeometryCollection < Geometry attr_reader :geometries def initialize(srid = DEFAULT_SRID, with_z = false, with_m = false) super(srid, with_z, with_m) ...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/simple_features/linear_ring.rb
Ruby
mit
243
master
1,154
require 'geo_ruby/simple_features/line_string' module GeoRuby module SimpleFeatures # Represents a linear ring, which is a closed line string (see LineString). # Currently, no check is performed to verify if the linear ring is really closed. class LinearRing < LineString def initialize(srid = DEFAU...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/simple_features/circle.rb
Ruby
mit
243
master
1,500
module GeoRuby module SimpleFeatures # Represents a point. It is in 3D if the Z coordinate is not +nil+. class Circle < Geometry attr_accessor :radius, :center alias_method :r, :radius alias_method :c, :center def initialize(srid = DEFAULT_SRID, with_z = false, with_m = false) ...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/simple_features/line_string.rb
Ruby
mit
243
master
7,286
require 'geo_ruby/simple_features/geometry' module GeoRuby module SimpleFeatures # Represents a line string as an array of points (see Point). class LineString < Geometry # the list of points forming the line string attr_reader :points def initialize(srid = DEFAULT_SRID, with_z = false, wi...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/simple_features/multi_polygon.rb
Ruby
mit
243
master
1,772
require 'geo_ruby/simple_features/geometry_collection' module GeoRuby module SimpleFeatures # Represents a group of polygons (see Polygon). class MultiPolygon < GeometryCollection def initialize(srid = DEFAULT_SRID, _with_z = false, _with_m = false) super(srid) end def binary_geome...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/simple_features/point.rb
Ruby
mit
243
master
15,153
# -*- coding: utf-8 -*- require 'geo_ruby/simple_features/geometry' module GeoRuby module SimpleFeatures # Represents a point. It is in 3D if the Z coordinate is not +nil+. class Point < Geometry DEG2RAD = 0.0174532925199433 HALFPI = 1.5707963267948966 attr_accessor :x, :y, :z, :m at...
github
nofxx/georuby
https://github.com/nofxx/georuby
lib/geo_ruby/simple_features/helper.rb
Ruby
mit
243
master
585
module GeoRuby module SimpleFeatures # indicates the presence of Z coordinates in EWKB strings Z_MASK = 0x80000000 # indicates the presence of M coordinates in EWKB strings. M_MASK = 0x40000000 # indicate the presence of a SRID in EWKB strings. SRID_MASK = 0x20000000 # GeoRSS namespace ...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby_spec.rb
Ruby
mit
243
master
629
require File.expand_path(File.dirname(__FILE__) + '/spec_helper') # Time to add your specs! # http://rspec.info/ describe GeoRuby do it 'should instantiate Geometry' do @geo = GeoRuby::SimpleFeatures::Geometry.new expect(@geo.class).to eql(::GeoRuby::SimpleFeatures::Geometry) end it 'should instantiate...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/spec_helper.rb
Ruby
mit
243
master
1,671
require 'rubygems' # Must require active_spport/core_ext/object and then json/pure # or the json module gets clobbered and geojson output # becomes invalid... ie. it never calls class specific to_json # require 'active_support/core_ext/object' # require 'json/pure' require 'rspec' require 'geo_ruby' require 'geo_rub...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/georss_spec.rb
Ruby
mit
243
master
12,347
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') RSS_DATA_DIR = File.dirname(__FILE__) + '/../data/georss/' describe GeoRuby::GeorssParser do it 'should parse an rss file' do geo = subject.parse(File.read(RSS_DATA_DIR + '/w3c.xml')) expect(geo).to be_a GeoRuby::SimpleFeatures::Point e...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/geojson_spec.rb
Ruby
mit
243
master
6,417
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') DATA_DIR = File.dirname(__FILE__) + '/../data/geojson/' # All geojson test examples are from the GeoJSON spec unless otherwise # specified # # TODO Refactor comon test approaches into methods # TODO Add use of contexts? describe GeoRuby::GeoJSONPars...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/gpx_spec.rb
Ruby
mit
243
master
3,892
require 'spec_helper' describe GeoRuby::Gpx4r do it "should add gpx extension and raise if doesn't exists" do expect do expect(File).to receive(:exist?).with('short.gpx').and_return(false) expect(GeoRuby::Gpx4r::GpxFile.open('short')).to be_truthy end.to raise_error GeoRuby::Gpx4r::MalformedGpxE...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/kml_spec.rb
Ruby
mit
243
master
5,955
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') describe GeoRuby::KmlParser do before(:all) do POINT = '<Point><coordinates>-82.4898187291883,34.2473206042649</coordinates></Point>' LINESTRING = '<LineString><coordinates>-122.365662,37.826988 -122.365202,37.826302 -122.364581,37.82655 -1...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/simple_features/line_string_spec.rb
Ruby
mit
243
master
11,565
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') module LineSpecHelper def mock_points(num) # @point = mock(GeoRuby::SimpleFeatures::Point, :x => 1.0, :y => 2.0) Array.new(num) { |i| mock_point(i, i) } end def mock_point(x = 1, y = 2) double(GeoRuby::SimpleFeatures::Point, ...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/simple_features/geometry_factory_spec.rb
Ruby
mit
243
master
260
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe GeoRuby::SimpleFeatures::GeometryFactory do # before(:each) do # @po = GeoRuby::SimpleFeatures::MultiPolygon.new # end # it "should f" do # violated # end end
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/simple_features/multi_line_string_spec.rb
Ruby
mit
243
master
4,490
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe GeoRuby::SimpleFeatures::MultiLineString do it 'test_multi_line_string_creation' do multi_line_string1 = GeoRuby::SimpleFeatures::MultiLineString.from_line_strings([GeoRuby::SimpleFeatures::LineString.from_coordinates([[1.5, 45.2],...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/simple_features/geometry_spec.rb
Ruby
mit
243
master
1,228
# -*- coding: binary -*- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe GeoRuby::SimpleFeatures::Geometry do it 'should instantiate' do violated unless subject end it 'should have a default srid' do expect(subject.srid).to eql(4326) # Geometry.default_srid) end i...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/simple_features/point_spec.rb
Ruby
mit
243
master
16,265
# -*- coding: utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe GeoRuby::SimpleFeatures::Point do let(:point) { GeoRuby::SimpleFeatures::Point.new(4326) } it 'should instantiatember' do violated unless point expect(point).to be_instance_of(GeoRuby::SimpleFeatures::...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/simple_features/multi_point_spec.rb
Ruby
mit
243
master
2,170
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe GeoRuby::SimpleFeatures::MultiPoint do it 'test_multi_point_creation' do multi_point = GeoRuby::SimpleFeatures::MultiPoint.from_coordinates([[12.4, -123.3], [-65.1, 123.4], [123.55555555, 123]], 444) expect(multi_point).to be_i...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/simple_features/geometry_collection_spec.rb
Ruby
mit
243
master
4,891
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe GeoRuby::SimpleFeatures::GeometryCollection do it 'should test_geometry_collection_creation' do geometry_collection = GeoRuby::SimpleFeatures::GeometryCollection.new(256) geometry_collection << GeoRuby::SimpleFeatures::Point.fr...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/simple_features/circle_spec.rb
Ruby
mit
243
master
345
# -*- coding: utf-8 -*- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe GeoRuby::SimpleFeatures::Circle do it 'should instantiate' do expect(subject).to be_kind_of GeoRuby::SimpleFeatures::Geometry end describe 'Instance' do let(:circle) { GeoRuby::SimpleFeatures::Circl...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/simple_features/multi_polygon_spec.rb
Ruby
mit
243
master
6,333
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe GeoRuby::SimpleFeatures::MultiPolygon do it 'test_multi_polygon_creation' do multi_polygon1 = GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[12.4, -45.3], [45.4, 41.6], [4....
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/simple_features/polygon_spec.rb
Ruby
mit
243
master
9,626
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe GeoRuby::SimpleFeatures::Polygon do describe 'Instance Methods' do let(:poly) { GeoRuby::SimpleFeatures::Polygon.from_coordinates([[[0, 0], [4, 0], [4, 4], [0, 4], [0, 0]], [[1, 1], [3, 1], [3, 3], [1, 3], [1, 1]]], 256) } it...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/simple_features/envelope_spec.rb
Ruby
mit
243
master
1,759
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe GeoRuby::SimpleFeatures::Envelope do before(:each) do @srid = 4269 @env = GeoRuby::SimpleFeatures::Envelope.from_points([GeoRuby::SimpleFeatures::Point.from_x_y(10, 20, @srid), GeoRuby::SimpleFeatures::Point.from_x_y(20, 30, @sr...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/simple_features/linear_ring_spec.rb
Ruby
mit
243
master
738
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe GeoRuby::SimpleFeatures::LinearRing do it 'should instantiate' do lr = GeoRuby::SimpleFeatures::LinearRing.new(4326) expect(lr).to be_instance_of(GeoRuby::SimpleFeatures::LinearRing) end describe 'Instance' do let(:lr...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/shp4r/shp_spec.rb
Ruby
mit
243
master
9,157
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe GeoRuby::Shp4r do describe 'Point' do before(:each) do @shpfile = GeoRuby::Shp4r::ShpFile.open(File.dirname(__FILE__) + '/../../data/point.shp') end it 'should parse ok' do expect(@shpfile.record_count).to eql(...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/ewk/ewkt_parser_spec.rb
Ruby
mit
243
master
11,714
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') describe GeoRuby::SimpleFeatures::EWKTParser do before(:each) do @factory = GeoRuby::SimpleFeatures::GeometryFactory.new @ewkt_parser = GeoRuby::SimpleFeatures::EWKTParser.new(@factory) end it 'test_point' do ewkt = 'POINT( 3.4...
github
nofxx/georuby
https://github.com/nofxx/georuby
spec/geo_ruby/ewk/ewkb_parser_spec.rb
Ruby
mit
243
master
14,683
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') # rubocop:disable Metrics/LineLength describe GeoRuby::SimpleFeatures::EWKBParser do before(:each) do @factory = GeoRuby::SimpleFeatures::GeometryFactory.new @hex_ewkb_parser = GeoRuby::SimpleFeatures::HexEWKBParser.new(@factory) end ...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
plezi.gemspec
Ruby
mit
242
master
1,526
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'plezi/version' Gem::Specification.new do |spec| spec.name = 'plezi' spec.version = Plezi::VERSION spec.authors = ['Boaz Segev'] spec.email = ['bo@plezi.io'] ...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
bin/config.ru
Ruby
mit
242
master
546
require 'benchmark' require 'plezi' # our Plezi application class MyCtrl def index 'Hello from Plezi!' end end # rewites Plezi.route '(:format)', /^(json|html)$/ # Our Plezi route Plezi.route 'plezi/*', MyCtrl # The Rack application app = proc { |env| req = Rack::Request.new(env); str = "Params: #{req.params}"...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
resources/ctrlr.rb
Ruby
mit
242
master
583
# Replace this sample with real code. class ExampleCtrl CHANNEL = "chat".freeze # HTTP def index # any String returned will be appended to the response. We return a String. render 'welcome' end # Websockets def on_open subscribe CHANNEL write 'Welcome to appname!' @handle = params['id'....
github
boazsegev/plezi
https://github.com/boazsegev/plezi
resources/mini_app.rb
Ruby
mit
242
master
1,654
# encoding: UTF-8 ## Set environment, working directory, load gems and create logs ENV['ENV'] ||= ENV['RACK_ENV'] ||= ENV['RAILS_ENV'] # production ENV will render SASS as compressed. ## Using pathname extentions for setting public folder require 'pathname' ## Set up root object, it might be used by the environment an...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
resources/rakefile
Ruby
mit
242
master
202
# load all application code and gems require 'bundler' Bundler.require(:default, ENV['ENV'].to_s.to_sym) # set Plezi to rake mode and load it's tasks (if relevant). Plezi.no_autostart # Add your tasks
github
boazsegev/plezi
https://github.com/boazsegev/plezi
resources/routes.rb
Ruby
mit
242
master
788
################ # # Place your application routes here. # # # # Add your routes and controllers by order of priority. # # A dynamic Websocket Client route can be used to automatically send the # # updated Websocket client whenever Plezi is updated. # Plezi.route 'ws/client', :client # # I18n re-write, i.e.: `/en/ho...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi.rb
Ruby
mit
242
master
665
# standard library used by Plezi require 'json' require 'erb' require 'thread' require 'fileutils' require 'set' require 'securerandom' require 'yaml' require 'rack' require 'rack/query_parser.rb' require 'iodine' require 'plezi/version' require 'plezi/api' require 'plezi/controller/controller' # Plezi is amazing. R...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/api.rb
Ruby
mit
242
master
2,518
require 'plezi/activation' require 'plezi/helpers' require 'plezi/router/router' module Plezi # Plezi is amazing. Read the {README} class << self # Get / set the template folder for the {Controller#render} function. attr_accessor :templates # Get / set the assets folder for the `:assets` route (th...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/activation.rb
Ruby
mit
242
master
1,065
require 'uri' unless defined?(::URI) module Plezi protected @plezi_finalize = nil def plezi_finalize if @plezi_finalize.nil? @plezi_finalize = true @plezi_finalize = 1 end end @plezi_initialize = nil def self.plezi_initialize if @plezi_initialize.nil? @plezi_initiali...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/helpers.rb
Ruby
mit
242
master
1,892
require 'plezi/activation' require 'plezi/router/router' module Plezi module_function # attempts to convert a string's encoding to UTF-8, but only when the string is a valid UTF-8 encoded string. def try_utf8!(string, encoding = ::Encoding::UTF_8) return nil unless string string.force_encoding(::Enco...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/router/assets.rb
Ruby
mit
242
master
2,672
module Plezi module Base class Assets if ENV['RACK_ENV'.freeze] == 'production'.freeze def index name = File.join(Plezi.assets, *params['*'.freeze]).freeze data = ::Plezi::AssetBaker.bake(name) return false unless data name = File...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/router/adclient.rb
Ruby
mit
242
master
526
require 'plezi/router/route' require 'plezi/router/errors' require 'plezi/router/assets' module Plezi module Base module Router class ADClient def index fname = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'resources', 'client.js')) re...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/router/route.rb
Ruby
mit
242
master
4,352
require 'plezi/controller/controller' module Plezi module Base class Route attr_reader :prefix, :controller, :param_names def initialize(path, controller) @route_id = "Route#{object_id.to_s(16)}".to_sym @params_range = (0..0) m = path.match(/([^\:\(\*]*)(...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/router/errors.rb
Ruby
mit
242
master
588
module Plezi module Base class Err404Ctrl def index response.status = 404 render('404') || 'Error 404, not found.' end def requested_method :index end include Plezi::Controller end class Err500Ctrl def index...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/router/router.rb
Ruby
mit
242
master
4,930
require 'plezi/router/route' require 'plezi/router/errors' require 'plezi/router/assets' require 'plezi/router/adclient' module Plezi module Base # this module is incharge of routing requests to the correct Controller. module Router @routes = [] @app = nil module_function ...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/render/sassc.rb
Ruby
mit
242
master
2,379
require 'plezi/render/has_cache' # Redcarpet might not be available, if so, allow the require to throw it's exception. unless defined?(::SassC) begin require('sassc') rescue Exception end end if defined?(::SassC) module Plezi module Base # This is a baker, not a renderer mod...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/render/slim.rb
Ruby
mit
242
master
1,151
require 'plezi/render/has_cache' unless defined? ::Plezi::Base::HasStore module Plezi module Base module RenderSlim extend ::Plezi::Base::HasStore module_function def call(filename, context, &block) return unless defined? ::Slim return unless File.exist?(fil...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/render/render.rb
Ruby
mit
242
master
2,099
module Plezi module Renderer @render_library = {}.dup public module_function # Registers a rendering extention. # # Slim, Markdown, ERB and SASS are registered by default. # # extention:: a Symbol or String representing the extention of the file to be rendered. i.e....
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/render/markdown.rb
Ruby
mit
242
master
2,775
require 'plezi/render/has_cache' unless defined? ::Plezi::Base::HasStore # Redcarpet might not be available, if so, allow the require to throw it's exception. unless defined?(::Redcarpet::Markdown) begin require('redcarpet') rescue Exception end end if defined?(Redcarpet::Markdown) module Plezi ...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/render/sass.rb
Ruby
mit
242
master
2,071
require 'plezi/render/has_cache' # Support for Sass if SassC wasn't loaded. unless defined?(::SassC) unless defined?(::Sass) begin require('sass') rescue Exception end end if defined?(::Sass) module Plezi module Base # This is a baker, not a renderer ...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/render/erb.rb
Ruby
mit
242
master
1,112
require 'plezi/render/has_cache' unless defined? ::Plezi::Base::HasStore module Plezi module Base module RenderERB extend ::Plezi::Base::HasStore module_function def call(filename, context, &block) return unless defined? ::ERB return unless File.exist?(filen...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/render/has_cache.rb
Ruby
mit
242
master
1,130
module Plezi module Base # Provides a thread-safe caching engine module HasCache # initializes the cache def self.extended(base) base.instance_variable_set :@_lock, Mutex.new base.instance_variable_set :@_cache, {}.dup end # Stores data in the ...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/controller/controller.rb
Ruby
mit
242
master
10,921
require 'plezi/render/render' require 'plezi/controller/identification' require 'plezi/controller/cookies' require 'plezi/controller/controller_class' require 'plezi/controller/bridge' module Plezi # This module contains the functionality provided to any Controller class. # # This module will be included with...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/controller/cookies.rb
Ruby
mit
242
master
2,057
module Plezi module Controller # The cookie jar class. Controllers have an instance of this class named `cookies`. class Cookies < Hash attr_reader :request, :response def initialize(request, response) @request = request @response = response end ...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/controller/controller_class.rb
Ruby
mit
242
master
5,999
module Plezi module Controller # this module extends the controller class with Plezi functions module ClassMethods # A Ruby callback used to initialize class data for new Controllers. def self.extended(base) base._pl_init_class_data end # Publishes a messa...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/controller/identification.rb
Ruby
mit
242
master
810
module Plezi module Base module Identification module_function @ppid = ::Process.pid # returns a Plezi flavored pid UUID, used to set the pub/sub channel when scaling def pid process_pid = ::Process.pid if @ppid != process_pid @pid = nil @ppid = ...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
lib/plezi/controller/bridge.rb
Ruby
mit
242
master
1,386
module Plezi module Base # This module bridges between the Plezi Controller and the Iodine::Connection . module Bridge CONTROLLER_NAME = "plezi.controller".to_sym CLIENT_NAME = "@_pl__client".to_sym # don't rename without updating Controller # returns a client's controller def controll...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
examples/chat.rb
Ruby
mit
242
master
1,464
# finish with `exit` if running within `irb` require 'plezi' class ChatServer def index "Use Websockets to connect." end def on_open return close unless params['id'] @name = params['id'] subscribe channel: "chat" publish channel: "chat", message: "#{@name} joind the chat." write "Welcome, ...
github
boazsegev/plezi
https://github.com/boazsegev/plezi
test/route_test.rb
Ruby
mit
242
master
4,202
require 'test_helper' require 'stringio' # a stub routing object for tests class Stub def index self.class.last_call = requested_method end def show self.class.last_call = requested_method end def new self.class.last_call = requested_method end def create self.class.last...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
Gemfile
Ruby
mit
242
master
242
source 'https://rubygems.org' # Specify your gem's dependencies in twterm.gemspec gemspec gem 'bundler', '~> 2.1.4' gem 'hashie', '~> 4.1.0' gem 'rake', '~> 13.0.3' gem 'rspec', '~> 3.10.0' gem 'rubocop', '~> 1.7.0' gem 'yard', '~> 0.9.26'
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
twterm.gemspec
Ruby
mit
242
master
1,187
lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'twterm/version' Gem::Specification.new do |spec| spec.name = 'twterm' spec.version = Twterm::VERSION spec.authors = ['Ryota Kameoka'] spec.email = ['kameoka.ryota@gmail.com']...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/spec_helper.rb
Ruby
mit
242
master
342
RSpec.configure do |config| config.run_all_when_everything_filtered = true config.filter_run :focus config.order = :random end def fixture(path) dir = File.expand_path('../fixtures', __FILE__) File.read("#{dir}/#{path}") end Dir['spec/supports/**/*.rb'].each { |f| require File.expand_path(f, __dir__ + '/..'...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/supports/shared_examples/abstract_key_mapper.rb
Ruby
mit
242
master
390
require 'twterm/key_mapper/abstract_key_mapper' RSpec.shared_examples Twterm::KeyMapper::AbstractKeyMapper do describe '.commands' do subject { described_class.commands } it { is_expected.to be_an Array } it { is_expected.to all be_kind_of Symbol } end describe '.category' do subject { describ...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/user_spec.rb
Ruby
mit
242
master
2,739
require 'twterm/user' RSpec.describe Twterm::User do let(:user) { described_class.new(Twitter::User.new(json)) } let(:json) { JSON.parse(fixture('user.json'), symbolize_names: true) } describe '#update!' do subject { -> { user.update!(Hashie::Mash.new(params)) } } before do user.update!(Hashie::M...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/status_spec.rb
Ruby
mit
242
master
1,598
require 'hashie/mash' describe Twterm::Status do let(:status) { described_class.new(Twitter::Tweet.new(json)) } let(:json) { JSON.parse(fixture('status.json'), symbolize_names: true) } describe '#==' do subject { status === other } context 'when having the same id' do let(:other) { status.dup } ...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/config_spec.rb
Ruby
mit
242
master
1,063
describe Twterm::Config do MOCK_CONFIG_PATH = 'spec/resources/config'.freeze let(:config) { described_class.new } describe '#[]' do it 'returns config value from config_file_path' do allow(config).to receive(:config_file_path).and_return(MOCK_CONFIG_PATH) expect(config[:access_token]).to eq 'to...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/image_spec.rb
Ruby
mit
242
master
1,367
require 'twterm/image' RSpec.describe Twterm::Image do describe '.number' do subject { described_class.number(n) } context 'when n = 42' do let(:n) { 42 } it 'is stringified as it is' do expect(subject.to_s).to eq '42' end end context 'when n = 1000000' do let(:n) {...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/event_dispatcher_spec.rb
Ruby
mit
242
master
434
require 'spec_helper' RSpec.describe Twterm::EventDispatcher do let(:event_dispatcher) { described_class.instance } describe '#dispatch' do subject { event_dispatcher.dispatch(event) } let(:event) { Twterm::Event::AbstractEvent.new } it { is_expected.to eq event_dispatcher } end describe '.inst...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/repository/friendship_repository_spec.rb
Ruby
mit
242
master
2,454
require 'twterm/repository/friendship_repository' RSpec.describe Twterm::Repository::FriendshipRepository do let(:repository) { described_class.new } describe '#already_looked_up?' do before do repository.looked_up!(1) end it 'returns true when the user is already looked up' do expect(rep...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/image_builder/user_name_image_builder_spec.rb
Ruby
mit
242
master
742
require 'twterm/image_builder/user_name_image_builder' RSpec.describe Twterm::ImageBuilder::UserNameImageBuilder do describe '#build' do let(:json) { json = JSON.parse(fixture('user.json'), symbolize_names: true) json[:screen_name] = screen_name json[:name] = name json } let(:u...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/completer/search_query_completer_spec.rb
Ruby
mit
242
master
6,076
require 'twterm/app' require 'twterm/completer/search_query_completer' RSpec.describe Twterm::Completer::SearchQueryCompleter do let(:app) { Twterm::App.new } let(:completer) { described_class.new(app) } describe '#complete' do subject { completer.complete(query) } context 'when the query is empty' do ...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/key_mapper/abstract_key_mapper_spec.rb
Ruby
mit
242
master
485
require 'twterm/key_mapper/abstract_key_mapper' describe Twterm::KeyMapper::AbstractKeyMapper do describe '#translate' do subject { described_class.new({}).send(:translate, key) } before { described_class.define_singleton_method(:commands) { [] } } context 'when key is ^A' do let(:key) { '^A' } ...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/extension/enumerator/lazy_spec.rb
Ruby
mit
242
master
277
require 'spec_helper' RSpec.describe Enumerator::Lazy do describe '#scan' do context 'when calculating summation of 0 thorugh 9' do subject { [*0..9].lazy.scan(0, :+).to_a } it { is_expected.to eq [0, 0, 1, 3, 6, 10, 15, 21, 28, 36, 45] } end end end
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/image/parens_spec.rb
Ruby
mit
242
master
258
require 'spec_helper' RSpec.describe Twterm::Image::Parens do let(:image) { described_class.new(foo) } let(:foo) { Twterm::Image::StringImage.new('foo') } describe '#to_s' do subject { image.to_s } it { is_expected.to eq '(foo)' } end end
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/image/string_image_spec.rb
Ruby
mit
242
master
229
require 'spec_helper' RSpec.describe Twterm::Image::StringImage do let(:image) { described_class.new(str) } let(:str) { 'Hello' } describe '#to_s' do subject { image.to_s } it { is_expected.to eq str } end end
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/image/brackets_spec.rb
Ruby
mit
242
master
260
require 'spec_helper' RSpec.describe Twterm::Image::Brackets do let(:image) { described_class.new(foo) } let(:foo) { Twterm::Image::StringImage.new('foo') } describe '#to_s' do subject { image.to_s } it { is_expected.to eq '[foo]' } end end
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/image/dim_spec.rb
Ruby
mit
242
master
635
require 'spec_helper' RSpec.describe Twterm::Image::Dim do let(:string_image) { Twterm::Image::StringImage.new(str) } let(:str) { 'Hello' } describe '#height' do subject { image.height } let(:image) { described_class.new(string_image) } it { is_expected.to eq string_image.height } end describ...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/image/color_spec.rb
Ruby
mit
242
master
912
require 'spec_helper' RSpec.describe Twterm::Image::Color do let(:string_image) { Twterm::Image::StringImage.new(str) } let(:str) { 'Hello' } describe '#height' do subject { image.height } let(:image) { described_class.new(string_image, :red) } it { is_expected.to eq string_image.height } end ...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/image/bold_spec.rb
Ruby
mit
242
master
636
require 'spec_helper' RSpec.describe Twterm::Image::Bold do let(:string_image) { Twterm::Image::StringImage.new(str) } let(:str) { 'Hello' } describe '#height' do subject { image.height } let(:image) { described_class.new(string_image) } it { is_expected.to eq string_image.height } end descri...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/image/horizontal_sequential_image_spec.rb
Ruby
mit
242
master
462
require 'spec_helper' RSpec.describe Twterm::Image::HorizontalSequentialImage do let(:image) { described_class.new([foo, ws, bar, ws, baz]) } let(:foo) { Twterm::Image::StringImage.new('foo') } let(:bar) { Twterm::Image::StringImage.new('bar') } let(:baz) { Twterm::Image::StringImage.new('baz') } let(:ws) { ...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
spec/twterm/image/vertical_sequential_image_spec.rb
Ruby
mit
242
master
402
require 'spec_helper' RSpec.describe Twterm::Image::VerticalSequentialImage do let(:image) { described_class.new([foo, bar, baz]) } let(:foo) { Twterm::Image::StringImage.new('foo') } let(:bar) { Twterm::Image::StringImage.new('bar') } let(:baz) { Twterm::Image::StringImage.new('baz') } describe '#to_s' do ...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
lib/twterm.rb
Ruby
mit
242
master
1,791
$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) require 'cgi' require 'curses' require 'forwardable' require 'launchy' require 'oauth' require 'readline' require 'singleton' require 'set' require 'twitter' require 'twitter-text' req...
github
ryota-ka/twterm
https://github.com/ryota-ka/twterm
lib/twterm/subscriber.rb
Ruby
mit
242
master
770
require 'twterm/event_dispatcher' module Twterm module Subscriber def subscribe(event, callback = nil, &block) cb = if callback.is_a?(Proc) callback elsif callback.is_a?(Symbol) if self.respond_to?(callback, true) self.method(callback) else ...