cncflora_commons 0.0.4 → 0.0.5
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/lib/cncflora_commons.rb +37 -5
- metadata +12 -8
- checksums.yaml +0 -7
data/lib/cncflora_commons.rb
CHANGED
@@ -82,20 +82,52 @@ def flatten(obj)
|
|
82
82
|
flat
|
83
83
|
end
|
84
84
|
|
85
|
-
def etcd2config(server)
|
85
|
+
def etcd2config(server,prefix)
|
86
86
|
config = flatten( http_get("#{server}/v2/keys/?recursive=true")["node"] )
|
87
87
|
config.keys.each {|k|
|
88
|
-
if k.to_s.end_with?
|
89
|
-
config[k.to_s.gsub("_url","").to_sym] = config[k]
|
88
|
+
if k.to_s.start_with?(prefix) && k.to_s.end_with?("_url") then
|
89
|
+
config[k.to_s.gsub(prefix,"").gsub("_url","").to_sym] = config[k]
|
90
90
|
end
|
91
91
|
}
|
92
92
|
config
|
93
93
|
end
|
94
94
|
|
95
|
-
def etcd2settings(server)
|
96
|
-
config = etcd2config(server)
|
95
|
+
def etcd2settings(server,prefix)
|
96
|
+
config = etcd2config(server,prefix)
|
97
97
|
config.keys.each { |key| set key, config[key] }
|
98
98
|
set :config, config
|
99
99
|
config
|
100
100
|
end
|
101
101
|
|
102
|
+
def setup(file)
|
103
|
+
config_file file
|
104
|
+
|
105
|
+
use Rack::Session::Pool
|
106
|
+
set :session_secret, '1flora2'
|
107
|
+
set :views, 'src/views'
|
108
|
+
|
109
|
+
if ENV["DB"] then
|
110
|
+
set :db, ENV["DB"]
|
111
|
+
end
|
112
|
+
|
113
|
+
if ENV["CONTEXT"] then
|
114
|
+
set :context, ENV["CONTEXT"]
|
115
|
+
end
|
116
|
+
|
117
|
+
if ENV["PREFIX"] then
|
118
|
+
set :prefix, "#{ENV["PREFIX"]}_"
|
119
|
+
else
|
120
|
+
set :prefix, ""
|
121
|
+
end
|
122
|
+
|
123
|
+
config = etcd2settings(ENV["ETCD"] || settings.etcd,settings.prefix)
|
124
|
+
|
125
|
+
config[:strings] = JSON.parse(File.read("src/locales/#{settings.lang}.json", :encoding => "BINARY"))
|
126
|
+
config[:elasticsearch] = "#{config[:datahub]}/#{settings.db}"
|
127
|
+
config[:couchdb] = "#{ config[:datahub] }/#{settings.db}"
|
128
|
+
config[:base] = settings.base
|
129
|
+
config[:context] = settings.context
|
130
|
+
|
131
|
+
config.keys.each { |key| set key, config[key] }
|
132
|
+
end
|
133
|
+
|
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cncflora_commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Diogo Silva
|
@@ -14,15 +15,17 @@ dependencies:
|
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: rspec
|
16
17
|
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
17
19
|
requirements:
|
18
|
-
- -
|
20
|
+
- - ! '>='
|
19
21
|
- !ruby/object:Gem::Version
|
20
22
|
version: '0'
|
21
23
|
type: :development
|
22
24
|
prerelease: false
|
23
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
24
27
|
requirements:
|
25
|
-
- -
|
28
|
+
- - ! '>='
|
26
29
|
- !ruby/object:Gem::Version
|
27
30
|
version: '0'
|
28
31
|
description: HTTP, etcd...
|
@@ -35,25 +38,26 @@ files:
|
|
35
38
|
homepage: https://github.com/CNCFlora/cncflora-commons
|
36
39
|
licenses:
|
37
40
|
- Apache License 2.0
|
38
|
-
metadata: {}
|
39
41
|
post_install_message:
|
40
42
|
rdoc_options: []
|
41
43
|
require_paths:
|
42
44
|
- lib
|
43
45
|
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
44
47
|
requirements:
|
45
|
-
- -
|
48
|
+
- - ! '>='
|
46
49
|
- !ruby/object:Gem::Version
|
47
50
|
version: '0'
|
48
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
49
53
|
requirements:
|
50
|
-
- -
|
54
|
+
- - ! '>='
|
51
55
|
- !ruby/object:Gem::Version
|
52
56
|
version: '0'
|
53
57
|
requirements: []
|
54
58
|
rubyforge_project:
|
55
|
-
rubygems_version:
|
59
|
+
rubygems_version: 1.8.23
|
56
60
|
signing_key:
|
57
|
-
specification_version:
|
61
|
+
specification_version: 3
|
58
62
|
summary: CNCFlora common functions
|
59
63
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 11008103bba7b72fb22d4bc550b194855802f77d
|
4
|
-
data.tar.gz: 66d19d780352857ad916100fa9a079c7bcc13613
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: c0a3301bb6713bc04070df35d5fa57aaf9133133575ba06c535518b5d215b0d3c7ee18e91ede83b25890d99336fc2f4a765bfea971a323f418791f3ed4ea88ea
|
7
|
-
data.tar.gz: 4ef2290fd899c22560678ee43e5394c17cb68c13c377f6fd8647efe056310ecd636411c58e8f5b86e9dbc544f9bf2eeaf49ded33770a2ba000ae62c7c382c543
|