elemeno 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ad83aa3e75e469c0e8d27052e844af2cb6899f80
4
+ data.tar.gz: 815a4ceae23c5cd4eef15348284bead79768c01d
5
+ SHA512:
6
+ metadata.gz: f8dbd87725382774760f856ea3151f61605e84979c3754e40866e9768e93f990cfbc2586c3415f621a8cadd36ee0b24dc425ebab55e0fcb5cb146619a706ccc1
7
+ data.tar.gz: 67ac205dbd3e66cca509878331a199d98b2067543b35fb100b31f1b61f826922742bbfd22bca03ead2517c60d95240d728d1609911f24464f9e90bbebf172877
@@ -0,0 +1,16 @@
1
+ # EditorConfig helps developers define and maintain consistent
2
+ # coding styles between different editors and IDEs
3
+ # editorconfig.org
4
+
5
+ root = true
6
+
7
+ [*]
8
+ end_of_line = lf
9
+ charset = utf-8
10
+ trim_trailing_whitespace = true
11
+ insert_final_newline = true
12
+ indent_style = tab
13
+ indent_size = 4
14
+
15
+ [*.{diff,md}]
16
+ trim_trailing_whitespace = false
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in elemeno.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Elemeno Technology Inc. (https://elemeno.io)
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.
@@ -0,0 +1,150 @@
1
+ # Elemeno
2
+
3
+ The official Ruby client for Elemeno, an API based CMS. Use this module to easily integrate your content created on Elemeno into your Ruby projects.
4
+
5
+ Create an account and get started for free at https://elemeno.io
6
+
7
+ ## Requirements
8
+
9
+ - A minimum of Ruby 1.9.3
10
+ - [Bundler](http://bundler.io/)
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'elemeno'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install elemeno
27
+
28
+ ## Elemeno Documentation
29
+
30
+ Documentation is available at http://docs.elemeno.io
31
+
32
+ ## Usage
33
+
34
+ Include the Elemeno module:
35
+
36
+ ```ruby
37
+ require "elemeno"
38
+ ```
39
+
40
+ Create a new instance of the Elemeno Client with an API Key from your project
41
+
42
+ ```ruby
43
+ elemeno = Elemeno::Client.new('123e4567-e89b-12d3-a456-426655440000')
44
+ ```
45
+
46
+ **Note: API keys can be created in your project settings**
47
+
48
+ ## Example Usage
49
+
50
+ ```ruby
51
+ require "elemeno"
52
+
53
+ elemeno = Elemeno::Client.new('123e4567-e89b-12d3-a456-426655440000')
54
+
55
+ options = {
56
+ 'filters': {
57
+ '$title': {
58
+ '$contains': 'pie'
59
+ }
60
+ },
61
+ 'sort': {
62
+ '$datePublished': 'ASC'
63
+ },
64
+ 'page': 1,
65
+ 'size': 20
66
+ }
67
+
68
+ collectionItems = elemeno.getCollectionItems('recipes', options);
69
+ ```
70
+
71
+ ## API Overview
72
+
73
+ ### Singles
74
+
75
+ #### `elemeno.getSingles([options])`
76
+
77
+ ```ruby
78
+ options = {
79
+ 'sort': {
80
+ '$dateUpdated': 'DESC'
81
+ },
82
+ 'page': 1,
83
+ 'size': 20
84
+ }
85
+
86
+ singles = elemeno.getSingles(options)
87
+ ```
88
+
89
+ #### `elemeno.getSingle(singleSlug)`
90
+
91
+ ```ruby
92
+ single = elemeno.getSingle('about')
93
+ ```
94
+
95
+ ### Collections
96
+
97
+ #### `elemeno.getCollections([options])`
98
+
99
+ ```ruby
100
+ options = {
101
+ 'sort': {
102
+ '$dateCreated': 'DESC'
103
+ },
104
+ 'page': 1,
105
+ 'size': 20
106
+ }
107
+
108
+ collections = `elemeno.getCollections(options)
109
+ ```
110
+
111
+ #### `elemeno.getCollection(collectionSlug)`
112
+
113
+ ```ruby
114
+ collection = `elemeno.getCollection('recipes')
115
+ ```
116
+
117
+ #### `elemeno.getCollectionItems(collectionSlug, [options])`
118
+
119
+ ```ruby
120
+ options = {
121
+ 'filters': {
122
+ '$title': {
123
+ '$contains': 'pie'
124
+ }
125
+ },
126
+ 'sort': {
127
+ '$datePublished': 'ASC'
128
+ },
129
+ 'page': 1,
130
+ 'size': 20
131
+ }
132
+
133
+ collectionItems = elemeno.getCollectionsItems('recipes', options)
134
+ ```
135
+
136
+ #### `elemeno.getCollectionItems(collectionSluge, itemSlug, [options])`
137
+
138
+ ```ruby
139
+ collectionItem = elemeno.getCollectionItem('recipes', 'applie-pie')
140
+ ```
141
+
142
+ or `byId`:
143
+
144
+ ```ruby
145
+ options = {
146
+ 'byId': true
147
+ }
148
+
149
+ collectionItem = elemeno.getCollectionItem('recipes', '281cf9b2-b355-11e6-b10e-5b3ff757fea2', options)
150
+ ```
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'elemeno/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "elemeno"
8
+ spec.version = Elemeno::VERSION
9
+ spec.authors = ["Chris Erwin", "Dave Bobak"]
10
+ spec.email = ["chris@elemeno.io", "dave@elemeno.io"]
11
+
12
+ spec.summary = %q{Elemeno Ruby Client}
13
+ spec.description = %q{Official Ruby Client for Elemeno, an API based CMS.}
14
+ spec.homepage = "https://elemeno.io"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = '>= 1.9'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.13"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+
28
+ spec.add_dependency "faraday", "~> 0.10"
29
+ end
@@ -0,0 +1,74 @@
1
+ require "elemeno/version"
2
+ require "faraday"
3
+ require "json"
4
+
5
+ module Elemeno
6
+ class Client
7
+
8
+ @@singleBase = 'singles/'
9
+ @@collectionBase = 'collections/'
10
+
11
+ def initialize(api_key)
12
+ @conn = Faraday.new :url => 'https://api.elemeno.io/v1/', :headers => {'Authorization' => api_key}
13
+ end
14
+
15
+ private def get(path, query = nil)
16
+ response = @conn.get do |req|
17
+ req.url path
18
+ if query
19
+ req.params = query
20
+ end
21
+ end
22
+
23
+ return JSON.parse(response.body)
24
+ end
25
+
26
+ private def getQuery(options = nil, allow = false)
27
+ query = Hash.new
28
+
29
+ if options && options.is_a?(Hash)
30
+ if options.has_key?(:filters) && allow.is_a?(Array) && allow.include?('filters')
31
+ query['filters'] = options[:filters].to_json
32
+ end
33
+ if options.has_key?(:sort) && allow.is_a?(Array) && allow.include?('sort')
34
+ query['sort'] = options[:sort].to_json
35
+ end
36
+ if options.has_key?(:page)
37
+ query['page'] = options[:page].to_json
38
+ end
39
+ if options.has_key?(:size)
40
+ query['size'] = options[:size].to_json
41
+ end
42
+ if options.has_key?(:byId)
43
+ query['byId'] = (options[:byId].is_a?(TrueClass) || options[:byId] == 'true') ? true : false
44
+ end
45
+ end
46
+
47
+ return query
48
+ end
49
+
50
+ def getSingles(options = nil)
51
+ return get(@@singleBase, getQuery(options, ['sort']))
52
+ end
53
+
54
+ def getSingle(singleSlug)
55
+ return get(@@singleBase + singleSlug)
56
+ end
57
+
58
+ def getCollections(options = nil)
59
+ return get(@@collectionBase, getQuery(options, ['sort']))
60
+ end
61
+
62
+ def getCollection(collectionSlug)
63
+ return get(@@collectionBase + collectionSlug)
64
+ end
65
+
66
+ def getCollectionItems(collectionSlug, options = nil)
67
+ return get(@@collectionBase + collectionSlug + '/items', getQuery(options, ['filters', 'sort']))
68
+ end
69
+
70
+ def getCollectionItem(collectionSlug, itemSlug, options = nil)
71
+ return get(@@collectionBase + collectionSlug + '/items/' + itemSlug, getQuery(options, ['sort']))
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,3 @@
1
+ module Elemeno
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: elemeno
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Chris Erwin
8
+ - Dave Bobak
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2016-12-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.13'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.13'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: faraday
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '0.10'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '0.10'
56
+ description: Official Ruby Client for Elemeno, an API based CMS.
57
+ email:
58
+ - chris@elemeno.io
59
+ - dave@elemeno.io
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".editorconfig"
65
+ - ".gitignore"
66
+ - Gemfile
67
+ - LICENSE.md
68
+ - README.md
69
+ - Rakefile
70
+ - elemeno.gemspec
71
+ - lib/elemeno.rb
72
+ - lib/elemeno/version.rb
73
+ homepage: https://elemeno.io
74
+ licenses:
75
+ - MIT
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: '1.9'
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.6.8
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Elemeno Ruby Client
97
+ test_files: []