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 | castwide/readapt | https://github.com/castwide/readapt | spec/readapt/finder_spec.rb | Ruby | mit | 45 | master | 523 | require 'tmpdir'
RSpec.describe Readapt::Finder do
it 'finds local files' do
program = File.absolute_path(File.join('spec', 'fixtures', 'file.rb'))
found = Readapt::Finder.find(program)
expect(found).to eq(program)
end
it 'finds Ruby programs' do
program = 'rspec'
found = Readapt::Finder.fin... |
github | castwide/readapt | https://github.com/castwide/readapt | spec/readapt/breakpoints_spec.rb | Ruby | mit | 45 | master | 1,456 | RSpec.describe Readapt::Breakpoints do
after :each do
Readapt::Breakpoints.clear
end
it 'matches set breakpoints' do
Readapt::Breakpoints.set 'test.rb', [1, 3]
expect(Readapt::Breakpoints.match('test.rb', 1)).to be(true)
expect(Readapt::Breakpoints.match('test.rb', 2)).to be(false)
expect(Rea... |
github | castwide/readapt | https://github.com/castwide/readapt | spec/readapt/monitor_spec.rb | Ruby | mit | 45 | master | 1,693 | RSpec.describe Readapt::Monitor do
it 'starts and stops' do
expect {
Readapt::Monitor.start "" do
nil
end
x = 1
y = 2
Readapt::Monitor.stop
}.not_to raise_error
end
it 'stops on breakpoints' do
file = File.absolute_path(File.join('spec', 'fixtures', 'app.rb'))
... |
github | castwide/readapt | https://github.com/castwide/readapt | spec/readapt/server_spec.rb | Ruby | mit | 45 | master | 914 | RSpec.describe Readapt::Server do
it 'shuts down gracefully for dead target processes' do
expect {
stdin, stdout, stderr, thr = Open3.popen3('ruby', 'gets.rb')
Readapt::Server.target_in = stdin
object = Object.new
object.define_singleton_method :close do; end # Mock method
object.ext... |
github | castwide/readapt | https://github.com/castwide/readapt | spec/readapt/frame_spec.rb | Ruby | mit | 45 | master | 268 | RSpec.describe Readapt::Frame do
it 'evaluates in bindings' do
var = 'var'
block = proc {
binding
}
bnd = block.call
frame = Readapt::Frame.new(nil, 0, bnd)
result = frame.evaluate('var')
expect(result).to eq(var.inspect)
end
end |
github | castwide/readapt | https://github.com/castwide/readapt | spec/readapt/message/set_breakpoints_spec.rb | Ruby | mit | 45 | master | 568 | RSpec.describe Readapt::Message::SetBreakpoints do
it 'sets breakpoints' do
debugger = double(:Debugger, clear_breakpoints: nil, set_breakpoint: nil)
message = Readapt::Message::SetBreakpoints.new({
'source' => {
'path' => 'test.rb'
},
'breakpoints' => [
{
'line' =>... |
github | castwide/readapt | https://github.com/castwide/readapt | spec/readapt/message/stack_trace_spec.rb | Ruby | mit | 45 | master | 721 | RSpec.describe Readapt::Message::StackTrace do
it 'gets stack traces' do
Readapt::Monitor.start __FILE__ do
# Disable GC to ensure the binding does not get garbage collected
# @todo There might be a better way to handle this. Consider holding a
# reference to the thread's frames in threads.c.
... |
github | castwide/readapt | https://github.com/castwide/readapt | spec/readapt/message/evaluate_spec.rb | Ruby | mit | 45 | master | 1,003 | RSpec.describe Readapt::Message::Evaluate do
it 'evaluates expressions' do
bind = proc {
value = 1
send(:binding)
}.call
@debugger = double(:Debugger)
@frame = Readapt::Frame.new(nil, 0, bind)
allow(@debugger).to receive(:frame) { @frame }
arguments = {
'expression' => '[valu... |
github | castwide/readapt | https://github.com/castwide/readapt | spec/readapt/message/variables_spec.rb | Ruby | mit | 45 | master | 3,175 | class TestCVar
@@cvar = 'cvar'
end
RSpec.describe Readapt::Message::Variables do
before :each do
@debugger = double(:Debugger)
allow(@debugger).to receive(:frame) { @frame }
@frame = nil
end
after :each do
Readapt::References.clear
end
it "finds local variables in frames" do
bind = pr... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | turkish_cities.gemspec | Ruby | mit | 45 | master | 1,621 | lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'turkish_cities/version'
Gem::Specification.new do |s|
s.name = 'turkish_cities'
s.version = TurkishCities::VERSION
s.required_ruby_version = '>= 2.5.1'
s.authors ... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | spec/turkish_cities_spec.rb | Ruby | mit | 45 | master | 6,905 | # frozen_string_literal: true
require_relative '../lib/turkish_cities'
RSpec.describe TurkishCities do
describe '#change_locale' do
context 'when input is supported' do
it 'changes to turkish' do
expect(TurkishCities.change_locale('tr')).to eq 'Dil Türkçe olarak ayarlandı'
end
it 'cha... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | spec/spec_helper.rb | Ruby | mit | 45 | master | 5,214 | # frozen_string_literal: true
require 'simplecov'
SimpleCov.start
require 'codecov'
SimpleCov.formatter = SimpleCov::Formatter::Codecov
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` fi... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | spec/classes/elevation_spec.rb | Ruby | mit | 45 | master | 2,427 | # frozen_string_literal: true
require_relative '../../lib/turkish_cities/elevation'
RSpec.describe Elevation do
describe '#find_by_elevation' do
context 'when input is supported' do
it 'finds cities with below elevation' do
expect(Elevation.new.find_by_elevation('below', 5)).to eq %w[Kocaeli]
... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | spec/classes/population_spec.rb | Ruby | mit | 45 | master | 3,105 | # frozen_string_literal: true
require_relative '../../lib/turkish_cities/population'
RSpec.describe Population do
describe '#find_by_population' do
context 'when input is supported' do
it 'finds city with exact population' do
expect(Population.new.find_by_population('exact', 15_840_900, nil)).to e... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | spec/classes/city_spec.rb | Ruby | mit | 45 | master | 8,927 | # frozen_string_literal: true
require_relative '../../lib/turkish_cities/city'
RSpec.describe City do
describe '#find_by_id' do
context 'when input is supported' do
it 'finds city by plate number' do
expect(City.new.find_by_id(6)).to eq 'Ankara'
expect(City.new.find_by_id(0o07)).to eq 'Ant... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | spec/classes/postcode_spec.rb | Ruby | mit | 45 | master | 1,298 | # frozen_string_literal: true
require_relative '../../lib/turkish_cities/postcode'
RSpec.describe Postcode do
describe '#find_by_postcode' do
context 'when input is supported' do
it 'finds city, district and subdistrict info of postcode' do
expect(Postcode.new.find_by_postcode(34_380)).to eq %w[İs... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | spec/classes/district_spec.rb | Ruby | mit | 45 | master | 614 | # frozen_string_literal: true
require_relative '../../lib/turkish_cities/district'
RSpec.describe District do
describe '#list_neighborhoods' do
context 'when input is supported' do
it 'finds neighborhoods of given city and district' do
expect(District.new('Artvin', 'Yusufeli').neighborhoods(nil).c... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | spec/classes/distance_spec.rb | Ruby | mit | 45 | master | 4,128 | # frozen_string_literal: true
require_relative '../../lib/turkish_cities/distance'
RSpec.describe Distance do
describe '#distance_between(land)' do
context 'when input is supported' do
it 'finds land distance between two location' do
land_distance_results = Distance.new('Adana', 'Bolu', 'land').di... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | lib/turkish_cities.rb | Ruby | mit | 45 | master | 2,220 | # frozen_string_literal: true
require_relative '../lib/turkish_cities/city'
require_relative '../lib/turkish_cities/distance'
require_relative '../lib/turkish_cities/district'
require_relative '../lib/turkish_cities/elevation'
require_relative '../lib/turkish_cities/population'
require_relative '../lib/turkish_cities/... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | lib/turkish_cities/population.rb | Ruby | mit | 45 | master | 1,848 | # frozen_string_literal: true
require 'i18n'
require 'yaml'
require_relative '../turkish_cities/helpers/decomposer_helper'
class Population
include DecomposerHelper
file_path = File.join(File.dirname(__FILE__), 'data/cities.yaml')
CITY_LIST = YAML.load_file(file_path)
MIN_POPULATION = 83_644
MAX_POPULATI... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | lib/turkish_cities/elevation.rb | Ruby | mit | 45 | master | 1,199 | # frozen_string_literal: true
class Elevation
include DecomposerHelper
file_path = File.join(File.dirname(__FILE__), 'data/cities.yaml')
CITY_LIST = YAML.load_file(file_path)
MIN_ELEVATION = 3
MAX_ELEVATION = 1924
def find_by_elevation(type, elevation_one, elevation_two = nil)
city_list = CITY_LIST
... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | lib/turkish_cities/district.rb | Ruby | mit | 45 | master | 1,452 | # frozen_string_literal: true
require 'i18n'
require 'yaml'
require_relative '../turkish_cities/helpers/decomposer_helper'
class District
include DecomposerHelper
def initialize(city_name, district_name)
@city_name = city_name
@district_name = district_name
@district_list = create_district_list(city... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | lib/turkish_cities/distance.rb | Ruby | mit | 45 | master | 4,100 | # frozen_string_literal: true
require 'i18n'
require 'yaml'
require_relative '../turkish_cities/helpers/decomposer_helper'
class Distance
include DecomposerHelper
file_path = File.join(File.dirname(__FILE__), 'data/cities.yaml')
CITY_LIST = YAML.load_file(file_path)
RADIUS_OF_EARTH = 6371 # Earth radius in ... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | lib/turkish_cities/postcode.rb | Ruby | mit | 45 | master | 635 | # frozen_string_literal: true
require 'i18n'
require 'yaml'
require_relative '../turkish_cities/helpers/decomposer_helper'
class Postcode
include DecomposerHelper
def find_by_postcode(postcode)
check_input_range(postcode, 1010, 81_952)
city_name = City.new.find_by_id(postcode.to_i / 1000)
city_file... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | lib/turkish_cities/city.rb | Ruby | mit | 45 | master | 2,176 | # frozen_string_literal: true
require 'i18n'
require 'yaml'
require_relative '../turkish_cities/helpers/decomposer_helper'
class City
include DecomposerHelper
file_path = File.join(File.dirname(__FILE__), 'data/cities.yaml')
CITY_LIST = YAML.load_file(file_path)
def find_by_id(plate_number)
check_input... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | lib/turkish_cities/data/neighborhoods_parser.rb | Ruby | mit | 45 | master | 1,727 | # frozen_string_literal: true
require 'csv'
require 'yaml'
require_relative '../helpers/decomposer_helper'
module NeighborhoodsParser
include DecomposerHelper
district_hash = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
mahalle_array = []
last_city = 'Adana'
last_district = ''
last_subdistrict =... |
github | sarslanoglu/turkish_cities | https://github.com/sarslanoglu/turkish_cities | lib/turkish_cities/helpers/decomposer_helper.rb | Ruby | mit | 45 | master | 4,306 | # frozen_string_literal: true
module DecomposerHelper
def check_input_range(input, min, max)
return if input.to_i.between?(min, max)
raise RangeError, I18n.t('errors.outside_bounds', input: input, min: min, max: max)
end
def city_not_found_error(input)
I18n.t('errors.city_not_found_error', input: i... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | Gemfile | Ruby | mit | 45 | master | 2,055 | source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use ... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | Vagrantfile | Ruby | mit | 45 | master | 1,395 | # -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commen... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | config/application.rb | Ruby | mit | 45 | master | 1,098 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Rails4Mapwarper
class Application < Rails::Application
# Settings in config/environments/* ta... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | config/routes.rb | Ruby | mit | 45 | master | 6,770 | Rails.application.routes.draw do
root 'home#index'
get '/about' => 'home#about', :as => 'about'
get '/help' => 'home#help', :as => 'help'
get '/offline' => 'home#offline', :as => 'offline'
devise_for :users, :path => 'u',:controllers => { :sessions => "sessions", :omniauth_callbacks => "omniauth_callbacks"... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | config/environments/development.rb | Ruby | mit | 45 | master | 1,710 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web serv... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | config/environments/production.rb | Ruby | mit | 45 | master | 3,610 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web serve... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | config/environments/test.rb | Ruby | mit | 45 | master | 1,771 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suit... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | config/initializers/nypl_repo.rb | Ruby | mit | 45 | master | 321 | #Loads in the authentication token per rails env
require "#{ Rails.root }/lib/nypl/nypl_repo.rb"
if File.exist?(File.join(Rails.root, "/config/nypl_repo.yml"))
config_file = YAML.load_file("#{ Rails.root }/config/nypl_repo.yml")
REPO_CONFIG = config_file[ENV['RAILS_ENV']].symbolize_keys
else
REPO_CONFIG = {}
end |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | config/initializers/mime_types.rb | Ruby | mit | 45 | master | 347 | # Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
Mime::Type.register "application/vnd.google-earth.kml+xml", :kml
#Mime::Type.register "image/png", :png
Mime::Type.register "application/xml", :aux_xml
Mime::Type.r... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | config/initializers/assets.rb | Ruby | mit | 45 | master | 1,162 | # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Rails.... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | config/initializers/devise.rb | Ruby | mit | 45 | master | 13,324 | # Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render invalid all existing
# confirmat... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | config/initializers/rack_attack.rb | Ruby | mit | 45 | master | 2,607 | module Rack::Attack
# Expose the warper app so we can call it
class << self
attr_accessor :app
def app
@app
end
end
end
if APP_CONFIG["enable_throttling"] == true
limit = APP_CONFIG["throttle_limit"] || 5
period = APP_CONFIG["throttle_period"] || 20
delay = APP_CONFIG["throttle_delay"]... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | config/initializers/application_config.rb | Ruby | mit | 45 | master | 1,740 | CONFIG_PATH="#{Rails.root}/config/application.yml"
APP_CONFIG = YAML.load_file(CONFIG_PATH)[Rails.env]
#directories for maps and layer/mosaic tileindex shapefiles
DST_MAPS_DIR = APP_CONFIG['dst_maps_dir'].blank? ? File.join(Rails.root, '/public/mapimages/dst/') : APP_CONFIG['dst_maps_dir']
SRC_MAPS_DIR = APP_CONFIG['... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | lib/misc/georuby_extension.rb | Ruby | mit | 45 | master | 809 | module GeoRuby
module SimpleFeatures
class Polygon
def to_json(options = nil)
coords = self.first.points.collect {|point| [point.x, point.y] }
{:type => "Polygon",
:coordinates => coords}.to_json
end
end
class Point
def to_json(options = nil)
{:type => ... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | lib/misc/gdalinfo.rb | Ruby | mit | 45 | master | 273 | require 'gdal-ruby/gdal'
def get_raster_extents(filename)
raster = Gdal::Gdal.open(filename)
dx = raster.RasterXSize
dy = raster.RasterYSize
x0, x_res, x_skew, y0, y_skew, y_res = raster.get_geo_transform
[x0, y0 + dy * y_res, x0 + dx * x_res, y0]
end |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | lib/tasks/tile_publish.rake | Ruby | mit | 45 | master | 474 | namespace :warper do
desc "seeds tiles using tilestache to S3 from a map or layer"
task :tilestache_seed => :environment do
unless ENV["id"] && ENV["type"] && ["map", "layer"].include?(ENV["type"])
puts "usage: rake warper:tilestache_seed type=map|layer id=123"
break
end
item = ... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | lib/tasks/nypl_repo_import.rake | Ruby | mit | 45 | master | 5,235 | namespace :map do
namespace :repo do
def deep_find(key, object=self, found=nil)
if object.respond_to?(:key?) && object.key?(key)
return object
elsif object.is_a? Enumerable
object.find { |*a| found = deep_find(key, a.last) }
return found
end
end
#cleans th... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | lib/tasks/import.rake | Ruby | mit | 45 | master | 3,919 | #called using arguments
#example: RAILS_ENV=development rake warper:import_images['/home/tim/tmp/helsinki',2,,,'helsinki','helsinki2']
namespace :warper do
desc "Import images from a directory to map"
task :import_images, [:directory, :user, :layer, :layer_name, :title, :description, :publisher, :authors, :scale] ... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | lib/tasks/nypl_repo.rake | Ruby | mit | 45 | master | 5,777 | namespace :map do
namespace :repo do
desc "Sets maps bibliographic item uuid from the nypl_digital_id using the NYPL Repo API if it doesnt have one already"
task(:update_bibl_uuid => :environment) do
desc "updates biblio_uuid for maps"
puts "This will update the maps uuid based on the nypl_digit... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | lib/tasks/db_export.rake | Ruby | mit | 45 | master | 1,682 | namespace :warper do
def dump_database
database = Rails.configuration.database_configuration[Rails.env]["database"]
dump_name = "#{database}-#{Time.now.strftime('%Y-%m-%d-%H%M%S')}.dump"
system "pg_dump #{database} -Fc -i > db/#{dump_name}"
dump_name
end
desc "PostgreSQL database dum... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | lib/enum_fu/lib/enum_fu.rb | Ruby | mit | 45 | master | 2,214 | module EnumFu
def self.included(including_class)
including_class.class_eval do
# make a enum colume in active record model
# db schema
# create_table 'users' do |t|
# t.column 'role', :integer, :limit => 2
# end
#
# model
# class User < ActiveRecord::Bas... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | lib/nypl/nypl_repo.rb | Ruby | mit | 45 | master | 6,102 | module NyplRepo
class Client
require 'uri'
require 'net/http'
require 'json'
def initialize(token, debug=false, logger=nil)
@token = token
@debug = debug
@logger = logger
end
def log(msg)
if @logger
@logger.info msg
else
puts msg
end
e... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/helpers/application_helper.rb | Ruby | mit | 45 | master | 2,886 | module ApplicationHelper
def admin_authorized?
user_signed_in? && current_user.has_role?('administrator')
end
def read_only_mode
if APP_CONFIG['status'] == :offline
return false
else
return APP_CONFIG['status'] == :read_only || (Setting.last && Setting.last.site_status == "read_only"... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/models/error_calculator.rb | Ruby | mit | 45 | master | 3,387 | #A module to assist in calculation RMS error of the control points and the map
#adapted to ruby by tim waters and based on bsd licenced code
#oldmapsonline.org Klokan Petr Pridal gcps2wld.py (new BSD licence)
#takes in an enumeration of control points, and returns them with error attribute
#and returns the rms of the w... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/models/user.rb | Ruby | mit | 45 | master | 5,135 | class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable, :encryptable,
:omniauthable, :omniauth_pr... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/models/layers_map.rb | Ruby | mit | 45 | master | 213 | class LayersMap < ActiveRecord::Base
def self.table_name()
"map_layers"
end
belongs_to :layer
belongs_to :map
validates_uniqueness_of :layer_id, :scope => :map_id, :message => "already has this map"
end |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/models/import.rb | Ruby | mit | 45 | master | 11,845 | class Import < ActiveRecord::Base
belongs_to :user, :class_name => "User"
acts_as_enum :status, [:ready, :running, :finished, :failed]
acts_as_enum :import_type, [:map, :layer, :latest]
validate :presence_of_a_param
validate :validate_correct_import_type
validates_presence_of :since_date, :if => (:until_d... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/models/map.rb | Ruby | mit | 45 | master | 25,471 | require "open3"
require "error_calculator"
require 'rmagick'
include ErrorCalculator
class Map < ActiveRecord::Base
include Tilestache
alias_attribute :bibl_uuid, :parent_uuid
alias_attribute :mods_uuid, :uuid
has_many :gcps, :dependent => :destroy
has_many :layers_maps, :dependent => :destroy
has_... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/models/gcp.rb | Ruby | mit | 45 | master | 801 | class Gcp < ActiveRecord::Base
belongs_to :map
has_paper_trail
validates_numericality_of :x, :y, :lat, :lon
validates_presence_of :x, :y, :lat, :lon, :map_id
scope :soft, -> { where(:soft => true)}
scope :hard, -> { where('soft IS NULL OR soft = ?', false) }
attr_accessor :error
after_upda... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/models/setting.rb | Ruby | mit | 45 | master | 444 | class Setting < ActiveRecord::Base
SITE_STATUSES = ["online", "read_only"]
validate :check_status
after_initialize :default_values
def check_status
unless Setting::SITE_STATUSES.include? self.site_status
errors.add :base, 'Site status can only be one of '+ Setting::SITE_STATUSES.to_s
end
e... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/models/flag.rb | Ruby | mit | 45 | master | 933 | class Flag < ActiveRecord::Base
belongs_to :flaggable, polymorphic: true
belongs_to :reporter, :class_name => "User"
belongs_to :closer, :class_name => "User"
validates_uniqueness_of :flaggable_id, :scope => :flaggable_type
validates_presence_of :flaggable_id
validates_presence_of :flaggable_type
valid... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/models/layer.rb | Ruby | mit | 45 | master | 5,573 | class Layer < ActiveRecord::Base
include Tilestache
has_many :layers_maps, :dependent => :destroy
has_many :maps,:through => :layers_maps
has_many :layer_properties #could be has_one
acts_as_commentable
validates_presence_of :name
validates_length_of :depicts_year, :maximum => 4,:allow_nil => t... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/models/user_mailer.rb | Ruby | mit | 45 | master | 1,158 | class UserMailer < ActionMailer::Base
default from: APP_CONFIG['email']
def disabled_change_password(user)
@user = user
@subject = "#{APP_CONFIG['site_name']} You account is disabled until you change your password"
mail(to: @user.email, subject: @subject)
end
def new_registration(user)
@user =... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/models/concerns/tilestache.rb | Ruby | mit | 45 | master | 7,029 | require 'rmagick'
module Tilestache
require "open3"
extend ActiveSupport::Concern
def tilestache_seed
who = self
options = create_options(who)
max_zoom = options[:max_zoom]
config_file = create_config_file(who, options)
command = build_tilestache_command(who, config_file, 1, max_zoom, op... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/views/maps/show_kml.kml.builder | Ruby | mit | 45 | master | 3,457 | #this acts as a kml reflector, called from the show as 8978.kml for example
#thanks to Jason Birch messily ported from http://www.jasonbirch.com/wms2kml/wms2kml.phps
bbox = @map.bounds
bounds = bbox.split(',')
west = bounds[0]
south = bounds[1]
east = bounds[2]
north = bounds[3]
width = 256
height = 256
wms_baseurl ... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/views/versions/index.rss.builder | Ruby | mit | 45 | master | 877 | xml.channel do
xml.title @title
xml.description "Feed for recent activity"
xml.link formatted_activity_url
for version in @versions
if version.item_type.downcase == "map"
typename = "Map"
elsif version.item_type.downcase == "gcp"
typename = "Control Point"
end
xml.item do
... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/views/layers/show_kml.kml.builder | Ruby | mit | 45 | master | 3,713 | #this acts as a kml reflector, called from the show as 8978.kml for example
#thanks to Jason Birch messily ported from http://www.jasonbirch.com/wms2kml/wms2kml.phps
bbox = @layer.get_bounds
bounds = bbox.split(',')
west = bounds[0]
south = bounds[1]
east = bounds[2]
north = bounds[3]
width = 256
height = 256
depicts... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/controllers/users_controller.rb | Ruby | mit | 45 | master | 8,039 | class UsersController < ApplicationController
layout 'application'
before_filter :authenticate_user!, :only => [:show, :edit, :update]
before_filter :check_super_user_role, :only => [:index, :destroy, :enable, :disable, :stats, :disable_and_reset, :force_confirm]
skip_before_filter :check_site_read_only,... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/controllers/versions_controller.rb | Ruby | mit | 45 | master | 3,349 | class VersionsController < ApplicationController
layout "application"
before_filter :authenticate_user!, :only => [ :revert_map, :revert_gcp]
skip_before_filter :check_site_read_only, :only => [:show, :index, :for_user, :for_map, :for_map_model]
def show
@version = PaperTrail::Version.find(params[... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/controllers/flags_controller.rb | Ruby | mit | 45 | master | 2,248 | class FlagsController < ApplicationController
layout 'application'
before_filter :authenticate_user!
before_filter :check_administrator_role
rescue_from ActiveRecord::RecordNotFound, :with => :bad_record
helper :sort
include SortHelper
def index
sort_init('updated_at', {:default_order => "d... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/controllers/comments_controller.rb | Ruby | mit | 45 | master | 1,908 | class CommentsController < ApplicationController
before_filter :authenticate_user!
before_filter :check_administrator_role, :only => [:index]
rescue_from ActiveRecord::RecordNotFound, :with => :bad_record
helper :sort
include SortHelper
def index
@html_title = "Browse Comments"
sort_init 'creat... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/controllers/imports_controller.rb | Ruby | mit | 45 | master | 2,872 | class ImportsController < ApplicationController
before_filter :authenticate_user!
before_filter :check_administrator_role
before_filter :find_import, :except => [:index, :new, :create]
before_filter :check_imported, :only => [:start]
rescue_from ActiveRecord::RecordNotFound, :with => :bad_record
helpe... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/controllers/my_maps_controller.rb | Ruby | mit | 45 | master | 1,488 | class MyMapsController < ApplicationController
before_filter :get_user
before_filter :authenticate_user!, :only => [:list, :show, :create, :destroy]
skip_before_filter :check_site_read_only, :only => [:list]
def list
@mymaps = @user.maps.order("updated_at DESC").paginate(:page => params[:page],:per_pag... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/controllers/maps_controller.rb | Ruby | mit | 45 | master | 32,252 | class MapsController < ApplicationController
layout 'mapdetail', :only => [:show, :edit, :preview, :warp, :clip, :align, :activity, :warped, :export, :metadata, :comments]
before_filter :store_location, :only => [:warp, :align, :clip, :export, :edit, :comments ]
before_filter :authenticate_user!, :only => ... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/controllers/layers_controller.rb | Ruby | mit | 45 | master | 22,052 | class LayersController < ApplicationController
layout 'layerdetail', :only => [:show, :edit, :export, :metadata]
before_filter :authenticate_user! , :except => [:wms, :wms2, :show_kml, :show, :index, :metadata, :maps, :thumb, :geosearch, :comments, :tile, :export]
before_filter :check_administrator_role, :only =... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/controllers/digitize_controller.rb | Ruby | mit | 45 | master | 4,745 | class DigitizeController < ApplicationController
#TODO add in other json files instead of static?
def subtype
parent_type = params[:query]
#TODO move this into a db table and do query this way
subtypes = [
{"parentType" => "Residential", "id" => "Apartments", "label" => "Apartments"},
{"pare... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/controllers/gcps_controller.rb | Ruby | mit | 45 | master | 4,837 | class GcpsController < ApplicationController
layout 'application'
#skip_before_filter :verify_authenticity_token, :only => [:update, :update_field, :add, :destroy, :show]
before_filter :authenticate_user!, :only => [:update, :update_field, :add, :destroy]
before_filter :find_gcp, :only => [:show, :update,:upda... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/controllers/home_controller.rb | Ruby | mit | 45 | master | 810 | class HomeController < ApplicationController
layout 'application'
skip_before_filter :check_site_online, :only => [:offline]
skip_before_filter :check_site_read_only
def index
@html_title = "Home - "
@maps = Map.where(:status => 4).order(:updated_at => :desc).limit(3).includes(:gcps)
... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/controllers/omniauth_callbacks_controller.rb | Ruby | mit | 45 | master | 4,009 | class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def failure
set_flash_message :alert, :failure, kind: OmniAuth::Utils.camelize(failed_strategy.name), reason: failure_message
redirect_to after_omniauth_failure_path_for(resource_name)
end
def twitter
@user = User.find_for_twit... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/controllers/application_controller.rb | Ruby | mit | 45 | master | 3,544 | class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
before_filter :check_site_online
before_f... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | app/controllers/admins_controller.rb | Ruby | mit | 45 | master | 924 | class AdminsController < ApplicationController
layout 'application'
before_filter :authenticate_user!
before_filter :check_administrator_role
def index
@html_title = "Admin - "
end
def read_only
@site_setting = Setting.last
if @site_setting.nil?
@site_setting = Setting.new
... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | test/test_helper.rb | Ruby | mit | 45 | master | 498 | ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all
# Add more helper methods to be used by all tests here...
end
module... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | test/controllers/home_controller_test.rb | Ruby | mit | 45 | master | 200 | class HomeControllerTest < ActionController::TestCase
include Devise::TestHelpers
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:maps)
end
end |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | test/controllers/flags_controller_test.rb | Ruby | mit | 45 | master | 1,070 | class FlagsControllerTest < ActionController::TestCase
include Devise::TestHelpers
fixtures :maps, :layers, :roles, :permissions
test "create new flag" do
sign_in users(:adminuser)
map = maps(:map1)
post :create, :flag => { :reason => "error"}, :map_id => map
flag = assigns(:flag)
assert... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | test/controllers/layers_controller_test.rb | Ruby | mit | 45 | master | 1,145 | class LayersControllerTest < ActionController::TestCase
include Devise::TestHelpers
fixtures :layers, :roles, :permissions
test "index all layers" do
get :index
assert_response :success
@layers = assigns(:layers)
assert_not_nil @layers
assert @layers.length == 2
end
test "search ... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | test/controllers/maps_controller_test.rb | Ruby | mit | 45 | master | 3,873 | class MapsControllerTest < ActionController::TestCase
include Devise::TestHelpers
fixtures :maps, :roles, :permissions
def teardown
# File.Utils rm @inset_map.filename
FileUtils.rm Dir.glob('test/data/inset*.tif')
end
test "index all maps" do
get :index
assert_response :success
@maps = ... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | test/models/flag.rb | Ruby | mit | 45 | master | 1,531 | class FlagTest < ActiveSupport::TestCase
def setup
@flag = Flag.new(:reason => :abuse)
@flag.flaggable_id = maps(:map1).id
@flag.flaggable_type = maps(:map1).class
@flag.reporter = users(:user1)
end
test "is valid" do
assert @flag.valid?
end
test "has valid reasons" do
@fl... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | test/models/map.rb | Ruby | mit | 45 | master | 1,770 | require 'test_helper'
class MapTest < ActiveSupport::TestCase
def setup
@map = Map.find(maps(:map1).id)
@inset_map = @map.create_inset
end
def teardown
# File.Utils rm @inset_map.filename
FileUtils.rm Dir.glob('test/data/inset*.tif')
end
test "can create inset maps" do
map = Map.f... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | test/models/version.rb | Ruby | mit | 45 | master | 1,268 | require 'test_helper'
class VersionTest < ActiveSupport::TestCase
PaperTrail.enabled = true
PaperTrail.enabled_for_controller = true
def setup
@map = Map.find(maps(:map1).id)
end
test "changing map title gives new version" do
new_title = "Warped map v2"
old_title = @map.title
... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | test/models/import.rb | Ruby | mit | 45 | master | 4,681 | require 'test_helper'
require 'vcr'
VCR.configure do |config|
config.cassette_library_dir = "fixtures/vcr_cassettes"
config.hook_into :webmock
end
class ImportTest < ActiveSupport::TestCase
def teardown
Import.all.each do | import |
if File.exist? "log/#{import.logfile}"
puts "deleting tes... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | db/schema.rb | Ruby | mit | 45 | master | 10,522 | # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative sou... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | db/migrate/025_add_spatial_bbox_geom_column_to_layers.rb | Ruby | mit | 45 | master | 301 | class AddSpatialBboxGeomColumnToLayers < ActiveRecord::Migration
def self.up
add_column :layers, :bbox_geom, :st_polygon, :srid => 4326
add_index :layers, :bbox_geom, :using => :gist
end
def self.down
remove_column :layers, :bbox_geom
remove_index :layers, :bbox_geom
end
end |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | db/migrate/010_create_permissions.rb | Ruby | mit | 45 | master | 326 | class CreatePermissions < ActiveRecord::Migration
def self.up
create_table :permissions do |t|
t.integer :role_id, :user_id, :null => false
t.timestamps
end
Role.create(:name => 'super user')
end
def self.down
drop_table :permissions
Role.find_by_name('super user').destroy
en... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | db/migrate/016_add_counter_caches_to_layer.rb | Ruby | mit | 45 | master | 739 | class AddCounterCachesToLayer < ActiveRecord::Migration
def self.up
add_column :layers, :mapscans_count, :integer, :default => 0
Layer.reset_column_information
def Layer.readonly_attributes; nil end #evil hack
Layer.all.each do |l|
l.mapscans_count = l.mapscans.count
l.save!
end
... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | db/migrate/20150531170560_create_version_associations.rb | Ruby | mit | 45 | master | 634 | class CreateVersionAssociations < ActiveRecord::Migration
def self.up
create_table :version_associations do |t|
t.integer :version_id
t.string :foreign_key_name, :null => false
t.integer :foreign_key_id
end
add_index :version_associations, [:version_id]
add_index :version_associa... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | db/migrate/013_add_masking_status_field_to_mapscans.rb | Ruby | mit | 45 | master | 202 | class AddMaskingStatusFieldToMapscans < ActiveRecord::Migration
def self.up
add_column :mapscans, :mask_status, :integer
end
def self.down
remove_column :mapscans, :mask_status
end
end |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | db/migrate/001_create_mapscans.rb | Ruby | mit | 45 | master | 312 | class CreateMapscans < ActiveRecord::Migration
def self.up
create_table :mapscans do |t|
t.string :title
t.text :description
t.string :filename
t.datetime :created_at
t.datetime :updated_at
t.timestamps
end
end
def self.down
drop_table :mapscans
end
end |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | db/migrate/005_change_mapscan_id_column_in_gcp.rb | Ruby | mit | 45 | master | 202 | class ChangeMapscanIdColumnInGcp < ActiveRecord::Migration
def self.up
rename_column "gcps", "map_id", "mapscan_id"
end
def self.down
rename_column "gcps", "mapscan_id", "map_id"
end
end |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | db/migrate/011_add_editor_and_administrator_role.rb | Ruby | mit | 45 | master | 276 | class AddEditorAndAdministratorRole < ActiveRecord::Migration
def self.up
Role.create(:name => 'editor')
Role.create(:name => 'administrator')
end
def self.down
Role.find_by_name('administrator').destroy
Role.find_by_name('editor').destroy
end
end |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | db/migrate/002_add_image_attachment_to_mapscan.rb | Ruby | mit | 45 | master | 595 | class AddImageAttachmentToMapscan < ActiveRecord::Migration
def self.up
add_column :mapscans, :content_type, :string
#already has filename
add_column :mapscans, :thumbnail, :string
add_column :mapscans, :size, :integer
add_column :mapscans, :width, :integer
add_column :... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | db/migrate/019_change_depicts_year_to_char.rb | Ruby | mit | 45 | master | 952 | class ChangeDepictsYearToChar < ActiveRecord::Migration
def self.up
remove_column :layers, :depicts_year
add_column :layers, :depicts_year, :string, :limit => 4, :default => ""
# note, these lines are PostgreSQL specific
# first, look in the layer title to regexp match the last year mentioned
exec... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | db/migrate/031_rename_mapscans_to_maps.rb | Ruby | mit | 45 | master | 868 | class RenameMapscansToMaps < ActiveRecord::Migration
def self.up
rename_table :mapscans, :maps
rename_table :mapscan_layers, :map_layers
rename_column :map_layers, :mapscan_id, :map_id
rename_column :gcps, :mapscan_id, :map_id
rename_column :layers, :mapscans_count, :maps_count
r... |
github | nypl-spacetime/nypl-warper | https://github.com/nypl-spacetime/nypl-warper | db/migrate/20160512195825_add_rectify_to_maps.rb | Ruby | mit | 45 | master | 212 | class AddRectifyToMaps < ActiveRecord::Migration
def change
add_column :maps, :transform_options, :string, :default => "auto"
add_column :maps, :resample_options, :string, :default => "cubic"
end
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.