travis-env_vars 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4d55467c1ca42239d43b306e44f1001a7eb487d0198b029cdf6e76fb384e255f
4
+ data.tar.gz: 1a3e120f3a5a7e8350372c2657d1a5fdd1cbef5032aac019ab4bda1e62232262
5
+ SHA512:
6
+ metadata.gz: 5d9f481764097b3b77d405434edadcd55d3ed7b11e89d2a77983358bdc89363a9178122c3988b760b3e12f4f717a2f990629b8a1f89dcc305a587ace3fa0dd7f
7
+ data.tar.gz: 44b44523835d582d5650a792ef331ab2008f311957c38ad99833b6f4be68cf596bd53f3cf01e7592e95be924a921daab5babae28474c52c569922f999d273e00
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5.1
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.1
5
+ before_install: gem install bundler -v 1.16.2
@@ -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 support@travis-ci.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/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in travis-env_vars.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,33 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ travis-env_vars (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ rspec (3.5.0)
11
+ rspec-core (~> 3.5.0)
12
+ rspec-expectations (~> 3.5.0)
13
+ rspec-mocks (~> 3.5.0)
14
+ rspec-core (3.5.2)
15
+ rspec-support (~> 3.5.0)
16
+ rspec-expectations (3.5.0)
17
+ diff-lcs (>= 1.2.0, < 2.0)
18
+ rspec-support (~> 3.5.0)
19
+ rspec-mocks (3.5.0)
20
+ diff-lcs (>= 1.2.0, < 2.0)
21
+ rspec-support (~> 3.5.0)
22
+ rspec-support (3.5.0)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ bundler (~> 1.16)
29
+ rspec (~> 3.0)
30
+ travis-env_vars!
31
+
32
+ BUNDLED WITH
33
+ 1.16.2
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Travis::EnvVars
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/travis/env_vars`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'travis-env_vars'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install travis-env_vars
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/joecorcoran/travis-env_vars. 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.
36
+
37
+ ## Code of Conduct
38
+
39
+ Everyone interacting in the Travis::EnvVars project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/joecorcoran/travis-env_vars/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,50 @@
1
+ require 'travis/env_vars/string'
2
+ require 'travis/env_vars/version'
3
+
4
+ # TODO this doesn't work with secure env vars, yet
5
+
6
+ module Travis
7
+ class EnvVars
8
+ ArgumentError = Class.new(::ArgumentError)
9
+ ParseError = Class.new(ArgumentError)
10
+
11
+ attr_reader :objs
12
+
13
+ def initialize(*objs)
14
+ @objs = objs.map { |obj| normalize(obj) }
15
+ end
16
+
17
+ def to_h(merge_mode = :merge)
18
+ send(merge_mode)
19
+ end
20
+
21
+ def to_a(merge_mode = :merge)
22
+ send(merge_mode).map { |pair| pair.join('=') }
23
+ end
24
+
25
+ private
26
+
27
+ def normalize(obj)
28
+ case obj
29
+ when ::String
30
+ String.new(obj).parse
31
+ when Hash
32
+ obj
33
+ else
34
+ raise ArgumentError, "unsupported type #{obj.class} (given: #{obj.inspect})"
35
+ end
36
+ end
37
+
38
+ def replace
39
+ # TODO
40
+ end
41
+
42
+ def merge
43
+ objs.inject(&:merge)
44
+ end
45
+
46
+ def deep_merge
47
+ # TODO
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,74 @@
1
+ require 'strscan'
2
+ require 'forwardable'
3
+
4
+ module Travis
5
+ class EnvVars
6
+ class String
7
+ KEY = %r([^\s=]+)
8
+ WORD = %r((\\.*|[^'"\s])+)
9
+ QUOTE = %r((['"`]{1}))
10
+ SPACE = %r(\s+)
11
+ EQUAL = %r(=)
12
+ SUBSH = %r(\$\(.*?\))
13
+
14
+ extend Forwardable
15
+
16
+ def_delegators :str, :check, :eos?, :peek, :pos, :scan, :skip, :string
17
+ attr_reader :str
18
+
19
+ def initialize(str)
20
+ @str = StringScanner.new(str)
21
+ end
22
+
23
+ def parse
24
+ pairs.to_h
25
+ end
26
+
27
+ def pairs
28
+ pairs = [pair]
29
+ pairs += self.pairs while space
30
+ pairs.tap { err('end of string') unless eos? }
31
+ end
32
+
33
+ def pair
34
+ return unless key = self.key
35
+ parts = [key, equal, value]
36
+ [parts.first, parts.last]
37
+ end
38
+
39
+ def key
40
+ scan(KEY)
41
+ end
42
+
43
+ def equal
44
+ scan(EQUAL) || err('=')
45
+ end
46
+
47
+ def value
48
+ quoted || subshell || word
49
+ end
50
+
51
+ def word
52
+ scan(WORD)
53
+ end
54
+
55
+ def subshell
56
+ scan(SUBSH)
57
+ end
58
+
59
+ def quoted
60
+ return unless peek(1) =~ QUOTE
61
+ err($1) if check(/#{$1}\\#{$1}($|\s)/)
62
+ scan(/#{$1}(\\#{$1}|[^#{$1}])*#{$1}/)
63
+ end
64
+
65
+ def space
66
+ scan(SPACE)
67
+ end
68
+
69
+ def err(char)
70
+ raise ParseError, "expected #{char} at position #{pos} in: #{string.inspect}"
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,5 @@
1
+ module Travis
2
+ class EnvVars
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,33 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "travis/env_vars/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "travis-env_vars"
7
+ spec.version = Travis::EnvVars::VERSION
8
+ spec.authors = ["Sven Fuchs", "Joe Corcoran"]
9
+ spec.email = ["sven@travis-ci.com", "joe@corcoran.online"]
10
+
11
+ spec.summary = %q{Parser for environment variables in .travis.yml}
12
+ spec.description = %q{Parser for environment variables in .travis.yml}
13
+ spec.homepage = "https://github.com/travis-ci/travis-env_vars"
14
+
15
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
16
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
17
+ if spec.respond_to?(:metadata)
18
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
19
+ else
20
+ raise "RubyGems 2.0 or newer is required to protect against " \
21
+ "public gem pushes."
22
+ end
23
+
24
+ # Specify which files should be added to the gem when it is released.
25
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
26
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
27
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
+ end
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.16"
32
+ spec.add_development_dependency "rspec", "~> 3.0"
33
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: travis-env_vars
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sven Fuchs
8
+ - Joe Corcoran
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2018-07-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.16'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.16'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rspec
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '3.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '3.0'
42
+ description: Parser for environment variables in .travis.yml
43
+ email:
44
+ - sven@travis-ci.com
45
+ - joe@corcoran.online
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - ".rspec"
52
+ - ".ruby-version"
53
+ - ".travis.yml"
54
+ - CODE_OF_CONDUCT.md
55
+ - Gemfile
56
+ - Gemfile.lock
57
+ - README.md
58
+ - lib/travis/env_vars.rb
59
+ - lib/travis/env_vars/string.rb
60
+ - lib/travis/env_vars/version.rb
61
+ - travis-env_vars.gemspec
62
+ homepage: https://github.com/travis-ci/travis-env_vars
63
+ licenses: []
64
+ metadata:
65
+ allowed_push_host: https://rubygems.org
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.7.6
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: Parser for environment variables in .travis.yml
86
+ test_files: []