contentstack 0.0.2 → 0.0.3

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: ee5dd72d68bfd14e2292a7dd9bd18f0f11fe6091
4
- data.tar.gz: 9903cbb89a02c2775a24a238727203c4d9ec9e10
3
+ metadata.gz: 1ba9cac23e4e20c7af32bb25d788cd226f489bb9
4
+ data.tar.gz: '0903ec191fca15f8664db5c9de793453657b3636'
5
5
  SHA512:
6
- metadata.gz: df87832f6264b3ac38745dd5cd4364e89c61c50f817f1321c979fae7f9d38d1b32a560784abfaf2ceaf9e558b30ebe033290d778b1eeae4bae408e5b03a609aa
7
- data.tar.gz: 9d98b68aae934eef4b344e1d19022d3c2b0ed795013f1023a322182588478d40f73fd6387d3b5887e22921d2620aceb5960b54bf4e9dff1e5caac6c9e32b7b4b
6
+ metadata.gz: '068954e3aac1861e09fe135fbcea77ac2fd528e8e295285bed5286026a1202fbd10f78f9418a7c1c5a8af14f8a9bfa107a7568567b9cb907c09374dae93415c3'
7
+ data.tar.gz: b38b4b0320cf45944edd04c6c0aed62578d9b029141f1b159f0dcf51e778a852623a4e06b270f11fdf5dd21613cdc41386614102c987426da2f9e02c2a202f1b
@@ -0,0 +1,100 @@
1
+ # **Ruby SDK for Contentstack**
2
+
3
+ Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/).
4
+
5
+ Contentstack provides Ruby SDK to build application on top of Ruby on Rails. Given below is the detailed guide and helpful resources to get started with our Ruby SDK.
6
+
7
+ ## **Prerequisite**
8
+
9
+ You need ruby v2.0 or later installed to use the Contentstack Ruby SDK.
10
+
11
+ ## **Setup and Installation**
12
+
13
+ Add the following code to your application's Gemfile and bundle:
14
+
15
+ gem 'contentstack'
16
+
17
+ Or you can run this command in your terminal (you might need administrator privileges to perform this installation):
18
+
19
+ gem install contentstack
20
+
21
+ To start using the SDK in your application, you will need to initialize the stack by providing the values for the keys given in the code snippet below.
22
+
23
+ client = Contentstack::Client.new("site_api_key", "access_token", "enviroment_name")
24
+
25
+ ## **Key Concepts for using Contentstack**
26
+
27
+ ### **Stack**
28
+
29
+ A stack is like a container that holds the content of your app. Learn more about [stacks](https://www.contentstack.com/docs/guide/stack).
30
+
31
+ ### **Content Type**
32
+
33
+ Content type lets you define the structure or blueprint of a page or a section of your digital property. It is a form-like page that gives Content Managers an interface to input and upload content. [Read more](https://www.contentstack.com/docs/guide/content-types).
34
+
35
+ ### **Entry**
36
+
37
+ An entry is the actual piece of content created using one of the defined content types. Learn more about [Entries](https://www.contentstack.com/docs/guide/content-management#working-with-entries).
38
+
39
+ ### **Asset**
40
+
41
+ Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded to Contentstack. These files can be used in multiple entries. Read more about [Assets](https://www.contentstack.com/docs/guide/content-management#working-with-assets).
42
+
43
+ ### **Environment**
44
+
45
+ A publishing environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published. Learn how to work with [Environments](https://www.contentstack.com/docs/guide/environments).
46
+
47
+ ## **Contentstack Ruby SDK: 5-minute Quickstart**
48
+
49
+ ### **Initializing your SDK **
50
+
51
+ To initialize the SDK, you need to provide values for the keys given in the snippet below:
52
+
53
+ stack = Contentstack::Client.new("site_api_key", "access_token", "enviroment_name")
54
+
55
+ To get the API credentials mentioned above, log in to your Contentstack account and then in your top panel navigation, go to Settings > Stack to view the API Key and Access Token.
56
+
57
+ ### **Querying content from your stack**
58
+
59
+ To fetch all entries of of a content type, use the query given below:
60
+
61
+ entry = stack.content_type(<<CONTENT_TYPE_UID>>).query();
62
+
63
+ To fetch a specific entry from a content type, use the following query:
64
+
65
+ entry = stack.content_type(<<CONTENT_TYPE_UID>>).entry(<<ENTRY_UID>>);
66
+
67
+ ## **Advanced Queries**
68
+
69
+ You can query for content types, entries, assets and more using our Ruby API Reference.
70
+
71
+ [Ruby API Reference Doc](http://www.rubydoc.info/gems/contentstack)
72
+
73
+ ## **Working with Images**
74
+
75
+ We have introduced Image Delivery APIs that let you retrieve images and then manipulate and optimize them for your digital properties. It lets you perform a host of other actions such as crop, trim, resize, rotate, overlay, and so on.
76
+
77
+ For example, if you want to crop an image (with width as 300 and height as 400), you simply need to append query parameters at the end of the image URL, such as, https://images.contentstack.io/v3/assets/blteae40eb499811073/bltc5064f36b5855343/59e0c41ac0eddd140d5a8e3e/download?crop=300,400. There are several more parameters that you can use for your images.
78
+
79
+ [Read Image Delivery API documentation](https://www.contentstack.com/docs/apis/image-delivery-api/).
80
+
81
+ SDK functions for Image Delivery API coming soon.
82
+
83
+ ## **Helpful Links**
84
+
85
+ * [Contentstack Website](https://www.contentstack.com)
86
+
87
+ * [Official Documentation](http://contentstack.com/docs)
88
+
89
+ * [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/)
90
+
91
+ ## **The MIT License (MIT)**
92
+
93
+ Copyright © 2012-2017 [Built.io](https://www.built.io/). All Rights Reserved
94
+
95
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
96
+
97
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
98
+
99
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
100
+
@@ -6,8 +6,10 @@ Gem::Specification.new do |s|
6
6
  s.name = %q{contentstack}
7
7
  s.version = Contentstack::VERSION.dup
8
8
  s.date = Time.now
9
- s.authors = [%q{Rohit Sharma}]
10
- s.email = ["rubygems@contentstack.com"]
9
+ s.authors = [%q{Contentstack}]
10
+ s.email = ["support@contentstack.com"]
11
+
12
+ s.required_ruby_version = '>= 2.0'
11
13
 
12
14
  s.license = "MIT"
13
15
  s.homepage = "https://github.com/builtio-contentstack/contentstack-ruby"
@@ -370,6 +370,20 @@ module Contentstack
370
370
  self
371
371
  end
372
372
 
373
+ # Get entries from the specified locale.
374
+ #
375
+ # @param [String] code The locale code of the entry
376
+ #
377
+ # Example
378
+ # @query = @stack.content_type('category').query
379
+ # @query.locale('en-us')
380
+ #
381
+ # @return [Contentstack::Query]
382
+ def locale(code)
383
+ @query[:locale] = code
384
+ self
385
+ end
386
+
373
387
  # Specifies an array of 'only' keys in BASE object that would be 'included' in the response.
374
388
  #
375
389
  # @param [Array] fields Array of the 'only' reference keys to be included in response.
@@ -1,3 +1,3 @@
1
1
  module Contentstack
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -185,4 +185,9 @@ describe Contentstack::Query do
185
185
  data = category_query.or([q1,q2]).fetch
186
186
  expect(data.length).to eq 5
187
187
  end
188
+
189
+ it "should set locale the in the request query" do
190
+ data = product_query.locale('en-us')
191
+ expect(data.query[:locale]).to eq 'en-us'
192
+ end
188
193
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contentstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
- - Rohit Sharma
7
+ - Contentstack
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-11 00:00:00.000000000 Z
11
+ date: 2018-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -68,7 +68,7 @@ dependencies:
68
68
  version: '0'
69
69
  description: Contentstack Ruby client for the Content Delivery API
70
70
  email:
71
- - rubygems@contentstack.com
71
+ - support@contentstack.com
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
@@ -77,7 +77,7 @@ files:
77
77
  - ".yardopts"
78
78
  - CODE_OF_CONDUCT.md
79
79
  - LICENSE.txt
80
- - README.rdoc
80
+ - README.md
81
81
  - contentstack.gemspec
82
82
  - coverage/.last_run.json
83
83
  - coverage/.resultset.json
@@ -148,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
148
  requirements:
149
149
  - - ">="
150
150
  - !ruby/object:Gem::Version
151
- version: '0'
151
+ version: '2.0'
152
152
  required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  requirements:
154
154
  - - ">="
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  version: '0'
157
157
  requirements: []
158
158
  rubyforge_project:
159
- rubygems_version: 2.6.11
159
+ rubygems_version: 2.6.12
160
160
  signing_key:
161
161
  specification_version: 4
162
162
  summary: Contentstack Ruby client for the Content Delivery API
@@ -1,61 +0,0 @@
1
- = Contentstack Ruby SDK
2
-
3
- <i>Use Built.io Contentstack to power content for your Ruby projects</i>
4
-
5
- Create Ruby based applications and use the Ruby SDK to fetch and deliver content from Built.io Contentstack. The SDK uses Content Delivery APIs.
6
-
7
- == Getting Started
8
-
9
- This guide will help you get started with our Ruby SDK to build apps powered by Built.io Contentstack.
10
-
11
- === SDK Installation and Setup
12
-
13
- To use the Ruby SDK, download it using the gem install command
14
-
15
- $ gem install contentstack
16
-
17
- === Initialize SDK
18
-
19
- You will need to specify the API key, Access token, and Environment Name of your stack to initialize the SDK:
20
-
21
- @stack = Contentstack::Client.new("site_api_key", "access_token", "enviroment_name")
22
-
23
- Once you have initialized the SDK, you can start getting content in your app.
24
-
25
- === Basic Queries
26
-
27
- ==== Get a Single Entry
28
-
29
- To get a single entry, you need to specify the content type as well as the uid of the entry.
30
-
31
- entry = @stack.content_type('content_type_uid').entry("entry_uid").fetch
32
- puts entry.get('title') # Use `get` method to retrieve field value by providing a field's unique ID
33
-
34
- ==== Get Multiple Entries
35
-
36
- To retrieve multiple entries of a content type, you need to specify the content type uid. You can also specify search parameters to filter results.
37
-
38
- @query = @stack.content_type('blog').query
39
- @entries = @query.where('title', 'welcome')
40
- .include_schema
41
- .include_count
42
- .fetch
43
-
44
- puts "Total Entries -- #{@entries.count}"
45
- @entries.each{|entry| puts "#{entry.get('title')}" }
46
-
47
-
48
- == API Reference
49
-
50
- Go through our SDK API Reference guide to know about the methods that can be used to query your content in Built.io Contentstack.
51
-
52
- {Read Ruby SDK API Reference Guide}[http://www.rubydoc.info/gems/contentstack/0.0.1]
53
-
54
-
55
- == Example Apps
56
-
57
- To help you get started, we have created some sample applications that are powered by Built.io Contentstack Ruby SDK. Click on any of the links below to read the tutorials of the app, view app demo, or download the code from GitHub.
58
-
59
- {Product Catalog}[#]
60
-
61
- Built.io Contentstack provides Ruby SDK using which you can create applications based on Ruby, or any other web frameworks created using Ruby.