microcms-ruby-sdk 0.2.0 → 1.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36a385106245efd6bff8bb32a5080188cc526452d2a6646c78e8b4a3dd6e0c7a
4
- data.tar.gz: f69e0cae151baa48de93ae0ec0439d4cf6fa914b10385004bb364a1b6c362c6d
3
+ metadata.gz: ce42fc094821080f133ac9faf93e5efbe4cc7fec65ad4930e65e61a4eb3e4add
4
+ data.tar.gz: bf9c56b513719887e1ac417db6e903d2b299e583a66f6a39c515e315dc54b714
5
5
  SHA512:
6
- metadata.gz: 04cc22687f37accb8ddfebf7597ec5722da698fd4bcc1f9a700a0ca4b675c2fdde6856a0036d1c0fa00587f198e2de2d50ef81780a7004987d5c97e3d82841c1
7
- data.tar.gz: 228aa61af54530e1ff3569d1e1ee1c07e896ea1342968740630db43c9e23060ccda55eadebc0333adc90deb1d0c879cbfc473a115a459d71c16bf90d655b79f7
6
+ metadata.gz: 18650d072175f4ce851f0d66cb60b6e2a6bd588bb6184bd88b8424783a73f183391e60b2a2ac07f75546efba1c29bf863939edccd5c74d6f35796ebfc1013ebf
7
+ data.tar.gz: 6f92d78767727676f97041bbb4bbc934ead25ab774b73322517c7664640cca91c9589c1dd47340da2fca434655977cc9a715d6966a8914145fd9177e84659f9c
@@ -0,0 +1,32 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+
8
+ jobs:
9
+ build:
10
+ name: Build + Publish
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ contents: read
14
+ packages: write
15
+
16
+ steps:
17
+ - uses: actions/checkout@v2
18
+ - name: Set up Ruby 2.6
19
+ uses: actions/setup-ruby@v1
20
+ with:
21
+ ruby-version: 2.6.x
22
+
23
+ - name: Publish to RubyGems
24
+ run: |
25
+ mkdir -p $HOME/.gem
26
+ touch $HOME/.gem/credentials
27
+ chmod 0600 $HOME/.gem/credentials
28
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
29
+ gem build *.gemspec
30
+ gem push *.gem
31
+ env:
32
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
data/README.md CHANGED
@@ -2,12 +2,16 @@
2
2
 
3
3
  [microCMS](https://document.microcms.io/manual/api-request) Ruby SDK.
4
4
 
5
+ ## Tutorial
6
+
7
+ See [official tutorial](https://document.microcms.io/tutorial/ruby/ruby-top).
8
+
5
9
  ## Installation
6
10
 
7
11
  Add this line to your application's Gemfile:
8
12
 
9
13
  ```ruby
10
- gem 'microcms'
14
+ gem 'microcms-ruby-sdk'
11
15
  ```
12
16
 
13
17
  And then execute:
@@ -20,36 +24,124 @@ Or install it yourself as:
20
24
 
21
25
  ## Usage
22
26
 
27
+ ### Import
28
+
29
+ ```rb
30
+ require 'microcms'
31
+ ```
32
+
33
+ ### Create client object
34
+
35
+ ```rb
36
+ MicroCMS.service_domain = 'YOUR_DOMAIN'
37
+ MicroCMS.api_key = 'YOUR_API_KEY'
38
+ ```
39
+
40
+ ### Get content list
41
+
42
+ ```rb
43
+ puts MicroCMS.list('endpoint')
44
+ ```
45
+
46
+ ### Get content list with parameters
47
+
48
+ ```rb
49
+ puts MicroCMS.list(
50
+ 'endpoint',
51
+ {
52
+ drarf_key: "abcd",
53
+ limit: 100,
54
+ offset: 1,
55
+ orders: ['updatedAt'],
56
+ q: 'Hello',
57
+ fields: %w[id title],
58
+ ids: ['foo'],
59
+ filters: 'publishedAt[greater_than]2021-01-01',
60
+ depth: 1,
61
+ },
62
+ )
63
+ ```
64
+
65
+ ### Get single content
66
+
67
+ ```rb
68
+ puts MicroCMS.get('endpoint', 'ruby')
69
+ ```
70
+
71
+ ### Get single content with parameters
72
+
23
73
  ```rb
24
- MicroCMS.service_domain = ENV['YOUR_DOMAIN']
25
- MicroCMS.api_key = ENV['YOUR_API_KEY']
74
+ puts MicroCMS.get(
75
+ 'endpoint',
76
+ 'ruby',
77
+ {
78
+ draft_key: 'abcdef1234',
79
+ fields: %w[title publishedAt],
80
+ depth: 1,
81
+ },
82
+ )
83
+ ```
26
84
 
27
- endpoint = ENV['YOUR_ENDPOINT']
85
+ ### Get object form content
28
86
 
29
- puts MicroCMS.list(endpoint)
87
+ ```rb
88
+ puts MicroCMS.get('endpoint')
89
+ ```
30
90
 
31
- puts MicroCMS.list(endpoint, {
32
- limit: 100,
33
- offset: 1,
34
- orders: ['updatedAt'],
35
- q: 'Hello',
36
- fields: %w[id title],
37
- filters: 'publishedAt[greater_than]2021-01-01'
38
- })
91
+ ### Create content
39
92
 
40
- puts MicroCMS.get(endpoint, 'ruby')
93
+ ```rb
94
+ puts MicroCMS.create('endpoint', { text: 'Hello, microcms-ruby-sdk!' })
95
+ ```
41
96
 
42
- puts MicroCMS.get(endpoint, 'ruby', { draft_key: 'abcdef1234' })
97
+ ### Create content with specified ID
43
98
 
44
- puts MicroCMS.create(endpoint, { text: 'Hello, microcms-ruby-sdk!' })
99
+ ```rb
100
+ puts MicroCMS.create(
101
+ 'endpoint',
102
+ {
103
+ id: 'my-content-id',
104
+ text: 'Hello, microcms-ruby-sdk!',
105
+ },
106
+ )
107
+ ```
45
108
 
46
- puts MicroCMS.create(endpoint, { id: 'microcms-ruby-sdk', text: 'Hello, microcms-ruby-sdk!' })
109
+ ### Create draft content
47
110
 
48
- puts MicroCMS.create(endpoint, { text: 'Hello, microcms-ruby-sdk!' }, { status: 'draft' })
111
+ ```rb
112
+ puts MicroCMS.create(
113
+ 'endpoint',
114
+ {
115
+ id: 'my-content-id',
116
+ text: 'Hello, microcms-ruby-sdk!',
117
+ },
118
+ { status: 'draft' },
119
+ )
120
+ ```
49
121
 
50
- puts MicroCMS.update(endpoint, { id: 'microcms-ruby-sdk', text: 'Hello, microcms-ruby-sdk update method!' })
122
+ ### Update content
51
123
 
52
- MicroCMS.delete(endpoint, 'microcms-ruby-sdk')
124
+ ```rb
125
+
126
+ puts MicroCMS.update(
127
+ 'endpoint',
128
+ {
129
+ id: 'microcms-ruby-sdk',
130
+ text: 'Hello, microcms-ruby-sdk update method!',
131
+ },
132
+ )
133
+ ```
134
+
135
+ ### Update object form content
136
+
137
+ ```rb
138
+ puts MicroCMS.update('endpoint', { text: 'Hello, microcms-ruby-sdk update method!' })
139
+ ```
140
+
141
+ ### Delete content
142
+
143
+ ```rb
144
+ MicroCMS.delete('endpoint', 'microcms-ruby-sdk')
53
145
  ```
54
146
 
55
147
  ## Development
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MicroCMS
4
- VERSION = '0.2.0'
4
+ VERSION = '1.0.2'
5
5
  end
data/lib/microcms.rb CHANGED
@@ -28,7 +28,12 @@ module MicroCMS
28
28
  end
29
29
 
30
30
  def list(endpoint, option = {})
31
- send_http_request('GET', endpoint, nil, build_query(option))
31
+ list = send_http_request('GET', endpoint, nil, build_query(option))
32
+ if list[:totalCount]
33
+ list[:total_count] = list[:totalCount]
34
+ list.delete_field(:totalCount)
35
+ end
36
+ list
32
37
  end
33
38
 
34
39
  def get(endpoint, id = '', option = {})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: microcms-ruby-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - microCMS
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-29 00:00:00.000000000 Z
11
+ date: 2021-11-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: microCMS Ruby SDK
14
14
  email:
@@ -17,6 +17,7 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - ".github/workflows/ci.yml"
20
+ - ".github/workflows/publish.yml"
20
21
  - ".gitignore"
21
22
  - ".rspec"
22
23
  - ".rubocop.yml"
@@ -52,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
53
  - !ruby/object:Gem::Version
53
54
  version: '0'
54
55
  requirements: []
55
- rubygems_version: 3.1.4
56
+ rubygems_version: 3.0.3.1
56
57
  signing_key:
57
58
  specification_version: 4
58
59
  summary: microCMS Ruby SDK