farm 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +17 -3
- data/lib/farm/http.rb +7 -3
- data/lib/farm/tasks.rb +1 -1
- data/lib/farm/version.rb +1 -1
- metadata +20 -9
data/README.md
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
Farm
|
2
2
|
====
|
3
3
|
|
4
|
-
"Farm out" background jobs by running them immediately as a one-off Heroku process.
|
4
|
+
"Farm out" background jobs by running them immediately as a one-off Heroku process.
|
5
5
|
|
6
|
-
|
6
|
+
Installation and Setup:
|
7
|
+
-----------------------
|
7
8
|
|
8
9
|
gem install farm
|
9
10
|
|
10
11
|
Set the environment variables `API_KEY` and `APP_NAME` to your Heroku API key and the name of your app on Heroku, respectively.
|
11
12
|
|
12
|
-
|
13
|
+
### Rails >= 3.0:
|
14
|
+
|
15
|
+
The installation is finished.
|
16
|
+
|
17
|
+
### Other Ruby apps:
|
18
|
+
|
19
|
+
Add the following line to your Rakefile:
|
20
|
+
|
21
|
+
load 'farm/tasks'
|
22
|
+
|
23
|
+
The Rakefile must also define a task called 'environment'. This task should load your application so that the farmed-out method can be executed in context.
|
24
|
+
|
25
|
+
Usage:
|
26
|
+
------
|
13
27
|
|
14
28
|
Foo.bar #=> Run directly
|
15
29
|
Foo.farm.bar #=> Run in background as one-off Heroku process.
|
data/lib/farm/http.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
|
+
require 'json'
|
1
2
|
require 'rest_client'
|
2
3
|
|
3
4
|
module Farm
|
4
5
|
class Http
|
5
6
|
def self.heroku_run(cmd)
|
6
|
-
endpoint
|
7
|
-
|
8
|
-
|
7
|
+
endpoint = RestClient::Resource.new "https://api.heroku.com/apps/#{ENV['APP_NAME']}/ps",
|
8
|
+
'', ENV['API_KEY']
|
9
|
+
headers = { :accept => 'application/json' }
|
10
|
+
post_params = { :command => 'rake farm:run', :ps_env => { 'CMD' => cmd } }
|
11
|
+
response = endpoint.post post_params, headers
|
12
|
+
JSON.parse response
|
9
13
|
end
|
10
14
|
end
|
11
15
|
end
|
data/lib/farm/tasks.rb
CHANGED
data/lib/farm/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: farm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-25 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
-
requirement: &
|
15
|
+
name: activesupport
|
16
|
+
requirement: &70304870410300 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,21 @@ dependencies:
|
|
21
21
|
version: '3.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70304870410300
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: json
|
27
|
+
requirement: &70304870397520 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.6.5
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70304870397520
|
25
36
|
- !ruby/object:Gem::Dependency
|
26
37
|
name: rake
|
27
|
-
requirement: &
|
38
|
+
requirement: &70304870397100 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
40
|
requirements:
|
30
41
|
- - ! '>='
|
@@ -32,10 +43,10 @@ dependencies:
|
|
32
43
|
version: '0'
|
33
44
|
type: :runtime
|
34
45
|
prerelease: false
|
35
|
-
version_requirements: *
|
46
|
+
version_requirements: *70304870397100
|
36
47
|
- !ruby/object:Gem::Dependency
|
37
48
|
name: rest-client
|
38
|
-
requirement: &
|
49
|
+
requirement: &70304870396520 !ruby/object:Gem::Requirement
|
39
50
|
none: false
|
40
51
|
requirements:
|
41
52
|
- - ~>
|
@@ -43,7 +54,7 @@ dependencies:
|
|
43
54
|
version: 1.6.7
|
44
55
|
type: :runtime
|
45
56
|
prerelease: false
|
46
|
-
version_requirements: *
|
57
|
+
version_requirements: *70304870396520
|
47
58
|
description: Run background jobs as one-off Heroku processes.
|
48
59
|
email: matt.manning@gmail.com
|
49
60
|
executables: []
|