code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
# encoding: utf-8
module ActiveSupport #:nodoc:
module Multibyte #:nodoc:
# Holds data about a codepoint in the Unicode database
class Codepoint
attr_accessor :code, :combining_class, :decomp_type, :decomp_mapping, :uppercase_mapping, :lowercase_mapping
end
# Holds static data from the Unicode... | Ruby |
require 'tzinfo'
module ActiveSupport
# A Time-like class that can represent a time in any time zone. Necessary because standard Ruby Time instances are
# limited to UTC and the system's <tt>ENV['TZ']</tt> zone.
#
# You shouldn't ever need to create a TimeWithZone instance directly via <tt>new</tt> -- instead, ... | Ruby |
# encoding: utf-8
require 'active_support/multibyte/chars'
require 'active_support/multibyte/exceptions'
require 'active_support/multibyte/unicode_database'
module ActiveSupport #:nodoc:
module Multibyte
# A list of all available normalization forms. See http://www.unicode.org/reports/tr15/tr15-29.html for more... | Ruby |
# The TimeZone class serves as a wrapper around TZInfo::Timezone instances. It allows us to do the following:
#
# * Limit the set of zones provided by TZInfo to a meaningful subset of 142 zones.
# * Retrieve and display zones with a friendlier name (e.g., "Eastern Time (US & Canada)" instead of "America/New_York").
# *... | Ruby |
# Prefer gems to the bundled libs.
require 'rubygems'
begin
gem 'builder', '~> 2.1.2'
rescue Gem::LoadError
$:.unshift "#{File.dirname(__FILE__)}/vendor/builder-2.1.2"
end
begin
gem 'xml-simple', '~> 1.0.11'
rescue Gem::LoadError
$:.unshift "#{File.dirname(__FILE__)}/vendor/xml-simple-1.0.11"
end
begin
gem... | Ruby |
module ActiveSupport
# If true, use ISO 8601 format for dates and times. Otherwise, fall back to the Active Support legacy format.
mattr_accessor :use_standard_json_time_format
class << self
def escape_html_entities_in_json
@escape_html_entities_in_json
end
def escape_html_entities_in_json=(va... | Ruby |
# A base class with no predefined methods that tries to behave like Builder's
# BlankSlate in Ruby 1.9. In Ruby pre-1.9, this is actually the
# Builder::BlankSlate class.
#
# Ruby 1.9 introduces BasicObject which differs slightly from Builder's
# BlankSlate that has been used so far. ActiveSupport::BasicObject provides... | Ruby |
module ActiveSupport #:nodoc:
module Dependencies #:nodoc:
extend self
# Should we turn on Ruby warnings on the first load of dependent files?
mattr_accessor :warnings_on_first_load
self.warnings_on_first_load = false
# All files ever loaded.
mattr_accessor :history
self.history = Set.ne... | Ruby |
module ActiveSupport
module JSON
module Encoding
mattr_accessor :escape_regex
ESCAPED_CHARS = {
"\010" => '\b',
"\f" => '\f',
"\n" => '\n',
"\r" => '\r',
"\t" => '\t',
'"' => '\"',
'\\' => '\\\\',
'>' => '\u003E',... | Ruby |
module Enumerable
# Returns a JSON string representing the enumerable. Any +options+
# given will be passed on to its elements. For example:
#
# users = User.find(:all)
# # => users.to_json(:only => :name)
#
# will pass the <tt>:only => :name</tt> option to each user.
def to_json(options = {}) #:nod... | Ruby |
class FalseClass
def to_json(options = nil) #:nodoc:
'false'
end
end
| Ruby |
class Object
# Dumps object in JSON (JavaScript Object Notation). See www.json.org for more info.
def to_json(options = {})
ActiveSupport::JSON.encode(instance_values, options)
end
end
| Ruby |
class TrueClass
def to_json(options = nil) #:nodoc:
'true'
end
end
| Ruby |
class NilClass
def to_json(options = nil) #:nodoc:
'null'
end
end
| Ruby |
class Symbol
def to_json(options = {}) #:nodoc:
ActiveSupport::JSON.encode(to_s, options)
end
end
| Ruby |
class DateTime
# Returns a JSON string representing the datetime. If ActiveSupport.use_standard_json_time_format is set to true, the
# ISO 8601 format is used.
#
# ==== Examples:
#
# # With ActiveSupport.use_standard_json_time_format = true
# DateTime.civil(2005,2,1,15,15,10).to_json
# # => "2005-... | Ruby |
class Numeric
def to_json(options = nil) #:nodoc:
to_s
end
end
| Ruby |
class Hash
# Returns a JSON string representing the hash.
#
# Without any +options+, the returned JSON string will include all
# the hash keys. For example:
#
# { :name => "Konata Izumi", 'age' => 16, 1 => 2 }.to_json
# # => {"name": "Konata Izumi", 1: 2, "age": 16}
#
# The keys in the JSON string... | Ruby |
class Time
# Returns a JSON string representing the time. If ActiveSupport.use_standard_json_time_format is set to true, the
# ISO 8601 format is used.
#
# ==== Examples:
#
# # With ActiveSupport.use_standard_json_time_format = true
# Time.utc(2005,2,1,15,15,10).to_json
# # => "2005-02-01T15:15:10... | Ruby |
class Date
# Returns a JSON string representing the date. If ActiveSupport.use_standard_json_time_format is set to true, the
# ISO 8601 format is used.
#
# ==== Examples:
#
# # With ActiveSupport.use_standard_json_time_format = true
# Date.new(2005,2,1).to_json
# # => "2005-02-01"
#
# # With... | Ruby |
class Regexp
def to_json(options = nil) #:nodoc:
inspect
end
end
| Ruby |
require 'yaml'
require 'strscan'
module ActiveSupport
module JSON
class ParseError < StandardError
end
class << self
# Converts a JSON string into a Ruby object.
def decode(json)
YAML.load(convert_json_to_yaml(json))
rescue ArgumentError => e
raise ParseError, "Inva... | Ruby |
module ActiveSupport
module JSON
# A string that returns itself as its JSON-encoded form.
class Variable < String
def to_json(options=nil)
self
end
end
end
end
| Ruby |
require 'active_support/json/variable'
require 'active_support/json/encoders/object' # Require explicitly for rdoc.
Dir["#{File.dirname(__FILE__)}/encoders/**/*.rb"].each do |file|
basename = File.basename(file, '.rb')
unless basename == 'object'
require "active_support/json/encoders/#{basename}"
end
end
mod... | Ruby |
module ActiveSupport
module VERSION #:nodoc:
MAJOR = 2
MINOR = 2
TINY = 2
STRING = [MAJOR, MINOR, TINY].join('.')
end
end
| Ruby |
begin
require 'openssl'
rescue LoadError
end
begin
require 'securerandom'
rescue LoadError
end
module ActiveSupport
if defined?(::SecureRandom)
# Use Ruby 1.9's SecureRandom library whenever possible.
SecureRandom = ::SecureRandom # :nodoc:
else
# = Secure random number generator interface.
#
... | Ruby |
require 'active_support/testing/core_ext/test/unit/assertions'
require 'active_support/testing/setup_and_teardown'
class Test::Unit::TestCase #:nodoc:
include ActiveSupport::Testing::SetupAndTeardown
end | Ruby |
require 'test/unit/assertions'
module Test
module Unit
#--
# FIXME: no Proc#binding in Ruby 2, must change this API
#++
module Assertions
# Test numeric difference between the return value of an expression as a result of what is evaluated
# in the yielded block.
#
# assert_di... | Ruby |
module ActiveSupport
module Testing
module SetupAndTeardown
# For compatibility with Ruby < 1.8.6
PASSTHROUGH_EXCEPTIONS =
if defined?(Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS)
Test::Unit::TestCase::PASSTHROUGH_EXCEPTIONS
else
[NoMemoryError, SignalException, In... | Ruby |
require 'rubygems'
gem 'ruby-prof', '>= 0.6.1'
require 'ruby-prof'
require 'fileutils'
require 'rails/version'
module ActiveSupport
module Testing
module Performance
DEFAULTS =
if benchmark = ARGV.include?('--benchmark') # HAX for rake test
{ :benchmark => true,
:runs => 4,
... | Ruby |
module ActiveSupport
module Testing
module Default #:nodoc:
# Placeholder so test/unit ignores test cases without any tests.
def default_test
end
end
end
end
| Ruby |
module ActiveSupport
class OptionMerger #:nodoc:
instance_methods.each do |method|
undef_method(method) if method !~ /^(__|instance_eval|class|object_id)/
end
def initialize(context, options)
@context, @options = context, options
end
private
def method_missing(method, *argument... | Ruby |
require 'benchmark'
module ActiveSupport
# See ActiveSupport::Cache::Store for documentation.
module Cache
# Creates a new CacheStore object according to the given options.
#
# If no arguments are passed to this method, then a new
# ActiveSupport::Cache::MemoryStore object will be returned.
#
... | Ruby |
module ActiveSupport
# Inspired by the buffered logger idea by Ezra
class BufferedLogger
module Severity
DEBUG = 0
INFO = 1
WARN = 2
ERROR = 3
FATAL = 4
UNKNOWN = 5
end
include Severity
MAX_BUFFER_SIZE = 1000
# Set to false to disable the silence... | Ruby |
require 'yaml'
module ActiveSupport
module Deprecation #:nodoc:
mattr_accessor :debug
self.debug = false
# Choose the default warn behavior according to RAILS_ENV.
# Ignore deprecation warnings in production.
DEFAULT_BEHAVIORS = {
'test' => Proc.new { |message, callstack|
... | Ruby |
module ActiveSupport
# Provides accurate date and time measurements using Date#advance and
# Time#advance, respectively. It mainly supports the methods on Numeric,
# such as in this example:
#
# 1.month.ago # equivalent to Time.now.advance(:months => -1)
class Duration < BasicObject
attr_access... | Ruby |
Dir[File.dirname(__FILE__) + "/core_ext/*.rb"].sort.each do |path|
filename = File.basename(path)
require "active_support/core_ext/#{filename}"
end
| Ruby |
module ActiveSupport #:nodoc:
class OrderedOptions < OrderedHash #:nodoc:
def []=(key, value)
super(key.to_sym, value)
end
def [](key)
super(key.to_sym)
end
def method_missing(name, *args)
if name.to_s =~ /(.*)=$/
self[$1.to_sym] = args.first
else
self[nam... | Ruby |
# encoding: utf-8
require 'singleton'
require 'iconv'
module ActiveSupport
# The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without,
# and class names to foreign keys. The default inflections for pluralization, singularization, and uncountable wo... | Ruby |
require 'zlib'
require 'stringio'
module ActiveSupport
# A convenient wrapper for the zlib standard library that allows compression/decompression of strings with gzip.
module Gzip
class Stream < StringIO
def close; rewind; end
end
# Decompresses a gzipped string.
def self.decompress(source)
... | Ruby |
module ActiveSupport
# Wrapping a string in this class gives you a prettier way to test
# for equality. The value returned by <tt>Rails.env</tt> is wrapped
# in a StringInquirer object so instead of calling this:
#
# Rails.env == "production"
#
# you can call this:
#
# Rails.env.production?
#
... | Ruby |
# Extensions to +nil+ which allow for more helpful error messages for people who
# are new to Rails.
#
# Ruby raises NoMethodError if you invoke a method on an object that does not
# respond to it:
#
# $ ruby -e nil.destroy
# -e:1: undefined method `destroy' for nil:NilClass (NoMethodError)
#
# With these extension... | Ruby |
# OrderedHash is namespaced to prevent conflicts with other implementations
module ActiveSupport
# Hash is ordered in Ruby 1.9!
if RUBY_VERSION >= '1.9'
OrderedHash = ::Hash
else
class OrderedHash < Array #:nodoc:
def []=(key, value)
if pair = assoc(key)
pair.pop
pair << ... | Ruby |
module ActiveSupport
module Memoizable
MEMOIZED_IVAR = Proc.new do |symbol|
"@_memoized_#{symbol.to_s.sub(/\?\Z/, '_query').sub(/!\Z/, '_bang')}".to_sym
end
module Freezable
def self.included(base)
base.class_eval do
unless base.method_defined?(:freeze_without_memoizable)
... | Ruby |
# = XmlSimple
#
# Author:: Maik Schmidt <contact@maik-schmidt.de>
# Copyright:: Copyright (c) 2003-2006 Maik Schmidt
# License:: Distributes under the same terms as Ruby.
#
require 'rexml/document'
require 'stringio'
# Easy API to maintain XML (especially configuration files).
class XmlSimple
include REXML
@... | Ruby |
require 'rubygems'
require 'ftools'
require 'json'
$pro_count = []
$con_count = []
$all_links = []
$basic_id = "11111111"
$all_ids = []
PRO_XVAL = -0.5
CON_XVAL = 5
class Link
attr_accessor :name
attr_accessor :source
attr_accessor :destination
def initialize(name, source, destination)
@name = name
... | Ruby |
require 'rubygems'
require 'json'
def get_story_data filename
fulltext = File.open(filename).read
story_data = {}
fulltext.gsub!("\r", "")
fulltext.gsub!("<br>", "")
fulltext.gsub(/.*?(\<h1\>)(.*?)(\<\/h1\>).*/, "")
story_data["name"] = $2
story_data["name"].gsub!(/([0-9][0-9])/, "")
story_data["number... | Ruby |
(38..72).each do |n|
puts n.to_s + " -- " + (n + 1).to_s + ' [label="adjacent"]'
end
38 -- 39 [label="adjacent"]
| Ruby |
require 'csv'
colors = {"Spatial"=>"red", "Interaction"=>"blue", "Incidental"=>"green", "Shared thoughts" => "cyan", "Spatial"=>"yellow", "Relationship"=>"orange", "Explanation"=>"magenta"}
links = CSV.read("253links.csv")
json_links = []
links.each do |link|
json_links << {:from=>link[0], :to=>link[1], :label=>lin... | Ruby |
#
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'rubygems'
require 'rake'
require 'rake/clean'
require 'rake/gempackagetask'
require 'rake/rdoctask'
require 'rake/testtask'
require 'spec/rake/spectask'
spec = Gem::Specification.new do |s|
s.name = 'coisadopai'... | Ruby |
# To change this template, choose Tools | Templates
# and open the template in the editor.
puts "Hello World"
require 'modulos/loja'
require Loja
c1 = Cliente.new("fulano", "3357 0180")
c2 = Cliente.new("ciclano","3352 2300")
c3 = Cliente.new("fulano", "3357 0180")
puts "C1=C2" << c1=c2
puts "C1=C3" << c1=c3
a=["um"... | Ruby |
# To change this template, choose Tools | Templates
# and open the template in the editor.
module Loja
require "Loja/pedido"
require 'Loja/cliente'
require 'Loja/constantes'
require 'Loja/local'
require 'Loja/foto'
require 'Loja/evento'
end
| Ruby |
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'pedido'
class Cliente
@nome
@telefone
@pedidos
attr_accessor :nome,:pedidos,:telefone
def initialize(nome,telefone)
@nome=nome
@telefone=telefone
end
def adiciona_pedido(pedido)
@pedidos.add... | Ruby |
# To change this template, choose Tools | Templates
# and open the template in the editor.
class Constantes
$tamanhos=[:t10x15,:t13x18,:t15x21,:t20x25,:t30x40]
$efeitos=[:fosco,:brilhante,:metalico,:borda_branca]
end
| Ruby |
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'cliente'
class Evento
@local
@nome
@data
@clientes={}
attr_accessor :local,:nome,:data,:clientes
def initialize(local,nome,data,clientes)
@local=local
@nome=nome
@data=data
@client... | Ruby |
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'evento'
class Foto
@id
@evento
@thumb
attr_accessor :id,:event,:thumb
def initialize(id,evento)
@id=id
@evento=evento
end
def gera_thumb
end
end
| Ruby |
# To change this template, choose Tools | Templates
# and open the template in the editor.
require 'cliente'
require 'foto'
class Pedido
@cliente
@fotos
@enviado=false
@obs
attr_accessor :enviado,:cliente,:fotos,:obs
def initialize(cliente,enviado,obs)
@cliente=cliente
@enviado=enviado
... | Ruby |
# To change this template, choose Tools | Templates
# and open the template in the editor.
class Local
@nome
@endereco
attr_accessor :nome,:endereco
def initialize(nome,endereco)
@nome=nome
@endereco=endereco
end
end | Ruby |
# Description
description "Generate a base for creating styling for an Acquia product."
# Stylesheet Import
file 'screen.scss', :like => :stylesheet, :media => 'screen, projection'
# Javascript Import
# file 'scripts.js', :like => :javascript, :to => 'scripts.js'
# General File Import
# file 'README.md', :to => "REA... | Ruby |
# All gems that are required for this extension to work should go here.
# These are the requires you would normally put in your config.rb file
# By default, you should always included Compass. Do not include your
# extension.
require 'compass'
require 'modular-scale'
require 'singularitygs'
require 'breakpoint'
# Thi... | Ruby |
http_path = "/"
css_dir = "styles"
sass_dir = "sass"
images_dir = "images"
fonts_dir = "fonts"
javascripts_dir = "scripts"
# output_style = :expanded or :nested or :compact or :compressed
output_style = :expanded
relative_assets = true
# line_comments and debug_info can be activated by setting the environment
# flag... | Ruby |
source 'https://rubygems.org'
gem 'sass'
gem 'compass'
gem 'breakpoint'
gem 'singularitygs'
gem 'modular-scale'
| Ruby |
#!/usr/bin/env ruby
# encoding: utf-8
project = 'battery-indicator'
user = `cat ~/.netrc | awk '{print $4;}'`.strip
pass = `cat ~/.netrc | awk '{print $6;}'`.strip
version = `grep "android:versionName=" AndroidManifest.xml`.split('"')[1]
apk_location = "BatteryIndicatorPro-#{version}.apk"
system("cp bin/*-release.ap... | Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
LANGS_URI = 'http://ath.darshancomputing.com/bi/langs/'
langs = Net::HTTP.get(URI.parse(LANGS_URI)).split()
langs.each do |lang|
if lang.length == 2
dir = 'res/values-' << lang
else
dir = 'res/values-' << lang[0,2] << '-r' << lang[2,2]
end
if ! D... | Ruby |
#!/usr/bin/env ruby
require 'nokogiri'
string_to_remove = ['pref_cat_themes',
'theme_settings',
'theme_settings_summary',
'theme_settings_help']
string_files = []
Dir.glob('res/values*').each do |d|
file = d << "/strings.xml"
string_files << file if Fil... | Ruby |
#!/usr/bin/env ruby
# encoding: utf-8
require 'nokogiri'
# read in convert.xml to see which how to convert the string-arrays
# for each strings.xml in res/values res/values-?? res/values-??-*
# find the string-arrays that match the ones in convert.xml and for each
# remove opening and closing string-array tag
#... | Ruby |
require 'RMagick'
class NumberImageGenerator
@@IMAGE_DIR = 'numbers-hdpi/'
def generate(text, fs=18)
#filename = "b" + sprintf("%03d", text) + ".png";
filename = "" + sprintf("%03d", text) + ".png";
font_size = fs;
height = 35;
width = 35;
image = Magick::Image.new(width, height) {self.ba... | Ruby |
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "stylesheets"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"
# You can select your preferred output style here (can be overridden via the command line):
# o... | Ruby |
#!/usr/bin/env ruby
# encoding: utf-8
project = 'battery-indicator'
user = `cat ~/.netrc | awk '{print $4;}'`.strip
pass = `cat ~/.netrc | awk '{print $6;}'`.strip
version = `grep "android:versionName=" AndroidManifest.xml`.split('"')[1]
apk_location = "BatteryIndicatorPro-#{version}.apk"
system("cp bin/*-release.ap... | Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
LANGS_URI = 'http://ath.darshancomputing.com/bi/langs/'
langs = Net::HTTP.get(URI.parse(LANGS_URI)).split()
langs.each do |lang|
if lang.length == 2
dir = 'res/values-' << lang
else
dir = 'res/values-' << lang[0,2] << '-r' << lang[2,2]
end
if ! D... | Ruby |
#!/usr/bin/env ruby
require 'nokogiri'
string_to_remove = ['pref_cat_themes',
'theme_settings',
'theme_settings_summary',
'theme_settings_help']
string_files = []
Dir.glob('res/values*').each do |d|
file = d << "/strings.xml"
string_files << file if Fil... | Ruby |
#!/usr/bin/env ruby
# encoding: utf-8
require 'nokogiri'
# read in convert.xml to see which how to convert the string-arrays
# for each strings.xml in res/values res/values-?? res/values-??-*
# find the string-arrays that match the ones in convert.xml and for each
# remove opening and closing string-array tag
#... | Ruby |
require 'RMagick'
class NumberImageGenerator
@@IMAGE_DIR = 'numbers-hdpi/'
def generate(text, fs=18)
#filename = "b" + sprintf("%03d", text) + ".png";
filename = "" + sprintf("%03d", text) + ".png";
font_size = fs;
height = 35;
width = 35;
image = Magick::Image.new(width, height) {self.ba... | Ruby |
#--------------------------------------------------
# Name: dangdangbook.rb
# Description: This script is used to download books from http://read.dangdang.com/
# The content of book is saved as text file under the same directory with this script
#
# Prerequisit:
# ... | Ruby |
require 'RMagick'
class NumberImageGenerator
@@IMAGE_DIR = 'numbers-hdpi/'
def generate(text, fs=18)
#filename = "b" + sprintf("%03d", text) + ".png";
filename = "" + sprintf("%03d", text) + ".png";
font_size = fs;
height = 35;
width = 35;
image = Magick::Image.new(width, height) {self.ba... | Ruby |
#!/usr/bin/env ruby
# encoding: utf-8
project = 'battery-indicator'
user = `cat ~/.netrc | awk '{print $4;}'`.strip
pass = `cat ~/.netrc | awk '{print $6;}'`.strip
version = `grep "android:versionName=" AndroidManifest.xml`.split('"')[1]
apk_location = "BatteryIndicatorPro-#{version}.apk"
system("cp bin/*-release.ap... | Ruby |
#!/usr/bin/env ruby
require 'nokogiri'
string_to_remove = ['pref_cat_themes',
'theme_settings',
'theme_settings_summary',
'theme_settings_help']
string_files = []
Dir.glob('res/values*').each do |d|
file = d << "/strings.xml"
string_files << file if Fil... | Ruby |
#!/usr/bin/env ruby
require 'net/http'
require 'uri'
LANGS_URI = 'http://ath.darshancomputing.com/bi/langs/'
langs = Net::HTTP.get(URI.parse(LANGS_URI)).split()
langs.each do |lang|
if lang.length == 2
dir = 'res/values-' << lang
else
dir = 'res/values-' << lang[0,2] << '-r' << lang[2,2]
end
if ! D... | Ruby |
#!/usr/bin/env ruby
# encoding: utf-8
require 'nokogiri'
# read in convert.xml to see which how to convert the string-arrays
# for each strings.xml in res/values res/values-?? res/values-??-*
# find the string-arrays that match the ones in convert.xml and for each
# remove opening and closing string-array tag
#... | Ruby |
stylesheet 'sencha-touch.scss' | Ruby |
# This file registers the sencha-touch framework with compass
# It's a magic name that compass knows how to find.
dir = File.dirname(__FILE__)
require File.join(dir, 'lib', 'theme_images.rb')
Compass::Frameworks.register 'sencha-touch', dir
| Ruby |
module SenchaTouch
module SassExtensions
module Functions
module ThemeImages
def theme_image(theme, path, mime_type = nil)
path = path.value
images_path = File.join(File.dirname(__FILE__), "..", "images", theme.value)
real_path = File.join(images_path, path)
i... | Ruby |
# Get the directory that this configuration file exists in
dir = File.dirname(__FILE__)
# Load the sencha-touch framework automatically.
load File.join(dir, '..', 'themes')
# Compass configurations
sass_path = dir
css_path = File.join(dir, "..", "css-debug")
environment = :development
output_style = :expanded | Ruby |
# Get the directory that this configuration file exists in
dir = File.dirname(__FILE__)
# Load the sencha-touch framework automatically.
load File.join(dir, '..', 'themes')
# Compass configurations
sass_path = dir
css_path = File.join(dir, "..", "css")
environment = :production
output_style = :compressed | 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 |
class RolifyCreateRoles < ActiveRecord::Migration
def change
create_table(:roles) do |t|
t.string :name
t.references :resource, :polymorphic => true
t.timestamps
end
create_table(:users_roles, :id => false) do |t|
t.references :user
t.references :role
end
add_index... | Ruby |
class DeviseCreateUsers < ActiveRecord::Migration
def change
create_table(:users) do |t|
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_to... | Ruby |
class AddNameToUsers < ActiveRecord::Migration
def change
add_column :users, :name, :string
end
end
| Ruby |
#!/usr/bin/env rake
# 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__)
Rails3BootstrapDeviseCancan::Application.load_tasks
| Ruby |
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '3.2.14'
gem 'sqlite3'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'bootstrap-sass'
gem 'cancan'
gem 'devise'
gem 'figaro'
gem 'rolify'
gem 'simple_form'
group :developm... | 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 |
#!/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 |
#!/usr/bin/env ruby
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
if vendored_cucumber_bin
load File.expand_path(vendored_cucumber_bin)
else
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'cucumber'
load Cucumber::BINARY
end
| Ruby |
#!/usr/bin/env ruby
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
if vendored_cucumber_bin
load File.expand_path(vendored_cucumber_bin)
else
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'cucumber'
load Cucumber::BINARY
end
| Ruby |
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'email_spec'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/suppo... | Ruby |
# Read about factories at https://github.com/thoughtbot/factory_girl
FactoryGirl.define do
factory :user do
name 'Test User'
email 'example@example.com'
password 'changeme'
password_confirmation 'changeme'
# required if the Devise Confirmable module is used
# confirmed_at Time.now
end
end
| Ruby |
RSpec.configure do |config|
config.include Devise::TestHelpers, :type => :controller
end
| Ruby |
module ApplicationHelper
def display_base_errors resource
return '' if (resource.errors.empty?) or (resource.errors[:base].empty?)
messages = resource.errors[:base].map { |msg| content_tag(:p, msg) }.join
html = <<-HTML
<div class="alert alert-error alert-block">
<button type="button" class="cl... | Ruby |
module HomeHelper
end
| Ruby |
class User < ActiveRecord::Base
rolify
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessib... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.