appjob 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +5 -0
- data/Gemfile +3 -0
- data/README.rdoc +3 -0
- data/Rakefile +1 -0
- data/appjob.gemspec +21 -0
- data/lib/appjob.rb +34 -0
- data/lib/appjob/every.rb +3 -0
- data/lib/appjob/version.rb +3 -0
- metadata +75 -0
data/Gemfile
ADDED
data/README.rdoc
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
data/appjob.gemspec
ADDED
|
@@ -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{Simple rails sheduler, which run ruby code in current 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/lib/appjob.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require "appjob/version"
|
|
2
|
+
|
|
3
|
+
class Appjob
|
|
4
|
+
include Singleton
|
|
5
|
+
|
|
6
|
+
EVERY_PATH = File.join(Rails.root,'config','every.rb')
|
|
7
|
+
|
|
8
|
+
def self.job(at, to_job)
|
|
9
|
+
t = Thread.new do
|
|
10
|
+
loop { sleep(at.to_i); eval(to_job) }
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.run
|
|
15
|
+
if defined? Rails and RAILS_ENV and RAILS_ROOT
|
|
16
|
+
log 'Init ok, env='+Rails.env.to_s
|
|
17
|
+
Thread.abort_on_exception = true
|
|
18
|
+
FileUtils.mv(File.join(File.dirname(__FILE__),'every.rb'), EVERY_PATH) unless File.exist? EVERY_PATH
|
|
19
|
+
eval(File.read(EVERY_PATH))
|
|
20
|
+
else
|
|
21
|
+
puts 'Appjob: No rails app detected'
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.every attrs, &block
|
|
26
|
+
job(attrs, (instance_eval &block if block_given?))
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def self.log(message)
|
|
30
|
+
RAILS_DEFAULT_LOGGER.warn("** [Appjob] #{message}")
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Appjob.run
|
data/lib/appjob/every.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: appjob
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 27
|
|
5
|
+
prerelease:
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 0
|
|
9
|
+
- 2
|
|
10
|
+
version: 0.0.2
|
|
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: Simple rails sheduler, which run ruby code in current environment
|
|
23
|
+
email:
|
|
24
|
+
- ya.jeks@yandex.com
|
|
25
|
+
executables: []
|
|
26
|
+
|
|
27
|
+
extensions: []
|
|
28
|
+
|
|
29
|
+
extra_rdoc_files: []
|
|
30
|
+
|
|
31
|
+
files:
|
|
32
|
+
- .gitignore
|
|
33
|
+
- Gemfile
|
|
34
|
+
- README.rdoc
|
|
35
|
+
- Rakefile
|
|
36
|
+
- appjob.gemspec
|
|
37
|
+
- lib/appjob.rb
|
|
38
|
+
- lib/appjob/every.rb
|
|
39
|
+
- lib/appjob/version.rb
|
|
40
|
+
has_rdoc: true
|
|
41
|
+
homepage: http://github.com/ya-jeks/appjob
|
|
42
|
+
licenses: []
|
|
43
|
+
|
|
44
|
+
post_install_message:
|
|
45
|
+
rdoc_options: []
|
|
46
|
+
|
|
47
|
+
require_paths:
|
|
48
|
+
- lib
|
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
|
+
none: false
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
hash: 3
|
|
55
|
+
segments:
|
|
56
|
+
- 0
|
|
57
|
+
version: "0"
|
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
|
+
none: false
|
|
60
|
+
requirements:
|
|
61
|
+
- - ">="
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
hash: 3
|
|
64
|
+
segments:
|
|
65
|
+
- 0
|
|
66
|
+
version: "0"
|
|
67
|
+
requirements: []
|
|
68
|
+
|
|
69
|
+
rubyforge_project: appjob
|
|
70
|
+
rubygems_version: 1.5.3
|
|
71
|
+
signing_key:
|
|
72
|
+
specification_version: 3
|
|
73
|
+
summary: "schedule a ruby \xE2\x80\x8B\xE2\x80\x8Bcode in the current rails-environment"
|
|
74
|
+
test_files: []
|
|
75
|
+
|