code
stringlengths
1
1.73M
language
stringclasses
1 value
VestalVersions.configure do |config| # Place any global options here. For example, in order to specify your own version model to use # throughout the application, simply specify: # # config.class_name = "MyCustomVersion" # # Any options passed to the "versioned" method in the model itself will override this...
Ruby
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attac...
Ruby
# 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_alias "text/html", :iphone
Ruby
# Be sure to restart your server when you modify this file. Marketplace::Application.config.session_store :cookie_store, :key => '_Marketplace_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table wi...
Ruby
Marketplace::Application.routes.draw do root :to => "apps#index" resources :apps do collection do post 'exists', 'ids' end resources :visuals do collection do post 'exists' end end end resources :app_targets do collection do post 'exists' end end ...
Ruby
require 'rubygems' # Set up gems listed in the Gemfile. gemfile = File.expand_path('../../Gemfile', __FILE__) begin ENV['BUNDLE_GEMFILE'] = gemfile require 'bundler' Bundler.setup rescue Bundler::GemNotFound => e STDERR.puts e.message STDERR.puts "Try running `bundle install`." exit! end if File.exist?(gem...
Ruby
require File.expand_path('../boot', __FILE__) require 'rails/all' # If you have a Gemfile, require the gems listed there, including any gems # you've limited to :test, :development, or :production. Bundler.require(:default, Rails.env) if defined?(Bundler) module Marketplace class Application < Rails::Application ...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Marketplace::Application.initialize!
Ruby
Marketplace::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turne...
Ruby
Marketplace::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 w...
Ruby
Marketplace::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 t...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Marketplace::Application
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) require 'rake' Marketplace::Application.load_tasks
Ruby
require 'rubygems' require 'pushmeup' APNS.host = 'gateway.sandbox.push.apple.com' APNS.port = 2195 APNS.pem = '</path/to/my/certificate/ck.pem>' APNS.pass = '<myCertificatePassword>' device_token = '<device token gleaned from xcode console>' # APNS.send_notification(device_token, 'Hello iPhone!' ) APN...
Ruby
require 'rubygems' require 'pushmeup' GCM.host = 'https://android.googleapis.com/gcm/send' GCM.format = :json GCM.key = "API_KEY_GOES_HERE" destination = ["REGISTRATION_ID_GOES_HERE"] data = {:message => "PhoneGap Build rocks!", :msgcnt => "1", :soundname => "beep.wav"} GCM.send_notification( destination, data...
Ruby
require 'mkmf' $CPPFLAGS = $CPPFLAGS + " -I../../include" $LDFLAGS = $LDFLAGS + " -L../../" $LIBS = $LIBS + " -lhpdf -lpng -lz" create_makefile 'hpdf'
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- demo.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appea...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- encryption.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- font_example.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright noti...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- arc_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear ...
Ruby
# # << Haru Free PDF Library 2.0.6 >> -- ext_gstate_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice ...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- ttfont_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appe...
Ruby
# # << Haru Free PDF Library 2.0.0 >> -- text_demo2.rb # # Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice...
Ruby
# # << Haru Free PDF Library 2.0.2 >> -- line_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice appear...
Ruby
# # << Haru Free PDF Library 2.0.6 >> -- slideshow_demo.rb # # http://libharu.org/ # # Copyright (c) 1999-2006 Takeshi Kanno # # Permission to use, copy, modify, distribute and sell this software # and its documentation for any purpose is hereby granted without fee, # provided that the above copyright notice a...
Ruby
<embed src="chat_queue.swf" width="1" height="1" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash">
Ruby
class CreateUsers < ActiveRecord::Migration def up create_table :users do |t| t.string :profile_id t.string :email t.string :refresh_token end add_index :users, :profile_id end def down drop_table :users end end
Ruby
# Copyright (C) 2012 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'sinatra-activerecord' gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client' group :development do gem 'rake' gem 'sqlite3-ruby' end
Ruby
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
require 'sinatra/activerecord/rake' require './main'
Ruby
watch("src/.*\.coffee") { |file| system "cake build" }
Ruby
class CreateTeachers < ActiveRecord::Migration def change create_table :teachers do |t| t.string :name t.text :cv t.text :publications t.string :photo t.text :bio t.integer :level t.references :courses, index: true t.references :activities, index: true t.time...
Ruby
class CreateActivities < ActiveRecord::Migration def change create_table :activities do |t| t.string :name t.date :date t.string :description t.integer :structure_id t.integer :teacher_id t.timestamps end end end
Ruby
class CreateRooms < ActiveRecord::Migration def change create_table :rooms do |t| t.string :name t.string :building t.text :howtogethere t.references :courses, index: true end end end
Ruby
class CreateCourses < ActiveRecord::Migration def change create_table :courses do |t| t.string :name t.integer :cfu t.integer :year t.text :books t.text :exams t.text :program t.text :description t.integer :teacher_id end end end
Ruby
class CreateStructures < ActiveRecord::Migration def change create_table :structures do |t| t.string :name t.text :info t.text :schedule t.text :howtoreach t.string :photo t.references :activities, index: true t.timestamps end end end
Ruby
class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :username t.string :password t.timestamps end end end
Ruby
class CreateSchedules < ActiveRecord::Migration def change create_table :schedules do |t| t.belongs_to :course t.belongs_to :room t.string :slot t.string :day t.timestamps end end end
Ruby
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) Blog::Application.load_tasks
Ruby
source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.1.0' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.0' gem 'bootstrap-sass', '~> 3.1.1' group :doc do # bundle exec rake doc:rails gener...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Rails.application
Ruby
class Room < ActiveRecord::Base validates :name, presence: true validates :building, presence: true validates :howtogethere, presence: true has_many :schedules has_many :rooms, :through => :schedules def to_s name end end
Ruby
class Structure < ActiveRecord::Base validates :name, presence: true validates :info, presence: true validates :schedule, presence: true validates :howtoreach, presence: true has_many :activities def to_s name end end
Ruby
class Course < ActiveRecord::Base validates :name, presence: true validates :cfu, presence: true validates :year, presence: true validates :books, presence: true validates :exams, presence: true validates :program, presence: true validates :description, presence: true belongs_to :teacher has_many :s...
Ruby
class Schedule < ActiveRecord::Base validates :slot, presence: true validates :day, presence: true belongs_to :room belongs_to :course end
Ruby
class Activity < ActiveRecord::Base validates :name, presence: true validates :date, presence: true validates :description, presence: true belongs_to :structure belongs_to :teacher def to_s name end end
Ruby
class Teacher < ActiveRecord::Base validates :name, presence: true validates :cv, presence: true validates :publications, presence:true validates :bio, presence:true validates :photo, presence:true has_many :courses has_many :activities def to_s name end end
Ruby
class User < ActiveRecord::Base end
Ruby
class ActivitiesController < ApplicationController def new @activity = Activity.new end def select_structure @activity = Activity.find(params[:id]) redirect_to add_structure_activity_path(@activity) end def select_teacher @activity = Activity.find(params[:id]) redirect_to add_teacher_ac...
Ruby
class StructuresController < ApplicationController def new @structure = Structure.new end def create @structure = Structure.new(structure_params) @user = User.find_by_username(params[:user][:username]) @psw = Digest::MD5.hexdigest(params[:user][:password]) if @user != nil && @user.password ...
Ruby
class SchedulesController < ApplicationController def create @schedule = Schedule.new(:course_id => params[:course][:id], :room_id => params[:room][:id], :slot => params[:slot], :day => params[:day]) @user = User.find_by_username(params[:user][:username]) @psw = Digest::MD5.hexdigest(params[:user][:pass...
Ruby
class TeachersController < ApplicationController def create @teacher = Teacher.new(teacher_params) @user = User.find_by_username(params[:user][:username]) @psw = Digest::MD5.hexdigest(params[:user][:password]) if @user != nil && @user.password == @psw if @teacher.save redirect_to @tea...
Ruby
class RoomsController < ApplicationController def index @rooms = Room.order(name: :asc).all end def new @room = Room.new end def create @room = Room.new(room_params) @user = User.find_by_username(params[:user][:username]) @psw = Digest::MD5.hexdigest(params[:user][:password]) if @user != nil && @us...
Ruby
class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. end
Ruby
class CoursesController < ApplicationController def index @courses = Course.order(year: :desc).all end def select @course = Course.find(params[:id]) redirect_to edit_course_path(@course) end def new @course = Course.new end def edit @course = Course.find(params[:id]) @teachers ...
Ruby
class PagesController < ApplicationController def school render "school_"+params[:name] end def admission render "admission_"+params[:name] end def special_support render "special_support_"+params[:name] end end
Ruby
ENV["RAILS_ENV"] ||= "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase ActiveRecord::Migration.check_pending! # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. # # Note: You'll currently still have to de...
Ruby
Blog::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 thread web servers...
Ruby
Blog::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...
Ruby
Blog::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...
Ruby
Blog::Application.routes.draw do root 'pages#index' resources :teachers, :only => [:new, :create, :show, :index] do member do get 'show_gallery' get 'cv' get 'publications' get 'courses' => 'teachers#course_index' get 'activities' => 'teachers#activity_index' end end re...
Ruby
# Be sure to restart your server when you modify this file. Blog::Application.config.session_store :cookie_store, key: '_blog_session'
Ruby
# Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters f...
Ruby
# Be sure to restart your server when you modify this file. # Your secret key is used for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to diction...
Ruby
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a probl...
Ruby
# Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [:password]
Ruby
# 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_alias "text/html", :iphone
Ruby
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflec...
Ruby
# Load the Rails application. require File.expand_path('../application', __FILE__) # Initialize the Rails application. Blog::Application.initialize!
Ruby
# Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
Ruby
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(:default, Rails.env) module Blog class Application < Rails::Application end end
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
#!/usr/bin/env ruby require 'rubygems' entrada = IO.new(0,'r') contador=0 endereco_num = 0 endereco_comeca = '0000' codigo_linha = '' soma = 0 entrada.each do |linha| if linha.match(/([01]{8})([01]{8})\s+([01]{8})([01]{8})/) addr_m = $1.to_i(2) addr_l = $2.to_i(2) code_m = $3.to_i(2) code_l = $4.to...
Ruby
# -*- coding: utf-8 -*- # Constantes de pseudo instruções NOP = /NOP/ LIW_cons = /LIW\s+\$(\d{1,2}),\s*(%\w+%)/ LIW_imm = /LIW\s+\$(\d{1,2}),\s*(\d+)/ nomeArquivo = ARGV[0] entrada = File.new(nomeArquivo+".asm",'r') arquivoIndexado = [] nLinha = 0 entrada.each do |linha| nLinha = nLinha+1 linha2 ='' linha.su...
Ruby
#!/usr/bin/env ruby require 'rubygems' require "serialport" sp = SerialPort.new "/dev/ttyS0", 9600 entrada = IO.new(0,'r') contador=0 endereco_num = 0 endereco_comeca = '0000' codigo_linha = '' soma = 0 entrada.each do |linha| if linha.match(/([01]{8})([01]{8})\s+([01]{8})([01]{8})/) addr_m = $1.to_i(2) ad...
Ruby
class CreateUsers < ActiveRecord::Migration def up create_table :users do |t| t.string :profile_id t.string :email t.string :refresh_token end add_index :users, :profile_id end def down drop_table :users end end
Ruby
# Copyright (C) 2012 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'sinatra-activerecord' gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client' group :development do gem 'rake' gem 'sqlite3-ruby' end
Ruby
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
require 'sinatra/activerecord/rake' require './main'
Ruby
#!/usr/bin/ruby1.8 -w # # Copyright:: Copyright 2009 Google Inc. # Original Author:: Ryan Brown (mailto:ribrdb@google.com) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www....
Ruby
require 'rubygems' unless ENV['NO_RUBYGEMS'] require 'rake/gempackagetask' require 'rubygems/specification' require 'date' require 'spec/rake/spectask' require 'yaml' require File.join(File.dirname(__FILE__), 'google_appengine.rb') spec = Gem::Specification.new do |s| s.name = "google-appengine" s.version = AppEn...
Ruby
#!/usr/bin/ruby # Copyright:: Copyright 2009 Google Inc. # Original Author:: Ryan Brown (mailto:ribrdb@google.com) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.o...
Ruby
require 'rubygems' unless ENV['NO_RUBYGEMS'] require 'rubygems/builder' require 'rubygems/specification' require 'date' require 'erb' require 'fileutils' module AppEngine module SDK end end def find_version unless defined? AppEngine::SDK::VERSION re = /^appengine-java-sdk-(\d+[.]\d+[.]\d+([.]\w+)?).+zip$/ ...
Ruby
require 'rubygems' unless ENV['NO_RUBYGEMS'] require 'rake/gempackagetask' require 'rubygems/specification' require 'date' require 'spec/rake/spectask' require 'fileutils' BOOT_JAR = "appengine-rack.jar" SUMMARY = <<EOF Commom dependencies for configuring an App Engine application via Rack. EOF spec = Gem::Specifica...
Ruby
#!/usr/bin/ruby1.8 -w # # Copyright:: Copyright 2009 Google Inc. # Original Author:: Ryan Brown (mailto:ribrdb@google.com) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www....
Ruby
#!/usr/bin/ruby1.8 -w # # Copyright:: Copyright 2010 Google Inc. # Original Author:: John Woodell (mailto:woodie@google.com) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://ww...
Ruby
# Critical default settings: disable_system_gems disable_rubygems bundle_path '.gems/bundler_gems' # List gems to bundle here: gem 'rails', '3.0.pre', :git => 'git://github.com/rails/rails.git', :ref => '1b27f5c4f72384081083fa025b6b10e5ab02ae5e' gem "rack", '1.0.1', :git => 'git://github.com/rack/rack.gi...
Ruby
class Rails::InfoController < ActionController::Base def properties info = [['Ruby version', "#{RUBY_VERSION} (#{RUBY_PLATFORM})"]] if defined? Gem::RubyGemsVersion info << ['RubyGems version', Gem::RubyGemsVersion] else info << ['RubyGems','disabled'] end info << ['Rack version', Rack...
Ruby
#!/usr/bin/ruby # # Copyright:: Copyright 2009 Google Inc. # Original Author:: John Woodell (mailto:woodie@google.com) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apac...
Ruby
# Set our own default Notifier module ActiveSupport::Notifications self.notifier = Notifier.new(Fanout.new(true)) end
Ruby
# replace this file with the following require 'fileutils' FileUtils = FileUtils::NoWrite if ENV['RAILS_ENV'].eql? 'production' # $LOAD_PATH << 'lib' require 'rails' #require "rails/core" # EXCLUDE: active_record action_mailer active_resource #%w(active_model action_controller action_view).each do |framework| # begi...
Ruby
disable_system_gems disable_rubygems bundle_path ".gems/bundler_gems" clear_sources #source 'http://gems.github.com' #source 'http://rc-gems.appspot.com' source 'http://gemcutter.org' gem "sinatra" gem "json" gem "dm-core" gem "dm-appengine" #gem "dm-validations" gem "dm-timestamps" gem "dm-serializer" gem "dm-ar-fin...
Ruby
class Counter include DataMapper::Resource property :id, Serial property :name, String property :sequence, Integer, :default => 0 def self.get_sequence(name) counter = find_or_create(:name => name) counter.sequence +=1 counter.save counter.sequence end end
Ruby
class ChatUser USER_CHAT_TIMEOUT = 60 include DataMapper::Resource property :id, Serial property :username, String, :length => 32 property :ip_address, String, :length => 15 #15 chars for xxx.xxx.xxx.xxx for ip4 property :created_at, DateTime property :updated_at, DateTime property :last_seen_at, Date...
Ruby
class Chat include DataMapper::Resource property :id, Serial property :entity_type, String property :entity_id, Integer property :created_at, DateTime property :updated_at, DateTime has n, :messages has n, :chat_users end
Ruby
class Message include DataMapper::Resource property :id, Serial property :text, String, :length => 256 property :created_at, DateTime property :updated_at, DateTime property :sequence, Integer property :chat_id, Integer property :chat_user_id, Integer belongs_to :chat belongs_to :chat_user de...
Ruby