summaryrefslogtreecommitdiff
path: root/core/lib
diff options
context:
space:
mode:
Diffstat (limited to 'core/lib')
-rw-r--r--core/lib/extensions/couchrest.rb95
-rw-r--r--core/lib/extensions/testing.rb48
-rw-r--r--core/lib/leap_web_core.rb14
-rw-r--r--core/lib/leap_web_core/dependencies.rb40
-rw-r--r--core/lib/leap_web_core/engine.rb9
-rw-r--r--core/lib/leap_web_core/ui_dependencies.rb11
-rw-r--r--core/lib/tasks/leap_web_core_tasks.rake25
7 files changed, 0 insertions, 242 deletions
diff --git a/core/lib/extensions/couchrest.rb b/core/lib/extensions/couchrest.rb
deleted file mode 100644
index a9a195e..0000000
--- a/core/lib/extensions/couchrest.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-module CouchRest
- module Model
- module Designs
-
- class View
-
- # so we can called Ticket.method.descending or Ticket.method.ascending
- def ascending
- self
- end
- end
-
- class DesignMapper
- def load_views(dir)
- Dir.glob("#{dir}/*.js") do |js|
- name = File.basename(js, '.js')
- file = File.open(js, 'r')
- view name.to_sym,
- :map => file.read,
- :reduce => "function(key, values, rereduce) { return sum(values); }"
- end
- end
- end
- end
-
- module Connection
-
- module ClassMethods
-
- def use_database(db)
- @database = prepare_database(db)
- rescue RestClient::Exception,
- Errno::EHOSTUNREACH,
- Errno::ECONNREFUSED => e
- message = "Could not connect to couch database #{db} due to #{e.to_s}"
- Rails.logger.warn message
- raise e.class.new(message) if APP_CONFIG[:reraise_errors]
- end
- end
-
- end
-
- module Utils
- module Migrate
- def self.load_all_models_with_engines
- self.load_all_models_without_engines
- return unless defined?(Rails)
- Dir[Rails.root + '*/app/models/**/*.rb'].each do |path|
- require path
- end
- end
-
- class << self
- alias_method_chain :load_all_models, :engines
- end
-
- def dump_all_models
- prepare_directory
- find_models.each do |model|
- model.design_docs.each do |design|
- dump_design(model, design)
- end
- end
- end
-
- protected
-
- def dump_design(model, design)
- dir = prepare_directory model.name.tableize
- filename = design.id.sub('_design/','') + '.json'
- puts dir + filename
- design.checksum
- File.open(dir + filename, "w") do |file|
- file.write(JSON.pretty_generate(design.to_hash))
- end
- end
-
- def prepare_directory(dir = '')
- dir = Rails.root + 'tmp' + 'designs' + dir
- Dir.mkdir(dir) unless Dir.exists?(dir)
- return dir
- end
-
- end
- end
-
- end
-
- class ModelRailtie
- config.action_dispatch.rescue_responses.merge!(
- 'CouchRest::Model::DocumentNotFound' => :not_found,
- 'RestClient::ResourceNotFound' => :not_found
- )
- end
-end
diff --git a/core/lib/extensions/testing.rb b/core/lib/extensions/testing.rb
deleted file mode 100644
index 8f7e73c..0000000
--- a/core/lib/extensions/testing.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-module LeapWebCore
- module AssertResponses
-
- # response that works with different TestCases:
- # ActionController::TestCase has @response
- # ActionDispatch::IntegrationTest has @response
- # Rack::Test::Methods defines last_response
- def get_response
- @response || last_response
- end
-
- def assert_attachement_filename(name)
- assert_equal %Q(attachment; filename="#{name}"),
- get_response.headers["Content-Disposition"]
- end
-
- def json_response
- response = JSON.parse(get_response.body)
- response.respond_to?(:with_indifferent_access) ?
- response.with_indifferent_access :
- response
- end
-
- def assert_json_response(object)
- assert_equal 'application/json',
- get_response.content_type.to_s.split(';').first
- if object.is_a? Hash
- object.stringify_keys! if object.respond_to? :stringify_keys!
- assert_equal object, json_response
- else
- assert_equal object.to_json, get_response.body
- end
- end
-
- def assert_json_error(object)
- object.stringify_keys! if object.respond_to? :stringify_keys!
- assert_json_response :errors => object
- end
- end
-end
-
-class ::ActionController::TestCase
- include LeapWebCore::AssertResponses
-end
-
-class ::ActionDispatch::IntegrationTest
- include LeapWebCore::AssertResponses
-end
diff --git a/core/lib/leap_web_core.rb b/core/lib/leap_web_core.rb
deleted file mode 100644
index a58d140..0000000
--- a/core/lib/leap_web_core.rb
+++ /dev/null
@@ -1,14 +0,0 @@
-require "rails"
-
-require "couchrest"
-require "couchrest_model"
-require "couchrest_session_store"
-
-require "json"
-
-require "extensions/testing"
-require "extensions/couchrest"
-require "leap_web_core/engine"
-
-module LeapWebCore
-end
diff --git a/core/lib/leap_web_core/dependencies.rb b/core/lib/leap_web_core/dependencies.rb
deleted file mode 100644
index 877e3d1..0000000
--- a/core/lib/leap_web_core/dependencies.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-module LeapWebCore
- class Dependencies
- UI_DEV = {
- "haml-rails" => "~> 0.3.4",
- "sass-rails" => "~> 3.2.5",
- "coffee-rails" => "~> 3.2.2",
- "uglifier" => "~> 1.2.7"
- }
-
- UI = {
- "haml" => "~> 3.1.7",
- "jquery-rails" => nil,
- "simple_form" => nil,
- "bootswatch-rails", "~> 0.5.0"
- }
-
- def self.require_ui_gems
- UI.keys.each {|dep| require dep}
- if Rails.env == "development"
- # This will be run in the app including plugins that run it.
- # However not all development_dependencies might be present.
- # So we better only require those that are.
- available = Bundler.definition.specs.map(&:name)
- gems_to_require = available & UI_DEV.keys
- gems_to_require.each {|dep| require dep}
- end
- end
-
- def self.add_ui_gems_to_spec(spec)
- UI.each do |dep, version|
- spec.add_dependency dep, version
- end
-
- UI_DEV.each do |dep, version|
- spec.add_development_dependency dep, version
- end
- end
-
- end
-end
diff --git a/core/lib/leap_web_core/engine.rb b/core/lib/leap_web_core/engine.rb
deleted file mode 100644
index 940b5e2..0000000
--- a/core/lib/leap_web_core/engine.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-# thou shall require all your dependencies in an engine.
-require "couchrest"
-require "couchrest_model"
-
-module LeapWebCore
- class Engine < ::Rails::Engine
-
- end
-end
diff --git a/core/lib/leap_web_core/ui_dependencies.rb b/core/lib/leap_web_core/ui_dependencies.rb
deleted file mode 100644
index 2daee37..0000000
--- a/core/lib/leap_web_core/ui_dependencies.rb
+++ /dev/null
@@ -1,11 +0,0 @@
-require "haml"
-require "jquery-rails"
-require "simple_form"
-require "bootswatch-rails"
-
-if Rails.env == "development"
- require "haml-rails"
- require "sass-rails"
- require "coffee-rails"
- require "uglifier"
-end
diff --git a/core/lib/tasks/leap_web_core_tasks.rake b/core/lib/tasks/leap_web_core_tasks.rake
deleted file mode 100644
index ec6abac..0000000
--- a/core/lib/tasks/leap_web_core_tasks.rake
+++ /dev/null
@@ -1,25 +0,0 @@
-namespace :couchrest do
-
- desc "Dump all the design docs found in each model"
- task :dump => :environment do
- CouchRest::Model::Utils::Migrate.load_all_models
- CouchRest::Model::Utils::Migrate.dump_all_models
- end
-end
-
-namespace :cleanup do
-
- desc "Cleanup all expired session documents"
- task :sessions => :environment do
- # make sure this is the same as in
- # config/initializers/session_store.rb
- store = CouchRest::Session::Store.new expire_after: 1800
- store.cleanup(store.expired)
- end
-
- desc "Cleanup all expired tokens"
- task :tokens => :environment do
- Token.destroy_all_expired
- end
-end
-