farm 0.0.4 → 0.1.0

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/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. Only works with Rails >= 3.0.
4
+ "Farm out" background jobs by running them immediately as a one-off Heroku process.
5
5
 
6
- Install:
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
- Call with the farm method:
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.
@@ -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 = RestClient::Resource.new "https://api.heroku.com/apps/#{ENV['APP_NAME']}/ps",
7
- '', ENV['API_KEY']
8
- endpoint.post :command => 'rake farm:run', :ps_env => { 'CMD' => cmd }, :accept => 'application/json'
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
@@ -3,6 +3,6 @@ require 'yaml'
3
3
 
4
4
  namespace :farm do
5
5
  task :run => :environment do
6
- puts YAML.load(CGI.unescape(ENV['CMD'])).perform
6
+ YAML.load(CGI.unescape(ENV['CMD'])).perform
7
7
  end
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module Farm
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
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
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-24 00:00:00.000000000Z
12
+ date: 2012-01-25 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rails
16
- requirement: &70177451658440 !ruby/object:Gem::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: *70177451658440
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: &70177451657900 !ruby/object:Gem::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: *70177451657900
46
+ version_requirements: *70304870397100
36
47
  - !ruby/object:Gem::Dependency
37
48
  name: rest-client
38
- requirement: &70177451657260 !ruby/object:Gem::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: *70177451657260
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: []