code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
AfaWeb::Application.initialize!
| Ruby |
AfaWeb::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 turned on
... | Ruby |
AfaWeb::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 webser... | Ruby |
AfaWeb::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 s... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run AfaWeb::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'
AfaWeb::Application.load_tasks
| 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 |
class CreateTechniqueTemplates < ActiveRecord::Migration
def self.up
create_table :technique_templates do |t|
t.integer :technique_id
t.string :name
t.boolean :filename, :default => true
t.boolean :location, :default => true
t.boolean :recursively, :default => true
t.boolean :h... | Ruby |
class ChangeColumnTypeToTechniques < ActiveRecord::Migration
def self.up
change_column :techniques, :technique_type_id, :integer, :default => 1
end
def self.down
end
end
| Ruby |
class CreateTechniques < ActiveRecord::Migration
def self.up
create_table :techniques do |t|
t.string :filename
t.string :location
t.integer :technique_type_id
t.integer :plugin_id
t.boolean :recursively
t.string :hash_type
t.string :hash_value
t.string :content
... | Ruby |
class CreatePlugins < ActiveRecord::Migration
def self.up
create_table :plugins do |t|
t.string :name
t.string :os
t.integer :category_id
t.string :author
t.timestamps
end
end
def self.down
drop_table :plugins
end
end
| Ruby |
class ChangeColumnsToTechniques < ActiveRecord::Migration
def self.up
change_column :techniques, :recursively, :boolean, :default => false
end
def self.down
end
end
| Ruby |
class CreatePluginTags < ActiveRecord::Migration
def self.up
create_table :plugin_tags do |t|
t.integer :plugin_id
t.integer :tag_id
t.timestamps
end
add_index :plugin_tags, [:plugin_id, :tag_id], :unique => true
end
def self.down
remove_index :plugin_tags, :column => [:plugin_... | Ruby |
class CreateTechniqueTypes < ActiveRecord::Migration
def self.up
create_table :technique_types do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :technique_types
end
end
| Ruby |
class CreateCategories < ActiveRecord::Migration
def self.up
create_table :categories do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :categories
end
end
| Ruby |
class CreateTags < ActiveRecord::Migration
def self.up
create_table :tags do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :tags
end
end
| Ruby |
class AddDescriptionToPlugins < ActiveRecord::Migration
def self.up
add_column :plugins, :description, :text
end
def self.down
remove_column :plugins, :description
end
end
| Ruby |
class AddMimetypeToTechniques < ActiveRecord::Migration
def self.up
add_column :techniques, :mimetype, :string
end
def self.down
remove_column :techniques, :mimetype
end
end
| Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integrati... | Ruby |
source 'http://rubygems.org'
gem 'rails', '3.0.5'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
gem 'jquery-rails', '>= 0.2.6'
gem 'mongrel'
gem 'mongrel_cluster'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To... | Ruby |
xml.instruct!
xml.plugins do
@plugins.each do |plugin|
xml.plugin do
xml.name(plugin.name)
xml.category(plugin.category.name)
xml.location(url_for(plugin)+".xml")
xml.last_updated(plugin.updated_at.to_i.to_s + "000")
end
end
end
| Ruby |
xml.instruct!
xml.declare! :DOCTYPE, :plugin, :SYSTEM, '../Plugin.dtd'
xml.plugin do
xml.metadata do
xml.name(@plugin.name)
xml.os(@plugin.os)
xml.category(@plugin.category.name)
xml.author(@plugin.author)
xml.description(@plugin.description)
#add 000 to make timemiliseconds compatible
xm... | Ruby |
module TechniquesHelper
end
| Ruby |
module ApplicationHelper
def selected_class(path)
(request.path[path])? "selected" : ""
end
def sortable(column, model)
title = column.titleize
css_class = column == sort_column(model) ? "current #{sort_direction}" : nil
direction = column == sort_column(model) && sort_direction == "asc" ? "desc... | Ruby |
module TechniqueTypesHelper
end
| Ruby |
module PluginsHelper
end
| Ruby |
module CategoriesHelper
end
| Ruby |
module TechniqueTemplatesHelper
end
| Ruby |
module TagsHelper
end
| Ruby |
module HomeHelper
end
| Ruby |
class Technique < ActiveRecord::Base
belongs_to :plugin
belongs_to :technique_type
validates :technique_type_id, :presence => true
end
| Ruby |
class TechniqueType < ActiveRecord::Base
validates :name, :presence => true, :uniqueness => true
validates_format_of :name, :with => /\A[a-zA-Z_\-0-9]*\Z/, :message => " format is not correct. Only letters, numbers, '_' and '-'."
end
| Ruby |
class PluginTag < ActiveRecord::Base
belongs_to :plugin
belongs_to :tag
validates :tag_id, :uniqueness => {:scope => :plugin_id}
end
| Ruby |
class Tag < ActiveRecord::Base
has_many :plugin_tags
has_many :plugins, :through => :plugin_tags
validates :name, :presence => true, :uniqueness => true
validates_format_of :name, :with => /\A[a-zA-Z_\-0-9]*\Z/, :message => " format is not correct. Only letters, numbers, '_' and '-'."
end
| Ruby |
class Category < ActiveRecord::Base
has_many :plugins
validates :name, :uniqueness => true, :presence => true
validates_format_of :name, :with => /\A[a-zA-Z_\-0-9]*\Z/, :message => " format is not correct. Only letters, numbers, '_' and '-'."
end
| Ruby |
class TechniqueTemplate < ActiveRecord::Base
belongs_to :technique
validates :name, :presence => true
end
| Ruby |
class Plugin < ActiveRecord::Base
has_many :techniques, :dependent => :destroy
belongs_to :category
has_many :plugin_tags, :dependent => :destroy
has_many :tags, :through => :plugin_tags
validates :category_id, :presence => true
validates :name, :uniqueness => {:scope => :category_id}, :presence => true
... | Ruby |
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :sort_column, :sort_direction
def sort_column(model)
model.column_names.include?(params[:sort]) ? params[:sort] : "id"
end
def sort_direction
%w[asc desc].include?(params[:direction]) ? params[:direction] : "asc... | Ruby |
class PluginsController < ApplicationController
# GET /plugins
# GET /plugins.xml
def index
@plugins = Plugin.order(sort_column(Plugin) + " " + sort_direction)
respond_to do |format|
format.html # index.html.erb
format.xml { render :layaout => false }
end
end
# GET /plugins/1
# ... | Ruby |
class CategoriesController < ApplicationController
# GET /categories
# GET /categories.xml
def index
@categories = Category.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @categories }
end
end
# GET /categories/1
# GET /categories/1.xml
de... | Ruby |
class HomeController < ApplicationController
def index
respond_to do |format|
format.html
end
end
def about
respond_to do |format|
format.html
end
end
end
| Ruby |
class TechniqueTypesController < ApplicationController
# GET /technique_types
# GET /technique_types.xml
def index
@technique_types = TechniqueType.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @technique_types }
end
end
# GET /technique_types/1... | Ruby |
class TechniquesController < ApplicationController
before_filter(:get_plugin)
# GET /techniques
# GET /techniques.xml
def index
@techniques = @plugin.techniques.order(sort_column(Technique) + " " + sort_direction)
respond_to do |format|
format.html # index.html.erb
format.xml { render :... | Ruby |
class TagsController < ApplicationController
# GET /tags
# GET /tags.xml
def index
@tags = Tag.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @tags }
end
end
# GET /tags/1
# GET /tags/1.xml
def show
@tag = Tag.find(params[:id])
respo... | Ruby |
class TechniqueTemplatesController < ApplicationController
# GET /technique_templates
# GET /technique_templates.xml
def index
@technique_templates = TechniqueTemplate.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @technique_templates }
end
end
... | Ruby |
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', ... | 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.
# 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.
AfaWeb::Application.config.session_store :cookie_store, :key => '_afa_web_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 with "rails... | Ruby |
AfaWeb::Application.routes.draw do
resources :technique_templates
resources :tags
resources :plugins do
resources :techniques
end
match 'plugins/:plugin_id/techniques/new' => 'techniques#new', :via => [:post]
match 'plugins/add_tag/:id' => 'plugins#add_tag'
resources :technique_types
resource... | Ruby |
require 'rubygems'
# 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'
# 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 AfaWeb
class Application < Rails::Application
# ... | Ruby |
# Load the rails application
require File.expand_path('../application', __FILE__)
# Initialize the rails application
AfaWeb::Application.initialize!
| Ruby |
AfaWeb::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 turned on
... | Ruby |
AfaWeb::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 webser... | Ruby |
AfaWeb::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 s... | Ruby |
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run AfaWeb::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'
AfaWeb::Application.load_tasks
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/request'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/benchmarker'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/profiler'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/performance/request'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/reaper'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/inspector'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
class RenameStartDateInPeriod < ActiveRecord::Migration
def self.up
change_table :periods do |t|
t.rename :startDate, :start_date
end
end
def self.down
change_table :periods do |t|
t.rename :start_date, :startDate
end
end
end
| Ruby |
class CreateTransactions < ActiveRecord::Migration
def self.up
create_table :transactions do |t|
t.string :description
t.date :date
t.decimal :amount
t.boolean :processed
t.timestamps
end
end
def self.down
drop_table :transactions
end
end
| Ruby |
class RenameEndDateInPeriod < ActiveRecord::Migration
def self.up
change_table :periods do |t|
t.rename :endDate, :end_date
end
end
def self.down
change_table :periods do |t|
t.rename :end_date, :endDate
end
end
end
| Ruby |
class CreateRecurringTransactions < ActiveRecord::Migration
def self.up
create_table :recurring_transactions do |t|
t.string :description
t.decimal :amount
t.date :base_date
t.integer :frequency
t.timestamps
end
end
def self.down
drop_table :recurring_transactions
end... | Ruby |
class CreatePeriods < ActiveRecord::Migration
def self.up
create_table :periods do |t|
t.date :startDate
t.date :endDate
t.timestamps
end
end
def self.down
drop_table :periods
end
end
| Ruby |
class AddPeriodIdToTransactions < ActiveRecord::Migration
def self.up
add_column :transactions, :period_id, :integer
end
def self.down
remove_column :transactions, :period_id
end
end
| 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.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
| Ruby |
class RecurringTransaction < ActiveRecord::Base
end
| Ruby |
class Transaction < ActiveRecord::Base
validates_presence_of :description
validates_presence_of :date
validates_presence_of :amount
validates_numericality_of :amount
belongs_to :period
end
| Ruby |
class Period < ActiveRecord::Base
validates_presence_of :start_date
validates_presence_of :end_date
has_many :transactions
def processed_transactions
transactions.select { |t| t.processed == true }.sort_by { |t| t.date }
end
def processed_transactions_total
processed_transactions.sum { |t| t.amount... | Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def title(page_title)
@content_for_title = page_title.to_s
end
end
| Ruby |
module TransactionsHelper
end
| Ruby |
module PeriodsHelper
def total_transactions_style(period)
period.total_transactions < 0 ? 'color: red' : 'color: black'
end
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.