global-codecov 1.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d056bea2a2bde07433024768db35201a5d3934f6
4
+ data.tar.gz: 131ed06f30454319647e171f47d76d7b8e9d22a5
5
+ SHA512:
6
+ metadata.gz: c5b56d1a534e041bf771a145d01bbe45a023385ebc74f0c40afaae781641fbd9a234445a28d7d8b65f1a0031a1f6e069ca81c7353574855532b01e85e2e30632
7
+ data.tar.gz: 38814095b8c33ab767e83eb2c2404456a070f0b4a90b03016c83ee522c7fd845928cd1d9df09b000daf42b5981214af8baedf29eeb332c0fc1241d8271113783
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at aguilerasanti@hotmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2017, Santi Aguilera
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,87 @@
1
+ # Codecov
2
+
3
+ [![CircleCI](https://circleci.com/gh/saantiaguilera/ruby-api-codecov/tree/master.svg?style=svg)](https://circleci.com/gh/saantiaguilera/ruby-api-codecov/tree/master) [![codecov](https://codecov.io/gh/saantiaguilera/ruby-api-codecov/branch/master/graph/badge.svg)](https://codecov.io/gh/saantiaguilera/ruby-api-codecov)
4
+
5
+ This gem is for running codecov for any language (apart from ruby itself, since [their bash script doesnt support it yet](https://github.com/codecov/codecov-ruby/issues/4#issuecomment-121964456)) from a ruby script.
6
+
7
+ If you were using bash, you would do a simple curl redirect into a shell (`bash <(curl -s http://some.bash.script.com)`). But this cant be done from ruby since the redirect isnt available.
8
+
9
+ This gem is here for providing exactly that behavior.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'global-codecov'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install codecov
26
+
27
+ ## Usage
28
+
29
+ ### Import
30
+
31
+ Require the module:
32
+ ```ruby
33
+ require 'global-codecov'
34
+ ```
35
+
36
+ ### Setting destination of the script
37
+
38
+ Use the provided setter
39
+ ```ruby
40
+ Codecov.set_script_destination "somewhere/over/the/rainbow/file.sh"
41
+ ```
42
+
43
+ _Note_: The module will only download the file once, so that the overhead of the api is as low as possible
44
+
45
+ ### Running
46
+
47
+ For running simply invoke
48
+ ```ruby
49
+ Codecov.run
50
+ ```
51
+ And thats it! It will be as running `bash <(https://www.codecov.io/bash)`
52
+
53
+ #### Arguments
54
+
55
+ If you wish to pass arguments to the bash script, pass them as a map of either `nil`, `String` or `Array`.
56
+
57
+ Eg.
58
+ ```ruby
59
+ params = {
60
+ 'c' => nil,
61
+ 'X' => [ 'glib', 'silent', 'test' ],
62
+ 't' => 'access_token',
63
+ 'root_dir' => '',
64
+ 's' => nil,
65
+ 'f' => [ 'file1.txt', 'file2.txt' ]
66
+ }
67
+ Codecov.run params
68
+ ```
69
+ Will be: `bash <(https://www.codecov.io/bash) -c -X glib -X silent -X test -t access_token -root_dir '' -s -f file1.txt -f file2.txt`
70
+
71
+ ## Development
72
+
73
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
74
+
75
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
76
+
77
+ ## Contributing
78
+
79
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/codecov. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
80
+
81
+ ## License
82
+
83
+ The gem is available as open source under the terms of the [BSD-3 License](https://opensource.org/licenses/BSD-3-Clause).
84
+
85
+ ## Code of Conduct
86
+
87
+ Everyone interacting in the Codecov project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/codecov/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,120 @@
1
+ require 'shellwords'
2
+ require 'open-uri'
3
+
4
+ ##
5
+ # Codecov module for executing codecov coverage
6
+ # for any platform independently
7
+ ##
8
+ module Codecov
9
+
10
+ ##
11
+ # Gem information
12
+ ##
13
+ NAME = 'global-codecov'.freeze
14
+ VERSION = '1.0.0'.freeze
15
+
16
+ class << self
17
+ attr_accessor :CODECOV_DESTINATION
18
+ attr_accessor :SCRIPT_ENDPOINT
19
+ end
20
+
21
+ ##
22
+ # Codecov absolute file destionation
23
+ ##
24
+ self.CODECOV_DESTINATION = "codecov_script.sh"
25
+
26
+ ##
27
+ # Script endpoint from where to download the codecov file
28
+ ##
29
+ self.SCRIPT_ENDPOINT = 'https://codecov.io/bash'.freeze
30
+
31
+ ##
32
+ # PUBLIC
33
+ #
34
+ # Set the script destination path.
35
+ # We will download the bash script in this path
36
+ #
37
+ # @param dest String with the absolute file path, used as destination
38
+ # for the bash script
39
+ #
40
+ # Defaults to "codecov_script.sh"
41
+ ##
42
+ def self.set_script_destination(dest)
43
+ self.CODECOV_DESTINATION = dest.to_s.shellescape
44
+ end
45
+
46
+ ##
47
+ # PUBLIC
48
+ #
49
+ # Runs codecov
50
+ #
51
+ # @params map with parameters for codecov
52
+ # @returns command ran
53
+ # Eg.
54
+ # params = {
55
+ # 'c' => nil,
56
+ # 'empty' => '',
57
+ # 'X' => [ 'gcov', 'coveragepy', 'fix' ],
58
+ # 'R' => 'root_dir',
59
+ # 't' => 'MY_ACCESS_TOKEN'
60
+ # }
61
+ #
62
+ # Translates to:
63
+ # bash <(http://codecov.io/bash) -c -empty '' -X gcov -X coveragepy
64
+ # -X fix -R root_dir -t MY_ACCESS_TOKEN
65
+ #
66
+ # Notes: This will shellescape ALL, since this is still a shell
67
+ # so using $MY_VAR wont work. If you want to pass a variable
68
+ # use ENV['MY_VAR'] and pass that in the map.
69
+ #
70
+ # For information about all the params codecov supports, refer
71
+ # to the bash script -h function :)
72
+ ##
73
+ def self.run(params = nil)
74
+ download_script unless File.file? self.CODECOV_DESTINATION
75
+
76
+ flags = ''
77
+ flags << as_flags(params) unless params.nil?
78
+
79
+ command = "bash #{self.CODECOV_DESTINATION} #{flags}"
80
+
81
+ system command
82
+ return command
83
+ end
84
+
85
+ ##
86
+ # Transforms the params into flags
87
+ # @param params nonnull map of <k,v>
88
+ ##
89
+ def self.as_flags(params)
90
+ return '' if params.nil?
91
+
92
+ return params.map { |k,v|
93
+ case
94
+ when v.nil?
95
+ "-#{k.to_s.shellescape}"
96
+ when v.is_a?(String)
97
+ "-#{k.to_s.shellescape} #{v.to_s.shellescape}"
98
+ when v.is_a?(Array)
99
+ v.flat_map { |iv| [ "-#{k.to_s.shellescape}", iv.to_s.shellescape ] }[0..-1].join(' ')
100
+ else
101
+ raise "Cant understand '#{k}' => '#{v}'"
102
+ end
103
+ }.join(' ')
104
+ end
105
+
106
+ ##
107
+ # PRIVATE. This method is for the api, avoid using it
108
+ #
109
+ # Downloads the SCRIPT_ENDPOINT into the CODECOV_DESTINATION
110
+ # This method doesnt have behavior if the CODECOV_DESTINATION
111
+ # already exists
112
+ ##
113
+ def self.download_script()
114
+ unless File.file? self.CODECOV_DESTINATION
115
+ download = open(self.SCRIPT_ENDPOINT)
116
+ IO.copy_stream(download, self.CODECOV_DESTINATION)
117
+ end
118
+ end
119
+
120
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: global-codecov
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - saantiaguilera
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-11-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: ''
56
+ email:
57
+ - aguilerasanti@hotmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - CODE_OF_CONDUCT.md
63
+ - LICENSE
64
+ - README.md
65
+ - lib/global-codecov.rb
66
+ homepage: https://www.github.com/saantiaguilera/ruby-api-codecov
67
+ licenses:
68
+ - BSD-3-Clause
69
+ metadata:
70
+ allowed_push_host: https://rubygems.org
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.6.14
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Codecov gem lets you run codecov for any language from ruby
91
+ test_files: []
92
+ has_rdoc: