trav3 0.3.3 → 0.3.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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/trav3.rb +234 -4
  4. data/lib/trav3/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cbe80498ecdd8cdfc666b5d4aebdf93e95e17ab2b5abcb4a82cddabbe70849e2
4
- data.tar.gz: ae6b79b2ac0378e1c3ada5cb55ce65d8564273f3700102f292f7e6e660fc8dd2
3
+ metadata.gz: ed23a93da595b3da695cb6caab54e75c06f8b0dad48f9765293a21698fe1893b
4
+ data.tar.gz: c6ca0a3472f8130457a2aadccdf757bfc4e8ba12c4ce43cc5bedf2e781c7a050
5
5
  SHA512:
6
- metadata.gz: 719cf9281a7b5f76f7ae6acdd72b93baafdef8e8abf12d0c478d55fb0a2be1a63e5b3f0c5cba828736677472dc5debe183cf594526e3b6241aace6722b99ba7f
7
- data.tar.gz: 63edbe4e649955a515288d3fe490a0e61113b8ce3589eac02fda43e8b031c670e9dcba07624651ec7ed84bcd5e7af6deb5b7395d1928ae9bf4e8a630c5fa49a6
6
+ metadata.gz: 57991342eb7e718ba0e4441a901e7765fd2bb19159eda1e124c2e214c86e60a7ee3a040ab931a8e5829c674035522126bfcaeb7f671570876baa9a5bc9414ea2
7
+ data.tar.gz: 235cbd08b2ec78926a8a142653ca98441c8063904e5686a37bf08d308c5c9495e9778023d9e8c5aac862b0ba9714f4d412e199474c7f29297297ef00899bf8b6
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/trav3.svg)](http://badge.fury.io/rb/trav3)
2
2
  [![Build Status](https://travis-ci.org/danielpclark/trav3.svg?branch=master)](https://travis-ci.org/danielpclark/trav3)
3
- [![Commits Since Release](https://img.shields.io/github/commits-since/danielpclark/trav3/v0.3.3.svg)](https://github.com/danielpclark/trav3/graphs/commit-activity)
3
+ [![Commits Since Release](https://img.shields.io/github/commits-since/danielpclark/trav3/v0.3.4.svg)](https://github.com/danielpclark/trav3/graphs/commit-activity)
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/1ed07a4baea3832b6207/maintainability)](https://codeclimate.com/github/danielpclark/trav3/maintainability)
5
5
  [![Test Coverage](https://api.codeclimate.com/v1/badges/1ed07a4baea3832b6207/test_coverage)](https://codeclimate.com/github/danielpclark/trav3/test_coverage)
6
6
  [![Red The Docs](https://img.shields.io/badge/Read-the%20docs-blue.svg)](http://danielpclark.github.io/trav3/Trav3/Travis.html)
@@ -662,6 +662,232 @@ module Trav3
662
662
  get("#{with_repo}/caches")
663
663
  end
664
664
 
665
+ # An individual cron. There can be only one cron per branch on a repository.
666
+ #
667
+ # If querying using the repository slug, it must be formatted using {http://www.w3schools.com/tags/ref_urlencode.asp standard URL encoding}, including any special characters.
668
+ #
669
+ # ## Attributes
670
+ #
671
+ # **Minimal Representation**
672
+ #
673
+ # Included when the resource is returned as part of another resource.
674
+ #
675
+ # Name Type Description
676
+ # id Integer Value uniquely identifying the cron.
677
+ #
678
+ # **Standard Representation**
679
+ #
680
+ # Included when the resource is the main response of a request, or is {https://developer.travis-ci.com/eager-loading eager loaded}.
681
+ #
682
+ # Name Type Description
683
+ # id Integer Value uniquely identifying the cron.
684
+ # repository Repository Github repository to which this cron belongs.
685
+ # branch Branch Git branch of repository to which this cron belongs.
686
+ # interval String Interval at which the cron will run (can be "daily", "weekly" or "monthly").
687
+ # dont_run_if_recent_build_exists Boolean Whether a cron build should run if there has been a build on this branch in the last 24 hours.
688
+ # last_run String When the cron ran last.
689
+ # next_run String When the cron is scheduled to run next.
690
+ # created_at String When the cron was created.
691
+ # active Unknown The cron's active.
692
+ #
693
+ # ## Actions
694
+ #
695
+ # **Find**
696
+ #
697
+ # This returns a single cron.
698
+ #
699
+ # GET <code>/cron/{cron.id}</code>
700
+ #
701
+ # Template Variable Type Description
702
+ # cron.id Integer Value uniquely identifying the cron.
703
+ # Query Parameter Type Description
704
+ # include [String] List of attributes to eager load.
705
+ #
706
+ # **Delete**
707
+ #
708
+ # This deletes a single cron.
709
+ #
710
+ # DELETE <code>/cron/{cron.id}</code>
711
+ #
712
+ # Template Variable Type Description
713
+ # cron.id Integer Value uniquely identifying the cron.
714
+ #
715
+ # **For Branch**
716
+ #
717
+ # This returns the cron set for the specified branch for the specified repository. It is possible to use the repository id or slug in the request.
718
+ #
719
+ # GET <code>/repo/{repository.id}/branch/{branch.name}/cron</code>
720
+ #
721
+ # Template Variable Type Description
722
+ # repository.id Integer Value uniquely identifying the repository.
723
+ # branch.name String Name of the git branch.
724
+ # Query Parameter Type Description
725
+ # include [String] List of attributes to eager load.
726
+ #
727
+ # Example: GET /repo/891/branch/master/cron
728
+ #
729
+ # GET <code>/repo/{repository.slug}/branch/{branch.name}/cron</code>
730
+ #
731
+ # Template Variable Type Description
732
+ # repository.slug String Same as {repository.owner.name}/{repository.name}.
733
+ # branch.name String Name of the git branch.
734
+ # Query Parameter Type Description
735
+ # include [String] List of attributes to eager load.
736
+ #
737
+ # Example: GET /repo/rails%2Frails/branch/master/cron
738
+ #
739
+ # **Create**
740
+ #
741
+ # This creates a cron on the specified branch for the specified repository. It is possible to use the repository id or slug in the request. Content-Type MUST be set in the header and an interval for the cron MUST be specified as a parameter.
742
+ #
743
+ # ```bash
744
+ # curl -X POST \
745
+ # -H "Content-Type: application/json" \
746
+ # -H "Travis-API-Version: 3" \
747
+ # -H "Authorization: token xxxxxxxxxxxx" \
748
+ # -d '{ "cron.interval": "monthly" }' \
749
+ # https://api.travis-ci.com/repo/1234/branch/master/cron
750
+ # ```
751
+ #
752
+ # POST <code>/repo/{repository.id}/branch/{branch.name}/cron</code>
753
+ #
754
+ # Template Variable Type Description
755
+ # repository.id Integer Value uniquely identifying the repository.
756
+ # branch.name String Name of the git branch.
757
+ # Accepted Parameter Type Description
758
+ # cron.interval String Interval at which the cron will run (can be "daily", "weekly" or "monthly").
759
+ # cron.dont_run_if_recent_build_exists Boolean Whether a cron build should run if there has been a build on this branch in the last 24 hours.
760
+ #
761
+ # Example: POST /repo/891/branch/master/cron
762
+ #
763
+ # POST <code>/repo/{repository.slug}/branch/{branch.name}/cron</code>
764
+ #
765
+ # Template Variable Type Description
766
+ # repository.slug String Same as {repository.owner.name}/{repository.name}.
767
+ # branch.name String Name of the git branch.
768
+ # Accepted Parameter Type Description
769
+ # cron.interval String Interval at which the cron will run (can be "daily", "weekly" or "monthly").
770
+ # cron.dont_run_if_recent_build_exists Boolean Whether a cron build should run if there has been a build on this branch in the last 24 hours.
771
+ #
772
+ # Example: POST /repo/rails%2Frails/branch/master/cron
773
+ #
774
+ # @param id [String, Integer] cron id to get or delete
775
+ # @param branch_name [String] branch name to get cron or create
776
+ # @param create [Hash] Properties for creating the cron. `branch_name` keyword argument required and `interval` key/value required.
777
+ # @param delete [Boolean] option for deleting cron. Cron `id` keyword argument required.
778
+ # @return [Success, RequestError]
779
+ def cron(id: nil, branch_name: nil, create: nil, delete: false)
780
+ if id
781
+ validate_number id
782
+
783
+ delete and return delete("#{without_repo}/cron/#{id}")
784
+ return get("#{without_repo}/cron/#{id}")
785
+ end
786
+ raise ArgumentError, 'id or branch_name required' unless branch_name
787
+
788
+ create and return create("#{with_repo}/branch/#{branch_name}/cron", cron_keys(create))
789
+ get("#{with_repo}/branch/#{branch_name}/cron")
790
+ end
791
+
792
+ # A list of crons.
793
+ #
794
+ # If querying using the repository slug, it must be formatted using {http://www.w3schools.com/tags/ref_urlencode.asp standard URL encoding}, including any special characters.
795
+ #
796
+ # ## Attributes
797
+ #
798
+ # Name Type Description
799
+ # crons [Cron] List of crons.
800
+ #
801
+ # **Collection Items**
802
+ #
803
+ # Each entry in the crons array has the following attributes:
804
+ #
805
+ # Name Type Description
806
+ # id Integer Value uniquely identifying the cron.
807
+ # repository Repository Github repository to which this cron belongs.
808
+ # branch Branch Git branch of repository to which this cron belongs.
809
+ # interval String Interval at which the cron will run (can be "daily", "weekly" or "monthly").
810
+ # dont_run_if_recent_build_exists Boolean Whether a cron build should run if there has been a build on this branch in the last 24 hours.
811
+ # last_run String When the cron ran last.
812
+ # next_run String When the cron is scheduled to run next.
813
+ # created_at String When the cron was created.
814
+ # active Unknown The cron's active.
815
+ #
816
+ # ## Actions
817
+ #
818
+ # **For Repository**
819
+ #
820
+ # This returns a list of crons for an individual repository. It is possible to use the repository id or slug in the request.
821
+ #
822
+ # GET <code>/repo/{repository.id}/crons</code>
823
+ #
824
+ # Template Variable Type Description
825
+ # repository.id Integer Value uniquely identifying the repository.
826
+ # Query Parameter Type Description
827
+ # include [String] List of attributes to eager load.
828
+ # limit Integer How many crons to include in the response. Used for pagination.
829
+ # offset Integer How many crons to skip before the first entry in the response. Used for pagination.
830
+ #
831
+ # Example: GET /repo/891/crons?limit=5
832
+ #
833
+ # GET <code>/repo/{repository.slug}/crons</code>
834
+ #
835
+ # Template Variable Type Description
836
+ # repository.slug String Same as {repository.owner.name}/{repository.name}.
837
+ # Query Parameter Type Description
838
+ # include [String] List of attributes to eager load.
839
+ # limit Integer How many crons to include in the response. Used for pagination.
840
+ # offset Integer How many crons to skip before the first entry in the response. Used for pagination.
841
+ #
842
+ # Example: GET /repo/rails%2Frails/crons?limit=5
843
+ #
844
+ # @return [Success, RequestError]
845
+ def crons
846
+ get("#{with_repo}/crons")
847
+ end
848
+
849
+ # POST <code>/repo/{repository.id}/email_subscription</code>
850
+ #
851
+ # Template Variable Type Description
852
+ # repository.id Integer Value uniquely identifying the repository.
853
+ #
854
+ # Example: POST /repo/891/email_subscription
855
+ #
856
+ # POST <code>/repo/{repository.slug}/email_subscription</code>
857
+ #
858
+ # Template Variable Type Description
859
+ # repository.slug String Same as {repository.owner.name}/{repository.name}.
860
+ #
861
+ # Example: POST /repo/rails%2Frails/email_subscription
862
+ #
863
+ # @note requests require an authorization token set in the headers. See: {authorization=}
864
+ #
865
+ # @return [Success, RequestError]
866
+ def email_resubscribe
867
+ post("#{with_repo}/email_subscription")
868
+ end
869
+
870
+ # DELETE <code>/repo/{repository.id}/email_subscription</code>
871
+ #
872
+ # Template Variable Type Description
873
+ # repository.id Integer Value uniquely identifying the repository.
874
+ #
875
+ # Example: DELETE /repo/891/email_subscription
876
+ #
877
+ # DELETE <code>/repo/{repository.slug}/email_subscription</code>
878
+ #
879
+ # Template Variable Type Description
880
+ # repository.slug String Same as {repository.owner.name}/{repository.name}.
881
+ #
882
+ # Example: DELETE /repo/rails%2Frails/email_subscription
883
+ #
884
+ # @note requests require an authorization token set in the headers. See: {authorization=}
885
+ #
886
+ # @return [Success, RequestError]
887
+ def email_unsubscribe
888
+ delete("#{with_repo}/email_subscription")
889
+ end
890
+
665
891
  # An individual environment variable.
666
892
  #
667
893
  # **If querying using the repository slug, it must be formatted using {http://www.w3schools.com/tags/ref_urlencode.asp standard URL encoding}, including any special characters.**
@@ -1338,8 +1564,6 @@ module Trav3
1338
1564
  #
1339
1565
  # Example: DELETE /job/86601347/log
1340
1566
  #
1341
- # @note DELETE is unimplemented
1342
- #
1343
1567
  # @param job_id [String, Integer] the job id number
1344
1568
  # @param option [Symbol] options for :text or :delete
1345
1569
  # @return [Success, String, RequestError]
@@ -1348,7 +1572,7 @@ module Trav3
1348
1572
  when :text
1349
1573
  get("#{without_repo}/job/#{job_id}/log.txt", true)
1350
1574
  when :delete
1351
- raise Unimplemented
1575
+ delete("#{without_repo}/job/#{job_id}/log")
1352
1576
  else
1353
1577
  get("#{without_repo}/job/#{job_id}/log")
1354
1578
  end
@@ -2485,6 +2709,10 @@ module Trav3
2485
2709
  Trav3::REST.create(self, url, data)
2486
2710
  end
2487
2711
 
2712
+ def cron_keys(hash)
2713
+ inject_property_name('cron', hash)
2714
+ end
2715
+
2488
2716
  def delete(url)
2489
2717
  Trav3::REST.delete(self, url)
2490
2718
  end
@@ -2517,7 +2745,9 @@ module Trav3
2517
2745
  end
2518
2746
 
2519
2747
  def inject_property_name(name, hash)
2520
- hash.map { |k, v| ["#{name}.#{k}", v] }.to_h unless hash.keys.first.match?(/#{name}\.\w+/)
2748
+ return hash.map { |k, v| ["#{name}.#{k}", v] }.to_h unless hash.keys.first.match?(/\A#{name}\.\w+\z/)
2749
+
2750
+ hash
2521
2751
  end
2522
2752
 
2523
2753
  def key_pair_keys(hash)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Trav3
4
- VERSION = '0.3.3'
4
+ VERSION = '0.3.4'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trav3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel P. Clark
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-26 00:00:00.000000000 Z
11
+ date: 2019-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler