app-runner 0.0.2

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
+ SHA1:
3
+ metadata.gz: 80ba22cacff0f81a7c5ea88c1e25ec9b70776276
4
+ data.tar.gz: 0358fe9cc19f602d941a7cb38375a882d1d08b60
5
+ SHA512:
6
+ metadata.gz: e8b979176082bedd0f582aadd8d55e2b6efc5fd5152af1c1304e7fa4aba862dcce45e7370c5a714e6f7fde301ed78e14aa7f94b59b07763603e48f91eb4d2d50
7
+ data.tar.gz: f89fc2877ca460572f763c380e0b4fb3b55a4a9c9ed28f397267f95f523f682a1ca19fdc34e94967db734fdf15570fe5b45b30fac263d22eabe890e6266d7c67
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,56 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ app-runner (0.0.1)
5
+ gli (= 2.16.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ aruba (0.14.2)
11
+ childprocess (~> 0.5.6)
12
+ contracts (~> 0.9)
13
+ cucumber (>= 1.3.19)
14
+ ffi (~> 1.9.10)
15
+ rspec-expectations (>= 2.99)
16
+ thor (~> 0.19)
17
+ builder (3.2.3)
18
+ childprocess (0.5.9)
19
+ ffi (~> 1.0, >= 1.0.11)
20
+ contracts (0.16.0)
21
+ cucumber (2.4.0)
22
+ builder (>= 2.1.2)
23
+ cucumber-core (~> 1.5.0)
24
+ cucumber-wire (~> 0.0.1)
25
+ diff-lcs (>= 1.1.3)
26
+ gherkin (~> 4.0)
27
+ multi_json (>= 1.7.5, < 2.0)
28
+ multi_test (>= 0.1.2)
29
+ cucumber-core (1.5.0)
30
+ gherkin (~> 4.0)
31
+ cucumber-wire (0.0.1)
32
+ diff-lcs (1.3)
33
+ ffi (1.9.18)
34
+ gherkin (4.1.3)
35
+ gli (2.16.0)
36
+ multi_json (1.12.1)
37
+ multi_test (0.1.2)
38
+ rake (10.5.0)
39
+ rdoc (4.2.1)
40
+ rspec-expectations (3.6.0)
41
+ diff-lcs (>= 1.2.0, < 2.0)
42
+ rspec-support (~> 3.6.0)
43
+ rspec-support (3.6.0)
44
+ thor (0.19.4)
45
+
46
+ PLATFORMS
47
+ ruby
48
+
49
+ DEPENDENCIES
50
+ app-runner!
51
+ aruba
52
+ rake
53
+ rdoc
54
+
55
+ BUNDLED WITH
56
+ 1.15.0
data/README.rdoc ADDED
@@ -0,0 +1,6 @@
1
+ = app-runner
2
+
3
+ Describe your project here
4
+
5
+ :include:app-runner.rdoc
6
+
data/Rakefile ADDED
@@ -0,0 +1,44 @@
1
+ require 'rake/clean'
2
+ require 'rubygems'
3
+ require 'rubygems/package_task'
4
+ require 'rdoc/task'
5
+ require 'cucumber'
6
+ require 'cucumber/rake/task'
7
+ Rake::RDocTask.new do |rd|
8
+ rd.main = "README.rdoc"
9
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
10
+ rd.title = 'Your application title'
11
+ end
12
+
13
+ spec = eval(File.read('app-runner.gemspec'))
14
+
15
+ Gem::PackageTask.new(spec) do |pkg|
16
+ end
17
+ CUKE_RESULTS = 'results.html'
18
+ CLEAN << CUKE_RESULTS
19
+ desc 'Run features'
20
+ Cucumber::Rake::Task.new(:features) do |t|
21
+ opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
22
+ opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
23
+ t.cucumber_opts = opts
24
+ t.fork = false
25
+ end
26
+
27
+ desc 'Run features tagged as work-in-progress (@wip)'
28
+ Cucumber::Rake::Task.new('features:wip') do |t|
29
+ tag_opts = ' --tags ~@pending'
30
+ tag_opts = ' --tags @wip'
31
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
32
+ t.fork = false
33
+ end
34
+
35
+ task :cucumber => :features
36
+ task 'cucumber:wip' => 'features:wip'
37
+ task :wip => 'features:wip'
38
+ require 'rake/testtask'
39
+ Rake::TestTask.new do |t|
40
+ t.libs << "test"
41
+ t.test_files = FileList['test/*_test.rb']
42
+ end
43
+
44
+ task :default => [:test,:features]
@@ -0,0 +1,23 @@
1
+ # Ensure we require the local version and not one we might have installed already
2
+ require File.join([File.dirname(__FILE__),'lib','app-runner','version.rb'])
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = 'app-runner'
5
+ s.version = AppRunner::VERSION
6
+ s.author = 'Rafał Libik'
7
+ s.email = 'rafal.libik@gmail.com'
8
+ s.homepage = ''
9
+ s.platform = Gem::Platform::RUBY
10
+ s.summary = 'App runner utils'
11
+ s.files = `git ls-files`.split("
12
+ ")
13
+ s.require_paths << 'lib'
14
+ s.has_rdoc = true
15
+ s.extra_rdoc_files = ['README.rdoc','app-runner.rdoc']
16
+ s.rdoc_options << '--title' << 'app-runner' << '--main' << 'README.rdoc' << '-ri'
17
+ s.bindir = 'bin'
18
+ s.executables << 'app-runner'
19
+ s.add_development_dependency('rake')
20
+ s.add_development_dependency('rdoc')
21
+ s.add_development_dependency('aruba')
22
+ s.add_runtime_dependency('gli','2.16.0')
23
+ end
data/app-runner.rdoc ADDED
@@ -0,0 +1,5 @@
1
+ = app-runner
2
+
3
+ Generate this with
4
+ app-runner rdoc
5
+ After you have described your command line interface
data/bin/app-runner ADDED
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gli'
3
+ require 'app-runner'
4
+
5
+ =begin
6
+ begin # XXX: Remove this begin/rescue before distributing your app
7
+ rescue LoadError
8
+ STDERR.puts "In development, you need to use `bundle exec bin/app-runner` to run your app"
9
+ STDERR.puts "At install-time, RubyGems will make sure lib, etc. are in the load path"
10
+ STDERR.puts "Feel free to remove this message from bin/app-runner now"
11
+ exit 64
12
+ end
13
+ =end
14
+
15
+ include GLI::App
16
+
17
+ program_desc 'CLI Client for managing artifacts from artifact''s provider'
18
+
19
+ version AppRunner::VERSION
20
+
21
+ subcommand_option_handling :normal
22
+ arguments :strict
23
+
24
+ desc 'Describe some switch here'
25
+ switch [:s,:switch]
26
+
27
+ desc 'Describe some flag here'
28
+ default_value 'the default'
29
+ arg_name 'The name of the argument'
30
+ flag [:f,:flagname]
31
+
32
+ desc 'Download artifact and run command'
33
+ arg_name 'Url e.g. mvn:group:artifact'
34
+ command :run do |c|
35
+ c.desc 'Full artifact url: jenkins:admin-mvn:10:*ear'
36
+ c.flag [:u, :url]
37
+
38
+ c.desc 'Exec command to run: /opt/app/start.sh'
39
+ c.flag [:e, :exec]
40
+
41
+ c.action do |global_options,options,args|
42
+ Commands::Run.new().execute(global_options, options, args)
43
+ end
44
+ end
45
+
46
+ desc 'Change artifact'
47
+ arg_name '[-t mvn|jenkins|ssh|...] [-v version] [--url jenkins:admin-mvn:10:*ear]', :optional
48
+ command :switch do |c|
49
+ c.desc 'Artifact source: mvn|jenkins|ssh|file|...'
50
+ c.default_value 'mvn'
51
+ c.flag :t
52
+
53
+ c.desc 'Artifact version: 7.57.0'
54
+ c.flag :v
55
+
56
+ c.desc 'Full artifact url: jenkins:admin-mvn:10:*ear'
57
+ c.flag [:u, :url]
58
+
59
+ c.action do |global_options,options,args|
60
+ Commands::Switch.new().execute(global_options, options, args)
61
+ end
62
+ end
63
+
64
+ desc 'Describe info here'
65
+ arg_name 'Describe arguments to info here'
66
+ command :info do |c|
67
+ c.action do |global_options,options,args|
68
+ puts "info command ran"
69
+ end
70
+ end
71
+
72
+ pre do |global,command,options,args|
73
+ # Pre logic here
74
+ # Return true to proceed; false to abort and not call the
75
+ # chosen command
76
+ # Use skips_pre before a command to skip this block
77
+ # on that command only
78
+ global['configHash']=YAML.load_file('/etc/app-runner/config.yml')
79
+ true
80
+ end
81
+
82
+ post do |global,command,options,args|
83
+ # Post logic here
84
+ # Use skips_post before a command to skip this
85
+ # block on that command only
86
+ end
87
+
88
+ on_error do |exception|
89
+ # Error logic here
90
+ # return false to skip default error handling
91
+ true
92
+ end
93
+
94
+ exit run(ARGV)
@@ -0,0 +1,8 @@
1
+ Feature: My bootstrapped app kinda works
2
+ In order to get going on coding my awesome app
3
+ I want to have aruba and cucumber setup
4
+ So I don't have to do it myself
5
+
6
+ Scenario: App just runs
7
+ When I get help for "app-runner"
8
+ Then the exit status should be 0
@@ -0,0 +1,6 @@
1
+ When /^I get help for "([^"]*)"$/ do |app_name|
2
+ @app_name = app_name
3
+ step %(I run `#{app_name} help`)
4
+ end
5
+
6
+ # Add more step definitions here
@@ -0,0 +1,15 @@
1
+ require 'aruba/cucumber'
2
+
3
+ ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
4
+ LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
5
+
6
+ Before do
7
+ # Using "announce" causes massive warnings on 1.9.2
8
+ @puts = true
9
+ @original_rubylib = ENV['RUBYLIB']
10
+ ENV['RUBYLIB'] = LIB_DIR + File::PATH_SEPARATOR + ENV['RUBYLIB'].to_s
11
+ end
12
+
13
+ After do
14
+ ENV['RUBYLIB'] = @original_rubylib
15
+ end
@@ -0,0 +1,32 @@
1
+ module Commands
2
+
3
+ class Run
4
+
5
+ def execute(global_options, options, args)
6
+ config=global_options['configHash'];
7
+ if (!args.empty?)
8
+ options["url"]=args.first
9
+ args.clear
10
+ Commands::Switch.new().execute(global_options, options, args)
11
+ end
12
+ exec=options["exec"]
13
+ exec=config['exec'] if !exec
14
+ app_pid=spawn(exec)
15
+ [ :INT, :TERM, :HUP ].each do |sig|
16
+ Signal.trap(sig) { signal(sig, app_pid) }
17
+ end
18
+ Process.wait(app_pid)
19
+
20
+ end
21
+
22
+ def signal(sig, pid)
23
+ begin
24
+ Process.kill(sig, pid)
25
+ rescue Errno::ESRCH
26
+ false
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,28 @@
1
+ module Commands
2
+
3
+ class Switch
4
+
5
+ def execute(global_options, options, args)
6
+ config=global_options['configHash'];
7
+ if (options["url"])
8
+ download(config["url"], options["url"], config["destination"])
9
+ elsif (options["v"] && options["t"]=='mvn')
10
+ mvn=config["mvn"];
11
+ download(config["url"], "#{options['t']}:#{mvn["group"]}:#{mvn["artifactId"]}:#{options['v']}:#{mvn["type"]}", config["destination"])
12
+ else
13
+ p "Not suported yet this combination"
14
+ end
15
+
16
+ end
17
+
18
+ def download(serviceUrl, artifactUrl, destination)
19
+ url="#{serviceUrl}/api/artifacts/url/#{artifactUrl}"
20
+ exitCode=system("wget \"#{url}\" -O /tmp/artifact")
21
+ if exitCode
22
+ FileUtils.mv '/tmp/artifact', destination['dir']+"/"+destination['filename'], :force => true
23
+ end
24
+ end
25
+ end
26
+
27
+
28
+ end
@@ -0,0 +1,3 @@
1
+ module AppRunner
2
+ VERSION = '0.0.2'
3
+ end
data/lib/app-runner.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'app-runner/version.rb'
2
+ require 'app-runner/commands/switch.rb'
3
+ require 'app-runner/commands/run.rb'
4
+
5
+ # Add requires for other files you add to your project here, so
6
+ # you just need to require this one file in your bin file
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ class DefaultTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def teardown
9
+ end
10
+
11
+ def test_the_truth
12
+ assert true
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ require 'test/unit'
2
+
3
+ # Add test libraries you want to use here, e.g. mocha
4
+
5
+ class Test::Unit::TestCase
6
+
7
+ # Add global extensions to the test case class here
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: app-runner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Rafał Libik
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aruba
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: gli
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.16.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.16.0
69
+ description:
70
+ email: rafal.libik@gmail.com
71
+ executables:
72
+ - app-runner
73
+ extensions: []
74
+ extra_rdoc_files:
75
+ - README.rdoc
76
+ - app-runner.rdoc
77
+ files:
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - README.rdoc
81
+ - Rakefile
82
+ - app-runner.gemspec
83
+ - app-runner.rdoc
84
+ - bin/app-runner
85
+ - features/app-runner.feature
86
+ - features/step_definitions/app-runner_steps.rb
87
+ - features/support/env.rb
88
+ - lib/app-runner.rb
89
+ - lib/app-runner/commands/run.rb
90
+ - lib/app-runner/commands/switch.rb
91
+ - lib/app-runner/version.rb
92
+ - test/default_test.rb
93
+ - test/test_helper.rb
94
+ homepage: ''
95
+ licenses: []
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options:
99
+ - "--title"
100
+ - app-runner
101
+ - "--main"
102
+ - README.rdoc
103
+ - "-ri"
104
+ require_paths:
105
+ - lib
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.6.12
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: App runner utils
123
+ test_files: []