From 3880ae6d893d1c1e2564c7ae0fd6969d8aefd9c4 Mon Sep 17 00:00:00 2001 From: Keval Gohil Date: Wed, 28 Aug 2019 14:15:48 +0530 Subject: [PATCH 1/2] custom host and region support --- README.md | 13 +- coverage/.last_run.json | 2 +- coverage/.resultset.json | 166 ++++--- coverage/index.html | 915 +++++++++++++++++++++++++----------- lib/contentstack.rb | 5 + lib/contentstack/api.rb | 5 +- lib/contentstack/client.rb | 18 +- lib/contentstack/region.rb | 6 + lib/contentstack/version.rb | 2 +- spec/content_type_spec.rb | 12 + spec/contentstack_spec.rb | 22 + spec/query_spec.rb | 2 +- spec/spec_helper.rb | 12 +- testc.rb | 7 + 14 files changed, 854 insertions(+), 333 deletions(-) create mode 100644 lib/contentstack/region.rb create mode 100644 testc.rb diff --git a/README.md b/README.md index 5ec9a96..1ccbf0d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + # **Ruby SDK for Contentstack** 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/). @@ -20,7 +21,17 @@ Or you can run this command in your terminal (you might need administrator privi 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. + # with default region client = Contentstack::Client.new("site_api_key", "access_token", "enviroment_name") + + # with specific region + client = Contentstack::Client.new("site_api_key", "access_token", "enviroment_name",{"region": Contentstack::Region::EU}) + + # with custom host + client = Contentstack::Client.new("site_api_key", "access_token", "enviroment_name",{"host": "https://custom-cdn.contentstack.com"}) + + + ## **Key Concepts for using Contentstack** @@ -90,7 +101,7 @@ SDK functions for Image Delivery API coming soon. ## **The MIT License (MIT)** -Copyright © 2012-2017 [Built.io](https://www.built.io/). All Rights Reserved +Copyright © 2012-2017 [Contentstack](https://www.contentstack.com). All Rights Reserved 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: diff --git a/coverage/.last_run.json b/coverage/.last_run.json index faf76fc..ff908d7 100644 --- a/coverage/.last_run.json +++ b/coverage/.last_run.json @@ -1,5 +1,5 @@ { "result": { - "covered_percent": 96.44 + "covered_percent": 96.63 } } diff --git a/coverage/.resultset.json b/coverage/.resultset.json index b5f94bc..1d639a9 100644 --- a/coverage/.resultset.json +++ b/coverage/.resultset.json @@ -1,12 +1,17 @@ { "RSpec": { "coverage": { - "/home/keval/ruby/sdk/contentstack-ruby/lib/contentstack.rb": [ + "/Users/kevalgohil/contentstack-ruby/lib/contentstack.rb": [ 1, null, 1, 1, 1, + 1, + null, + null, + null, + null, null, null, null, @@ -23,26 +28,29 @@ 1, null ], - "/home/keval/ruby/sdk/contentstack-ruby/lib/contentstack/version.rb": [ + "/Users/kevalgohil/contentstack-ruby/lib/contentstack/version.rb": [ 1, 1, null ], - "/home/keval/ruby/sdk/contentstack-ruby/lib/contentstack/client.rb": [ + "/Users/kevalgohil/contentstack-ruby/lib/contentstack/client.rb": [ 1, 1, 1, null, 1, 1, + 1, null, 1, - 59, + 64, + 64, + 64, null, null, null, 1, - 6, + 8, null, null, 1, @@ -57,9 +65,20 @@ 7, null, null, + 1, + 1, + 62, + null, + 60, + null, + 2, + null, + 62, + null, + null, null ], - "/home/keval/ruby/sdk/contentstack-ruby/lib/contentstack/api.rb": [ + "/Users/kevalgohil/contentstack-ruby/lib/contentstack/api.rb": [ 1, 1, 1, @@ -69,19 +88,19 @@ 1, 1, 1, - 59, - 59, - 59, - 59, + 64, + 64, + 64, + 64, null, null, 1, - 6, + 8, 0, null, - 6, + 8, null, - 6, + 8, null, null, 1, @@ -102,20 +121,19 @@ null, 1, 1, - 64, + 66, null, - 64, - 64, + 66, null, - 64, + 66, null, null, - 64, + 66, null, null, null ], - "/home/keval/ruby/sdk/contentstack-ruby/lib/contentstack/content_type.rb": [ + "/Users/kevalgohil/contentstack-ruby/lib/contentstack/content_type.rb": [ 1, null, 1, @@ -137,13 +155,13 @@ null, null, 2, - 62, + 64, null, null, null, null, 1, - 71, + 75, null, null, 1, @@ -156,9 +174,9 @@ null, null, 1, - 6, - 6, - 168, + 8, + 8, + 224, null, null, null, @@ -169,7 +187,7 @@ null, null ], - "/home/keval/ruby/sdk/contentstack-ruby/lib/contentstack/query.rb": [ + "/Users/kevalgohil/contentstack-ruby/lib/contentstack/query.rb": [ 1, null, 1, @@ -774,7 +792,7 @@ null, null ], - "/home/keval/ruby/sdk/contentstack-ruby/lib/contentstack/entry_collection.rb": [ + "/Users/kevalgohil/contentstack-ruby/lib/contentstack/entry_collection.rb": [ 1, null, 1, @@ -819,7 +837,7 @@ null, null ], - "/home/keval/ruby/sdk/contentstack-ruby/lib/contentstack/entry.rb": [ + "/Users/kevalgohil/contentstack-ruby/lib/contentstack/entry.rb": [ 1, 1, 1, @@ -848,7 +866,7 @@ null, null ], - "/home/keval/ruby/sdk/contentstack-ruby/lib/contentstack/asset_collection.rb": [ + "/Users/kevalgohil/contentstack-ruby/lib/contentstack/asset_collection.rb": [ 1, null, 1, @@ -876,7 +894,7 @@ null, null ], - "/home/keval/ruby/sdk/contentstack-ruby/lib/contentstack/asset.rb": [ + "/Users/kevalgohil/contentstack-ruby/lib/contentstack/asset.rb": [ 1, null, null, @@ -945,24 +963,32 @@ null, null ], - "/home/keval/ruby/sdk/contentstack-ruby/lib/util.rb": [ + "/Users/kevalgohil/contentstack-ruby/lib/contentstack/region.rb": [ + 1, + 1, 1, 1, null, - 577, - 70, + null + ], + "/Users/kevalgohil/contentstack-ruby/lib/util.rb": [ + 1, + 1, + null, + 521, + 72, null, null, 1, - 2942, - 2942, - 15210, - 3020, + 3056, + 3056, + 15692, + 3118, null, - 12190, + 12574, null, null, - 2942, + 3056, null, null, null, @@ -973,9 +999,9 @@ null, null, 1, - 1222, - 967, - 761, + 1250, + 1007, + 801, null, 206, null, @@ -985,12 +1011,12 @@ null, 1, 1, - 362, - 362, + 370, + 370, null, null, 1, - 373, + 381, null, null, null, @@ -1000,7 +1026,7 @@ null, null, 1, - 561, + 505, null, null, null, @@ -1040,7 +1066,7 @@ null, null, 1, - 159, + 95, null, null, null, @@ -1054,7 +1080,7 @@ null, null ], - "/home/keval/ruby/sdk/contentstack-ruby/spec/asset_spec.rb": [ + "/Users/kevalgohil/contentstack-ruby/spec/asset_spec.rb": [ 1, 1, null, @@ -1104,12 +1130,14 @@ null, null ], - "/home/keval/ruby/sdk/contentstack-ruby/spec/content_type_spec.rb": [ + "/Users/kevalgohil/contentstack-ruby/spec/content_type_spec.rb": [ 1, 1, null, 1, 7, + 2, + 2, null, 1, 1, @@ -1142,6 +1170,16 @@ 1, null, null, + 1, + 1, + 1, + null, + null, + 1, + 1, + 1, + null, + null, null, 1, 1, @@ -1170,19 +1208,41 @@ null, null ], - "/home/keval/ruby/sdk/contentstack-ruby/spec/contentstack_spec.rb": [ + "/Users/kevalgohil/contentstack-ruby/spec/contentstack_spec.rb": [ 1, 1, null, 1, + 2, + 2, + 2, + null, + 1, + 1, + null, + null, + 1, + 1, + 1, + null, + null, + 1, + 1, + 1, + null, + null, + 1, + 1, 1, null, + null, 1, 1, null, + null, null ], - "/home/keval/ruby/sdk/contentstack-ruby/spec/entry_collection_spec.rb": [ + "/Users/kevalgohil/contentstack-ruby/spec/entry_collection_spec.rb": [ 1, 1, null, @@ -1226,7 +1286,7 @@ null, null ], - "/home/keval/ruby/sdk/contentstack-ruby/spec/entry_spec.rb": [ + "/Users/kevalgohil/contentstack-ruby/spec/entry_spec.rb": [ 1, 1, null, @@ -1251,7 +1311,7 @@ null, null ], - "/home/keval/ruby/sdk/contentstack-ruby/spec/query_spec.rb": [ + "/Users/kevalgohil/contentstack-ruby/spec/query_spec.rb": [ 1, 1, null, @@ -1447,6 +1507,6 @@ null ] }, - "timestamp": 1525251776 + "timestamp": 1566976586 } } diff --git a/coverage/index.html b/coverage/index.html index df738f7..4255392 100644 --- a/coverage/index.html +++ b/coverage/index.html @@ -14,26 +14,26 @@ loading