pdc 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: c02ee3706682bd870a7d07cec3251bac20b87595
4
- data.tar.gz: e6a3760b8c6fe85de7563e7f953d5c0087987d8a
3
+ metadata.gz: 92f8058cc0be41a5a3c04adfa2746b6e5220a2c7
4
+ data.tar.gz: 80cc4a9ccab91400ac9b24cb423ee817489ed4eb
5
5
  SHA512:
6
- metadata.gz: f63e7f73f932b1280312dddbc1c6307a9e197bd4fb386ad0eec37a3b21b4e2a245535a94598a0af556b7690c934a03b93324bee9b7674588c585620849b3872a
7
- data.tar.gz: a3afbe4a4ff77aff8be32d187c6fa18c3451ce743fe95fb996ea94e6f08b31da2c595eb5ad50dab82908202c0bbb86d16c3f8d43cf227897ff86be6814c55347
6
+ metadata.gz: 7775dc341f3444c9aec9e233d406c44da542ea4e6646764020e461d78ea974dae1c8b8f45fe2c54ff1f760642360d7ba16d3ef271894c3e8d81ff86825fcb599
7
+ data.tar.gz: bafeac858e978afbde52515f7d0011806598d334f92e658c29c6d19a4b6445fddfc3b94624f430ee0797280fac688dc2f0a3363f902849b6922a38d3b5a884fe
data/examples/url.rb ADDED
@@ -0,0 +1,17 @@
1
+ require_relative '../lib/pdc'
2
+
3
+ PDC.configure do |config|
4
+ # dev server
5
+ config.site = 'https://pdc.engineering.redhat.com/'
6
+ config.log_level = :info
7
+ end
8
+
9
+ def main
10
+ rhel7_1 = PDC::V1::Release.find('rhel-7.1')
11
+ puts "release url : #{rhel7_1.url}"
12
+ rhel7_1.variants.all.each do |v|
13
+ puts "release variant url : #{v.url}"
14
+ end
15
+ end
16
+
17
+ main if __FILE__ == $PROGRAM_NAME
@@ -29,6 +29,13 @@ module PDC::Resource
29
29
  request(:get, uri, query)
30
30
  end
31
31
  end # classmethod
32
+
33
+ def initialize(attr = {})
34
+ super
35
+ @url = connection.build_url(uri).to_s
36
+ end
37
+ attr_reader :url
38
+
32
39
  end
33
40
  end
34
41
 
@@ -8,6 +8,17 @@ module PDC::V1
8
8
  Release.find(attributes[:release])
9
9
  end
10
10
 
11
+ ### NOTE
12
+ # ReleaseVariant is different from other resources in the way
13
+ # its url is created so it requires special handling
14
+ def initialize(attrs = {})
15
+ super
16
+
17
+ instance_uri = self.class.resource_path + '/(:release)/(:uid)'
18
+ instance_path = PDC::Resource::Path.new(instance_uri, attrs).expanded
19
+ @url = connection.build_url(instance_path).to_s
20
+ end
21
+
11
22
  # attribute_rename :release, :release_id
12
23
 
13
24
  # belongs_to :release, class_name: 'PDC::V1::Release',
data/lib/pdc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module PDC
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://pdc.host.dev.eng.pek2.redhat.com/rest_api/v1/releases/rhel-7.1/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Content-Type:
13
+ - application/json
14
+ User-Agent:
15
+ - Faraday v0.9.2
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ date:
22
+ - Mon, 12 Sep 2016 07:48:03 GMT
23
+ server:
24
+ - Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.1e-fips mod_auth_kerb/5.4
25
+ mod_wsgi/3.4 Python/2.7.5
26
+ expires:
27
+ - Mon, 12 Sep 2016 07:48:35 GMT
28
+ vary:
29
+ - Accept,Cookie
30
+ last-modified:
31
+ - Thu, 08 Sep 2016 05:59:08 GMT
32
+ allow:
33
+ - GET, PUT, PATCH, HEAD, OPTIONS
34
+ cache-control:
35
+ - max-age=30
36
+ x-frame-options:
37
+ - SAMEORIGIN
38
+ transfer-encoding:
39
+ - chunked
40
+ content-type:
41
+ - application/json
42
+ body:
43
+ encoding: UTF-8
44
+ string: '{"release_id":"rhel-7.1","short":"rhel","version":"7.1","name":"Red
45
+ Hat Enterprise Linux","base_product":null,"active":true,"product_version":"rhel-7","release_type":"ga","compose_set":["RHEL-7.1-20140507.2","RHEL-7.1-20140708.n.0","RHEL-7.1-20150219.1"],"integrated_with":null,"bugzilla":null,"dist_git":null,"brew":null,"product_pages":null,"errata":null}'
46
+ http_version:
47
+ recorded_at: Mon, 12 Sep 2016 07:48:06 GMT
48
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,95 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://pdc.host.dev.eng.pek2.redhat.com/rest_api/v1/releases/rhel-7.1/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Content-Type:
13
+ - application/json
14
+ User-Agent:
15
+ - Faraday v0.9.2
16
+ response:
17
+ status:
18
+ code: 200
19
+ message:
20
+ headers:
21
+ date:
22
+ - Mon, 12 Sep 2016 07:48:08 GMT
23
+ server:
24
+ - Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.1e-fips mod_auth_kerb/5.4
25
+ mod_wsgi/3.4 Python/2.7.5
26
+ expires:
27
+ - Mon, 12 Sep 2016 07:48:40 GMT
28
+ vary:
29
+ - Accept,Cookie
30
+ last-modified:
31
+ - Thu, 08 Sep 2016 05:59:08 GMT
32
+ allow:
33
+ - GET, PUT, PATCH, HEAD, OPTIONS
34
+ cache-control:
35
+ - max-age=30
36
+ x-frame-options:
37
+ - SAMEORIGIN
38
+ transfer-encoding:
39
+ - chunked
40
+ content-type:
41
+ - application/json
42
+ body:
43
+ encoding: UTF-8
44
+ string: '{"release_id":"rhel-7.1","short":"rhel","version":"7.1","name":"Red
45
+ Hat Enterprise Linux","base_product":null,"active":true,"product_version":"rhel-7","release_type":"ga","compose_set":["RHEL-7.1-20140507.2","RHEL-7.1-20140708.n.0","RHEL-7.1-20150219.1"],"integrated_with":null,"bugzilla":null,"dist_git":null,"brew":null,"product_pages":null,"errata":null}'
46
+ http_version:
47
+ recorded_at: Mon, 12 Sep 2016 07:48:10 GMT
48
+ - request:
49
+ method: get
50
+ uri: https://pdc.host.dev.eng.pek2.redhat.com/rest_api/v1/release%2Dvariants/?release=rhel-7.1
51
+ body:
52
+ encoding: US-ASCII
53
+ string: ''
54
+ headers:
55
+ Accept:
56
+ - application/json
57
+ Content-Type:
58
+ - application/json
59
+ User-Agent:
60
+ - Faraday v0.9.2
61
+ response:
62
+ status:
63
+ code: 200
64
+ message:
65
+ headers:
66
+ date:
67
+ - Mon, 12 Sep 2016 07:48:12 GMT
68
+ server:
69
+ - Apache/2.4.6 (Red Hat Enterprise Linux) OpenSSL/1.0.1e-fips mod_auth_kerb/5.4
70
+ mod_wsgi/3.4 Python/2.7.5
71
+ expires:
72
+ - Mon, 12 Sep 2016 07:48:44 GMT
73
+ vary:
74
+ - Accept,Cookie
75
+ last-modified:
76
+ - Thu, 08 Sep 2016 05:59:08 GMT
77
+ allow:
78
+ - GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
79
+ cache-control:
80
+ - max-age=30
81
+ x-frame-options:
82
+ - SAMEORIGIN
83
+ transfer-encoding:
84
+ - chunked
85
+ content-type:
86
+ - application/json
87
+ body:
88
+ encoding: UTF-8
89
+ string: '{"count":12,"next":null,"previous":null,"results":[{"release":"rhel-7.1","id":"Client","uid":"Client","name":"Client","type":"variant","arches":["x86_64"]},{"release":"rhel-7.1","id":"optional","uid":"Client-optional","name":"optional","type":"optional","arches":["x86_64"]},{"release":"rhel-7.1","id":"ComputeNode","uid":"ComputeNode","name":"Compute
90
+ Node","type":"variant","arches":["x86_64"]},{"release":"rhel-7.1","id":"optional","uid":"ComputeNode-optional","name":"optional","type":"optional","arches":["x86_64"]},{"release":"rhel-7.1","id":"Server","uid":"Server","name":"Server","type":"variant","arches":["ppc64","s390x","x86_64"]},{"release":"rhel-7.1","id":"HighAvailability","uid":"Server-HighAvailability","name":"High
91
+ Availability","type":"addon","arches":["x86_64"]},{"release":"rhel-7.1","id":"optional","uid":"Server-optional","name":"optional","type":"optional","arches":["ppc64","s390x","x86_64"]},{"release":"rhel-7.1","id":"ResilientStorage","uid":"Server-ResilientStorage","name":"Resilient
92
+ Storage","type":"addon","arches":["x86_64"]},{"release":"rhel-7.1","id":"RT","uid":"Server-RT","name":"RT","type":"layered-product","arches":["x86_64"]},{"release":"rhel-7.1","id":"SAP","uid":"Server-SAP","name":"SAP","type":"layered-product","arches":["x86_64"]},{"release":"rhel-7.1","id":"Workstation","uid":"Workstation","name":"Workstation","type":"variant","arches":["x86_64"]},{"release":"rhel-7.1","id":"optional","uid":"Workstation-optional","name":"optional","type":"optional","arches":["x86_64"]}]}'
93
+ http_version:
94
+ recorded_at: Mon, 12 Sep 2016 07:48:14 GMT
95
+ recorded_with: VCR 3.0.3
@@ -20,4 +20,14 @@ describe :find do
20
20
  variant.v_id.must_equal 'v2'
21
21
  variant.title.must_equal 'variant'
22
22
  end
23
+
24
+ describe 'url' do
25
+ it 'returns url for resources fetched from remote' do
26
+ stub_get('products/1')
27
+ .to_return_json(data: [{ product_id: 1, title: 'foobar' }])
28
+ instance = Fixtures::Product.find(1)
29
+ expected_url = Fixtures::Base.connection.build_url('fixtures/products/1').to_s
30
+ instance.url.must_equal expected_url
31
+ end
32
+ end
23
33
  end
@@ -51,4 +51,18 @@ describe PDC::V1::Release do
51
51
  releases.must_equal [rhel7_1] * variants.length
52
52
  end
53
53
  end
54
+
55
+ describe '#url' do
56
+ it 'returns url of a release' do
57
+ rhel7_1 = release.find('rhel-7.1')
58
+ rhel7_1.url.must_equal(PDC_SITE + 'rest_api/v1/releases/rhel-7.1')
59
+ end
60
+
61
+ it 'returns url of a release_variant' do
62
+ rhel7_1 = release.find('rhel-7.1')
63
+ rhel7_1.variants.all.each do |v|
64
+ v.url.must_equal(PDC_SITE + 'rest_api/v1/release%2Dvariants/rhel-7.1/' + v.uid)
65
+ end
66
+ end
67
+ end
54
68
  end
data/spec/spec_helper.rb CHANGED
@@ -28,8 +28,10 @@ Minitest::Reporters.use! [
28
28
  # require all support files
29
29
  Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
30
30
 
31
+ PDC_SITE = 'https://pdc.host.dev.eng.pek2.redhat.com/'
32
+
31
33
  PDC.configure do |config|
32
- config.site = 'https://pdc.host.dev.eng.pek2.redhat.com/'
34
+ config.site = PDC_SITE
33
35
  config.requires_token = false
34
36
  config.disable_caching = true
35
37
  ### config.log_level = :debug # enable to see details log
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sunil Thaha
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-09-13 00:00:00.000000000 Z
12
+ date: 2016-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -164,6 +164,7 @@ files:
164
164
  - examples/prod_failures.rb
165
165
  - examples/prod_pdc.rb
166
166
  - examples/test_no_ssl_verification.rb
167
+ - examples/url.rb
167
168
  - lib/pdc.rb
168
169
  - lib/pdc/base.rb
169
170
  - lib/pdc/config.rb
@@ -217,6 +218,8 @@ files:
217
218
  - spec/fixtures/vcr/preserves_the_filters.yml
218
219
  - spec/fixtures/vcr/returns_resources_on_that_page.yml
219
220
  - spec/fixtures/vcr/returns_the_total_count_and_not_items_in_page.yml
221
+ - spec/fixtures/vcr/returns_url_of_a_release.yml
222
+ - spec/fixtures/vcr/returns_url_of_a_release_variant.yml
220
223
  - spec/fixtures/vcr/should_not_be_in_the_list_of_attributes.yml
221
224
  - spec/fixtures/vcr/works_with_where.yml
222
225
  - spec/pdc/config_spec.rb
@@ -277,6 +280,8 @@ test_files:
277
280
  - spec/fixtures/vcr/preserves_the_filters.yml
278
281
  - spec/fixtures/vcr/returns_resources_on_that_page.yml
279
282
  - spec/fixtures/vcr/returns_the_total_count_and_not_items_in_page.yml
283
+ - spec/fixtures/vcr/returns_url_of_a_release.yml
284
+ - spec/fixtures/vcr/returns_url_of_a_release_variant.yml
280
285
  - spec/fixtures/vcr/should_not_be_in_the_list_of_attributes.yml
281
286
  - spec/fixtures/vcr/works_with_where.yml
282
287
  - spec/pdc/config_spec.rb