Skip to content

Instantly share code, notes, and snippets.

View nomasprime's full-sized avatar

Rick Jones nomasprime

View GitHub Profile
class AdminBound < ActiveRecord::Base
scope :sites, -> {
where(arel_table[:iso].eq('BRA').and(Arel::Nodes::NamedFunction.new('st_contains', [arel_table[:geom], Site.arel_table[:lonlat]]))).project(Site.arel_table[Arel.star])
}
end
class CreateAdminBoundsSchema < ActiveRecord::Migration
def change
reversible do |dir|
dir.up do
execute <<-SQL
CREATE SCHEMA IF NOT EXISTS admin_bounds;
CREATE EXTENSION IF NOT EXISTS postgis SCHEMA admin_bounds;
CREATE EXTENSION IF NOT EXISTS hstore SCHEMA admin_bounds;
SQL
end
require 'spec_helper'
module AdminBounds
describe Osmosis do
context 'when pbf file does not exist' do
subject(:osmosis) { Osmosis.new('no.osm.pbf') }
it 'raises runtime error' do
expect { osmosis.import_administrative_boundaries }.to raise_error(RuntimeError)
end
module AdminBounds
describe Osmosis do
context 'when pbf file does not exist' do
subject(:osmosis) { Osmosis.new('no.osm.pbf') }
before { osmosis.import_administrative_boundaries }
it { is_expected.to raise_error(RuntimeError) }
end
end
end
require 'rails/generators/active_record'
module ActiveRecord
module Generators
class AdminBoundsGenerator < ActiveRecord::Generators::Base
source_root File.expand_path('../templates', __FILE__)
puts 'here'
puts behavior
def copy_migration
migration_template 'migration.rb', "db/migrate/admin_bounds_create_#{table_name}.rb"
module Cucumber
module Ast
class TreeWalker
alias_method :visit_features_alias, :visit_features
def visit_features(features)
EM.synchrony do
visit_features_alias features
EM.stop
end
class Application < Rails::Application
config.middleware.insert_after ActionDispatch::Session::CookieStore,
FayeRails::Middleware,
extensions: [Faye::Extensions::AuthenticationExtension.new],
engine: { type: Faye::Redis, host: 'localhost' },
mount: '/rt',
timeout: 25 do
map '/runbook/**' => RealtimeController
end
...
require 'rails/generators/active_record'
module ActiveRecord
module Generators
class AdminBoundsGenerator < ActiveRecord::Generators::Base
source_root File.expand_path('../templates', __FILE__)
def copy_migration
migration_template 'migration.rb', "db/migrate/admin_bounds_create_#{table_name}.rb"
binding.pry
class Survey < ActiveRecord::Base
acts_as_paranoid
include Importable
###### Associations ########
belongs_to :project
belongs_to :publication, counter_cache: true
belongs_to :site
belongs_to :location_type, :class_name => ListItem, :foreign_key => "location_type_id"
belongs_to :study_design, :class_name => ListItem, :foreign_key => "study_design_id"
@nomasprime
nomasprime / error
Last active September 14, 2015 16:47
/Users/rick/Organisations/playtimestudios/admin_bounds/spec/lib/install_generator_spec.rb:1:in `<top (required)>': uninitialized constant InstallGenerator (NameError)
from /Users/rick/Organisations/playtimestudios/admin_bounds/vendor/bundle/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `load'
from /Users/rick/Organisations/playtimestudios/admin_bounds/vendor/bundle/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1327:in `block in load_spec_files'
from /Users/rick/Organisations/playtimestudios/admin_bounds/vendor/bundle/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `each'
from /Users/rick/Organisations/playtimestudios/admin_bounds/vendor/bundle/gems/rspec-core-3.3.2/lib/rspec/core/configuration.rb:1325:in `load_spec_files'
from /Users/rick/Organisations/playtimestudios/admin_bounds/vendor/bundle/gems/rspec-core-3.3.2/lib/rspec/core/runner.rb:102:in `setup'
from /Users/rick/Organisations/playtimestudios/admin_bounds/vendor/bundle/gems/rspec-core-3.3.2/lib/rspec/core/r