aide 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +36 -0
- data/Rakefile +1 -0
- data/aide.gemspec +25 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/aide/config.rb +20 -0
- data/lib/aide/error.rb +8 -0
- data/lib/aide/service.rb +34 -0
- data/lib/aide/version.rb +3 -0
- data/lib/aide.rb +25 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7eef3d5522744f8076dc05b1fab9b6bfd26e6b32
|
4
|
+
data.tar.gz: c27b21840a2368f2203e2a2458c308491656f085
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 84b58d501e9107df905d73be6bc374ff8a0ccd017ae3cbfc6d8df4f64f1b3fc8ea7cc96d9466f037dcfa86e03f982b4928c5530b5b9b786c0bfb478d69a2caf8
|
7
|
+
data.tar.gz: 1b1507dd493bb07a06de2b3f61c82bc81bea6c1ee7e8ee17350c247ed948efe30cafa61e7808cd1a10d62496c7ae0fb2555b85660f12fac58c932125cd26117f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Aide
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/aide`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'aide'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install aide
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/aide.
|
36
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/aide.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'aide/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "aide"
|
8
|
+
spec.version = Aide::VERSION
|
9
|
+
spec.authors = ["Ryan Schlesinger"]
|
10
|
+
spec.email = ["ryan@outstand.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A configuration helper for Diplomat}
|
13
|
+
spec.description = %q{Allows a user to mash up keys without multiple calls to Consul}
|
14
|
+
spec.homepage = "https://github.com/outstand/aide"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
|
24
|
+
spec.add_runtime_dependency 'diplomat'
|
25
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "aide"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/aide/config.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Aide
|
2
|
+
class Config
|
3
|
+
attr_accessor :services
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@services = {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def add_service(name:, url:)
|
10
|
+
services[name] = {
|
11
|
+
name: name,
|
12
|
+
url: url
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_service(name:)
|
17
|
+
services[name] || {}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/aide/error.rb
ADDED
data/lib/aide/service.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
module Aide
|
2
|
+
class Service
|
3
|
+
attr_accessor :name
|
4
|
+
|
5
|
+
def initialize(name:)
|
6
|
+
@name = name
|
7
|
+
end
|
8
|
+
|
9
|
+
delegate :Address, :ServiceAddress, :ServicePort, to: :service
|
10
|
+
|
11
|
+
def url
|
12
|
+
template = Aide.config.get_service(name: name)[:url]
|
13
|
+
return if template.nil?
|
14
|
+
|
15
|
+
template = template.dup
|
16
|
+
template.gsub!(/{{\.Address}}/, self.Address.to_s)
|
17
|
+
template.gsub!(/{{\.ServiceAddress}}/, self.ServiceAddress.to_s)
|
18
|
+
template.gsub!(/{{\.ServicePort}}/, self.ServicePort.to_s)
|
19
|
+
|
20
|
+
template
|
21
|
+
end
|
22
|
+
|
23
|
+
def url!
|
24
|
+
self.url.tap do |orig_url|
|
25
|
+
raise MissingService if orig_url.nil?
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def service
|
31
|
+
@service ||= Diplomat::Service.get(name)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/aide/version.rb
ADDED
data/lib/aide.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'aide/version'
|
2
|
+
require 'aide/error'
|
3
|
+
require 'aide/config'
|
4
|
+
require 'aide/service'
|
5
|
+
|
6
|
+
module Aide
|
7
|
+
class << self
|
8
|
+
def services
|
9
|
+
@services ||= {}
|
10
|
+
end
|
11
|
+
attr_writer :services
|
12
|
+
|
13
|
+
def service(name)
|
14
|
+
self.services[name] ||= Aide::Service.new(name: name)
|
15
|
+
end
|
16
|
+
|
17
|
+
def config
|
18
|
+
@config ||= Aide::Config.new
|
19
|
+
end
|
20
|
+
|
21
|
+
def configure(&block)
|
22
|
+
self.config.instance_eval(&block)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aide
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Schlesinger
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: diplomat
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Allows a user to mash up keys without multiple calls to Consul
|
56
|
+
email:
|
57
|
+
- ryan@outstand.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- README.md
|
65
|
+
- Rakefile
|
66
|
+
- aide.gemspec
|
67
|
+
- bin/console
|
68
|
+
- bin/setup
|
69
|
+
- lib/aide.rb
|
70
|
+
- lib/aide/config.rb
|
71
|
+
- lib/aide/error.rb
|
72
|
+
- lib/aide/service.rb
|
73
|
+
- lib/aide/version.rb
|
74
|
+
homepage: https://github.com/outstand/aide
|
75
|
+
licenses: []
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.4.8
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: A configuration helper for Diplomat
|
97
|
+
test_files: []
|