pdc 0.1.0

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.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +27 -0
  3. data/.gitignore +10 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +21 -0
  7. data/CODE_OF_CONDUCT.md +49 -0
  8. data/Gemfile +32 -0
  9. data/Guardfile +36 -0
  10. data/LICENSE +21 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +41 -0
  13. data/Rakefile +11 -0
  14. data/bin/console +11 -0
  15. data/bin/setup +11 -0
  16. data/docs/.gitignore +3 -0
  17. data/docs/LICENSE_sphinx_deployment +27 -0
  18. data/docs/Makefile +179 -0
  19. data/docs/source/conf.py +257 -0
  20. data/docs/source/example.rst +10 -0
  21. data/docs/source/index.rst +23 -0
  22. data/docs/sphinx_deployment.mk +117 -0
  23. data/examples/active_attr.rb +33 -0
  24. data/examples/http_failures.rb +18 -0
  25. data/examples/local_pdc_dev.rb +15 -0
  26. data/examples/logger.rb +50 -0
  27. data/examples/pdc_curb_access_token.rb +36 -0
  28. data/examples/pdc_resource_tests.rb +173 -0
  29. data/examples/pdc_test_cache.rb +48 -0
  30. data/examples/prod_failures.rb +26 -0
  31. data/examples/prod_pdc.rb +14 -0
  32. data/lib/pdc/base.rb +14 -0
  33. data/lib/pdc/config.rb +157 -0
  34. data/lib/pdc/errors.rb +8 -0
  35. data/lib/pdc/http/errors.rb +43 -0
  36. data/lib/pdc/http/request/append_slash.rb +19 -0
  37. data/lib/pdc/http/request.rb +12 -0
  38. data/lib/pdc/http/response/pagination.rb +43 -0
  39. data/lib/pdc/http/response/parser.rb +62 -0
  40. data/lib/pdc/http/response/raise_error.rb +13 -0
  41. data/lib/pdc/http/response.rb +3 -0
  42. data/lib/pdc/http/result.rb +28 -0
  43. data/lib/pdc/http.rb +12 -0
  44. data/lib/pdc/logger.rb +19 -0
  45. data/lib/pdc/resource/attribute_modifier.rb +43 -0
  46. data/lib/pdc/resource/attribute_store.rb +22 -0
  47. data/lib/pdc/resource/attributes.rb +144 -0
  48. data/lib/pdc/resource/errors.rb +3 -0
  49. data/lib/pdc/resource/identity.rb +75 -0
  50. data/lib/pdc/resource/path.rb +63 -0
  51. data/lib/pdc/resource/per_thread_registry.rb +54 -0
  52. data/lib/pdc/resource/relation/finder.rb +24 -0
  53. data/lib/pdc/resource/relation/pagination.rb +33 -0
  54. data/lib/pdc/resource/relation/query.rb +14 -0
  55. data/lib/pdc/resource/relation.rb +81 -0
  56. data/lib/pdc/resource/rest_api.rb +34 -0
  57. data/lib/pdc/resource/scope_registry.rb +19 -0
  58. data/lib/pdc/resource/scopes.rb +29 -0
  59. data/lib/pdc/resource/value_parser.rb +31 -0
  60. data/lib/pdc/resource/wip.rb +0 -0
  61. data/lib/pdc/resource.rb +12 -0
  62. data/lib/pdc/v1/arch.rb +6 -0
  63. data/lib/pdc/v1/product.rb +5 -0
  64. data/lib/pdc/v1/release.rb +18 -0
  65. data/lib/pdc/v1/release_variant.rb +17 -0
  66. data/lib/pdc/v1.rb +8 -0
  67. data/lib/pdc/version.rb +3 -0
  68. data/lib/pdc.rb +25 -0
  69. data/pdc.gemspec +38 -0
  70. data/spec/fixtures/vcr/_page_count_returns_total_count.yml +141 -0
  71. data/spec/fixtures/vcr/brew_can_be_nil.yml +61 -0
  72. data/spec/fixtures/vcr/brew_may_be_present.yml +50 -0
  73. data/spec/fixtures/vcr/caches_multiple_response.yml +173 -0
  74. data/spec/fixtures/vcr/caches_response_with_a_query.yml +64 -0
  75. data/spec/fixtures/vcr/caches_response_with_multiple_query.yml +64 -0
  76. data/spec/fixtures/vcr/caches_response_without_query.yml +61 -0
  77. data/spec/fixtures/vcr/can_iterate_using_each.yml +187 -0
  78. data/spec/fixtures/vcr/fetches_variants_of_a_release.yml +663 -0
  79. data/spec/fixtures/vcr/must_return_number_of_resources.yml +61 -0
  80. data/spec/fixtures/vcr/preserves_the_filters.yml +49 -0
  81. data/spec/fixtures/vcr/returns_resources_on_that_page.yml +49 -0
  82. data/spec/fixtures/vcr/returns_the_total_count_and_not_items_in_page.yml +135 -0
  83. data/spec/fixtures/vcr/should_not_be_in_the_list_of_attributes.yml +95 -0
  84. data/spec/fixtures/vcr/works_with_where.yml +49 -0
  85. data/spec/pdc/config_spec.rb +115 -0
  86. data/spec/pdc/http/errors_spec.rb +58 -0
  87. data/spec/pdc/resource/attributes_spec.rb +231 -0
  88. data/spec/pdc/resource/cache_spec.rb +88 -0
  89. data/spec/pdc/resource/count_spec.rb +45 -0
  90. data/spec/pdc/resource/identity_spec.rb +96 -0
  91. data/spec/pdc/resource/pagination_spec.rb +51 -0
  92. data/spec/pdc/resource/path_spec.rb +30 -0
  93. data/spec/pdc/resource/relation_spec.rb +94 -0
  94. data/spec/pdc/resource/rest_api_spec.rb +23 -0
  95. data/spec/pdc/resource/value_parser_spec.rb +15 -0
  96. data/spec/pdc/resource/wip_spec.rb +0 -0
  97. data/spec/pdc/v1/arch_spec.rb +34 -0
  98. data/spec/pdc/v1/release_spec.rb +54 -0
  99. data/spec/pdc/version_spec.rb +5 -0
  100. data/spec/spec_helper.rb +39 -0
  101. data/spec/support/fixtures.rb +116 -0
  102. data/spec/support/vcr.rb +10 -0
  103. data/spec/support/webmock.rb +34 -0
  104. metadata +295 -0
@@ -0,0 +1,257 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # PDC documentation build configuration file, created by
4
+ # sphinx-quickstart on Tue Nov 18 14:45:45 2014.
5
+ #
6
+ # This file is execfile()d with the current directory set to its
7
+ # containing dir.
8
+ #
9
+ # Note that not all possible configuration values are present in this
10
+ # autogenerated file.
11
+ #
12
+ # All configuration values have a default; values that are commented out
13
+ # serve to show the default.
14
+
15
+
16
+ # If extensions (or modules to document with autodoc) are in another directory,
17
+ # add these directories to sys.path here. If the directory is relative to the
18
+ # documentation root, use os.path.abspath to make it absolute, like shown here.
19
+ #sys.path.insert(0, os.path.abspath('.'))
20
+
21
+ # -- General configuration ------------------------------------------------
22
+
23
+ # If your documentation needs a minimal Sphinx version, state it here.
24
+ #needs_sphinx = '1.0'
25
+
26
+ # Add any Sphinx extension module names here, as strings. They can be
27
+ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
28
+ # ones.
29
+ extensions = [
30
+ ]
31
+
32
+ # Add any paths that contain templates here, relative to this directory.
33
+ templates_path = ['_templates']
34
+
35
+ # The suffix of source filenames.
36
+ source_suffix = '.rst'
37
+
38
+ # The encoding of source files.
39
+ #source_encoding = 'utf-8-sig'
40
+
41
+ # The master toctree document.
42
+ master_doc = 'index'
43
+
44
+ # General information about the project.
45
+ project = u'PDC Client'
46
+ copyright = u'2014-2016, PDC Devel Team'
47
+
48
+ # The version info for the project you're documenting, acts as replacement for
49
+ # |version| and |release|, also used in various other places throughout the
50
+ # built documents.
51
+ #
52
+
53
+ version = '0.1'
54
+ # The full version, including alpha/beta/rc tags.
55
+ release = '0.1.0-1'
56
+
57
+ # The language for content autogenerated by Sphinx. Refer to documentation
58
+ # for a list of supported languages.
59
+ #language = None
60
+
61
+ # There are two options for replacing |today|: either, you set today to some
62
+ # non-false value, then it is used:
63
+ #today = ''
64
+ # Else, today_fmt is used as the format for a strftime call.
65
+ #today_fmt = '%B %d, %Y'
66
+
67
+ # List of patterns, relative to source directory, that match files and
68
+ # directories to ignore when looking for source files.
69
+ exclude_patterns = []
70
+
71
+ # The reST default role (used for this markup: `text`) to use for all
72
+ # documents.
73
+ #default_role = None
74
+
75
+ # If true, '()' will be appended to :func: etc. cross-reference text.
76
+ #add_function_parentheses = True
77
+
78
+ # If true, the current module name will be prepended to all description
79
+ # unit titles (such as .. function::).
80
+ #add_module_names = True
81
+
82
+ # If true, sectionauthor and moduleauthor directives will be shown in the
83
+ # output. They are ignored by default.
84
+ #show_authors = False
85
+
86
+ # The name of the Pygments (syntax highlighting) style to use.
87
+ pygments_style = 'sphinx'
88
+
89
+ # A list of ignored prefixes for module index sorting.
90
+ #modindex_common_prefix = []
91
+
92
+ # If true, keep warnings as "system message" paragraphs in the built documents.
93
+ #keep_warnings = False
94
+
95
+
96
+ # -- Options for HTML output ----------------------------------------------
97
+
98
+ # The theme to use for HTML and HTML Help pages. See the documentation for
99
+ # a list of builtin themes.
100
+ html_theme = 'default'
101
+
102
+ # Theme options are theme-specific and customize the look and feel of a theme
103
+ # further. For a list of options available for each theme, see the
104
+ # documentation.
105
+ #html_theme_options = {}
106
+
107
+ # Add any paths that contain custom themes here, relative to this directory.
108
+ #html_theme_path = []
109
+
110
+ # The name for this set of Sphinx documents. If None, it defaults to
111
+ # "<project> v<release> documentation".
112
+ #html_title = None
113
+
114
+ # A shorter title for the navigation bar. Default is the same as html_title.
115
+ #html_short_title = None
116
+
117
+ # The name of an image file (relative to this directory) to place at the top
118
+ # of the sidebar.
119
+ #html_logo = None
120
+
121
+ # The name of an image file (within the static path) to use as favicon of the
122
+ # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
123
+ # pixels large.
124
+ #html_favicon = None
125
+
126
+ # Add any paths that contain custom static files (such as style sheets) here,
127
+ # relative to this directory. They are copied after the builtin static files,
128
+ # so a file named "default.css" will overwrite the builtin "default.css".
129
+ html_static_path = ['_static']
130
+
131
+ # Add any extra paths that contain custom files (such as robots.txt or
132
+ # .htaccess) here, relative to this directory. These files are copied
133
+ # directly to the root of the documentation.
134
+ #html_extra_path = []
135
+
136
+ # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
137
+ # using the given strftime format.
138
+ #html_last_updated_fmt = '%b %d, %Y'
139
+
140
+ # If true, SmartyPants will be used to convert quotes and dashes to
141
+ # typographically correct entities.
142
+ #html_use_smartypants = True
143
+
144
+ # Custom sidebar templates, maps document names to template names.
145
+ #html_sidebars = {}
146
+
147
+ # Additional templates that should be rendered to pages, maps page names to
148
+ # template names.
149
+ #html_additional_pages = {}
150
+
151
+ # If false, no module index is generated.
152
+ #html_domain_indices = True
153
+
154
+ # If false, no index is generated.
155
+ #html_use_index = True
156
+
157
+ # If true, the index is split into individual pages for each letter.
158
+ #html_split_index = False
159
+
160
+ # If true, links to the reST sources are added to the pages.
161
+ #html_show_sourcelink = True
162
+
163
+ # If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
164
+ #html_show_sphinx = True
165
+
166
+ # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
167
+ #html_show_copyright = True
168
+
169
+ # If true, an OpenSearch description file will be output, and all pages will
170
+ # contain a <link> tag referring to it. The value of this option must be the
171
+ # base URL from which the finished HTML is served.
172
+ #html_use_opensearch = ''
173
+
174
+ # This is the file name suffix for HTML files (e.g. ".xhtml").
175
+ #html_file_suffix = None
176
+
177
+ # Output file base name for HTML help builder.
178
+ htmlhelp_basename = 'PDCRubyGemdoc'
179
+
180
+
181
+ # -- Options for LaTeX output ---------------------------------------------
182
+
183
+ latex_elements = {
184
+ # The paper size ('letterpaper' or 'a4paper').
185
+ #'papersize': 'letterpaper',
186
+
187
+ # The font size ('10pt', '11pt' or '12pt').
188
+ #'pointsize': '10pt',
189
+
190
+ # Additional stuff for the LaTeX preamble.
191
+ #'preamble': '',
192
+ }
193
+
194
+ # Grouping the document tree into LaTeX files. List of tuples
195
+ # (source start file, target name, title,
196
+ # author, documentclass [howto, manual, or own class]).
197
+ #latex_documents = [
198
+ # ('index', 'PDC_client.tex', u'PDC Ruby Gem Documentation',
199
+ # u'PDC Devel Team', 'manual'),
200
+ #]
201
+
202
+ # The name of an image file (relative to this directory) to place at the top of
203
+ # the title page.
204
+ #latex_logo = None
205
+
206
+ # For "manual" documents, if this is true, then toplevel headings are parts,
207
+ # not chapters.
208
+ #latex_use_parts = False
209
+
210
+ # If true, show page references after internal links.
211
+ #latex_show_pagerefs = False
212
+
213
+ # If true, show URL addresses after external links.
214
+ #latex_show_urls = False
215
+
216
+ # Documents to append as an appendix to all manuals.
217
+ #latex_appendices = []
218
+
219
+ # If false, no module index is generated.
220
+ #latex_domain_indices = True
221
+
222
+
223
+ # -- Options for manual page output ---------------------------------------
224
+
225
+ # One entry per manual page. List of tuples
226
+ # (source start file, name, description, authors, manual section).
227
+ #man_pages = [
228
+ # ('index', 'pdc client', u'PDC Client Documentation',
229
+ # [u'PDC Devel Team'], 1)
230
+ #]
231
+
232
+ # If true, show URL addresses after external links.
233
+ #man_show_urls = False
234
+
235
+
236
+ # -- Options for Texinfo output -------------------------------------------
237
+
238
+ # Grouping the document tree into Texinfo files. List of tuples
239
+ # (source start file, target name, title, author,
240
+ # dir menu entry, description, category)
241
+ #texinfo_documents = [
242
+ # ('index', 'PDC Client', u'PDC Client Documentation',
243
+ # u'PDC Devel Team', 'PDC', 'One line description of project.',
244
+ # 'Miscellaneous'),
245
+ #]
246
+
247
+ # Documents to append as an appendix to all manuals.
248
+ #texinfo_appendices = []
249
+
250
+ # If false, no module index is generated.
251
+ #texinfo_domain_indices = True
252
+
253
+ # How to display URL addresses: 'footnote', 'no', or 'inline'.
254
+ #texinfo_show_urls = 'footnote'
255
+
256
+ # If true, do not generate a @detailmenu in the "Top" node's menu.
257
+ #texinfo_no_detailmenu = False
@@ -0,0 +1,10 @@
1
+ .. _example:
2
+
3
+
4
+ First page
5
+ =======
6
+
7
+ Example page
8
+ -------------
9
+
10
+ Please use markdown to write the documentation file.
@@ -0,0 +1,23 @@
1
+ .. PDC Ruby Gem documentation master file, created by
2
+ sphinx-quickstart on Tue Aug 17 14:45:45 2016.
3
+ You can adapt this file completely to your liking, but it should at least
4
+ contain the root `toctree` directive.
5
+
6
+ Welcome to PDC Ruby Gem's documentation!
7
+ ===============================
8
+
9
+ Contents:
10
+
11
+ .. toctree::
12
+ :maxdepth: 3
13
+ :numbered:
14
+
15
+ example
16
+
17
+
18
+ Indices and tables
19
+ ==================
20
+
21
+ * :ref:`genindex`
22
+ * :ref:`search`
23
+
@@ -0,0 +1,117 @@
1
+ # Copyright (c) Teracy, Inc. and individual contributors.
2
+ # All rights reserved.
3
+
4
+ # Redistribution and use in source and binary forms, with or without modification,
5
+ # are permitted provided that the following conditions are met:
6
+
7
+ # 1. Redistributions of source code must retain the above copyright notice,
8
+ # this list of conditions and the following disclaimer.
9
+
10
+ # 2. Redistributions in binary form must reproduce the above copyright
11
+ # notice, this list of conditions and the following disclaimer in the
12
+ # documentation and/or other materials provided with the distribution.
13
+
14
+ # 3. Neither the name of Teracy, Inc. nor the names of its contributors may be used
15
+ # to endorse or promote products derived from this software without
16
+ # specific prior written permission.
17
+
18
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22
+ # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
29
+ # Deployment configurations from sphinx_deployment project
30
+
31
+ # default deployment when $ make deploy
32
+ # deploy_gh_pages : to $ make deploy_gh_pages
33
+
34
+ # default value: deploy_gh_pages
35
+ ifndef DEPLOY_DEFAULT
36
+ DEPLOY_DEFAULT = deploy_gh_pages
37
+ endif
38
+
39
+ # The deployment directory to be deployed
40
+ ifndef DEPLOY_DIR
41
+ DEPLOY_DIR = _deploy
42
+ endif
43
+
44
+ # The heroku deployment directory to be deployed
45
+ # we must create this separated dir to avoid any conflict with _deploy (rsync and gh_pages)
46
+ ifndef DEPLOY_DIR_HEROKU
47
+ DEPLOY_DIR_HEROKU = _deploy_heroku
48
+ endif
49
+
50
+ # Copy contents from $(BUILDDIR) to $(DEPLOY_DIR)/$(DEPLOY_HTML_DIR) directory
51
+ ifndef DEPLOY_HTML_DIR
52
+ DEPLOY_HTML_DIR = .
53
+ endif
54
+
55
+ ## -- Github Pages Deploy config -- ##
56
+
57
+ # Configure the right deployment branch
58
+ ifndef DEPLOY_BRANCH_GITHUB
59
+ DEPLOY_BRANCH_GITHUB = gh-pages
60
+ endif
61
+
62
+ #if REPO_URL_GITHUB was NOT defined by travis-ci
63
+ ifndef REPO_URL_GITHUB
64
+ # Configure your right github project repo
65
+ # REPO_URL_GITHUB = https://github.com/product-definition-center/pdc-client
66
+ endif
67
+
68
+ ## end deployment configuration, don't edit anything below this line ##
69
+ #######################################################################
70
+
71
+ ifeq ($(RSYNC_DELETE), true)
72
+ RSYNC_DELETE_OPT = --delete
73
+ endif
74
+
75
+ init_gh_pages:
76
+ @rm -rf $(DEPLOY_DIR)
77
+ @mkdir -p $(DEPLOY_DIR)
78
+ @cd $(DEPLOY_DIR); git init;\
79
+ echo 'sphinx docs comming soon...' > index.html;\
80
+ touch .nojekyll;\
81
+ git add .; git commit -m "sphinx docs init";\
82
+ git branch -m $(DEPLOY_BRANCH_GITHUB);\
83
+ git remote add origin $(REPO_URL_GITHUB);
84
+ @cd $(DEPLOY_DIR);\
85
+ if ! git ls-remote origin $(DEPLOY_BRANCH_GITHUB) | grep $(DEPLOY_BRANCH_GITHUB) ; then \
86
+ echo "Preparing Github deployment branch: $(DEPLOY_BRANCH_GITHUB) for the first time only...";\
87
+ git push -u origin $(DEPLOY_BRANCH_GITHUB);\
88
+ fi
89
+
90
+ setup_gh_pages: init_gh_pages
91
+ @echo "Setting up gh-pages deployment..."
92
+ @cd $(DEPLOY_DIR);\
93
+ git fetch origin;\
94
+ git reset --hard origin/$(DEPLOY_BRANCH_GITHUB);\
95
+ git branch --set-upstream $(DEPLOY_BRANCH_GITHUB) origin/$(DEPLOY_BRANCH_GITHUB)
96
+ @echo "Now you can deploy to Github Pages with 'make generate' and then 'make deploy_gh_pages'"
97
+
98
+ generate: html
99
+
100
+ prepare_gh_pages_deployment:
101
+ @echo "Preparing gh_pages deployment..."
102
+ @echo "Pulling any updates from Github Pages..."
103
+ @cd $(DEPLOY_DIR); git pull;
104
+ @mkdir -p $(DEPLOY_DIR)/$(DEPLOY_HTML_DIR)
105
+ @echo "Copying files from '$(BUILDDIR)/html/.' to '$(DEPLOY_DIR)/$(DEPLOY_HTML_DIR)'"
106
+ @cp -r $(BUILDDIR)/html/. $(DEPLOY_DIR)/$(DEPLOY_HTML_DIR)
107
+
108
+ deploy_gh_pages: prepare_gh_pages_deployment
109
+ @echo "Deploying on github pages now..."
110
+ @cd $(DEPLOY_DIR); git add -A; git commit -m "docs updated at `LC_ALL=en_US.utf8 date -u`";\
111
+ git push origin $(DEPLOY_BRANCH) --quiet
112
+ @echo "Github Pages deploy was completed at `LC_ALL=en_US.utf8 date -u`"
113
+
114
+
115
+ deploy: $(DEPLOY_DEFAULT)
116
+
117
+ gen_deploy: generate deploy
@@ -0,0 +1,33 @@
1
+
2
+ # module PDC
3
+ # class Base
4
+ # include ActiveAttr::Model
5
+ # include Resource::Identity
6
+ # end
7
+ # end
8
+ #
9
+ # module PDC::V1
10
+ # class Release < PDC::Base
11
+ # attribute :first_name
12
+ # attribute :last_name
13
+ # end
14
+ # end
15
+ #
16
+ #
17
+ #
18
+ #
19
+ # describe PDC::V1::Release do
20
+ # let(:release_class) { PDC::V1::Release }
21
+ # it 'works' do
22
+ # person = release_class.new
23
+ # person.first_name = "Chris"
24
+ # person.last_name = "Griego"
25
+ # person.attributes #=> {"first_name"=>"Chris", "last_name"=>"Griego"}
26
+ # person.first_name = "Chris"
27
+ # person.last_name = "Griego"
28
+ # require 'pry'; binding.pry
29
+ # person.attributes #=> {"first_name"=>"Chris", "last_name"=>"Griego"}
30
+ # end
31
+ # end
32
+ #
33
+ #
@@ -0,0 +1,18 @@
1
+ require 'ap'
2
+ require './lib/pdc'
3
+
4
+ PDC.configure do |config|
5
+ # invalid
6
+ config.site = 'http://localhost:8000/foo/bar/baz'
7
+ config.enable_logging = true
8
+ config.auth_type = :basic
9
+ config.use_ssl = false
10
+ end
11
+
12
+ begin
13
+ release = PDC::V1::Release.all
14
+ release.to_a
15
+ rescue PDC::Error::ResourceNotFound => e
16
+ ap e
17
+ puts "Got resource not found as expected: #{e.response[:status]}".yellowish
18
+ end
@@ -0,0 +1,15 @@
1
+ require 'ap'
2
+ require_relative '../lib/pdc'
3
+
4
+ def main
5
+ PDC.configure do |config|
6
+ config.site = 'http://localhost:8000'
7
+ config.requires_token = false
8
+ config.log_level = :debug
9
+ end
10
+
11
+ releases = PDC::V1::Release.all!.to_a
12
+ ap releases
13
+ end
14
+
15
+ main if __FILE__ == $PROGRAM_NAME
@@ -0,0 +1,50 @@
1
+ require_relative '../lib/pdc'
2
+ require 'ap'
3
+
4
+ class FakeLogger
5
+ attr_accessor :level
6
+
7
+ def debug(*args)
8
+ end
9
+ def info(*args)
10
+ end
11
+ def warn(*args)
12
+ end
13
+ def fatal(*args)
14
+ end
15
+
16
+ def error(*args)
17
+ end
18
+ end
19
+
20
+ #PDC.logger = FakeLogger.new
21
+
22
+
23
+ logger = PDC.logger
24
+
25
+ logger.debug("Debug will be logged")
26
+ logger.info("Info will be logged as well")
27
+
28
+ logger.level = Logger::WARN
29
+
30
+ logger.debug("Created logger") # won't be logged
31
+ logger.info("Program started") # won't be logged
32
+ logger.warn("Nothing to do!")
33
+ logger.error("Error something really went wrong")
34
+
35
+ path = "a_non_existent_file"
36
+
37
+ begin
38
+ File.foreach(path) do |line|
39
+ unless line =~ /^(\w+) = (.*)$/
40
+ logger.error("Line in wrong format: #{line.chomp}")
41
+ end
42
+ end
43
+ rescue => err
44
+ logger.fatal("Caught exception; exiting")
45
+ logger.fatal(err)
46
+ end
47
+
48
+ logger.level = Logger::INFO
49
+ logger.info("will continue here")
50
+
@@ -0,0 +1,36 @@
1
+ require 'ap'
2
+ require 'curb'
3
+ require 'json'
4
+ require './lib/pdc'
5
+
6
+ def obtain_token
7
+ url = PDC.config.site + PDC.config.rest_api_path + '/' + PDC.config.token_obtain_path
8
+
9
+ c = Curl::Easy.new(url) do |request|
10
+ request.headers["Accept"] = "application/json"
11
+ request.http_auth_types = :gssnegotiate
12
+
13
+ # The curl man page (http://curl.haxx.se/docs/manpage.html) specifes
14
+ # setting a fake username when using Negotiate auth, and use ':'
15
+ # in their example.
16
+ request.username = ':'
17
+ end
18
+ c.perform
19
+ raise "Obtain token from #{url} failed: #{c.body_str}" if c.response_code != 200
20
+ result = JSON.parse(c.body_str)
21
+ ap result
22
+ c.close
23
+ result['token']
24
+ end
25
+
26
+ PDC.configure do |config|
27
+ # invalid
28
+ config.site = 'https://pdc.engineering.redhat.com/'
29
+ end
30
+
31
+ def show_releases
32
+ releases = PDC::V1::Release.all
33
+ ap releases.to_a
34
+ end
35
+
36
+ show_releases