rake-opt-current_invocation_chain 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.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Yjc4YzU3OGJhYzk2MDA5ZDU5Y2NlYmVkZWIyODAyMTkyNWVhMDJjZg==
5
+ data.tar.gz: !binary |-
6
+ OGRiZjBmOWUzNzM4MWM4OWIzNTAwNmE0NzdiMTM3MzA2MWQ4OTUxYQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YTg3ZGY3MmU3NmUxNGQyYmZkZTE3MWE0OTE5NDAzYTE4NmQzMWMxZmViNDAx
10
+ ZThkOWYzYWFjYzU1MzJmYWY3NzM5ZmViNTAyOTEwNTg4NGJiZGRiYjRlMzUw
11
+ OGVmODE3Yzg3ODVhYWFiNzcyOGQ1YjMzMjE3ZjdjOTExYjI4YzY=
12
+ data.tar.gz: !binary |-
13
+ NTNkZDA5MGIwODFiMTIzYjE5MzlkMzg3ZTdmY2ZkNGYyMjQzZmQ0NDU2ZjJl
14
+ NDI3MjkxMDJkY2Y5MDI4NTlmODcyZjRkOGVkMWU5MzUwNTI1NjI1ZmRiOTRi
15
+ NWVjZDI5ODZiNWFiM2E2MzBlYWQ1NDJkZjJmZTRhYjlmYjQ0NGY=
@@ -0,0 +1,11 @@
1
+ require_relative '../thread.rb'
2
+
3
+ module Rake::DSL
4
+ def current_invocation_chain
5
+ promise = Thread.current.promise
6
+ while promise
7
+ return promise.invocation_chain if promise.invocation_chain
8
+ promise = promise.parent
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ class Rake::Promise
2
+ attr_accessor :invocation_chain
3
+ attr_reader :parent
4
+
5
+ # Create a promise to do the chore specified by the block.
6
+ # Overrides by adding @parent
7
+ def initialize(args, &block)
8
+ @mutex = Mutex.new
9
+ @result = NOT_SET
10
+ @error = NOT_SET
11
+ @args = args
12
+ @block = block
13
+ @invocation_chain = nil
14
+ @parent = Thread.current.promise
15
+ end
16
+
17
+ alias_method :__chore__, :chore
18
+
19
+ # Properly set the parent thread
20
+ def chore(*args, &block)
21
+ old_promise = Thread.current.promise
22
+ Thread.current.promise = self
23
+ __chore__(*args, &block)
24
+ Thread.current.promise = old_promise
25
+ end
26
+
27
+ class Fake
28
+ attr_accessor :invocation_chain
29
+ attr_reader :parent
30
+ def initialize
31
+ @invocation_chain = nil
32
+ @parent = nil
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,15 @@
1
+ # Class Override for Rake::Task
2
+ class ::Rake::Task
3
+ # Save the original invoke_with_call_chain instance method
4
+ alias_method "__invoke_with_call_chain__", "invoke_with_call_chain"
5
+
6
+ # Override the invoke_with_call_chain instance method
7
+ # Provides a thread-safe variable to access information about the currently invoked chain
8
+ def invoke_with_call_chain(task_args, invocation_chain)
9
+ old_chain = Thread.current.promise.invocation_chain
10
+ new_chain = ::Rake::InvocationChain.append(self, invocation_chain)
11
+ Thread.current.promise.invocation_chain = new_chain
12
+ __invoke_with_call_chain__(task_args, invocation_chain) # And call the original invocation
13
+ Thread.current.promise.invocation_chain = old_chain
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ require_relative 'rake/promise.rb'
2
+
3
+ # Thread class override
4
+ # Keep track of parents and lineage
5
+ class ::Thread
6
+ def promise
7
+ self['promise']
8
+ end
9
+
10
+ def promise=(promise)
11
+ self['promise'] = promise
12
+ end
13
+ end
14
+
15
+ Thread.main.promise = Rake::Promise::Fake.new
@@ -0,0 +1,4 @@
1
+ require_relative 'patches/thread.rb'
2
+ require_relative 'patches/rake/dsl.rb'
3
+ require_relative 'patches/rake/promise.rb'
4
+ require_relative 'patches/rake/task.rb'
@@ -0,0 +1 @@
1
+ require_relative 'current_invocation_chain/patches.rb'
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rake-opt-current_invocation_chain
3
+ version: !ruby/object:Gem::Version
4
+ version: !binary |-
5
+ MC4xLjA=
6
+ platform: ruby
7
+ authors:
8
+ - Jon San Miguel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-03-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: !binary |-
21
+ NC4xLjA=
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ version: !binary |-
29
+ NC4xLjA=
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: !binary |-
37
+ MTAuMy4y
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: !binary |-
45
+ MTAuMy4y
46
+ description: Enables accessing of invocation chain from within the task execution
47
+ context
48
+ email: jon.sanmiguel@optimizely.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - lib/rake/opt/current_invocation_chain.rb
54
+ - lib/rake/opt/current_invocation_chain/patches.rb
55
+ - lib/rake/opt/current_invocation_chain/patches/rake/dsl.rb
56
+ - lib/rake/opt/current_invocation_chain/patches/rake/promise.rb
57
+ - lib/rake/opt/current_invocation_chain/patches/rake/task.rb
58
+ - lib/rake/opt/current_invocation_chain/patches/thread.rb
59
+ homepage: http://rubygems.org/gems/rake-opt-current_invocation_chain
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.4.8
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Enables accessing of invocation chain from within the task execution context
83
+ test_files: []