kek 0.0.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c8bf295105bd57da842d28df2ccd71f8c59bdd6
4
- data.tar.gz: 2f78a9e154e374192a70a6eebbbc2e91e8e4aff6
3
+ metadata.gz: 13e39bcda807decf7fd8192291f311014cdef419
4
+ data.tar.gz: f23fc4cddefc977d5335edea23566b76cb3fdcc4
5
5
  SHA512:
6
- metadata.gz: 50a0c67d028b336efa202def59a6a02b2599756d7ee7e85ceb771fe67ebb5e93c47cf06c82d4c8b74c0759c348886645f2a3505e91b41a503a4cbb83972f1f1f
7
- data.tar.gz: fd6c0a6c129e105fdfdd7455c427b5cb6162ead299df6727f376d21595a701ccfac81e8d761e8b2b3ffff0a9493d5d84ed62b0eea11d2e9c38f66b3a9971f1f7
6
+ metadata.gz: 2a2eded8f9a7a71354d4fbfe25d6dd3f8fc3e2188dd9036566d682629df2279ff4be2d0af097ec439045c2590fe6560899cbc3ed9eac3f80e23109fc1b00ae68
7
+ data.tar.gz: 434d944c78faf3959da7c6a4cb53d81cb61b320673ee54ef63a1ed5f4a3565811b80c207615458a704ec6727e6d72323a5a55e896d1d9f149c376ad736d433f8
data/README.md CHANGED
@@ -1,3 +1,8 @@
1
1
  # kek
2
2
 
3
- An easy to use [etcd](http://etcd.io) client.
3
+ An easy to use [etcd](http://etcd.io) client. View the full documentation [here](https://github.com/kblanks/kek/wiki).
4
+
5
+ ## Basic Usage
6
+ ```
7
+ $ gem install kek
8
+ ```
@@ -14,10 +14,10 @@ Gem::Specification.new do |spec|
14
14
  spec.license = "MIT"
15
15
 
16
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
17
  spec.require_paths = ["lib"]
20
18
 
19
+ spec.add_dependency "faraday", "~> 0.9.2"
20
+
21
21
  spec.add_development_dependency "bundler", "~> 1.12"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  end
data/lib/kek.rb CHANGED
@@ -1,4 +1,26 @@
1
+ require "faraday"
2
+
3
+ # utilities
1
4
  require "kek/version"
5
+ require "kek/json"
6
+
7
+ # methods
8
+ require "kek/keys"
9
+
10
+ class Kek
11
+
12
+ attr_accessor :client
13
+
14
+ def initialize(url)
15
+ @client = Faraday.new url do |conn|
16
+ conn.request :url_encoded
17
+ conn.use JSONParser
18
+ conn.adapter Faraday.default_adapter
19
+ end
20
+ end
21
+
22
+ def version
23
+ @client.get('/version').body
24
+ end
2
25
 
3
- module Kek
4
26
  end
@@ -0,0 +1,17 @@
1
+ require "json"
2
+
3
+ class Kek
4
+ class JSONParser < Faraday::Middleware
5
+
6
+ def initialize(app)
7
+ super(app)
8
+ end
9
+
10
+ def call(request)
11
+ @app.call(request).on_complete do |response|
12
+ response[:body] = JSON.parse(response[:body], symbolize_names: true)
13
+ end
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ class Kek
2
+
3
+ def set(key, value, opts = {})
4
+ @client.put("/v2/keys/#{key}", opts.merge(value: value)).body[:action] == 'set'
5
+ end
6
+
7
+ def get(key)
8
+ @client.get("/v2/keys/#{key}").body.dig(:node, :value)
9
+ end
10
+
11
+ def delete(key)
12
+ @client.delete("/v2/keys/#{key}").body[:action] == "delete"
13
+ end
14
+
15
+ end
@@ -1,3 +1,3 @@
1
- module Kek
2
- VERSION = "0.0.0"
1
+ class Kek
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kek
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kailan Blanks
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.2
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -54,6 +68,8 @@ files:
54
68
  - bin/setup
55
69
  - kek.gemspec
56
70
  - lib/kek.rb
71
+ - lib/kek/json.rb
72
+ - lib/kek/keys.rb
57
73
  - lib/kek/version.rb
58
74
  homepage: https://github.com/kblanks/kek
59
75
  licenses: