lib/engineyard-metadata/insider.rb in engineyard-metadata-0.2.2 vs lib/engineyard-metadata/insider.rb in engineyard-metadata-0.2.3
- old
+ new
@@ -1,28 +1,9 @@
module EY
class Metadata
# This gets pulled in when you're running directly on a cloud instance.
- module Insider
- DELEGATED_TO_AMAZON_EC2_API = %w{
- present_instance_id
- present_security_group
- }
-
- DELEGATED_TO_CHEF_DNA = METHODS - DELEGATED_TO_AMAZON_EC2_API
-
- DELEGATED_TO_AMAZON_EC2_API.each do |name|
- define_method name do
- amazon_ec2_api.send name
- end
- end
-
- DELEGATED_TO_CHEF_DNA.each do |name|
- define_method name do
- chef_dna.send name
- end
- end
-
+ class Insider < Metadata
# You can't get the list of environment names while you're on the instances themselves.
def environment_names
raise CannotGetFromHere
end
@@ -43,9 +24,28 @@
elsif Dir.pwd =~ %r{/data/([^/]+)/current} or Dir.pwd =~ %r{/data/([^/]+)/releases}
@app_name = $1
end
raise RuntimeError, "[engineyard-metadata gem] Please set EY.metadata.app_name= or set ENV['EY_APP_NAME']" unless @app_name.to_s.strip.length > 0
@app_name
+ end
+
+ DELEGATED_TO_AMAZON_EC2_API = %w{
+ present_instance_id
+ present_security_group
+ }
+
+ DELEGATED_TO_CHEF_DNA = METHODS - instance_methods.map { |m| m.to_s } - DELEGATED_TO_AMAZON_EC2_API
+
+ DELEGATED_TO_AMAZON_EC2_API.each do |name|
+ define_method name do
+ amazon_ec2_api.send name
+ end
+ end
+
+ DELEGATED_TO_CHEF_DNA.each do |name|
+ define_method name do
+ chef_dna.send name
+ end
end
end
end
end