code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Handle Documents
class DocumentsController < ApplicationController
include ApplicationHelper
access_control :acl do
allow :superuser, :admin, :analyst
end
layout 'dashboard'
def edit
@do... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2011
# License:: Apache 2.0
# Controller for showing a dashboard consisting of BizProcess -> System -> Control
# tree.
class DashboardController < ApplicationController
include ApplicationHelper
layout 'application'
access_contro... | Ruby |
class Admin::ProgramsController < ApplicationController
layout "admin"
# Slug for AJAX
def slug
respond_to do |format|
format.js { render :json => [Program.find(params[:id]).slug] }
end
end
# List Programs
def index
@programs = Program.all
respond_to do |format|
format.html
... | Ruby |
class Admin::AccountsController < ApplicationController
layout "admin"
access_control :acl do
allow :superuser
end
# List accounts
def index
@accounts = Account.all
respond_to do |format|
format.html
format.xml { render :xml => @accounts }
end
end
# Show one account
def ... | Ruby |
class Admin::BizProcessesController < ApplicationController
layout "admin"
include Admin::BizProcessesHelper
include ManyHelper
include AutofilterHelper
# List all biz processes
def index
@biz_processes = BizProcess.all
respond_to do |format|
format.html # index.html.erb
format.xml { ... | Ruby |
class Admin::SystemsController < ApplicationController
layout "admin"
include ManyHelper
# List Systems
def index
@systems = System.order(:slug)
respond_to do |format|
format.html
format.xml { render :xml => @systems }
end
end
# Show a system
def show
@system = System.find(... | Ruby |
class Admin::BusinessAreasController < ApplicationController
layout "admin"
# List of biz areas
def index
@business_areas = BusinessArea.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @business_areas }
end
end
# Show a biz area
def show
@b... | Ruby |
class Admin::DocumentsController < ApplicationController
layout "admin"
# List documents
def index
@documents = Document.where({})
respond_to do |format|
format.html
format.xml { render :xml => @documents }
end
end
# Show a doc
def show
@document = Document.find(params[:id])
... | Ruby |
class Admin::BaseController < ApplicationController
layout "admin"
def index
end
end
| Ruby |
class Admin::PeopleController < ApplicationController
layout "admin"
# List People
def index
@people = Person.where({})
respond_to do |format|
format.html
format.xml { render :xml => @people }
end
end
# Show a person
def show
@person = Person.find(params[:id])
respond_to... | Ruby |
class Admin::CyclesController < ApplicationController
layout "admin"
# List cycles
def index
@cycles = Cycle.order([:program_id, :start_at])
respond_to do |format|
format.html
format.xml { render :xml => @cycles }
end
end
# Show a doc
def show
@cycle = Cycle.find(params[:id])... | Ruby |
class Admin::SectionsController < ApplicationController
layout "admin"
include ManyHelper
include AutofilterHelper
# List (possibly filtered) Control Objectives
def index
@sections = filtered_sections
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @sect... | Ruby |
class Admin::ControlsController < ApplicationController
layout "admin"
include ManyHelper
include AutofilterHelper
# List Controls
def index
@controls = filtered_controls
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @controls }
end
end
# Show... | Ruby |
class Admin::DocumentDescriptorsController < ApplicationController
layout "admin"
# List Document Descriptors
def index
@document_descriptors = DocumentDescriptor.where({})
respond_to do |format|
format.html
format.xml { render :xml => @document_descriptors }
end
end
# Show a descr... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
class PeopleController < ApplicationController
include ApplicationHelper
access_control :acl do
allow :superuser, :admin
end
layout 'dashboard'
def tooltip
@person = Person.find(params[:id... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2011
# License:: Apache 2.0
# Handle the filter-by-slug form
class SlugfilterController < ApplicationController
include SlugfilterHelper
access_control :acl do
allow :superuser, :admin, :analyst
end
# Update the last-used ... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
class CyclesController < ApplicationController
layout 'dashboard'
def show
@cycle = Cycle.find(params[:id])
end
def create
@cycle = Cycle.new(params[:cycle])
respond_to do |format|
... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2011
# License:: Apache 2.0
# Handle Google Docs integration
class DocumentController < ApplicationController
include GdataHelper
include DocumentHelper
access_control :acl do
allow :superuser, :admin, :analyst
end
befor... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2011
# License:: Apache 2.0
# This class is the base for all controllers used in this app
#require 'dm-rails/middleware/identity_map'
class ApplicationController < ActionController::Base
include ApplicationHelper
before_filter :req... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Browse sections
class SectionsController < ApplicationController
include ApplicationHelper
include ProgramsHelper
access_control :acl do
allow :superuser, :admin, :analyst
end
layout 'dashboa... | Ruby |
class MappingController < ApplicationController
layout 'dashboard'
respond_to :html, :json
skip_after_filter :flash_to_headers, :only => [:buttons]
cache_sweeper :section_sweeper, :only => [:map_rcontrol, :map_ccontrol]
cache_sweeper :control_sweeper, :only => [:map_rcontrol, :map_ccontrol]
def show
@... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Handle Controls
class ControlsController < ApplicationController
include ApplicationHelper
include ControlsHelper
access_control :acl do
allow :superuser, :admin, :analyst
end
layout 'dashboa... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2011
# License:: Apache 2.0
# Report on the results of analyst testing for an audit
class TestreportController < ApplicationController
include ApplicationHelper
access_control :acl do
allow :superuser, :admin, :analyst
end
... | Ruby |
# Author:: Miron Cuperman (mailto:miron+cms@google.com)
# Copyright:: Google Inc. 2012
# License:: Apache 2.0
# Admin dashboard
class AdminDashController < ApplicationController
access_control :acl do
allow :admin, :superuser
end
layout 'dashboard'
def index
@accounts = Account.all
@people = Per... | 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'
CmsRails::Application.load_tasks
if Rails.env.development? || Rails.env.test?
requ... | Ruby |
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'
| Ruby |
source 'http://rubygems.org'
if File.exist? 'Gemfile.local'
instance_eval(Bundler.read_file('Gemfile.local'), 'Gemfile.local', 1)
end
RAILS_VERSION = '= 3.2.3'
# Get latest psych - work around crash during reorg migration
gem 'psych'
#gem 'gdata-ruby-util', '1.1.2'
gem 'gdata_19',
:git => 'https://github.com/to... | Ruby |
class AddNaToSection < ActiveRecord::Migration
def change
add_column :sections, :na, :boolean, :null => false, :default => false
add_column :sections, :notes, :text
end
end
| Ruby |
class UniqueSlug < ActiveRecord::Migration
def up
add_index :sections, :slug, :unique => true
add_index :controls, :slug, :unique => true
add_index :biz_processes, :slug, :unique => true
add_index :systems, :slug, :unique => true
add_index :programs, :slug, :unique => true
end
def down
re... | Ruby |
class CreateVersions < ActiveRecord::Migration
def self.up
create_table :versions do |t|
t.string :item_type, :null => false
t.integer :item_id, :null => false
t.string :event, :null => false
t.string :whodunnit
t.text :object
t.datetime :created_at
end
... | Ruby |
class RegulationToProgram < ActiveRecord::Migration
def up
rename_table :regulations, :programs
rename_table :control_objectives, :sections
change_table :sections do |t|
t.integer :parent_id
t.index :parent_id
end
end
end
| Ruby |
class CreateInitialTables < ActiveRecord::Migration
def up
create_table :accounts do |t|
t.string :username
t.string :name
t.string :surname
t.string :email
t.string :crypted_password
t.string :role
t.string :persistence_token
t.belongs_to :modified_by
t.time... | Ruby |
class AddToProgram < ActiveRecord::Migration
def up
change_table :programs do |t|
t.integer :frequency_type, :default => 1
t.integer :frequency, :default => 1
end
end
def down
change_table :programs do |t|
t.remove :frequency, :frequency_type
end
end
end
| Ruby |
class ReorgControls < ActiveRecord::Migration
class Program < ActiveRecord::Base
end
class Section < ActiveRecord::Base
belongs_to :parent, :class_name => "Section"
end
def up
raise "do not know how to migrate ControlControls" unless ControlControl.count == 0
rename_table :control_control_object... | 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 =>... | Ruby |
require 'spork'
require 'simplecov'
if ENV['COVERAGE']
SimpleCov.start do
add_group 'Models', 'app/models'
add_group 'Helpers', 'app/helpers'
add_group 'Controllers', 'app/controllers'
add_group 'Admin C', 'app/controllers/admin'
add_filter 'config'
add_filter 'spec'
end
end
Spo... | Ruby |
module UserSpecHelper
# Set the rspec environment so that we can call stub_model
def set_rspec(rspec)
@_rspec = rspec
end
def current_user(stubs = {})
return @current_user if @current_user
role = (stubs.delete(:role) || :guest).to_s
if respond_to?(:stub_model)
@current_user = stub_model... | Ruby |
module BaseObjects
def create_base_objects
@creg = Program.create(:title => 'Company', :slug => 'COM1', :company => true)
@reg = Program.create(:title => 'Reg 1', :slug => 'REG1', :company => false)
@ctl = Control.create(:title => 'Control 1', :slug => 'REG1-CTL1', :description => 'x', :program => @reg, :... | Ruby |
require 'gdata'
module Gdoc
DOCLIST_SCOPE = 'https://docs.google.com/feeds/'
DOCLIST_DOWNLOD_SCOPE = 'https://docs.googleusercontent.com/'
CONTACTS_SCOPE = 'https://www.google.com/m8/feeds/'
SPREADSHEETS_SCOPE = 'https://spreadsheets.google.com/feeds/'
DEFAULT_FEED = DOCLIST_SCOPE + 'default/private/full'
... | Ruby |
namespace :import do
desc "Import various documents into CMS"
task :consolidated, [:filename] => [:environment] do |t, args|
puts "Import consolidated format from #{args[:filename]}"
require 'importer/consolidated'
ActiveRecord::Base.transaction do
importer = Importer::Consolidated.new
imp... | Ruby |
# Importer contains classes and methods to import data from various formats
# into the system.
module Importer
class ImportError < StandardError
end
end
| Ruby |
require 'open-uri'
require 'csv'
module Importer
# Importer for specialized CSV document format
#
# Expected columns are:
# 0-4: Company control index, unused, title, description-part-1, description-part-2
# 5-6: Program 1: description, slug(s)
# 7-8: Program 2: description, slug(s)
# 9-10: Pr... | Ruby |
require 'open-uri'
require 'csv'
module Importer
class Regulation
def initialize
end
def run_file(filename)
open(filename, 'r:utf-8') do |file|
run_csv(file.read)
end
end
def run_csv(csv_string)
program = nil
headers_seen = false
CSV.parse(csv_string) do... | Ruby |
# Copyright (C) 2009 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 |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run CmsRails::Application
| 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
#encoding: utf-8
class Presentation
attr_reader :subject, :presenter, :team, :link, :present_at, :answer_id, :deleted, :deleted_at, :create_at, :update_at
def initialize data
@data = data
#@data = data.slice(0..300)
#@data = data.slice(0..200)
begin
@answer_id, @thread_i... | 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 'sinatra/activerecord/rake'
require './main' | 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 |
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 |
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 |
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 |
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 |
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 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 'sinatra/activerecord/rake'
require './main' | 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 |
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 |
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 |
# Is sheet 01 (after the TOC) a left sheet or a right sheet?
sheet1: right
# "left" and "right" specify which page of a two-page spread a file
# must start on. "left" means that a file must start on the first of
# the two pages. "right" means it must start on the second of the two
# pages. The file may start in eit... | Ruby |
require 'tempfile'
Tempfile.class_eval do
# overwrite so tempfiles use the extension of the basename. important for rmagick and image science
def make_tmpname(basename, n)
ext = nil
sprintf("%s%d-%d%s", basename.to_s.gsub(/\.\w+$/) { |s| ext = s; '' }, $$, n, ext)
end
end
ActiveRecord::Base.sen... | Ruby |
require 'mime/types'
require 'fileutils'
module Simapse
module AssetFury
# This class creates a nice holder for working with the file
class CurrentFile
@@tempfiles_path = File.expand_path Simapse::AssetFury.tempfile_path
#~ @@tempfiles_path = 'test'
attr_reader :filename, :content_ty... | Ruby |
module Simapse
module AssetFury
module IsThumbnails
module ActMethods
# This is to be called in the thumb class (e.g : Image -> is_thumbs :from=>Asset )
# the option :from tells from wich class the thumbs will the original file to be (re)generated
def is_thumbnails(options=... | Ruby |
require 'fileutils'
module Simapse::AssetFury
module Storage
module FileSystem
def full_filename
File.join("#{RAILS_ROOT}/downloads", self.id.to_s, self.filename)
end
def public_filename
end
private
def save_to_storage
logger.info 'copyi... | Ruby |
module Simapse
module AssetFury
module IsAsset
module ActMethods
# This is to be called in the asset class (e.g : Asset -> is_asset :has_thumbs=>Image )
# the option :has_thumbs tells which class holds the generated thumbs
def is_asset(options={})
options[:storage] ||= :f... | Ruby |
require 'mini_magick'
module Simapse # :nodoc:
module AssetFury # :nodoc:
module Processors
module MiniMagickProcessor
def self.included(base)
base.send :extend, ClassMethods
base.alias_method_chain :process_attachment, :processing
end
module ClassMethods... | Ruby |
module Simapse
module AssetFury
#all the defaults stuf goes here
@@default_processors = %w(ImageScience Rmagick MiniMagick)
@@tempfile_path = File.join(RAILS_ROOT, 'tmp', 'asset_fury')
@@content_types = ['image/jpeg', 'image/pjpeg', 'image/gif', 'image/png', 'image/x-png']
mattr_reade... | Ruby |
class CreateProblems < ActiveRecord::Migration
def self.up
create_table :problems do |t|
t.column :name, :string, :limit => 80
t.column :input, :string
t.column :output, :sting
end
for i in (0..5)
problem = Problem.new()
problem.name = "problem_"+i.to_s()
p... | Ruby |
class CreateSubmissions < ActiveRecord::Migration
def self.up
create_table (:submissions) do |t|
t.column :name, :string, :limit => 80
t.column :submitted, :datetime, :null => false
t.column :team_id, :integer, :null => false
t.column "file", :text, :default => "", :null => false... | Ruby |
class CreateTeams < ActiveRecord::Migration
def self.up
create_table :teams do |t|
t.column :name, :string, :limit => 80, :unique => true, :null => false
t.column :password, :string, :limit => 80, :default => ""
t.column :is_admin, :boolean, :default => false
t.column :is_grading, ... | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end
| Ruby |
module SubmitHelper
end
| Ruby |
module AdminHelper
def grade(submission)
if submission.language == "haskell"
haskell(submission)
elsif submission.language == "java"
java(submission)
else
puts "bzrt an error"
puts "unknown language"
end
end
def haskell(submis... | Ruby |
module TeamHelper
end
| Ruby |
class Submission < ActiveRecord::Base
belongs_to :team
end
| Ruby |
class Problem < ActiveRecord::Base
end
| Ruby |
class Team < ActiveRecord::Base
has_many :submissions, :dependent => :destroy
end
| Ruby |
class TeamController < ApplicationController
def login
@title = 'Login'
end
def verify
submissions = Submission.new()
team = Team.find(:first,:conditions =>
["name = ? and password = ?",
params[:team][:name], params[:team][:p... | Ruby |
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
# Pick a unique cookie name to distinguish our session data from others'
#Changed in Rails
#No longer need... | Ruby |
require 'fileutils'
require 'timeout'
class SubmitController < ApplicationController
before_filter :authenticate
def scores
teams = Team.find(:all, :conditions => {:is_admin => "f"})
@scores = []
@title = "Scores"
for team in teams
points = team.submissions.select{|x| x.status == "SUCCESSFU... | Ruby |
class AdminController < ApplicationController
before_filter :authenticate
=begin
*Submission control structure
=end
def submissions
@title = "Listing all submissions"
@teams = Team.find(:all)
end
def edit_submission
@submission = Submission.find(params[:submission])
@title = "Editing " + @s... | Ruby |
require 'sinatra/activerecord/rake'
require './main' | 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 |
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 |
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 "wx"
require "starruby"
require "yaml"
require "yaml/store"
module Wx
class DC
def draw_texture(texture, x, y)
image = Wx::Image.new(texture.width, texture.height)
image.data = texture.dump("rgb")
bitmap = Wx::Bitmap.new(image)
draw_bitmap(bitmap, x, y, false)
end
end
end
r... | Ruby |
module Asterism
UpdatedEventArgs = Struct.new(:type, :model_id)
class Model
def initialize(store)
@store = store
@controllers = []
end
def [](model_id, key)
@store.transaction do
@store[model_id][key]
end
end
def []=(model_id, key, value)
... | Ruby |
module Asterism
class MapEditorFrame < Wx::Frame
def initialize
super(nil, :title => "Asterism", :size => [800, 600])
main_menu = Wx::MenuBar.new
menu = Wx::Menu.new
menu.append(Wx::ID_EXIT, "E&xit")
evt_menu(Wx::ID_EXIT) {exit}
main_menu.append(menu, "&File")
... | Ruby |
module Asterism
class Controller
def initialize(model)
@model = model
@model.add_controller(self)
@views = []
end
def [](model_id, key)
@model[model_id, key]
end
def []=(model_id, key, value)
@model[model_id, key] = value
end
def add_ite... | Ruby |
require "wx"
module Asterism
class ItemEditorPanel < Wx::Panel
attr_reader :data
def initialize(parent, data)
super(parent, -1)
@data = data
id = Wx::ID_HIGHEST
l1 = Wx::StaticText.new(self, -1, "Name:")
t1 = Wx::TextCtrl.new(self, (id += 1))
t1.value =... | Ruby |
require "wx"
require "view"
module Asterism
class ModelEditor < Wx::Panel
def initialize(parent, controller)
super(parent)
splitter = Wx::SplitterWindow.new(self)
list_panel = Wx::Panel.new(splitter)
style = Wx::LC_REPORT | Wx::LC_HRULES | Wx::LC_VRULES | Wx::... | Ruby |
module Asterism
class TexturePanel < Wx::Panel
attr_reader :texture
def initialize(parent, id = Wx::ID_ANY)
super(parent, id)
@texture = StarRuby::Texture.load("town01_a")
font = StarRuby::Font.new("Arial", 48)
color = StarRuby::Color.new(255, 255, 255)
@texture.rend... | Ruby |
module Asterism
module View
def controller
@controller
end
def controller=(val)
@controller.remove_view(self) if @controller
@controller = val
@controller.add_view(self) if @controller
end
end
end
| Ruby |
require 'socket'
@number = ARGV[0]
if(!@number) then
@number = "";
end
@number = @number+"||92"
#puts "Sending: "+@number
#@number = "||92"
socket = UDPSocket.open
socket.send( @number, 0, "localhost", 40000)
socket.close
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.