bcdatabase 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +5 -2
- data/lib/bcdatabase.rb +16 -6
- data/lib/bcdatabase/version.rb +1 -1
- metadata +4 -4
data/CHANGELOG.markdown
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
Bcdatabase history
|
2
2
|
==================
|
3
3
|
|
4
|
-
1.2.
|
4
|
+
1.2.1
|
5
5
|
-----
|
6
|
+
- Generalize `datamapper_adapter` and `jruby_adapter` transforms to
|
7
|
+
work with any similarly prefixed keys. (#15)
|
6
8
|
|
9
|
+
1.2.0
|
10
|
+
-----
|
7
11
|
- Add automatic transform for `jruby_adapter` when running under
|
8
12
|
JRuby. (#14)
|
9
13
|
|
10
14
|
1.1.0
|
11
15
|
-----
|
12
|
-
|
13
16
|
- Introduce "transforms" -- a way to attach behavior to modify entries
|
14
17
|
on load. See {Bcdatabase.load} for details.
|
15
18
|
- Add `:datamapper` built-in transform to support sharing one set of
|
data/lib/bcdatabase.rb
CHANGED
@@ -111,6 +111,20 @@ module Bcdatabase
|
|
111
111
|
##
|
112
112
|
# The set of groups and entries returned by one call to {Bcdatabase.load}.
|
113
113
|
class DatabaseConfigurations
|
114
|
+
##
|
115
|
+
# @return [#call] a transform that copies a prefixed key's value
|
116
|
+
# to the name without the prefix. E.g., the built-in
|
117
|
+
# `:datamapper` transform is `prefix_remove_copy_transform('datamapper_')`.
|
118
|
+
def self.prefix_remove_copy_transform(prefix)
|
119
|
+
lambda { |entry, name, group|
|
120
|
+
entry.merge(
|
121
|
+
entry.keys.select { |k| k =~ /^#{prefix}/ }.inject({}) { |additions, k|
|
122
|
+
additions[k.sub(/^#{prefix}/, '')] = entry[k]; additions
|
123
|
+
}
|
124
|
+
)
|
125
|
+
}
|
126
|
+
end
|
127
|
+
|
114
128
|
BUILT_IN_TRANSFORMS = {
|
115
129
|
:key_defaults => lambda { |entry, name, group|
|
116
130
|
{ 'username' => name, 'database' => name }.merge(entry)
|
@@ -118,12 +132,8 @@ module Bcdatabase
|
|
118
132
|
:decrypt => lambda { |entry, name, group|
|
119
133
|
entry.merge({ 'password' => Bcdatabase.decrypt(entry['epassword']) }) if entry['epassword']
|
120
134
|
},
|
121
|
-
:datamapper =>
|
122
|
-
|
123
|
-
},
|
124
|
-
:jruby => lambda { |entry, name, group|
|
125
|
-
entry.merge('adapter' => entry['jruby_adapter']) if entry['jruby_adapter']
|
126
|
-
}
|
135
|
+
:datamapper => prefix_remove_copy_transform('datamapper_'),
|
136
|
+
:jruby => prefix_remove_copy_transform('jruby_')
|
127
137
|
}
|
128
138
|
|
129
139
|
def self.automatic_transforms
|
data/lib/bcdatabase/version.rb
CHANGED
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:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 1
|
10
|
+
version: 1.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rhett Sutphin
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-09-
|
18
|
+
date: 2011-09-15 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|