sn-chell 0.1.3
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 +7 -0
- data/CHANGELOG.md +39 -0
- data/LICENSE +3 -0
- data/README.md +74 -0
- data/bin/console +16 -0
- data/bin/setup +8 -0
- data/lib/chell.rb +2 -0
- data/lib/chell/client.rb +47 -0
- data/lib/chell/version.rb +3 -0
- metadata +177 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f38b33a63091ea900385082c15185e658ec8b1a3
|
4
|
+
data.tar.gz: 1209e9f5c4fe73b8fb374f21135582d720d2d054
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 92079bc2e404f8779d13bbdbd64527fbd9c0ab739594d0dde60f862fdf57ad937995ecabde0e3ea322133b31d9228032be5efa111eb8da5456aa268de948eec8
|
7
|
+
data.tar.gz: 35634c5fccf2001e2fc42ef2eaa4ee679839dc36202684f888fddcda450df38320f4e158bba8e9038d4886c5de2223f2820d714c84d5099327f693b6752f1aa5
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
|
+
|
7
|
+
## [Unreleased][]
|
8
|
+
|
9
|
+
## [0.1.3][] - 2018-02-24
|
10
|
+
### Changed
|
11
|
+
- Update `oj` dependency version.
|
12
|
+
|
13
|
+
## [0.1.2][] - 2017-04-17
|
14
|
+
### Fixed
|
15
|
+
- Course content retrieval.
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
- Split "retrieve course" and "retrieve course content" API into
|
19
|
+
`course(...)` and `course_content(...)`, respectively.
|
20
|
+
|
21
|
+
## [0.1.1][] - 2017-04-12
|
22
|
+
### Added
|
23
|
+
- Enable CI.
|
24
|
+
- Use Docker for development.
|
25
|
+
- Instance variable `@chell` to development console (`bin/console`).
|
26
|
+
|
27
|
+
### Changed
|
28
|
+
- Rename Chel to Chell.
|
29
|
+
- Rename "Chell Client" to just "Chell".
|
30
|
+
- Publishing to Artifactory is now driven by Git tags.
|
31
|
+
- Use `url/access_key/secret_key` convention in constructor.
|
32
|
+
|
33
|
+
## 0.1.0 - 2017-02-22
|
34
|
+
Initial release.
|
35
|
+
|
36
|
+
[Unreleased]: https://github.ibm.com/bdu/companion-cube-ruby/compare/0.1.3...HEAD
|
37
|
+
[0.1.3]: https://github.ibm.com/bdu/companion-cube-ruby/compare/0.1.2...0.1.3
|
38
|
+
[0.1.2]: https://github.ibm.com/bdu/companion-cube-ruby/compare/0.1.1...0.1.2
|
39
|
+
[0.1.1]: https://github.ibm.com/bdu/companion-cube-ruby/compare/0.1.0...0.1.1
|
data/LICENSE
ADDED
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
[](https://travis.ibm.com/bdu/chell=ruby)
|
2
|
+
|
3
|
+
# Chell
|
4
|
+
|
5
|
+
Ruby client for [Chell](https://github.ibm.com/bdu/chell).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's `Gemfile`:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem "chell"
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
```sh
|
18
|
+
bundle install
|
19
|
+
```
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
```sh
|
24
|
+
gem install chell
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
# To start, create a client
|
31
|
+
chell = Chell::Client.new(url: "https://chell.example.com/api")
|
32
|
+
|
33
|
+
# Retrieve all courses
|
34
|
+
courses = chell.courses
|
35
|
+
|
36
|
+
# Retrieve an existing course
|
37
|
+
course_id = courses.first[:id]
|
38
|
+
course = chell.course(course_id)
|
39
|
+
|
40
|
+
# Retrieve an existing course's content
|
41
|
+
version_id = couse[:versions].last[:id]
|
42
|
+
content = chell.course_content(course_id, version_id)
|
43
|
+
```
|
44
|
+
|
45
|
+
## Development
|
46
|
+
|
47
|
+
Start by creating a `chell.env` file based on `chell.env.example`. Then:
|
48
|
+
|
49
|
+
* To run the tests:
|
50
|
+
|
51
|
+
```sh
|
52
|
+
docker-compose run chell-ruby rake spec; docker-compose down
|
53
|
+
```
|
54
|
+
|
55
|
+
* You can also run the following command for an interactive prompt that will
|
56
|
+
allow you to experiment.
|
57
|
+
|
58
|
+
```sh
|
59
|
+
docker-compose run chell-ruby bin/console; docker-compose down
|
60
|
+
```
|
61
|
+
|
62
|
+
* For added flexibility, you can use Bash.
|
63
|
+
|
64
|
+
```sh
|
65
|
+
docker-compose run --service-ports chell-ruby bash; docker-compose down
|
66
|
+
```
|
67
|
+
|
68
|
+
## License
|
69
|
+
|
70
|
+
Please refer to [LICENSE](LICENSE).
|
71
|
+
|
72
|
+
## Authors
|
73
|
+
|
74
|
+
* Partner Ecosystem Team, IBM Digital Business Group <mailto:imcloud@ca.ibm.com>
|
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "json"
|
5
|
+
require "chell"
|
6
|
+
|
7
|
+
require "irb"
|
8
|
+
|
9
|
+
instance_variable_set(:@chell,
|
10
|
+
Chell::Client.new(
|
11
|
+
url: ENV.fetch("CHELL_URL"),
|
12
|
+
access_key: ENV.fetch("CHELL_ACCESS_KEY"),
|
13
|
+
secret_key: ENV.fetch("CHELL_SECRET_KEY")
|
14
|
+
))
|
15
|
+
|
16
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/chell.rb
ADDED
data/lib/chell/client.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require "oj"
|
2
|
+
require "rest-client"
|
3
|
+
|
4
|
+
module Chell
|
5
|
+
class Client
|
6
|
+
FORMATS = {
|
7
|
+
json: "application/json",
|
8
|
+
gzip: "application/x-gzip"
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
def initialize(options = {})
|
12
|
+
@access_key = options.fetch(:access_key)
|
13
|
+
@secret_key = options.fetch(:secret_key)
|
14
|
+
@url = options.fetch(:url)
|
15
|
+
end
|
16
|
+
|
17
|
+
def courses
|
18
|
+
parse_json(resource["/courses"].get.body)
|
19
|
+
end
|
20
|
+
|
21
|
+
def course(id)
|
22
|
+
path = "/courses/#{id}"
|
23
|
+
headers = { accept: FORMATS[:json] }
|
24
|
+
|
25
|
+
response = resource[path].get(headers)
|
26
|
+
parse_json(response.body)
|
27
|
+
end
|
28
|
+
|
29
|
+
def course_content(id, version_id)
|
30
|
+
path = "/courses/#{id}/versions/#{version_id}"
|
31
|
+
headers = { accept: FORMATS[:gzip] }
|
32
|
+
|
33
|
+
resource[path].get(headers).body
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def parse_json(body)
|
39
|
+
Oj.default_options = { mode: :compat, symbol_keys: true }
|
40
|
+
Oj.load(body)
|
41
|
+
end
|
42
|
+
|
43
|
+
def resource
|
44
|
+
@resource ||= RestClient::Resource.new(@url, user: @access_key, password: @secret_key)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sn-chell
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Skills Network
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler-audit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '12.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '12.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.12'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.12'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.3'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.3'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.48'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.48'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: oj
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.3'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.3'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rest-client
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.0'
|
139
|
+
description: Client for the Chell service
|
140
|
+
email: info@skills.network
|
141
|
+
executables: []
|
142
|
+
extensions: []
|
143
|
+
extra_rdoc_files: []
|
144
|
+
files:
|
145
|
+
- CHANGELOG.md
|
146
|
+
- LICENSE
|
147
|
+
- README.md
|
148
|
+
- bin/console
|
149
|
+
- bin/setup
|
150
|
+
- lib/chell.rb
|
151
|
+
- lib/chell/client.rb
|
152
|
+
- lib/chell/version.rb
|
153
|
+
homepage: https://github.ibm.com/bdu/chell-ruby
|
154
|
+
licenses:
|
155
|
+
- All rights reserved.
|
156
|
+
metadata: {}
|
157
|
+
post_install_message:
|
158
|
+
rdoc_options: []
|
159
|
+
require_paths:
|
160
|
+
- lib
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
requirements: []
|
172
|
+
rubyforge_project:
|
173
|
+
rubygems_version: 2.6.14
|
174
|
+
signing_key:
|
175
|
+
specification_version: 4
|
176
|
+
summary: Chell Client
|
177
|
+
test_files: []
|