plek 1.7.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +24 -1
- data/lib/plek.rb +9 -0
- data/lib/plek/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -1,4 +1,27 @@
|
|
1
1
|
Plek
|
2
2
|
====
|
3
3
|
|
4
|
-
"Plek" is Afrikaans. It means "Location."
|
4
|
+
"Plek" is Afrikaans. It means "Location." Plek is used to generate the correct hostnames for internal GOV.UK services, eg:
|
5
|
+
|
6
|
+
```ruby
|
7
|
+
Plek.current.find('frontend')
|
8
|
+
```
|
9
|
+
|
10
|
+
returns `https://frontend.production.alphagov.co.uk`. This means we can use this in our code and let our environment configuration figure out the correct hosts for us at runtime.
|
11
|
+
|
12
|
+
Hacking Plek URLs
|
13
|
+
-----------------
|
14
|
+
|
15
|
+
Plek allows one to alter the URI returned using environment variables, eg:
|
16
|
+
|
17
|
+
```shell
|
18
|
+
PLEK_SERVICE_EXAMPLE_CHEESE_THING_URI=http://example.com bundle exec rails s
|
19
|
+
```
|
20
|
+
|
21
|
+
would set
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
Plek.current.find('example-cheese-thing')
|
25
|
+
```
|
26
|
+
|
27
|
+
to `http://example.com`. Underscores in environment variables are converted to dashes in Plek names as demonstrated.
|
data/lib/plek.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'plek/version'
|
2
|
+
require 'uri'
|
2
3
|
|
3
4
|
class Plek
|
4
5
|
class NoConfigurationError < StandardError; end
|
@@ -38,6 +39,14 @@ class Plek
|
|
38
39
|
env_var_or_dev_fallback("GOVUK_WEBSITE_ROOT") { find("www") }
|
39
40
|
end
|
40
41
|
|
42
|
+
def asset_uri
|
43
|
+
URI(asset_root)
|
44
|
+
end
|
45
|
+
|
46
|
+
def website_uri
|
47
|
+
URI(website_root)
|
48
|
+
end
|
49
|
+
|
41
50
|
def name_for(service)
|
42
51
|
name = service.to_s.dup
|
43
52
|
name.downcase!
|
data/lib/plek/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plek
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-06-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -68,7 +68,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
68
|
version: '0'
|
69
69
|
segments:
|
70
70
|
- 0
|
71
|
-
hash:
|
71
|
+
hash: 2827728248884362676
|
72
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
segments:
|
79
79
|
- 0
|
80
|
-
hash:
|
80
|
+
hash: 2827728248884362676
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project:
|
83
83
|
rubygems_version: 1.8.23
|