This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RailsRename | |
class << self | |
def args() | |
if (ARGV.size != 2) | |
raise ArgumentError, "Você deve passar dois parametros: path_da_app novo_nome_app" | |
end | |
ARGV[0] += '/' unless ARGV[0].end_with? '/' | |
ARGV[0].match(/.*(^|\/)(.*)\/$/) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
class Base | |
def self.build | |
instance = self.new | |
self.column_names.grep(/_id/).each { |coluna| | |
coluna.match(/(.*)_id$/) | |
instance.send($1+"=", $1.camelize.constantize.new) | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (ARGV.size != 1) | |
raise ArgumentError, "you must inform a param with path of ruby files" | |
end | |
files_path = Dir["#{ARGV[0]}**/**{.rb}"] | |
files_path.each do |file_path| | |
data = File.new(file_path).read | |
utf8 = "# encoding: utf-8" | |
File.open(file_path, 'w') { |f| f.write(utf8 + "\n\n" + data) } unless data.include? utf8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ActiveRecord::Base#dup and ActiveRecord::Base#clone semantics have changed to closer match normal Ruby dup and clone semantics. | |
# Calling ActiveRecord::Base#clone will result in a shallow copy of the record, including copying the frozen state. No callbacks will be called. | |
# Calling ActiveRecord::Base#dup will duplicate the record, including calling after initialize hooks. Frozen state will not be copied, and all associations will be cleared. A duped record will return true for new_record?, have a nil id field, and is saveable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ActiveRecord::Base#dup and ActiveRecord::Base#clone semantics have changed to closer match normal Ruby dup and clone semantics. | |
# Calling ActiveRecord::Base#clone will result in a shallow copy of the record, including copying the frozen state. No callbacks will be called. | |
# Calling ActiveRecord::Base#dup will duplicate the record, including calling after initialize hooks. Frozen state will not be copied, and all associations will be cleared. A duped record will return true for new_record?, have a nil id field, and is saveable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#new way: | |
describe Model do | |
before(:all) do | |
@model_factory = Factory.build(:factory_model) | |
end | |
before(:each) do | |
@model = @model_factory.clone | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[core] | |
quotepath = false | |
[color] | |
branch = auto | |
diff = auto | |
status = auto | |
[color "branch"] | |
current = yellow reverse |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
socket = TCPSocket.new('localhost', 8081) | |
socket.write(configs) | |
all_data = [] | |
while true | |
partial_data = socket.recv(1012) | |
if partial_data.length == 0 | |
break | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'eventmachine' | |
module EchoServer | |
def post_init | |
puts "-- someone connected to the echo server!" | |
end | |
def receive_data data | |
send_data ">>>you sent: #{data}" | |
close_connection if data =~ /quit/i |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
require 'rubygems' | |
require 'eventmachine' | |
require 'java' | |
require 'lib/report' | |
require 'lib/filler' | |
module ReportServer |
OlderNewer