bcdatabase 1.0.2 → 1.0.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.
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,7 @@
1
+ 1.0.3
2
+ =====
3
+ - Support ActiveSupport 3. ActiveSupport 2 continues to work.
4
+
1
5
  1.0.2
2
6
  =====
3
7
  - Tighten up gemspec gem deps. Bcdatabase does not currently work
data/README.markdown CHANGED
@@ -5,8 +5,6 @@ bcdatabase
5
5
 
6
6
  ## Installing bcdatabase
7
7
 
8
- Ensure that [gemcutter](http://gemcutter.org) is in your gem sources list, then:
9
-
10
8
  $ gem install bcdatabase
11
9
 
12
10
  ## Using bcdatabase to configure the database for a Rails application
data/lib/bcdatabase.rb CHANGED
@@ -4,10 +4,6 @@ require 'digest/sha2'
4
4
  require 'base64'
5
5
 
6
6
  module Bcdatabase
7
- VERSION = begin
8
- config = YAML.load(File.read(File.expand_path('../VERSION.yml', File.dirname(__FILE__))))
9
- [config[:major], config[:minor], config[:patch]].join('.')
10
- end
11
7
  DEFAULT_BASE_PATH = File.join('/', 'etc', 'nubic', 'db')
12
8
  DEFAULT_PASS_FILE = File.join('/', 'var', 'lib', 'nubic', 'db.pass')
13
9
  CIPHER = 'aes-256-ecb'
@@ -113,4 +109,4 @@ module Bcdatabase
113
109
  end
114
110
 
115
111
  class Error < Exception; end
116
- end unless defined?(Bcdatabase)
112
+ end
@@ -0,0 +1,3 @@
1
+ module Bcdatabase
2
+ VERSION = '1.0.3'
3
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bcdatabase
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
5
- prerelease: false
4
+ hash: 17
5
+ prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 2
10
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rhett Sutphin
@@ -15,23 +15,23 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-08 00:00:00 -05:00
19
- default_executable: bcdatabase
18
+ date: 2011-02-03 00:00:00 -06:00
19
+ default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: rspec
22
+ name: activesupport
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 11
29
+ hash: 3
30
30
  segments:
31
- - 1
32
31
  - 2
33
- version: "1.2"
34
- type: :development
32
+ - 0
33
+ version: "2.0"
34
+ type: :runtime
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: highline
@@ -49,19 +49,19 @@ dependencies:
49
49
  type: :runtime
50
50
  version_requirements: *id002
51
51
  - !ruby/object:Gem::Dependency
52
- name: activesupport
52
+ name: rspec
53
53
  prerelease: false
54
54
  requirement: &id003 !ruby/object:Gem::Requirement
55
55
  none: false
56
56
  requirements:
57
57
  - - ~>
58
58
  - !ruby/object:Gem::Version
59
- hash: 3
59
+ hash: 11
60
60
  segments:
61
+ - 1
61
62
  - 2
62
- - 0
63
- version: "2.0"
64
- type: :runtime
63
+ version: "1.2"
64
+ type: :development
65
65
  version_requirements: *id003
66
66
  description: bcdatabase is a tool for storing passwords and other database configuration information outside of your application source tree.
67
67
  email: rhett@detailedbalance.net
@@ -69,30 +69,23 @@ executables:
69
69
  - bcdatabase
70
70
  extensions: []
71
71
 
72
- extra_rdoc_files:
73
- - LICENSE
74
- - README.markdown
72
+ extra_rdoc_files: []
73
+
75
74
  files:
76
- - .gitignore
77
- - .rvmrc
78
75
  - CHANGELOG.markdown
79
76
  - LICENSE
80
77
  - README.markdown
81
- - Rakefile
82
- - VERSION.yml
83
78
  - bin/bcdatabase
84
- - lib/bcdatabase.rb
85
79
  - lib/bcdatabase/commands.rb
86
- - spec/bcdatabase/commands_spec.rb
87
- - spec/bcdatabase_spec.rb
88
- - spec/spec_helper.rb
80
+ - lib/bcdatabase/version.rb
81
+ - lib/bcdatabase.rb
89
82
  has_rdoc: true
90
83
  homepage: http://github.com/rsutphin/bcdatabase
91
84
  licenses: []
92
85
 
93
86
  post_install_message:
94
- rdoc_options:
95
- - --charset=UTF-8
87
+ rdoc_options: []
88
+
96
89
  require_paths:
97
90
  - lib
98
91
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -116,11 +109,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
109
  requirements: []
117
110
 
118
111
  rubyforge_project:
119
- rubygems_version: 1.3.7
112
+ rubygems_version: 1.5.0
120
113
  signing_key:
121
114
  specification_version: 3
122
115
  summary: Server-central database configuration for rails and other ruby apps
123
- test_files:
124
- - spec/bcdatabase/commands_spec.rb
125
- - spec/bcdatabase_spec.rb
126
- - spec/spec_helper.rb
116
+ test_files: []
117
+
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- *.gemspec
2
- pkg
3
- coverage
data/.rvmrc DELETED
@@ -1,2 +0,0 @@
1
- rvm use ruby-1.8.7@bcdatabase
2
-
data/Rakefile DELETED
@@ -1,53 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "bcdatabase"
8
- gem.summary = %Q{Server-central database configuration for rails and other ruby apps}
9
- gem.description = %Q{bcdatabase is a tool for storing passwords and other database configuration information outside of your application source tree.}
10
- gem.email = "rhett@detailedbalance.net"
11
- gem.homepage = "http://github.com/rsutphin/bcdatabase"
12
- gem.authors = ["Rhett Sutphin"]
13
- gem.add_development_dependency 'rspec', ">= 1.2"
14
- gem.add_dependency 'highline', '~> 1.6'
15
- gem.add_dependency 'activesupport', '~> 2.0'
16
- end
17
- Jeweler::GemcutterTasks.new
18
- rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
- end
21
-
22
- require 'spec/rake/spectask'
23
- Spec::Rake::SpecTask.new(:spec) do |spec|
24
- spec.libs << 'lib' << 'spec'
25
- spec.spec_files = FileList['spec/**/*_spec.rb']
26
- end
27
-
28
- Spec::Rake::SpecTask.new(:rcov) do |spec|
29
- spec.libs << 'lib' << 'spec'
30
- spec.pattern = 'spec/**/*_spec.rb'
31
- spec.rcov = true
32
- # rcov can't tell that /Library/Ruby is a system path
33
- spec.rcov_opts = ['--exclude', "spec/*,/Library/Ruby/*"]
34
- end
35
-
36
- task :spec => :check_dependencies
37
-
38
- task :default => :spec
39
-
40
- require 'rake/rdoctask'
41
- Rake::RDocTask.new do |rdoc|
42
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
43
-
44
- rdoc.rdoc_dir = 'rdoc'
45
- rdoc.title = "schema_qualified_tables #{version}"
46
- rdoc.rdoc_files.include('README*')
47
- rdoc.rdoc_files.include('lib/**/*.rb')
48
- end
49
-
50
- # Disable github release since I don't want to commit the gemspec
51
- Rake::Task[:release].prerequisites.delete 'github:release'
52
-
53
- task :build => [:gemspec]
data/VERSION.yml DELETED
@@ -1,5 +0,0 @@
1
- ---
2
- :major: 1
3
- :minor: 0
4
- :build:
5
- :patch: 2
@@ -1,55 +0,0 @@
1
- require File.expand_path("../spec_helper", File.dirname(__FILE__))
2
-
3
- require "bcdatabase/commands"
4
-
5
- describe "CLI: bcdatabase" do
6
- before(:each) do
7
- ENV["BCDATABASE_PATH"] = "/tmp/bcdb_specs"
8
- FileUtils.mkdir_p ENV["BCDATABASE_PATH"]
9
- end
10
-
11
- after(:each) do
12
- FileUtils.rm_rf ENV["BCDATABASE_PATH"]
13
- ENV["BCDATABASE_PATH"] = nil
14
- end
15
-
16
- describe "encrypt" do
17
- before do
18
- enable_fake_cipherment
19
- end
20
-
21
- after do
22
- disable_fake_cipherment
23
- end
24
-
25
- def bcdatabase_encrypt(infile)
26
- StringIO.open("", "w") do |io|
27
- $stdout = io
28
- Bcdatabase::Commands::Encrypt.new([File.join(ENV["BCDATABASE_PATH"], infile)]).main
29
- $stdout = STDOUT
30
- YAML::load(io.string)
31
- end
32
- end
33
-
34
- it "replaces password: clauses with epasswords" do
35
- temporary_yaml "plain", {
36
- "single" => {
37
- "password" => 'zanzibar'
38
- }
39
- }
40
-
41
- bcdatabase_encrypt('plain.yaml')['single']['epassword'].should == 'rabiznaz'
42
- bcdatabase_encrypt('plain.yaml')['single']['password'].should be_nil
43
- end
44
-
45
- it "leaves existing epasswords alone" do
46
- temporary_yaml "plain", {
47
- "single" => {
48
- "epassword" => 'etalocohc'
49
- }
50
- }
51
-
52
- bcdatabase_encrypt('plain.yaml')['single']['epassword'].should == 'etalocohc'
53
- end
54
- end
55
- end
@@ -1,264 +0,0 @@
1
- require File.expand_path("spec_helper", File.dirname(__FILE__))
2
-
3
- describe Bcdatabase do
4
- it "should have a d.d.d version" do
5
- Bcdatabase::VERSION.should =~ /^\d+\.\d+\.\d+$/
6
- end
7
-
8
- before(:each) do
9
- ENV["BCDATABASE_PATH"] = "/tmp/bcdb_specs"
10
- FileUtils.mkdir_p ENV["BCDATABASE_PATH"]
11
- end
12
-
13
- after(:each) do
14
- FileUtils.rm_rf ENV["BCDATABASE_PATH"]
15
- ENV["BCDATABASE_PATH"] = nil
16
- end
17
-
18
- describe "cipherment" do
19
- before(:all) do
20
- keyfile = "/tmp/bcdb-spec-key"
21
- open(keyfile, 'w') { |f| f.write "01234567890123456789012345678901" }
22
- ENV["BCDATABASE_PASS"] = keyfile
23
- end
24
-
25
- after(:all) do
26
- FileUtils.rm ENV["BCDATABASE_PASS"]
27
- ENV["BCDATABASE_PASS"] = nil
28
- end
29
-
30
- it "should be reversible" do
31
- e = Bcdatabase.encrypt("riboflavin")
32
- Bcdatabase.decrypt(e).should == "riboflavin"
33
- end
34
-
35
- it "should permute the input" do
36
- Bcdatabase.encrypt("zanzibar").should_not == "zanzibar"
37
- end
38
-
39
- it "should do more than just encode" do
40
- Bcdatabase.encrypt("zanzibar").should_not == Base64.encode64("zanzibar")
41
- end
42
- end
43
-
44
- describe "loading" do
45
- it "should read simple YAML" do
46
- temporary_yaml "simple", {
47
- "single" => {
48
- "adapter" => "foo", "username" => "baz"
49
- }
50
- }
51
- bcdb = Bcdatabase.load
52
- bcdb[:simple, :single]['adapter'].should == "foo"
53
- bcdb[:simple, :single]['username'].should == "baz"
54
- end
55
-
56
- it "should read and expose multiple groups from multiple files" do
57
- temporary_yaml "one", {
58
- "first" => { "dc" => "etc" }
59
- }
60
- temporary_yaml "two", {
61
- "fourth" => { "dc" => "etc" }
62
- }
63
- bcdb = Bcdatabase.load
64
- bcdb['one', 'first'].should_not be_nil
65
- bcdb['two', 'fourth'].should_not be_nil
66
- end
67
-
68
- it "should merge defaults from 'defaults'" do
69
- temporary_yaml "defaulted", {
70
- "defaults" => {
71
- "database" => "postgresql"
72
- },
73
- "real" => {
74
- "password" => "frood"
75
- }
76
- }
77
- bcdb = Bcdatabase.load
78
- bcdb['defaulted', 'real']['password'].should == 'frood'
79
- bcdb['defaulted', 'real']['database'].should == 'postgresql'
80
- end
81
-
82
- it "should merge defaults from 'default'" do
83
- temporary_yaml "singular", {
84
- "default" => {
85
- "adapter" => "three-eighths"
86
- },
87
- "real" => {
88
- "password" => "frood"
89
- }
90
- }
91
- bcdb = Bcdatabase.load
92
- bcdb['singular', 'real']['adapter'].should == 'three-eighths'
93
- end
94
-
95
- it "should preserve values overridden from defaults" do
96
- temporary_yaml "jam", {
97
- "default" => {
98
- "adapter" => "three-eighths"
99
- },
100
- "standard" => {
101
- "password" => "frood"
102
- },
103
- "custom" => {
104
- "adapter" => "five-sixteenths",
105
- "password" => "lazlo"
106
- }
107
- }
108
- bcdb = Bcdatabase.load
109
- bcdb['jam', 'standard']['adapter'].should == 'three-eighths'
110
- bcdb['jam', 'custom']['adapter'].should == 'five-sixteenths'
111
- end
112
-
113
- it "should default the username to the entry name" do
114
- temporary_yaml "scran", {
115
- "jim" => { "password" => "leather" }
116
- }
117
- bcdb = Bcdatabase.load
118
- bcdb['scran', 'jim']['username'].should == 'jim'
119
- bcdb['scran', 'jim']['password'].should == 'leather'
120
- end
121
-
122
- it "should default the database name to the entry name" do
123
- temporary_yaml "scran", {
124
- "jim" => { "password" => "leather" }
125
- }
126
- bcdb = Bcdatabase.load
127
- bcdb['scran', 'jim']['database'].should == 'jim'
128
- bcdb['scran', 'jim']['password'].should == 'leather'
129
- end
130
-
131
- it "should not default the database name if there's an explicit database name" do
132
- temporary_yaml "scran", {
133
- "jim" => {
134
- "password" => "leather",
135
- "database" => "james"
136
- }
137
- }
138
- bcdb = Bcdatabase.load
139
- bcdb['scran', 'jim']['database'].should == 'james'
140
- bcdb['scran', 'jim']['password'].should == 'leather'
141
- end
142
-
143
- it "should not default the database name to the entry name if there's a default database name" do
144
- temporary_yaml "scran", {
145
- "default" => {
146
- "database" => "//localhost:345/etc"
147
- },
148
- "jim" => {
149
- "password" => "leather",
150
- }
151
- }
152
- bcdb = Bcdatabase.load
153
- bcdb['scran', 'jim']['database'].should == '//localhost:345/etc'
154
- bcdb['scran', 'jim']['password'].should == 'leather'
155
- end
156
-
157
- it "should use an explicit username instead of the entry name if provided" do
158
- temporary_yaml "scran", {
159
- "jim" => {
160
- "username" => "james",
161
- "password" => "earldom"
162
- }
163
- }
164
- bcdb = Bcdatabase.load
165
- bcdb['scran', 'jim']['username'].should == 'james'
166
- bcdb['scran', 'jim']['password'].should == 'earldom'
167
- end
168
-
169
- describe "with encrypted passwords" do
170
- before do
171
- enable_fake_cipherment
172
- end
173
-
174
- after do
175
- disable_fake_cipherment
176
- end
177
-
178
- it "should decrypt and expose the password" do
179
- temporary_yaml "secure", {
180
- "safe" => {
181
- "epassword" => "moof"
182
- }
183
- }
184
- bcdb = Bcdatabase.load
185
- bcdb['secure', 'safe']['password'].should == "foom"
186
- end
187
-
188
- it "should prefer the decrypted version of an epassword" do
189
- temporary_yaml "secure", {
190
- "safe" => {
191
- "password" => "fake",
192
- "epassword" => "moof"
193
- }
194
- }
195
- bcdb = Bcdatabase.load
196
- bcdb['secure', 'safe']['password'].should == "foom" # not "fake"
197
- end
198
- end
199
- end
200
-
201
- describe "for database.yml" do
202
- before do
203
- temporary_yaml "scran", {
204
- "jim" => {
205
- "username" => "james",
206
- "password" => "earldom"
207
- },
208
-
209
- "dwide" => {
210
- "username" => "dwight",
211
- "password" => "help"
212
- }
213
- }
214
- @bcdb = Bcdatabase.load
215
- end
216
-
217
- describe "the yaml for a valid reference" do
218
- before do
219
- @yaml = @bcdb.development(:scran, :jim)
220
- @actual = YAML.load(@yaml)
221
- end
222
-
223
- it "isn't a separated YAML doc" do
224
- @yaml.should_not =~ /---/
225
- end
226
-
227
- it "has a single top-level key" do
228
- @actual.keys.should have(1).key
229
- @actual.should have_key("development")
230
- end
231
-
232
- it "reflects the selected configuration" do
233
- @actual['development']['username'].should == 'james'
234
- @actual['development']['password'].should == 'earldom'
235
- end
236
- end
237
-
238
- describe "an invalid reference" do
239
- before do
240
- ::RAILS_ENV = "staging"
241
- end
242
-
243
- after do
244
- Object.class_eval { remove_const "RAILS_ENV" }
245
- end
246
-
247
- describe "for the current RAILS_ENV" do
248
- it "allows the exception through" do
249
- lambda { @bcdb.staging(:scran, :phil) }.should raise_error
250
- end
251
- end
252
-
253
- describe "for a different RAILS_ENV" do
254
- it "does not throw an exception" do
255
- lambda { @bcdb.production(:scran, :phil) }.should_not raise_error
256
- end
257
-
258
- it "includes the error in the resulting hash" do
259
- @bcdb.production(:scran, :phil).should =~ / error: No database entry for \"phil\" in scran/
260
- end
261
- end
262
- end
263
- end
264
- end
data/spec/spec_helper.rb DELETED
@@ -1,32 +0,0 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'bcdatabase'
4
- require 'rubygems'
5
- require 'fileutils'
6
-
7
- def temporary_yaml(name, hash)
8
- filename = "/#{ENV['BCDATABASE_PATH']}/#{name}.yaml"
9
- open(filename, "w") { |f| YAML.dump(hash, f) }
10
- filename
11
- end
12
-
13
- def enable_fake_cipherment
14
- # replace real encryption methods with something predictable
15
- Bcdatabase.module_eval do
16
- class << self
17
- alias :encrypt_original :encrypt
18
- alias :decrypt_original :decrypt
19
- def encrypt(s); s.reverse; end
20
- def decrypt(s); s.reverse; end
21
- end
22
- end
23
- end
24
-
25
- def disable_fake_cipherment
26
- Bcdatabase.module_eval do
27
- class << self
28
- alias :encrypt :encrypt_original
29
- alias :decrypt :decrypt_original
30
- end
31
- end
32
- end