beret 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 +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +23 -0
- data/beret.gemspec +20 -0
- data/lib/beret/hash.rb +52 -0
- data/lib/beret/version.rb +9 -0
- data/lib/beret.rb +11 -0
- metadata +52 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 080b4b65d075cdafbd2c3b47ca269e0ffb96f667
|
4
|
+
data.tar.gz: 79c7eaf729ffe3f9605080eb117743db5fd700be
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 80e88484b46722c3d144acc41f9659d32a818aa42332cf58c627d581f0a96ccc3e63390b8c12b6e715ebbd0f9138ffef96417dce260583f8fd7f93c303c259c7
|
7
|
+
data.tar.gz: a2279ac02496949c267b43315ae24637100a982c8f4fd0877bec82f4e3dc54162fee79523db15a1623d70479be1fb320d9dda79551ab646de3496afa322163da
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Viget
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Beret
|
2
|
+
|
3
|
+
A Ruby utility for consuming and manipulating Colonel Kurtz data
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'beret'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install beret
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Beret lets you easily work with [Colonel Kurtz](https://github.com/vigetlabs/colonel-kurtz)-generated JSON data in your Ruby application.
|
data/beret.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'beret/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "beret"
|
8
|
+
spec.version = Beret::VERSION
|
9
|
+
spec.authors = ["Lawson Kurtz (Viget)"]
|
10
|
+
spec.email = ["lawson.kurtz@viget.com"]
|
11
|
+
|
12
|
+
spec.summary = "Utility for consuming and manipulating Colonel Kurtz data"
|
13
|
+
spec.description = "Easily work with Colonel Kurtz-generated JSON data in your Ruby application"
|
14
|
+
spec.homepage = "https://github.com/vigetlabs/beret"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
end
|
data/lib/beret/hash.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Ruby wrapper for Colonel Kurtz data
|
2
|
+
#
|
3
|
+
# Contents of `data` hash
|
4
|
+
#
|
5
|
+
# type:
|
6
|
+
# block type
|
7
|
+
# string, lower-cased and dashed, e.g. "hero-photo"
|
8
|
+
#
|
9
|
+
# content:
|
10
|
+
# block content
|
11
|
+
# hash
|
12
|
+
#
|
13
|
+
# blocks:
|
14
|
+
# block children
|
15
|
+
# array of `data` hashes
|
16
|
+
#
|
17
|
+
|
18
|
+
module ColonelKurtz
|
19
|
+
class Block
|
20
|
+
|
21
|
+
attr_reader :parent
|
22
|
+
|
23
|
+
def initialize(data)
|
24
|
+
@data = Data.new(data).to_hash
|
25
|
+
end
|
26
|
+
|
27
|
+
def type
|
28
|
+
@type ||= Type.new(data.fetch("type")).to_sym
|
29
|
+
end
|
30
|
+
|
31
|
+
def content
|
32
|
+
@content ||= data.fetch("content", {})
|
33
|
+
end
|
34
|
+
|
35
|
+
def parent
|
36
|
+
@parent ||= data.fetch("parent", nil)
|
37
|
+
end
|
38
|
+
|
39
|
+
def children
|
40
|
+
@children ||= blocks.map{ |data| Block.new(data.merge("parent" => self)) }
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
attr_reader :data
|
47
|
+
|
48
|
+
def blocks
|
49
|
+
data.fetch("blocks", [])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/beret.rb
ADDED
metadata
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: beret
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lawson Kurtz (Viget)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Easily work with Colonel Kurtz-generated JSON data in your Ruby application
|
14
|
+
email:
|
15
|
+
- lawson.kurtz@viget.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- .gitignore
|
21
|
+
- Gemfile
|
22
|
+
- LICENSE.txt
|
23
|
+
- README.md
|
24
|
+
- beret.gemspec
|
25
|
+
- lib/beret.rb
|
26
|
+
- lib/beret/hash.rb
|
27
|
+
- lib/beret/version.rb
|
28
|
+
homepage: https://github.com/vigetlabs/beret
|
29
|
+
licenses:
|
30
|
+
- MIT
|
31
|
+
metadata: {}
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 2.0.2
|
49
|
+
signing_key:
|
50
|
+
specification_version: 4
|
51
|
+
summary: Utility for consuming and manipulating Colonel Kurtz data
|
52
|
+
test_files: []
|