atdis 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 156b40028c933cc59a604386a05f8c893f79cf81
4
- data.tar.gz: c53d84d1a1c21e40a782c758981070088a0031bd
3
+ metadata.gz: 569aa3967302c8529a9c74433f54fd105ebe45d7
4
+ data.tar.gz: 0eb50df65474e2d5bc5787994d58c8a282e87e4a
5
5
  SHA512:
6
- metadata.gz: 861de4c29391b0ca955e65487197e4ba1590066d09fd2da8e10db4f98a1b3a00267b1c9dda21bdf4c9394c3141b69f3d1402a1a90d5bf697ef70114c2deb9899
7
- data.tar.gz: ee2148c4ab7e514380056b133d3319beb2f09df8985e701a1edfcc83d0762a5acf2ca57d535669faa6d7df41abfa5e6b84562fd90ce5dec6a48ec80ffe451a9d
6
+ metadata.gz: b6aa7bae02ff0fa4a4a2776ef4bbb16f7438f2332f5b3e419f2281abebe8f25e8894a2beb50b325ca3ca24dce598b58f9c0580b5de408f1e4fe69f712dd4bd57
7
+ data.tar.gz: 029202949e54506691b3e5c6bb36f2bb73aafd14e707e4ff328b5f739c0a55762a6b35a2f801a5ccbe5d63c8233d23db6c575d40230bf453c2afc4760268f5e7
@@ -4,7 +4,7 @@ require "rest-client"
4
4
 
5
5
  module ATDIS
6
6
  class Feed
7
- attr_reader :base_url, :timezone
7
+ attr_reader :base_url, :timezone, :ignore_ssl_certificate
8
8
 
9
9
  VALID_OPTIONS = %i[page street suburb postcode lodgement_date_start
10
10
  lodgement_date_end last_modified_date_start last_modified_date_end].freeze
@@ -18,9 +18,10 @@ module ATDIS
18
18
  # get interpreted in the given timezone)
19
19
  # See https://api.rubyonrails.org/classes/ActiveSupport/TimeZone.html for the
20
20
  # list of possible timezone strings
21
- def initialize(base_url, timezone)
21
+ def initialize(base_url, timezone, ignore_ssl_certificate = false)
22
22
  @base_url = base_url
23
23
  @timezone = timezone
24
+ @ignore_ssl_certificate = ignore_ssl_certificate
24
25
  end
25
26
 
26
27
  def applications_url(options = {})
@@ -68,11 +69,11 @@ module ATDIS
68
69
  end
69
70
 
70
71
  def applications(options = {})
71
- Models::Page.read_url(applications_url(options), timezone)
72
+ Models::Page.read_url(applications_url(options), timezone, ignore_ssl_certificate)
72
73
  end
73
74
 
74
75
  def application(id)
75
- Models::Application.read_url(application_url(id), timezone)
76
+ Models::Application.read_url(application_url(id), timezone, ignore_ssl_certificate)
76
77
  end
77
78
 
78
79
  # Turn a query string of the form "foo=bar&hello=sir" to {foo: "bar", hello: sir"}
@@ -72,8 +72,15 @@ module ATDIS
72
72
  [used, unused]
73
73
  end
74
74
 
75
- def self.read_url(url, timezone)
76
- r = read_json(RestClient.get(url.to_s).to_str, timezone)
75
+ def self.read_url_raw(url, ignore_ssl_certificate = false)
76
+ RestClient::Resource.new(
77
+ url.to_s,
78
+ verify_ssl: (OpenSSL::SSL::VERIFY_NONE if ignore_ssl_certificate)
79
+ ).get.to_str
80
+ end
81
+
82
+ def self.read_url(url, timezone, ignore_ssl_certificate = false)
83
+ r = read_json(read_url_raw(url, ignore_ssl_certificate), timezone)
77
84
  r.url = url.to_s
78
85
  r
79
86
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Atdis
4
- VERSION = "0.4.1"
4
+ VERSION = "0.5.0"
5
5
  end
@@ -9,7 +9,8 @@ describe ATDIS::Feed do
9
9
  it "should return all the applications" do
10
10
  expect(ATDIS::Models::Page).to receive(:read_url).with(
11
11
  "http://www.council.nsw.gov.au/atdis/1.0/applications.json",
12
- "UTC"
12
+ "UTC",
13
+ false
13
14
  ).and_return(page)
14
15
  expect(feed.applications).to eq page
15
16
  end
@@ -194,7 +195,8 @@ describe ATDIS::Feed do
194
195
  application = double
195
196
  expect(ATDIS::Models::Application).to receive(:read_url).with(
196
197
  "http://www.council.nsw.gov.au/atdis/1.0/27B%2F6.json",
197
- "UTC"
198
+ "UTC",
199
+ false
198
200
  ).and_return(application)
199
201
  expect(feed.application("27B/6")).to eq application
200
202
  }
@@ -301,9 +301,10 @@ describe ATDIS::Models::Page do
301
301
  ]
302
302
  }
303
303
  JSON
304
- expect(RestClient).to receive(:get).with(
305
- "http://www.council.nsw.gov.au/atdis/1.0/applications.json"
306
- ).and_return(double(to_str: json))
304
+ expect(ATDIS::Model).to receive(:read_url_raw).with(
305
+ "http://www.council.nsw.gov.au/atdis/1.0/applications.json",
306
+ false
307
+ ).and_return(json)
307
308
  end
308
309
 
309
310
  let(:applications_results) do
@@ -365,9 +366,10 @@ describe ATDIS::Models::Page do
365
366
  }
366
367
  }
367
368
  JSON
368
- expect(RestClient).to receive(:get).with(
369
- "http://www.council.nsw.gov.au/atdis/1.0/applications.json?page=2"
370
- ).and_return(double(to_str: json))
369
+ expect(ATDIS::Model).to receive(:read_url_raw).with(
370
+ "http://www.council.nsw.gov.au/atdis/1.0/applications.json?page=2",
371
+ false
372
+ ).and_return(json)
371
373
  end
372
374
 
373
375
  let(:applications_results) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atdis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Landauer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-28 00:00:00.000000000 Z
11
+ date: 2020-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -184,7 +184,7 @@ homepage: http://github.com/openaustralia/atdis
184
184
  licenses:
185
185
  - MIT
186
186
  metadata: {}
187
- post_install_message:
187
+ post_install_message:
188
188
  rdoc_options: []
189
189
  require_paths:
190
190
  - lib
@@ -199,9 +199,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  - !ruby/object:Gem::Version
200
200
  version: '0'
201
201
  requirements: []
202
- rubyforge_project:
202
+ rubyforge_project:
203
203
  rubygems_version: 2.5.1
204
- signing_key:
204
+ signing_key:
205
205
  specification_version: 4
206
206
  summary: A ruby interface to the application tracking data interchange specification
207
207
  (ATDIS) API