Appjob 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "Appjob/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "Appjob"
7
+ s.version = Appjob::VERSION
8
+ s.authors = ["Jeks"]
9
+ s.email = ["ya.jeks@yandex.com"]
10
+ s.homepage = "http://github.com/ya-jeks/appjob"
11
+ s.summary = %q{schedule a ruby ​​code in the current rails-environment}
12
+ s.description = %q{user can schedule a ruby ​​code in the current rails-environment}
13
+
14
+ s.rubyforge_project = "Appjob"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ end
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,31 @@
1
+ require "Appjob/version"
2
+
3
+ class Appjob
4
+ include Singleton
5
+
6
+ def self.job(at, to_job)
7
+ t = Thread.new do
8
+ loop { sleep(at.to_i); eval(to_job) }
9
+ end
10
+ end
11
+
12
+ def self.run
13
+ if defined? Rails and RAILS_ENV and RAILS_ROOT
14
+ log 'Init ok, env='+Rails.env.to_s
15
+ Thread.abort_on_exception = true
16
+ e = eval(File.read(File.join(Rails.root,'config','every.rb')))
17
+ else
18
+ puts 'Appjob: No rails app detected'
19
+ end
20
+ end
21
+
22
+ def self.every attrs, &block
23
+ job(attrs, (instance_eval &block if block_given?))
24
+ end
25
+
26
+ def self.log(message)
27
+ RAILS_DEFAULT_LOGGER.warn("** [Appjob] #{message}")
28
+ end
29
+ end
30
+
31
+ Appjob.run
@@ -0,0 +1,3 @@
1
+ every 10.seconds do 'log "task one"' end
2
+ every 15.seconds do 'log "task two"' end
3
+ log "task three"
@@ -0,0 +1,3 @@
1
+ class Appjob
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Appjob
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Jeks
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-10-24 00:00:00 +04:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: "user can schedule a ruby \xE2\x80\x8B\xE2\x80\x8Bcode in the current rails-environment"
23
+ email:
24
+ - ya.jeks@yandex.com
25
+ executables: []
26
+
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Appjob.gemspec
34
+ - Gemfile
35
+ - Rakefile
36
+ - lib/Appjob.rb
37
+ - lib/Appjob/every.rb
38
+ - lib/Appjob/version.rb
39
+ has_rdoc: true
40
+ homepage: http://github.com/ya-jeks/appjob
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ hash: 3
54
+ segments:
55
+ - 0
56
+ version: "0"
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ hash: 3
63
+ segments:
64
+ - 0
65
+ version: "0"
66
+ requirements: []
67
+
68
+ rubyforge_project: Appjob
69
+ rubygems_version: 1.5.3
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: "schedule a ruby \xE2\x80\x8B\xE2\x80\x8Bcode in the current rails-environment"
73
+ test_files: []
74
+