remote_rails_rake_runner 0.9.2 → 0.9.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 610999e3c885e28757a8c816e24cdcd3967b61d5
4
- data.tar.gz: 790ec5511874efecab37f2ae582e26a14499c9a7
3
+ metadata.gz: eb303908393d8ffa837ed087519e484d4706ac40
4
+ data.tar.gz: d1be224486d228562240528a9d693c5f940b0e1f
5
5
  SHA512:
6
- metadata.gz: 06eaf10dbdb56c1756b9929d6f4b6b3a6bcbe70ba3072ed14f6d11809d87cf5fa032970174b7228b578f8c50aad8039aad1a2b2c156d8274dfc7a24442231eb8
7
- data.tar.gz: 30a260899e03a79a7b2d0991e9d7bba63a2629a9a2c1418a9c92490352483ed183799fc83a96e0ba19489bc4ba59e725d9684c42d9ddd8ad8a736c4e094bd2a0
6
+ metadata.gz: e72a3988e7124940b7d093df72e06ada3b774b7768f541cd58875a08efab0b9c4f0305f3eeb8209e94ae44143d4fba68763d5794d2c2b1e502979f9f341a4fdb
7
+ data.tar.gz: ef0e8015068af60bd5f87c1184e3adc27835d51482d442d15c97fbf32800b6a964fd2625798d1f2a9f678ccb39b19fa5719dc417268bf72e46898492693ef480
data/README.md CHANGED
@@ -3,6 +3,10 @@
3
3
  The goal to deal with one problem: The startup time of a big Rails
4
4
  project when running a functional suite across multiple servers.
5
5
 
6
+ [![Circle CI](https://circleci.com/gh/gaqzi/remote_rails_rake_runner/tree/master.svg?style=svg)](https://circleci.com/gh/gaqzi/remote_rails_rake_runner/tree/master)
7
+ [![Coverage Status](https://coveralls.io/repos/gaqzi/remote_rails_rake_runner/badge.svg?branch=master&service=github)](https://coveralls.io/github/gaqzi/remote_rails_rake_runner?branch=master)
8
+ [![Gem Version](https://badge.fury.io/rb/remote_rails_rake_runner.svg)](http://badge.fury.io/rb/remote_rails_rake_runner)
9
+
6
10
  ## Background
7
11
  The project this lil' app was started on is running a Cucumber suite
8
12
  that spans a total of 10 concurrent runners, all of whom need data at
@@ -35,13 +39,18 @@ end
35
39
  ## Configuration
36
40
 
37
41
  You can specify the path to your `Rakefile` by setting the option
38
- `Rails.application.config.remote_rake_runner_rakefile_path` which defaults to `Rails.root.join('Rakefile').to_s`.
42
+ `Rails.application.config.remote_rake_runner_rakefile_path` which defaults to
43
+ `Rails.root.join('Rakefile').to_s`.
39
44
 
40
45
  ## Usage
41
46
 
42
- The app exposes two endpoints, a listing of all the rake tasks and the actual runner.
43
- To run a task with arguments just put the arguments in into the argument `args` separated by commas.
44
- The task will not be considered successful if it raises an exception, otherwise it's assumed to have been successful.
47
+ The app exposes two endpoints, a listing of all the rake tasks and the actual
48
+ runner. To run a task with arguments just put the arguments in into the argument
49
+ `args` separated by commas. The task will not be considered successful if it
50
+ raises an exception, otherwise it's assumed to have been successful.
51
+
52
+ To override an environment variable for one task run set the variable in the
53
+ `environment` variable which acts like a hash.
45
54
 
46
55
  If you mount the app under `/rake` as suggested above:
47
56
 
@@ -51,8 +60,19 @@ $ curl http://localhost:3000/rake
51
60
 
52
61
  $ curl http://localhost:3000/rake/simple:hello -d args=Björn
53
62
  {"success":true,"output":"Hello Björn!\n"}
63
+
64
+ $ curl http://localhost:3000/rake/simple:hello_environment -d 'environment[name]=Björn&args=Ahlo'
65
+ {"success":true,"output":"Ahlo Björn!\n"}
54
66
  ```
55
67
 
68
+ ## Arguments
69
+
70
+ * `args`: A comma separated list string of arguments passed to the rake task,
71
+ like on the command line
72
+ * `environment`: A hash of overridden values.
73
+ Example in Ruby: `{environment: {name: 'Björn'}}` or in curl
74
+ `environment[name]=Björn`.
75
+
56
76
  ## Acknowledgements
57
77
 
58
78
  The running and capturing of output that was taken from
@@ -23,12 +23,14 @@ module RemoteRailsRakeRunner
23
23
  return head :not_found unless task
24
24
 
25
25
  begin
26
- output = capture_stdout { task.invoke(*(params[:args] || '').split(',')) }
26
+ output = capture_stdout do
27
+ override_env(params[:environment]) { task.invoke(*(params[:args] || '').split(',')) }
28
+ end
27
29
  rescue => e
28
30
  success = false
29
31
  output = e.inspect
30
32
  ensure
31
- rake_tasks.each {|task| task.reenable}
33
+ rake_tasks.each { |task| task.reenable }
32
34
  end
33
35
 
34
36
  render json: {success: success, output: output}
@@ -43,8 +45,22 @@ module RemoteRailsRakeRunner
43
45
  $stdout = previous
44
46
  end
45
47
 
48
+ def override_env(variables)
49
+ unless variables.blank?
50
+ begin
51
+ previous = ENV.to_h
52
+ ENV.update(variables)
53
+ yield
54
+ ensure
55
+ ENV.replace(previous)
56
+ end
57
+ else
58
+ yield
59
+ end
60
+ end
61
+
46
62
  def load_rake
47
- return if defined? Rake
63
+ return if defined? Rake.application
48
64
 
49
65
  require 'rake'
50
66
  load Rails.application.config.try(:remote_rake_runner_rakefile_path) || Rails.root.join('Rakefile').to_s
@@ -1,3 +1,3 @@
1
1
  module RemoteRailsRakeRunner
2
- VERSION = '0.9.2'
2
+ VERSION = '0.9.3'
3
3
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: remote_rails_rake_runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Björn Andersson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-13 00:00:00.000000000 Z
11
+ date: 2015-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description:
@@ -31,16 +31,16 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - MIT-LICENSE
35
+ - README.md
36
+ - Rakefile
34
37
  - app/controllers/remote_rails_rake_runner/application_controller.rb
35
38
  - app/controllers/remote_rails_rake_runner/runner_controller.rb
36
39
  - config/routes.rb
40
+ - lib/remote_rails_rake_runner.rb
37
41
  - lib/remote_rails_rake_runner/engine.rb
38
42
  - lib/remote_rails_rake_runner/version.rb
39
- - lib/remote_rails_rake_runner.rb
40
43
  - lib/tasks/remote_rails_rake_runner_tasks.rake
41
- - MIT-LICENSE
42
- - Rakefile
43
- - README.md
44
44
  homepage: https://github.com/gaqzi/remote_rails_rake_runner
45
45
  licenses:
46
46
  - MIT
@@ -51,17 +51,17 @@ require_paths:
51
51
  - lib
52
52
  required_ruby_version: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - '>='
54
+ - - ">="
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  requirements: []
63
63
  rubyforge_project:
64
- rubygems_version: 2.0.14
64
+ rubygems_version: 2.2.3
65
65
  signing_key:
66
66
  specification_version: 4
67
67
  summary: A simple API endpoint to run your rake tasks in the Rails context.