engineyard-metadata 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ begin
14
14
  gem.add_dependency 'nap', '>=0.4'
15
15
  gem.add_development_dependency "fakeweb"
16
16
  gem.add_development_dependency "fakefs"
17
- gem.add_development_dependency "rspec", "~>1"
17
+ gem.add_development_dependency "rspec", "~>2"
18
18
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
19
19
  end
20
20
  Jeweler::GemcutterTasks.new
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{engineyard-metadata}
8
- s.version = "0.0.6"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Seamus Abshere"]
@@ -55,20 +55,20 @@ Gem::Specification.new do |s|
55
55
  s.add_runtime_dependency(%q<nap>, [">= 0.4"])
56
56
  s.add_development_dependency(%q<fakeweb>, [">= 0"])
57
57
  s.add_development_dependency(%q<fakefs>, [">= 0"])
58
- s.add_development_dependency(%q<rspec>, ["~> 1"])
58
+ s.add_development_dependency(%q<rspec>, ["~> 2"])
59
59
  else
60
60
  s.add_dependency(%q<activesupport>, [">= 2.3.4"])
61
61
  s.add_dependency(%q<nap>, [">= 0.4"])
62
62
  s.add_dependency(%q<fakeweb>, [">= 0"])
63
63
  s.add_dependency(%q<fakefs>, [">= 0"])
64
- s.add_dependency(%q<rspec>, ["~> 1"])
64
+ s.add_dependency(%q<rspec>, ["~> 2"])
65
65
  end
66
66
  else
67
67
  s.add_dependency(%q<activesupport>, [">= 2.3.4"])
68
68
  s.add_dependency(%q<nap>, [">= 0.4"])
69
69
  s.add_dependency(%q<fakeweb>, [">= 0"])
70
70
  s.add_dependency(%q<fakefs>, [">= 0"])
71
- s.add_dependency(%q<rspec>, ["~> 1"])
71
+ s.add_dependency(%q<rspec>, ["~> 2"])
72
72
  end
73
73
  end
74
74
 
@@ -113,7 +113,7 @@ module EY
113
113
  end
114
114
 
115
115
  def data_loaded?
116
- @data.is_a? Hash
116
+ defined?(@data) and @data.is_a? Hash
117
117
  end
118
118
 
119
119
  def data
@@ -29,7 +29,7 @@ module EY
29
29
  environment_name
30
30
  stack_name
31
31
  repository_uri
32
- }
32
+ } unless defined?(KEYS)
33
33
 
34
34
  # This gets raised when you can't get a particular piece of metadata from the execution environment you're in.
35
35
  class CannotGetFromHere < RuntimeError
@@ -54,6 +54,8 @@ module EY
54
54
  elsif ENV['EY_ENVIRONMENT_NAME']
55
55
  ENV['EY_ENVIRONMENT_NAME']
56
56
  end
57
+ raise RuntimeError, "[engineyard-metadata gem] You need to run this from the application repo, set EY::Metadata.environment_name= or set ENV['EY_ENVIRONMENT_NAME']" unless @environment_name.to_s.strip.length > 0
58
+ @environment_name
57
59
  end
58
60
 
59
61
  def ey_cloud_token=(str)
@@ -70,10 +72,10 @@ module EY
70
72
  @ey_cloud_token = if ENV['EY_CLOUD_TOKEN']
71
73
  ENV['EY_CLOUD_TOKEN']
72
74
  elsif File.exist? eyrc_path
73
- YAML.load(File.read(eyrc_path))['ey_cloud_token']
74
- else
75
- raise RuntimeError, "[engineyard-metadata gem] You need to download #{eyrc_path} or set ENV['EY_CLOUD_TOKEN']"
75
+ YAML.load(File.read(eyrc_path))['api_token']
76
76
  end
77
+ raise RuntimeError, "[engineyard-metadata gem] You need to have #{eyrc_path}, set EY::Metadata.ey_cloud_token= or set ENV['EY_CLOUD_TOKEN']" unless @ey_cloud_token.to_s.strip.length > 0
78
+ @ey_cloud_token
77
79
  end
78
80
 
79
81
  # The URL that EngineYard has on file for your application.
@@ -118,31 +118,44 @@ end
118
118
 
119
119
  describe 'EY::Metadata' do
120
120
  describe "being executed from a developer/administrator's local machine" do
121
- before(:all) do
121
+ before do
122
122
  pretend_we_are_on_a_developer_machine
123
- # forcibly reload metadata.rb, so that it can extend itself based on its execution environment
124
123
  load File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'engineyard-metadata', 'metadata.rb'))
124
+ EY::Metadata.clear
125
+ ENV.delete 'EY_CLOUD_TOKEN'
126
+ ENV.delete 'EY_ENVIRONMENT_NAME'
125
127
  end
126
-
127
- after(:all) do
128
+
129
+ after do
128
130
  stop_pretending
129
131
  end
130
132
 
131
133
  describe "controlled with environment variables" do
132
- before(:all) do
133
- EY::Metadata.clear
134
- ENV['EY_CLOUD_TOKEN'] = FAKE_CLOUD_TOKEN
134
+ before do
135
+ ENV['EY_CLOUD_TOKEN'] = FAKE_CLOUD_TOKEN + 'aaa'
135
136
  ENV['EY_ENVIRONMENT_NAME'] = FAKE_ENVIRONMENT_NAME
136
- end
137
+ EY::Metadata.ey_cloud_token.should == FAKE_CLOUD_TOKEN + 'aaa' # sanity check
138
+ end
137
139
  it_should_behave_like "all execution environments"
138
140
  it_should_behave_like "execution outside the cloud"
139
141
  end
140
142
 
141
143
  describe "controlled with attr writers" do
142
- before(:all) do
143
- EY::Metadata.clear
144
- EY::Metadata.ey_cloud_token = FAKE_CLOUD_TOKEN
144
+ before do
145
+ EY::Metadata.ey_cloud_token = FAKE_CLOUD_TOKEN + 'bbb'
146
+ EY::Metadata.environment_name = FAKE_ENVIRONMENT_NAME
147
+ EY::Metadata.ey_cloud_token.should == FAKE_CLOUD_TOKEN + 'bbb' # sanity check
148
+ end
149
+ it_should_behave_like "all execution environments"
150
+ it_should_behave_like "execution outside the cloud"
151
+ end
152
+
153
+ describe "depending on .eyrc" do
154
+ before do
155
+ FakeFS.activate!
156
+ File.open(EY::Metadata.eyrc_path, 'w') { |f| f.write({'api_token' => FAKE_CLOUD_TOKEN + 'ccc'}.to_yaml) }
145
157
  EY::Metadata.environment_name = FAKE_ENVIRONMENT_NAME
158
+ EY::Metadata.ey_cloud_token.should == FAKE_CLOUD_TOKEN + 'ccc' # sanity check
146
159
  end
147
160
  it_should_behave_like "all execution environments"
148
161
  it_should_behave_like "execution outside the cloud"
@@ -150,13 +163,12 @@ describe 'EY::Metadata' do
150
163
  end
151
164
 
152
165
  describe "being executed on an EngineYard AppCloud (i.e. Amazon EC2) instance" do
153
- before(:all) do
166
+ before do
154
167
  pretend_we_are_on_an_engineyard_appcloud_ec2_instance
155
- # forcibly reload metadata.rb, so that it can extend itself based on its execution environment
156
168
  load File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'engineyard-metadata', 'metadata.rb'))
157
169
  end
158
170
 
159
- after(:all) do
171
+ after do
160
172
  stop_pretending
161
173
  end
162
174
 
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- require 'spec'
2
+ require 'rspec'
3
3
  # require 'ruby-debug'
4
4
  # assumes active-support 3
5
5
  require 'active_support/json/encoding'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engineyard-metadata
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Seamus Abshere
@@ -85,10 +85,10 @@ dependencies:
85
85
  requirements:
86
86
  - - ~>
87
87
  - !ruby/object:Gem::Version
88
- hash: 1
88
+ hash: 7
89
89
  segments:
90
- - 1
91
- version: "1"
90
+ - 2
91
+ version: "2"
92
92
  type: :development
93
93
  version_requirements: *id005
94
94
  description: Pulls metadata from EC2 and EngineYard so that your EngineYard AppCloud (Amazon EC2) instances know about each other.