Skip to content

Commit d930b31

Browse files
authored
Merge pull request #12 from contentstack/publish_fallback
Publish fallback
2 parents 1b60742 + 161f6e1 commit d930b31

37 files changed

Lines changed: 6146 additions & 5369 deletions

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
11
## CHANGELOG
22
------------------------------------------------
33

4+
## Version 0.2.0
5+
6+
### New Features
7+
- Entry
8+
- locale - function for passing locale is added
9+
- only - function for getting only specified field
10+
- except - function for getting field except specified field
11+
- include_reference - function for including reference in entry
12+
- include_schema - function for including schema along with entry added
13+
- include_content_type - function for including content type details along with entry added
14+
- include_owner - function for getting owner of entry
15+
- include_fallback - function for getting published fallback locale content, if specified locale content is not published
16+
17+
- Query
18+
- include_fallback - function for getting published fallback locale content, if specified locale content is not published
19+
20+
21+
------------------------------------------------
22+
423
## Version 0.1.0
524

625
### Bug

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ include:
2222

2323
Examples of unacceptable behavior by participants include:
2424

25-
* The use of sexualized language or imagery and unwelcome sexual attention or
26-
advances
25+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
2726
* Trolling, insulting/derogatory comments, and personal or political attacks
2827
* Public or private harassment
2928
* Publishing others' private information, such as a physical or electronic

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ source "https://rubygems.org"
44
gem "rspec"
55
gem "webmock"
66
gem "simplecov"
7-
gem "activesupport"
7+
gem "activesupport"
8+
gem "yard"

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ GEM
4444
addressable (>= 2.3.6)
4545
crack (>= 0.3.2)
4646
hashdiff (>= 0.4.0, < 2.0.0)
47+
yard (0.9.25)
4748
zeitwerk (2.3.0)
4849

4950
PLATFORMS
@@ -54,6 +55,7 @@ DEPENDENCIES
5455
rspec
5556
simplecov
5657
webmock
58+
yard
5759

5860
BUNDLED WITH
5961
2.1.4

README.md

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# **Ruby SDK for Contentstack**
32

43
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/).
@@ -22,16 +21,13 @@ Or you can run this command in your terminal (you might need administrator privi
2221
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.
2322

2423
# with default region
25-
client = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name")
24+
client = Contentstack::Client.new("api_key", "delivery_token", "enviroment_name")
2625

2726
# with specific region
28-
client = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name",{"region": Contentstack::Region::EU})
27+
client = Contentstack::Client.new("api_key", "delivery_token", "enviroment_name",{"region": Contentstack::Region::EU})
2928

3029
# with custom host
31-
client = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name",{"host": "https://custom-cdn.contentstack.com"})
32-
33-
34-
30+
client = Contentstack::Client.new("api_key", "delivery_token", "enviroment_name",{"host": "https://custom-cdn.contentstack.com"})
3531

3632
## **Key Concepts for using Contentstack**
3733

@@ -57,11 +53,11 @@ A publishing environment corresponds to one or more deployment servers or a cont
5753

5854
## **Contentstack Ruby SDK: 5-minute Quickstart**
5955

60-
### **Initializing your SDK **
56+
### **Initializing your SDK**
6157

6258
To initialize the SDK, you need to provide values for the keys given in the snippet below:
6359

64-
stack = Contentstack::Client.new("site_api_key", "delivery_token", "enviroment_name")
60+
stack = Contentstack::Client.new("api_key", "delivery_token", "enviroment_name")
6561

6662
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.
6763

@@ -75,12 +71,39 @@ To fetch a specific entry from a content type, use the following query:
7571

7672
entry = stack.content_type(<<CONTENT_TYPE_UID>>).entry(<<ENTRY_UID>>);
7773

74+
### Get Multiple Entries
75+
To retrieve multiple entries of a content type, specify the content type UID. You can also specify search parameters to filter results:
76+
77+
@query = @stack.content_type('blog').query
78+
@entries = @query.where('title', 'welcome')
79+
.include_schema
80+
.include_count
81+
.fetch
82+
puts "Total Entries -- #{@entries.count}"
83+
@entries.each{|entry| puts "#{entry.get('title')}" }
84+
To retrieve localized versions of entries, you can use the query attribute:
85+
86+
entry = @stack.content_type('content_type_uid').query.locale('locale_code').fetch()
87+
88+
> Note: Currently, the above query works in case of retrieving localized versions of multiple entries only.
89+
7890
## **Advanced Queries**
7991

8092
You can query for content types, entries, assets and more using our Ruby API Reference.
8193

8294
[Ruby API Reference Doc](http://www.rubydoc.info/gems/contentstack)
8395

96+
### Paginating Responses
97+
In a single instance, the [Get Multiple Entries](https://www.contentstack.com/docs/developers/ruby/get-started-with-ruby-sdk/#get-multiple-entries) query will retrieve only the first 100 items of the specified content type. You can paginate and retrieve the rest of the items in batches using the [skip](https://www.rubydoc.info/gems/contentstack/Contentstack/Query#skip-instance_method) and [limit](https://www.rubydoc.info/gems/contentstack/Contentstack/Query#limit-instance_method) parameters in subsequent requests.
98+
99+
@stack = Contentstack::Client.new("api_key", "delivery_token", "environment")
100+
@entries = @stack.content_type('category').query
101+
.limit(20)
102+
.skip(50)
103+
.fetch
104+
105+
> Note: Currently, the Ruby SDK does not support multiple content types referencing in a single query. For more information on how to query entries and assets, refer the Queries section of our Content Delivery API documentation.
106+
84107
## **Working with Images**
85108

86109
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.

coverage/.last_run.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"result": {
3-
"covered_percent": 96.65
3+
"covered_percent": 97.5
44
}
55
}

0 commit comments

Comments
 (0)