rascal 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 814d874743694d11422907bf02213100735789bb30c4f6a04d5bf57d3a686541
4
+ data.tar.gz: 77a43969306a5d45e84a8f7a4e3518604b09989701afc4829188ae6385ef464d
5
+ SHA512:
6
+ metadata.gz: f076c894c0bebe868de8f56764ce47d2bd54ed8052550aa4595c48238515db324f5582f0f0f612976b81e06f99597bd76d303f8b2171ada400b221280c7ca4ae
7
+ data.tar.gz: e2ac5cf785f08ab3f1adfafde4c2bd8e6e0a2bb72ebb740b279d584379341915f4e595c5b987a1b8ecb00236cc7f50321e449074c83223cb62a3618ce6d88c7a
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.5
data/.travis.yml ADDED
@@ -0,0 +1,16 @@
1
+ # yes, we use travis for open source gems
2
+
3
+ language: ruby
4
+ rvm:
5
+ - '2.5.4'
6
+ gemfile:
7
+ - Gemfile
8
+ script: bundle exec rake
9
+ sudo: false
10
+ cache: vendor/bundler
11
+ notifications:
12
+ email:
13
+ - fail@makandra.de
14
+ install:
15
+ - gem install bundler:2.0.1
16
+ - bundle install --no-deployment --jobs=3 --retry=3 --path=${BUNDLE_PATH:-vendor/bundle}
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ # Rascal Changelog
2
+
3
+ All notable changes to this project will be documented here.
4
+
5
+ Rascal follows semantic versioning. This has little consequence pre 1.0, so expect breaking changes.
6
+
7
+
8
+ ## 0.1.0 (2019-03-21)
9
+
10
+ initial release
data/Gemfile ADDED
@@ -0,0 +1,14 @@
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 rascal.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 10.0'
9
+ gem 'rspec'
10
+ gem 'cucumber'
11
+ gem 'aruba'
12
+
13
+ gem 'guard-rspec'
14
+ gem 'guard-cucumber'
data/Gemfile.lock ADDED
@@ -0,0 +1,110 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rascal (0.1.0)
5
+ thor (~> 0.20.3)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ aruba (0.14.9)
11
+ childprocess (>= 0.6.3, < 1.1.0)
12
+ contracts (~> 0.9)
13
+ cucumber (>= 1.3.19)
14
+ ffi (~> 1.9)
15
+ rspec-expectations (>= 2.99)
16
+ thor (~> 0.19)
17
+ backports (3.12.0)
18
+ builder (3.2.3)
19
+ childprocess (1.0.1)
20
+ rake (< 13.0)
21
+ coderay (1.1.2)
22
+ contracts (0.16.0)
23
+ cucumber (3.1.2)
24
+ builder (>= 2.1.2)
25
+ cucumber-core (~> 3.2.0)
26
+ cucumber-expressions (~> 6.0.1)
27
+ cucumber-wire (~> 0.0.1)
28
+ diff-lcs (~> 1.3)
29
+ gherkin (~> 5.1.0)
30
+ multi_json (>= 1.7.5, < 2.0)
31
+ multi_test (>= 0.1.2)
32
+ cucumber-core (3.2.1)
33
+ backports (>= 3.8.0)
34
+ cucumber-tag_expressions (~> 1.1.0)
35
+ gherkin (~> 5.0)
36
+ cucumber-expressions (6.0.1)
37
+ cucumber-tag_expressions (1.1.1)
38
+ cucumber-wire (0.0.1)
39
+ diff-lcs (1.3)
40
+ ffi (1.10.0)
41
+ formatador (0.2.5)
42
+ gherkin (5.1.0)
43
+ guard (2.15.0)
44
+ formatador (>= 0.2.4)
45
+ listen (>= 2.7, < 4.0)
46
+ lumberjack (>= 1.0.12, < 2.0)
47
+ nenv (~> 0.1)
48
+ notiffany (~> 0.0)
49
+ pry (>= 0.9.12)
50
+ shellany (~> 0.0)
51
+ thor (>= 0.18.1)
52
+ guard-compat (1.2.1)
53
+ guard-cucumber (1.5.4)
54
+ cucumber (>= 1.3.0)
55
+ guard-compat (~> 1.0)
56
+ nenv (~> 0.1)
57
+ guard-rspec (4.7.3)
58
+ guard (~> 2.1)
59
+ guard-compat (~> 1.1)
60
+ rspec (>= 2.99.0, < 4.0)
61
+ listen (3.1.5)
62
+ rb-fsevent (~> 0.9, >= 0.9.4)
63
+ rb-inotify (~> 0.9, >= 0.9.7)
64
+ ruby_dep (~> 1.2)
65
+ lumberjack (1.0.13)
66
+ method_source (0.9.2)
67
+ multi_json (1.13.1)
68
+ multi_test (0.1.2)
69
+ nenv (0.3.0)
70
+ notiffany (0.1.1)
71
+ nenv (~> 0.1)
72
+ shellany (~> 0.0)
73
+ pry (0.12.2)
74
+ coderay (~> 1.1.0)
75
+ method_source (~> 0.9.0)
76
+ rake (10.5.0)
77
+ rb-fsevent (0.10.3)
78
+ rb-inotify (0.10.0)
79
+ ffi (~> 1.0)
80
+ rspec (3.8.0)
81
+ rspec-core (~> 3.8.0)
82
+ rspec-expectations (~> 3.8.0)
83
+ rspec-mocks (~> 3.8.0)
84
+ rspec-core (3.8.0)
85
+ rspec-support (~> 3.8.0)
86
+ rspec-expectations (3.8.2)
87
+ diff-lcs (>= 1.2.0, < 2.0)
88
+ rspec-support (~> 3.8.0)
89
+ rspec-mocks (3.8.0)
90
+ diff-lcs (>= 1.2.0, < 2.0)
91
+ rspec-support (~> 3.8.0)
92
+ rspec-support (3.8.0)
93
+ ruby_dep (1.5.0)
94
+ shellany (0.0.1)
95
+ thor (0.20.3)
96
+
97
+ PLATFORMS
98
+ ruby
99
+
100
+ DEPENDENCIES
101
+ aruba
102
+ cucumber
103
+ guard-cucumber
104
+ guard-rspec
105
+ rake (~> 10.0)
106
+ rascal!
107
+ rspec
108
+
109
+ BUNDLED WITH
110
+ 2.0.1
data/Guardfile ADDED
@@ -0,0 +1,25 @@
1
+ guard :rspec, cmd: 'bundle exec rspec', notification: false, failed_mode: :focus do
2
+ require "guard/rspec/dsl"
3
+ dsl = Guard::RSpec::Dsl.new(self)
4
+
5
+ # Feel free to open issues for suggestions and improvements
6
+
7
+ # RSpec files
8
+ rspec = dsl.rspec
9
+ watch(rspec.spec_helper) { rspec.spec_dir }
10
+ watch(rspec.spec_support) { rspec.spec_dir }
11
+ watch(rspec.spec_files)
12
+
13
+ # Ruby files
14
+ ruby = dsl.ruby
15
+ dsl.watch_spec_files_for(ruby.lib_files)
16
+ end
17
+
18
+ guard 'cucumber', all_on_start: false, all_after_pass: false, notification: false do
19
+ watch(%r{^features/.+\.feature$})
20
+ watch(%r{^features/support/.+$}) { "features" }
21
+
22
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
23
+ Dir[File.join("**/#{m[1]}.feature")][0] || "features"
24
+ end
25
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Tobias Kraze
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # Rascal [![Build Status](https://travis-ci.org/makandra/rascal.svg?branch=master)](https://travis-ci.org/makandra/rascal)
2
+
3
+ ### Use CI environments locally. Not quite a vagrant.
4
+
5
+ We use Gitlab-CI to run CI for our projects, using Docker containers.
6
+
7
+ In certain situations, it can be helpful to set up an environment identical to a CI
8
+ node on your local machine. `rascal` allows you to do just that by parsing your CI config
9
+ (currently only `.gitlab-ci.yml`), starting required services and bringing up a Docker
10
+ container.
11
+
12
+ ## Installation
13
+
14
+ Install with
15
+
16
+ $ gem install rascal
17
+
18
+
19
+ ## Caveats
20
+
21
+ *This is an early alpha version. Use at your own risk.*
22
+
23
+ Only the parsing of `.gitlab-ci.yml` is currently supported, and only a subset of the possible syntax
24
+ will be properly interpreted.
25
+
26
+
27
+ ## Usage
28
+
29
+ You need to add some extra information to your `.gitlab-ci.yml`. A working version might look like this:
30
+
31
+ ```
32
+ # settings here override job settings
33
+ .rascal:
34
+ repo_dir: /repo
35
+ variables:
36
+ BUNDLE_PATH: /cache/bundle
37
+ volumes:
38
+ cache: /cache
39
+ before_shell:
40
+ - bundle check
41
+
42
+ .environment: &environment
43
+ image: registry.makandra.de/makandra/ci-images/test-env:2.5
44
+ services:
45
+ - name: registry.makandra.de/makandra/ci-images/pg:9.5
46
+ alias: pg-db
47
+ - name: registry.makandra.de/makandra/ci-images/redis:4
48
+ alias: redis
49
+ before_script:
50
+ - ruby -v
51
+ - bundle install
52
+ - bundle exec rake db:create db:schema:load
53
+ variables:
54
+ BUNDLE_PATH: ./bundle/vendor
55
+ DATABASE_URL: postgresql://pg_user@pg-db/test-db
56
+ DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL: "true"
57
+ REDIS_URL: redis://redis
58
+ PROMPT: CI env
59
+ cache:
60
+ paths:
61
+ - ./bundle/vendor
62
+
63
+
64
+ # ============= Actual jobs ================
65
+
66
+ rspec:
67
+ <<: *environment
68
+ script:
69
+ - bundle exec rake knapsack:rspec
70
+ parallel: 4
71
+ ```
72
+
73
+ Then, in your project root, run `rascal shell rspec`.
74
+
75
+
76
+ ## License
77
+
78
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'cucumber'
4
+ require 'cucumber/rake/task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+ Cucumber::Rake::Task.new(:features)
8
+
9
+ desc 'Run specs and features'
10
+ task :test => [:spec, :features]
11
+
12
+ task default: :test
data/bin/_guard-core ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application '_guard-core' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("guard", "_guard-core")
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rascal"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/cucumber ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'cucumber' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("cucumber", "cucumber")
data/bin/guard ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'guard' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("guard", "guard")
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/rascal ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
+
5
+ require 'rascal/io_helper'
6
+ require 'rascal/cli'
7
+ require 'rascal/version'
8
+
9
+ if ARGV == ['-v'] || ARGV == ['--version']
10
+ puts "Rascal version #{Rascal::VERSION}."
11
+ else
12
+ Rascal::CLI::Main.start
13
+ end
@@ -0,0 +1,39 @@
1
+ require 'pathname'
2
+
3
+ module Rascal
4
+ module CLI
5
+ class Base
6
+ def initialize(thor, options)
7
+ @thor = thor
8
+ @options = options
9
+ end
10
+
11
+ private
12
+
13
+ def config_location
14
+ Pathname.new(@options[:config_file]).expand_path
15
+ end
16
+
17
+ def fail_with_error(message)
18
+ raise Thor::Error, message
19
+ end
20
+
21
+ def find_environment(environment_name)
22
+ if (definition = EnvironmentsDefinition.detect(config_location))
23
+ if (environment = definition.environment(environment_name))
24
+ return environment
25
+ else
26
+ available_environments = definition.available_environment_names.join(', ')
27
+ if environment_name
28
+ fail_with_error("Unknown environment #{environment_name}. Available: #{available_environments}.")
29
+ else
30
+ fail_with_error("Missing environment. Available: #{available_environments}.")
31
+ end
32
+ end
33
+ else
34
+ fail_with_error("Could not find an environment definition in current working directory.")
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,16 @@
1
+ require 'rascal'
2
+
3
+ module Rascal
4
+ module CLI
5
+ class Clean < Base
6
+ def initialize(thor, options, environment_name)
7
+ @environment_name = environment_name
8
+ super(thor, options)
9
+ end
10
+
11
+ def run
12
+ find_environment(@environment_name)&.clean
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,45 @@
1
+ module Rascal
2
+ module CLI
3
+ class Main < Thor
4
+ def help(subcommand = false)
5
+ if subcommand
6
+ super
7
+ else
8
+ say
9
+ say 'Usage:'
10
+ say ' rascal <command> <args>'
11
+ say 'For example:'
12
+ say ' rascal shell 2.6'
13
+ say
14
+ super
15
+ say 'For Further information about the commands, you can use "rascal help <command>".'
16
+ say
17
+ end
18
+ end
19
+
20
+ def self.exit_on_failure?
21
+ # return non-zero exit code for failures
22
+ true
23
+ end
24
+
25
+ def self.start(*)
26
+ IOHelper.setup
27
+ super
28
+ end
29
+
30
+
31
+ map "shell" => "_shell"
32
+ desc 'shell ENVIRONMENT', 'Start a docker shell for the given environment'
33
+ def _shell(environment_name = nil)
34
+ Shell.new(self, options, environment_name).run
35
+ end
36
+
37
+ desc 'clean ENVIRONMENT', 'Stop and remove docker containers for the given environment'
38
+ def clean(environment_name = nil)
39
+ Clean.new(self, options, environment_name).run
40
+ end
41
+
42
+ class_option :config_file, aliases: ['-c'], default: '.', required: true, banner: 'path to configuration file or directory containing it'
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,16 @@
1
+ require 'rascal'
2
+
3
+ module Rascal
4
+ module CLI
5
+ class Shell < Base
6
+ def initialize(thor, options, environment_name)
7
+ @environment_name = environment_name
8
+ super(thor, options)
9
+ end
10
+
11
+ def run
12
+ find_environment(@environment_name)&.run_shell
13
+ end
14
+ end
15
+ end
16
+ end
data/lib/rascal/cli.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'thor'
2
+
3
+ module Rascal
4
+ module CLI
5
+ autoload :Base, 'rascal/cli/base'
6
+ autoload :Clean, 'rascal/cli/clean'
7
+ autoload :Main, 'rascal/cli/main'
8
+ autoload :Shell, 'rascal/cli/shell'
9
+ end
10
+ end