Permalink
Browse files

mais milhoes

  • Loading branch information...
1 parent dd19d1a commit d2919bcfa8855117d52b30515cef4b5f98293e3a @nofxx committed Nov 19, 2008
Showing with 1,852 additions and 16 deletions.
  1. +2 −0 app/models/comment.rb
  2. +1 −0 app/models/install.rb
  3. +1 −0 app/models/karma.rb
  4. +5 −0 app/models/pkg.rb
  5. +7 −3 app/models/user.rb
  6. +1 −0 app/models/version.rb
  7. +48 −0 config/backgroundrb.yml
  8. +6 −2 db/migrate/20081119125336_create_pkgs.rb
  9. +2 −2 db/migrate/20081119130130_create_versions.rb
  10. +3 −3 db/migrate/20081119130210_create_comments.rb
  11. +4 −4 db/migrate/20081119130246_create_karmas.rb
  12. +2 −2 db/migrate/20081119130423_create_installs.rb
  13. +27 −0 db/migrate/20081119131136_create_backgroundrb_queue_table.rb
  14. +19 −0 lib/arch/arch_fetcher.rb
  15. +30 −0 lib/workers/fetch_worker.rb
  16. +7 −0 lib/workers/git_worker.rb
  17. +39 −0 script/backgroundrb
  18. +25 −0 script/load_worker_env.rb
  19. +5 −0 spec/spec.opts
  20. +99 −0 test/bdrb_test_helper.rb
  21. +3 −0 vendor/plugins/object_daddy/.gitignore
  22. +20 −0 vendor/plugins/object_daddy/MIT-LICENSE
  23. +307 −0 vendor/plugins/object_daddy/README
  24. +12 −0 vendor/plugins/object_daddy/init.rb
  25. +28 −0 vendor/plugins/object_daddy/install.rb
  26. +215 −0 vendor/plugins/object_daddy/lib/object_daddy.rb
  27. +123 −0 vendor/plugins/object_daddy/spec/install_spec.rb
  28. +753 −0 vendor/plugins/object_daddy/spec/object_daddy_spec.rb
  29. +3 −0 vendor/plugins/object_daddy/spec/resources/config/database.yml
  30. +30 −0 vendor/plugins/object_daddy/spec/resources/schema
  31. +5 −0 vendor/plugins/object_daddy/spec/spec.opts
  32. +20 −0 vendor/plugins/object_daddy/spec/spec_helper.rb
  33. 0 vendor/plugins/object_daddy/spec/tmp/.git_sucks
View
@@ -1,2 +1,4 @@
class Comment < ActiveRecord::Base
+ belongs_to :pkg
+ belongs_to :user
end
View
@@ -1,2 +1,3 @@
class Install < ActiveRecord::Base
+ belongs_to :pkg
end
View
@@ -1,2 +1,3 @@
class Karma < ActiveRecord::Base
+ belongs_to :pkg
end
View
@@ -1,2 +1,7 @@
class Pkg < ActiveRecord::Base
+ belongs_to :maitainer, :foreign_key => :mainteiner_id, :class_name => "User"
+ has_many :versions, :dependent => :destroy
+ has_many :installs, :dependent => :destroy
+ has_many :comments, :dependent => :destroy
+ has_many :karmas, :dependent => :destroy
end
View
@@ -5,6 +5,10 @@ class User < ActiveRecord::Base
include Authentication::ByPassword
include Authentication::ByCookieToken
include Authorization::StatefulRoles
+
+ has_many :pkgs, :foreign_key => :maintainer_id, :dependent => :nullify
+ has_many :comments, :dependent => :destroy
+
validates_presence_of :login
validates_length_of :login, :within => 3..40
validates_uniqueness_of :login
@@ -18,7 +22,7 @@ class User < ActiveRecord::Base
validates_uniqueness_of :email
validates_format_of :email, :with => Authentication.email_regex, :message => Authentication.bad_email_message
-
+
# HACK HACK HACK -- how to do attr_accessible from here?
# prevents a user from submitting a crafted form that bypasses activation
@@ -29,7 +33,7 @@ class User < ActiveRecord::Base
# Authenticates a user by their login name and unencrypted password. Returns the user or nil.
#
- # uff. this is really an authorization, not authentication routine.
+ # uff. this is really an authorization, not authentication routine.
# We really need a Dispatch Chain here or something.
# This will also let us return a human error message.
#
@@ -48,7 +52,7 @@ def email=(value)
end
protected
-
+
def make_activation_code
self.deleted_at = nil
self.activation_code = self.class.make_token
View
@@ -1,2 +1,3 @@
class Version < ActiveRecord::Base
+ belongs_to :pkg
end
View
@@ -0,0 +1,48 @@
+---
+:backgroundrb:
+ :ip: 0.0.0.0
+ :port: 11006
+ :log: foreground # foreground mode,print log messages on console
+# :environment: production
+
+:development:
+ :backgroundrb:
+ :log: foreground
+ # turn this off if your application doesn't use backgroundrb's persistent/enqueued tasks system
+ :persistent_disabled: false
+ # the time (seconds) between
+ :persistent_delay: 20
+ # foreground mode,print log messages on console
+
+:production:
+ :backgroundrb:
+# :port: 22222 # use port 22222
+ :lazy_load: true # do not load models eagerly
+ :debug_log: false # disable log workers and other logging
+
+:schedules:
+ :fetch_worker:
+ :arch:
+ :trigger_args: * * */1 * * * *
+
+# :backgroundrb:
+# :ip: 0.0.0.0 #ip on which backgroundrb server is running
+# :port: 11006 #port on which backgroundrb server is running
+# :environment: production # rails environment loaded, defaults to development
+# :debug_log: true # whether to print debug logs to a seperate worker, defaults to true
+# :log: foreground # will print log messages to STDOUT, defaults to seperate log worker
+# :result_storage: memcache # store results in a mecache cluster, you also need to specify location of your memcache clusters in next section
+#
+# :memcache: "10.0.0.1:11211,10.0.0.2:11211" #=> location of mecache clusters seperated by comma
+#
+# # following section is totally optional, and only useful if you are trying to cluster of backgroundrb server
+# # if you do not specify this section backgroundrb will assume that, from rails you are connecting to the
+# # backgroundrb server which has been specified in previous section
+# :client: "10.0.0.1:11006,10.0.0.2:11007"
+#
+# # You specify your worker schedules here
+# :schedules:
+# :foo_worker: # worker name
+# :barbar: #worker method
+# :trigger_args: */5 * * * * * * #worker schedule
+# cheduling section
@@ -1,13 +1,17 @@
class CreatePkgs < ActiveRecord::Migration
def self.up
create_table :pkgs do |t|
- t.string :name
- t.text :desc
+ t.string :name, :null => false
+ t.text :desc, :null => false
+ t.integer :weight, :null => false, :default => 0
t.references :maintainer
t.string :repo
t.timestamps
end
+
+ add_index :pkgs, :name
+ add_index :pkgs, :maitainer
end
def self.down
@@ -1,8 +1,8 @@
class CreateVersions < ActiveRecord::Migration
def self.up
create_table :versions do |t|
- t.references :pkg
- t.string :name
+ t.references :pkg, :null => false
+ t.string :name, :null => false
t.text :desc
t.timestamps
@@ -1,9 +1,9 @@
class CreateComments < ActiveRecord::Migration
def self.up
create_table :comments do |t|
- t.references :user
- t.references :pkg
- t.text :content
+ t.references :user, :null => false
+ t.references :pkg, :null => false
+ t.text :content, :null => false
t.timestamps
end
@@ -1,10 +1,10 @@
class CreateKarmas < ActiveRecord::Migration
def self.up
create_table :karmas do |t|
- t.references :pkg
- t.integer :value
- t.references :user
- t.references :version
+ t.references :pkg, :null => false
+ t.integer :value, :null => false
+ t.references :user, :null => false
+ t.references :version, :null => false
t.timestamps
end
@@ -1,8 +1,8 @@
class CreateInstalls < ActiveRecord::Migration
def self.up
create_table :installs do |t|
- t.references :pkg
- t.boolean :code
+ t.references :pkg, :null => false
+ t.boolean :code, :null => false
t.timestamps
end
@@ -0,0 +1,27 @@
+class CreateBackgroundrbQueueTable < ActiveRecord::Migration
+ def self.up
+ create_table :bdrb_job_queues do |t|
+ t.column :args, :binary
+ t.column :worker_name, :string
+ t.column :worker_method, :string
+ t.column :job_key, :string
+ t.column :taken, :int
+ t.column :finished, :int
+ t.column :timeout, :int
+ t.column :priority, :int
+ t.column :submitted_at, :datetime
+ t.column :started_at, :datetime
+ t.column :finished_at, :datetime
+ t.column :archived_at, :datetime
+ t.column :tag, :string
+ t.column :submitter_info, :string
+ t.column :runner_info, :string
+ t.column :worker_key, :string
+ t.column :scheduled_at, :datetime
+ end
+ end
+
+ def self.down
+ drop_table :bdrb_job_queues
+ end
+end
View
@@ -0,0 +1,19 @@
+#
+# Pacman fetcher.... simple thing that could work?
+#
+
+module Arch
+ module Fetcher
+
+ def self.get_list
+ text_list = system("pacman -Sl")
+
+ end
+
+
+
+
+ end
+
+
+end
@@ -0,0 +1,30 @@
+class FetchWorker < BackgrounDRb::MetaWorker
+ set_worker_name :fetch_worker
+ def create(args = nil)
+ # this method is called, when worker is loaded for the first time
+ end
+
+
+ def update_pkgs(pkgs)
+
+ for pkg in pkgs
+
+ Pkg.create!(:name => pkg[:name])
+
+
+ end
+
+
+
+ end
+
+
+
+ def arch
+ update_pkgs(Arch::Fetcher.run!)
+ end
+
+
+
+
+end
@@ -0,0 +1,7 @@
+class GitWorker < BackgrounDRb::MetaWorker
+ set_worker_name :git_worker
+ def create(args = nil)
+ # this method is called, when worker is loaded for the first time
+ end
+end
+
View
@@ -0,0 +1,39 @@
+#!/usr/bin/env ruby
+
+RAILS_HOME = File.expand_path(File.join(File.dirname(__FILE__),".."))
+BDRB_HOME = File.join(RAILS_HOME,"vendor","plugins","backgroundrb")
+WORKER_ROOT = File.join(RAILS_HOME,"lib","workers")
+WORKER_LOAD_ENV = File.join(RAILS_HOME,"script","load_worker_env")
+
+["server","server/lib","lib","lib/backgroundrb"].each { |x| $LOAD_PATH.unshift(BDRB_HOME + "/#{x}")}
+$LOAD_PATH.unshift(WORKER_ROOT)
+
+require "rubygems"
+require "yaml"
+require "erb"
+require "logger"
+require "packet"
+require "optparse"
+
+require "bdrb_config"
+require RAILS_HOME + "/config/boot"
+require "active_support"
+
+BackgrounDRb::Config.parse_cmd_options ARGV
+BDRB_CONFIG = BackgrounDRb::Config.read_config("#{RAILS_HOME}/config/backgroundrb.yml")
+
+require RAILS_HOME + "/config/environment"
+require "bdrb_job_queue"
+require "backgroundrb_server"
+
+PID_FILE = "#{RAILS_HOME}/tmp/pids/backgroundrb_#{BDRB_CONFIG[:backgroundrb][:port]}.pid"
+SERVER_LOGGER = "#{RAILS_HOME}/log/backgroundrb_debug_#{BDRB_CONFIG[:backgroundrb][:port]}.log"
+
+daemon = BackgrounDRb::StartStop.new
+
+case ARGV[0]
+when 'start'; daemon.start
+when 'stop'; daemon.stop()
+else; BackgrounDRb::MasterProxy.new()
+end
+
View
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+
+RAILS_HOME = File.expand_path(File.join(File.dirname(__FILE__),".."))
+BDRB_HOME = File.join(RAILS_HOME,"vendor","plugins","backgroundrb")
+
+["server","server/lib","lib","lib/backgroundrb"].each { |x| $LOAD_PATH.unshift(BDRB_HOME + "/#{x}")}
+
+$LOAD_PATH.unshift(File.join(RAILS_HOME,"lib","workers"))
+
+require "yaml"
+require "erb"
+require "logger"
+require "optparse"
+require "bdrb_config"
+require RAILS_HOME + "/config/boot"
+require "active_support"
+
+BDRB_CONFIG = BackgrounDRb::Config.read_config("#{RAILS_HOME}/config/backgroundrb.yml")
+
+if !(::Packet::WorkerRunner::WORKER_OPTIONS[:worker_env] == false)
+ require RAILS_HOME + "/config/environment"
+ ActiveRecord::Base.allow_concurrency = true
+end
+require "backgroundrb_server"
+
View
@@ -0,0 +1,5 @@
+--colour
+--loadby random
+--format progress
+--reverse
+--diff
Oops, something went wrong.

0 comments on commit d2919bc

Please sign in to comment.