lane_groove 0.0.2 → 0.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/bin/lane_groove +1 -1
- data/lib/{app.rb → lane_groove.rb} +30 -7
- metadata +17 -8
data/bin/lane_groove
CHANGED
@@ -13,6 +13,15 @@ class Hash
|
|
13
13
|
new_hash
|
14
14
|
}
|
15
15
|
end
|
16
|
+
|
17
|
+
def recursive_values
|
18
|
+
self.inject([]){ |new_array, key_value|
|
19
|
+
key, value = key_value
|
20
|
+
value = value.recursive_values if value.is_a?(Hash)
|
21
|
+
new_array << value
|
22
|
+
new_array.flatten
|
23
|
+
}
|
24
|
+
end
|
16
25
|
end
|
17
26
|
|
18
27
|
class LaneGroove < Sinatra::Base
|
@@ -36,10 +45,11 @@ class LaneGroove < Sinatra::Base
|
|
36
45
|
|
37
46
|
def content_type_for(format)
|
38
47
|
{
|
39
|
-
:json =>
|
40
|
-
:xml
|
41
|
-
:yaml =>
|
42
|
-
:rb
|
48
|
+
:json => {'Content-Type' => 'application/json; charset=utf-8'},
|
49
|
+
:xml => {'Content-Type' => 'application/xml; charset=utf-8'},
|
50
|
+
:yaml => {'Content-Type' => 'application/x-yaml; charset=utf-8'},
|
51
|
+
:rb => {'Content-Type' => 'application/x-ruby; charset=utf-8'},
|
52
|
+
:line => {'Content-Type' => 'application/x-line; charset=utf-8'}
|
43
53
|
}[format]
|
44
54
|
end
|
45
55
|
|
@@ -65,13 +75,26 @@ class LaneGroove < Sinatra::Base
|
|
65
75
|
|
66
76
|
return cfg
|
67
77
|
end
|
78
|
+
|
79
|
+
def parse_path(path)
|
80
|
+
path.split('/').delete_if{|n| n.empty?}.compact.map{|n| n.to_sym}
|
81
|
+
end
|
82
|
+
def extract_values(path)
|
83
|
+
path.is_a?(Hash) ? path.recursive_values : path
|
84
|
+
end
|
68
85
|
end
|
69
86
|
|
70
|
-
|
87
|
+
before do
|
71
88
|
reload_yaml if params['reload']
|
72
|
-
|
89
|
+
end
|
90
|
+
|
91
|
+
get /^(.*)\.line$/ do |paths|
|
92
|
+
[200, content_type_for(:line), paths.split(',').map{ |path| extract_values config(*parse_path(path)) }.flatten.join(params['F'] || ' ')]
|
93
|
+
end
|
94
|
+
|
95
|
+
get /^(.*)\.([\w\d]{2,4})$/ do |path, ext|
|
73
96
|
ext = ext.to_sym
|
74
|
-
path = path
|
97
|
+
path = parse_path(path)
|
75
98
|
|
76
99
|
case ext
|
77
100
|
when :yaml then [200, content_type_for(:yaml), config(*path).to_yaml]
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: lane_groove
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Niko
|
@@ -11,8 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2011-
|
15
|
-
default_executable:
|
14
|
+
date: 2011-10-28 00:00:00 Z
|
16
15
|
dependencies:
|
17
16
|
- !ruby/object:Gem::Dependency
|
18
17
|
name: xml-simple
|
@@ -48,7 +47,7 @@ dependencies:
|
|
48
47
|
type: :runtime
|
49
48
|
version_requirements: *id003
|
50
49
|
- !ruby/object:Gem::Dependency
|
51
|
-
name:
|
50
|
+
name: foreverb
|
52
51
|
prerelease: false
|
53
52
|
requirement: &id004 !ruby/object:Gem::Requirement
|
54
53
|
none: false
|
@@ -56,8 +55,19 @@ dependencies:
|
|
56
55
|
- - ">="
|
57
56
|
- !ruby/object:Gem::Version
|
58
57
|
version: "0"
|
59
|
-
type: :
|
58
|
+
type: :runtime
|
60
59
|
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: rack-test
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
type: :development
|
70
|
+
version_requirements: *id005
|
61
71
|
description: A small HTTP configuration server. Eats YAML, returns JSON, XML, YAML and rb. Restricts requests to local subnet.
|
62
72
|
email: mail@niko-dittmann.com
|
63
73
|
executables:
|
@@ -68,11 +78,10 @@ extensions: []
|
|
68
78
|
extra_rdoc_files: []
|
69
79
|
|
70
80
|
files:
|
71
|
-
- lib/
|
81
|
+
- lib/lane_groove.rb
|
72
82
|
- test/lane_groove_test.rb
|
73
83
|
- bin/lane_groove
|
74
84
|
- bin/lane_groove_test
|
75
|
-
has_rdoc: true
|
76
85
|
homepage: http://github.com/niko/lane_groove
|
77
86
|
licenses: []
|
78
87
|
|
@@ -96,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
105
|
requirements: []
|
97
106
|
|
98
107
|
rubyforge_project: nowarning
|
99
|
-
rubygems_version: 1.
|
108
|
+
rubygems_version: 1.8.11
|
100
109
|
signing_key:
|
101
110
|
specification_version: 3
|
102
111
|
summary: A small HTTP configuration server. Eats YAML, returns JSON, XML, YAML and rb. Restricts requests to local subnet.
|