Skip to content

Commit 1c92702

Browse files
committed
Add new material/event attributes from TeSS 1.2 release
Bump Ruby version and various gem versions
1 parent 184ee23 commit 1c92702

20 files changed

Lines changed: 220 additions & 111 deletions

.github/workflows/tests.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Tests
2+
on: [push, pull_request]
3+
jobs:
4+
run-tests:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
ruby: ['2.5', '2.6', '2.7', '3.0.4']
9+
fail-fast: false
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2.3.1 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
13+
with:
14+
persist-credentials: false
15+
- name: Setup Ruby
16+
uses: ruby/setup-ruby@v1
17+
with:
18+
ruby-version: ${{ matrix.ruby }}
19+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
20+
- name: Run tests
21+
run: bundle exec rake test

.ruby-gemset

Lines changed: 0 additions & 1 deletion
This file was deleted.

.ruby-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
ruby-2.2.6
1+
ruby-3.0.4

README.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1-
# TeSS API Client
2-
A gem for uploading data to the [TeSS](http://tess.elixir-uk.org) portal. Use if you have training or event content you wish to push to TeSS.
3-
4-
## Get Started
5-
Add the TeSS API to your Gemfile and use bundle to install
6-
7-
`$ echo "gem 'tess_api_client', :git => git://github.com/ElixirUK/TeSS_api_client.git" >> Gemfile`
8-
9-
`$ bundle install`
10-
11-
Create a new ruby script which uses the gem. Use the ContentProvider model to create a new content provider in TeSS and the Material or Event model to create new resources.
12-
`$ nano my_upload_script.rb`
13-
14-
```ruby
15-
require 'tess_api_client'
16-
17-
content_provider = Tess::API::ContentProvider.new(
18-
title: 'My Organization Name',
19-
url: 'https://my.org.org/',
20-
image_url: 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Smiley.svg/2000px-Smiley.svg.png',
21-
description: "We're sharing our content with TeSS!")
22-
23-
material = Tess::API::Material.new(
24-
title: 'How to use TeSS API',
25-
url: 'http://mysite.org/tess_api',
26-
short_description: 'Everything you need to know to get you started using the TeSS API',
27-
doi: 'http://dx.doi.org/10002-20fk',
28-
remote_updated_date: Time.now,
29-
content_provider: content_provider, # The content provider is created if needed when the material is created.
30-
scientific_topic: ['Computational Biology'],
31-
keywords: ['tutorial', 'TeSS', 'sharing'])
32-
33-
material.create
34-
```
35-
36-
## Futher Examples
37-
More examples can be found in the `test` directory of this repository, or in the [TeSS Scrapers repository](https://github.com/ElixirTeSS/TeSS_scrapers)
1+
# TeSS API Client
2+
A gem for uploading data to the [TeSS](http://tess.elixir-uk.org) portal. Use if you have training or event content you wish to push to TeSS.
3+
4+
## Get Started
5+
Add the TeSS API to your Gemfile and use bundle to install
6+
7+
`$ echo "gem 'tess_api_client', :git => git://github.com/ElixirUK/TeSS_api_client.git" >> Gemfile`
8+
9+
`$ bundle install`
10+
11+
Create a new ruby script which uses the gem. Use the ContentProvider model to create a new content provider in TeSS and the Material or Event model to create new resources.
12+
`$ nano my_upload_script.rb`
13+
14+
```ruby
15+
require 'tess_api_client'
16+
17+
content_provider = Tess::API::ContentProvider.new(
18+
title: 'My Organization Name',
19+
url: 'https://my.org.org/',
20+
image_url: 'https://upload.wikimedia.org/wikipedia/commons/thumb/8/85/Smiley.svg/2000px-Smiley.svg.png',
21+
description: "We're sharing our content with TeSS!")
22+
23+
material = Tess::API::Material.new(
24+
title: 'How to use TeSS API',
25+
url: 'http://mysite.org/tess_api',
26+
description: 'Everything you need to know to get you started using the TeSS API',
27+
doi: 'http://dx.doi.org/10002-20fk',
28+
remote_updated_date: Time.now,
29+
content_provider: content_provider, # The content provider is created if needed when the material is created.
30+
scientific_topic: ['Computational Biology'],
31+
keywords: ['tutorial', 'TeSS', 'sharing'])
32+
33+
material.create
34+
```
35+
36+
## Futher Examples
37+
More examples can be found in the `test` directory of this repository, or in the [TeSS Scrapers repository](https://github.com/ElixirTeSS/TeSS_scrapers)

lib/tess/api/content_provider.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ def self.resource_path
1212
'content_providers'
1313
end
1414

15-
attr_accessor :title, :url, :image_url, :description, :id, :content_provider_type, :node_name, :keywords
15+
attr_accessor :title, :url, :image_url, :description, :id, :content_provider_type, :node_name, :keywords,
16+
:contact
1617

1718
PROVIDER_TYPE = {
1819
organisation: 'Organisation',

lib/tess/api/event.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ def self.resource_path
1717
:scientific_topic_names, :scientific_topic_uris, :operation_names, :operation_uris,
1818
:event_types, :keywords, :start, :end, :sponsors, :online, :for_profit, :venue,
1919
:city, :county, :country, :postcode, :latitude, :longitude, :package_ids, :node_ids, :target_audience,
20-
:eligibility, :host_institutions, :capacity, :contact, :external_resources_attributes, :timezone
20+
:eligibility, :host_institutions, :capacity, :contact, :external_resources_attributes, :timezone,
21+
:cost_value, :funding, :attendee_count, :applicant_count, :trainer_count, :feedback, :notes,
22+
:duration, :recognition, :learning_objectives, :prerequisites, :tech_requirements, :cost_basis,
23+
:cost_currency, :fields
24+
2125

2226
EVENT_TYPE = {
2327
awards_and_prizegivings: 'awards_and_prizegivings',

lib/tess/api/material.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ def self.resource_path
1313
'materials'
1414
end
1515

16-
attr_accessor :id, :title, :url, :short_description, :long_description, :doi,:last_scraped, :scraper_record,
16+
attr_accessor :id, :title, :url, :description, :doi, :last_scraped, :scraper_record,
1717
:remote_created_date, :remote_updated_date, :package_ids, :keywords,
1818
:scientific_topic_names, :scientific_topic_uris, :operation_names, :operation_uris,
1919
:licence, :difficulty_level, :contributors, :authors, :target_audience, :node_ids,
20-
:external_resources_attributes, :resource_type
20+
:external_resources_attributes, :resource_type, :other_types, :date_created, :date_modified,
21+
:date_published, :prerequisites, :version, :status, :syllabus, :subsets, :contact,
22+
:learning_objectives, :fields
2123

2224
def initialize(params = {})
2325
params[:last_scraped] = Time.now

lib/tess_api_client.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
module Tess
22
module API
33
require 'inifile'
4-
require 'net/http'
5-
require 'net/https'
64
require 'json'
7-
require 'open-uri'
85
require 'digest/sha1'
96
require 'rest-client'
107

tess_api_client.gemspec

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,18 @@
11
Gem::Specification.new do |s|
22
s.name = 'tess_api_client'
3-
s.version = '0.3.3'
4-
s.date = '2018-04-30'
3+
s.version = '0.4.0'
4+
s.date = '2022-07-28'
55
s.summary = 'Libraries for uploading files to https://github.com/ElixirTeSS/TeSS'
66
s.description = 'Uses the a Custom RoR API on https://tess.elixir-europe.org to upload data in the format being used by the TeSS project.'
77
s.authors = ['Milo Thurston','Niall Beard','Aleksandra Nenadic','Finn Bacall']
88
s.email = 'tess-support@googlegroups.com'
9-
s.files = ['lib/tess_api_client.rb',
10-
'lib/tess/api/api_resource.rb',
11-
'lib/tess/api/content_provider.rb',
12-
'lib/tess/api/exceptions.rb',
13-
'lib/tess/api/has_content_provider.rb',
14-
'lib/tess/api/event.rb',
15-
'lib/tess/api/material.rb',
16-
'lib/tess/api/node.rb',
17-
'lib/tess/api/resource.rb',
18-
'lib/tess/api/uploader.rb'
19-
]
9+
s.files = `git ls-files`.split("\n")
2010
s.homepage = 'https://github.com/ElixirTeSS/TeSS_api_client'
2111
s.license = 'BSD'
22-
s.add_runtime_dependency 'json', '~> 1.8'
23-
s.add_runtime_dependency 'net', '~> 0.3'
2412
s.add_runtime_dependency 'inifile', '~> 3.0.0'
2513
s.add_runtime_dependency 'rest-client', '~> 2.0.0'
2614
s.add_development_dependency 'rake'
27-
s.add_development_dependency 'test-unit', '~> 3.2.1'
28-
s.add_development_dependency 'webmock', '~> 1.24.6'
15+
s.add_development_dependency 'webmock'
2916
s.add_development_dependency 'vcr', '~> 3.0.3'
3017
s.add_development_dependency 'simplecov'
3118
end

test/content_provider_test.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class ContentProviderTest < Test::Unit::TestCase
1515
description: 'Hey!',
1616
content_provider_type: 'anything?',
1717
node_name: 'Francis',
18-
keywords: ['cat', 'dog'] })
18+
keywords: ['cat', 'dog'],
19+
contact: 'Jane Smith' })
1920

2021
@content_provider_to_be_created = Tess::API::ContentProvider.new(
2122
{ title: 'Provider of Content',
@@ -96,10 +97,14 @@ class ContentProviderTest < Test::Unit::TestCase
9697
c.keywords = ['hamster']
9798
assert_equal ['hamster'], c.keywords
9899

100+
assert_equal 'Jane Smith', c.contact
101+
c.contact = 'Robert Smith'
102+
assert_equal 'Robert Smith', c.contact
103+
99104
dump = c.dump
100105
parsed_json = JSON.parse(c.to_json)
101106

102-
[:title, :url, :image_url, :description, :id, :content_provider_type, :node_name, :keywords].each do |attr|
107+
[:title, :url, :image_url, :description, :id, :content_provider_type, :node_name, :keywords, :contact].each do |attr|
103108
assert_equal c.send(attr), c[attr.to_s], "Unexpected value of '#{attr}' for content provider when using []"
104109
assert_equal c.send(attr), dump[attr.to_s], "Unexpected value of '#{attr}' for content provider in hash dump"
105110
assert_equal c.send(attr).to_s, parsed_json[attr.to_s].to_s, "Unexpected value of '#{attr}' for content provider in JSON"

0 commit comments

Comments
 (0)