# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
-gem 'pg'
+gem 'sqlite3'
# Gems used only for assets and not required
fastthread (>= 1.0.1)
rack
rake (>= 0.8.1)
- pg (0.14.1)
polyglot (0.3.3)
rack (1.4.4)
rack-cache (1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.7)
therubyracer (0.11.2)
libv8 (~> 3.11.8.12)
ref
coffee-rails (~> 3.2.1)
jquery-rails
passenger
- pg
rails (= 3.2.11)
rvm-capistrano
sass-rails (~> 3.2.3)
+ sqlite3
therubyracer
uglifier (>= 1.0.3)
--- /dev/null
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
--- /dev/null
+// Place all the styles related to the Collections controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
--- /dev/null
+class CollectionsController < ApplicationController
+end
--- /dev/null
+module CollectionsHelper
+end
--- /dev/null
+class Collection < OrvosBase
+end
--- /dev/null
+class OrvosBase < ActiveRecord::Base
+ @@orvos_v1_base = Rails.configuration.orvos_v1_base
+ def self.columns
+ return @columns unless @columns.nil?
+ @columns = []
+ return @columns if orvos_schema[self.to_s.to_sym].nil?
+ orvos_schema[self.to_s.to_sym].each do |coldef|
+ k = coldef[:name].to_sym
+ if coldef[:type] == coldef[:type].downcase
+ @columns << column(k, coldef[:type].to_sym)
+ else
+ @columns << column(k, :text)
+ serialize k, coldef[:type].to_sym
+ end
+ attr_accessible k
+ end
+ attr_reader :etag
+ attr_reader :kind
+ @columns
+ end
+ def self.column(name, sql_type = nil, default = nil, null = true)
+ ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
+ end
+ def self.all
+ thelist = api('')
+ thelist[:items].collect { |x| new(x) }
+ end
+ def self.find(uuid)
+ new(api('/' + uuid))
+ end
+ def save
+ self.class.api('/' + uuid, {
+ '_method' => 'PUT',
+ self.class.to_s.underscore => { :name => self.name }
+ })
+ end
+ def initialize(h={})
+ @etag = h.delete :etag
+ @kind = h.delete :kind
+ super
+ end
+
+ protected
+ def self.api(action, data=nil, o={})
+ dataargs = []
+ if !data.nil?
+ data.each do |k,v|
+ dataargs << '-d'
+ if v.is_a? String
+ dataargs << "#{k}=#{v}"
+ else
+ dataargs << "#{k}=#{JSON.generate v}"
+ end
+ end
+ end
+ json = nil
+ IO.popen([ENV,
+ 'curl',
+ '-sk',
+ *dataargs,
+ "#{@@orvos_v1_base}/#{o[:resource_path] || self.to_s.underscore.pluralize}#{action}"],
+ 'r') do |io|
+ json = io.read
+ end
+ JSON.parse json, :symbolize_names => true
+ end
+
+ def self.orvos_schema
+ $orvos_schema ||= api '', nil, {resource_path: 'schema'}
+ end
+end
# Expands the lines which load the assets
config.assets.debug = true
+
+ config.orvos_v1_base = 'https://orvos/orvos/v1'
end
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
# config.active_record.auto_explain_threshold_in_seconds = 0.5
+
+ config.orvos_v1_base = 'https://9ujm1.orvosapi.com/orvos/v1'
end
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
+
+ config.orvos_v1_base = 'https://orvos/orvos/v1'
end
Vcffarm::Application.routes.draw do
+ resources :collections
+
+
# The priority is based upon order of creation:
# first created -> highest priority.
--- /dev/null
+# 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 source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended to check this file into your version control system.
+
+ActiveRecord::Schema.define(:version => 0) do
+
+end
--- /dev/null
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
--- /dev/null
+require 'test_helper'
+
+class CollectionsControllerTest < ActionController::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
--- /dev/null
+require 'test_helper'
+
+class CollectionTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
--- /dev/null
+require 'test_helper'
+
+class CollectionsHelperTest < ActionView::TestCase
+end