kamukabi-kash 0.1.1

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: eed21e7311cb959ef4f11ba00973ef46e81b2fc1
4
+ data.tar.gz: 548ada26ad9612910c1c8eecae888900f3d9bb0f
5
+ SHA512:
6
+ metadata.gz: da1ab58c915dccd7de64b86a6a84ebbf6d5d5fefe43641188f16d02e7e3b5e275bcd3ec10bb04a4acbbe19977e9d6f00926a9d55127171f8942acbbeeca6fba6
7
+ data.tar.gz: 2df1a63e2a8931e4bca741c76853f7cb92f189df83ce49515561b1cb56a5ad5fb826c3ac40f957e6c2d5b1a62692193777bddcc9a168a60d2578b6fee4f325b5
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.2
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kamukabi-kash.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Marcin Wierzbicki
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,41 @@
1
+ # Kamukabi::Kash
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/kamukabi/kash`. 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 'kamukabi-kash'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install kamukabi-kash
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/[USERNAME]/kamukabi-kash. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kamukabi/kash"
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/contributors.txt ADDED
@@ -0,0 +1,2 @@
1
+ Marek Polewski
2
+ Marcin Wierzbicki
data/exe/kash ADDED
@@ -0,0 +1,201 @@
1
+ #!/usr/bin/perl
2
+
3
+ use warnings;
4
+ use strict;
5
+ use Carp;
6
+ use Getopt::Std;
7
+
8
+ my $root_path = "";
9
+ my $app = "";
10
+ my $version = "0.3.2";
11
+ my $app_domain = "kamukabi.com";
12
+ my $remotes = "kamukabi";
13
+ my $quoted_domain = quotemeta $app_domain;
14
+ my $stage = "";
15
+
16
+ my %opt = ();
17
+ getopts( "si:", \%opt );
18
+ my %stages = get_stages();
19
+ if ( defined $opt{s} ) {
20
+ my @stages = sort keys %stages;
21
+ print "@stages\n";
22
+ exit(0);
23
+ }
24
+
25
+ my $identity = "";
26
+ my $gsc = "ssh";
27
+ if ( $opt{i} && $opt{i} ne "" ) {
28
+ die "identity file $opt{i} not exists.\n" unless -f $opt{i};
29
+ $identity = "-i " . $opt{i};
30
+ $gsc = "ssh $identity";
31
+ }
32
+
33
+ my %commands = (
34
+ 'autoupdate' => {
35
+ type => "local",
36
+ appname_not_required => 1,
37
+ desc => "automatically download and install new kash",
38
+ run => sub {
39
+ my $tmp = `mktemp -d`;
40
+ chomp($tmp);
41
+ system( "git", "clone", "git\@bitbucket.org:kamukabi/kash.git",
42
+ $tmp );
43
+ chdir $tmp;
44
+ exec("./install.sh");
45
+ },
46
+ },
47
+ 'clone' => {
48
+ type => "local",
49
+ min_args => 1,
50
+ desc => "clone application repository",
51
+
52
+ run => sub {
53
+ my $app = $ARGV[1];
54
+ print
55
+ `git clone --origin $remotes$stage git\@$app.$app_domain:$app`;
56
+ },
57
+ },
58
+ 'init' => {
59
+ type => "local",
60
+ min_args => 1,
61
+ appname_not_required => 1,
62
+ desc => "initialize git repo in current directory and set remotes",
63
+ run => sub {
64
+ my $app = $ARGV[1];
65
+ die "First initialize git in this folder. Use: git init\n"
66
+ unless ( -d ".git" );
67
+ print
68
+ `GIT_SSH_COMMAND='$gsc' git remote add $remotes$stage git\@$app.$app_domain:$app`;
69
+ },
70
+ },
71
+ 'deploy' => {
72
+ type => "local",
73
+ desc => "send code to kamukabi server",
74
+ run => sub {
75
+ system("GIT_SSH_COMMAND='$gsc' git push $remotes$stage `git branch --no-color 2>/dev/null | grep '*' | sed -e 's/\\* //'`:master");
76
+ if ( $? == 0 ) {
77
+ print
78
+ "Your build went fine. Let's attach to your app output. (Ctrl+c to exit)\n";
79
+ exec
80
+ "ssh $identity -t cmd\@$app.$app_domain $app $version logs -f";
81
+ }
82
+ },
83
+ },
84
+ 'ftp' => {
85
+ type => "sftp",
86
+ desc => "start ftp shell on your app storage",
87
+ },
88
+ 'run' => {
89
+ min_args => 1,
90
+ desc => "send command to aplication",
91
+ },
92
+ 'restart' => { desc => "restart your aplication", },
93
+ 'rebuild' => { desc => "restart build process", },
94
+ 'logs' => { desc => "show app output", args => "[{-f|-n NUM}]", },
95
+ 'pg' => {
96
+ desc => "Shared postgresql managment",
97
+ childs => {
98
+ 'backup' => { desc => "backup your database to ftp", },
99
+ 'restore' =>
100
+ { desc => "restore your database from database.sql on ftp", },
101
+ 'console' => { desc => "open pgsql console", },
102
+ }
103
+ },
104
+ 'mysql' => {
105
+ desc => "Shared mysql managment",
106
+ childs => {
107
+ 'backup' => { desc => "backup your database to ftp", },
108
+ 'restore' =>
109
+ { desc => "restore your database from database.sql on ftp", },
110
+ 'console' => { desc => "open mysql console", },
111
+ }
112
+ },
113
+ );
114
+
115
+ usage() if scalar @ARGV == 0;
116
+
117
+ if ( scalar @ARGV > 1 && defined $commands{ $ARGV[1] } ) {
118
+ $stage = "$ARGV[0]";
119
+ shift @ARGV;
120
+ }
121
+
122
+ my $command = $ARGV[0];
123
+ my $c = $commands{$command};
124
+ usage() if not defined $c;
125
+ while ( defined $c->{childs} ) {
126
+ usage() if scalar @ARGV == 1;
127
+ usage() if not defined $c->{childs}->{ $ARGV[1] };
128
+ $command = "$ARGV[0]:$ARGV[1]";
129
+ $c = $c->{childs}->{ $ARGV[1] };
130
+ shift @ARGV;
131
+ }
132
+
133
+ my @args = @ARGV[ 1 .. $#ARGV ];
134
+ if ( $c->{min_args} && scalar @args < $c->{min_args} ) {
135
+ die("Command ($command) require at least $c->{min_args} arguments.\n");
136
+ }
137
+ if ( !defined $c->{appname_not_required} ) {
138
+ die("Unknow stage: $stage\n")
139
+ if $stage ne "" && not defined $stages{$stage};
140
+ die("First initialize project or clone it!\n")
141
+ if not defined $stages{$stage};
142
+ $app = $stages{$stage};
143
+ }
144
+ $stage = "-$stage" if $stage ne "";
145
+ $c->{type} //= 'ssh';
146
+ for ( $c->{type} ) {
147
+ exit( $c->{run}() ) if /local/;
148
+ exec "sftp $identity -P2222 $app\@$app.$app_domain" if /ftp/;
149
+ exec
150
+ "ssh $identity -t cmd\@$app.$app_domain $app $version $command @args";
151
+ }
152
+
153
+ sub get_stages {
154
+ $root_path = `git rev-parse --show-toplevel 2>/dev/null`;
155
+ return () if ( $root_path eq "\n" );
156
+ chomp($root_path);
157
+ open( my $fh, "<", ".git/config" ) or return ();
158
+ my %stages;
159
+ my $st;
160
+ while (<$fh>) {
161
+ if (/^\[(.+)\]$/) {
162
+ $st = undef;
163
+ }
164
+ if (/\[remote "$remotes-?(.*)"\]/) {
165
+ $st = $1;
166
+ }
167
+ if (/url = git@(.+)\.$quoted_domain:/) {
168
+ $stages{$st} = $1 if defined $st;
169
+ }
170
+ }
171
+ return %stages;
172
+ }
173
+
174
+ sub usage {
175
+ print "Kamukabi toolbox $version\nUsage: \n";
176
+ print " kash [-i key.pub] [-s] [STAGE] COMMAND\n";
177
+ print "Stage is a sufix used in git remote definition.\n";
178
+ print
179
+ " -i Selects a file from which the identity (private key) for public key authentication is read.\n";
180
+ print " -s List known stages in this project.\n";
181
+ print "Supported commands:\n";
182
+ usage_commands( " ", \%commands );
183
+ exit 0;
184
+ }
185
+
186
+ sub usage_commands {
187
+ my ( $i, $commands_ref ) = @_;
188
+ for ( sort keys %{$commands_ref} ) {
189
+ $commands_ref->{$_}->{args} //= "";
190
+ printf(
191
+ "$i%-11s %-14s - %s\n",
192
+ $_,
193
+ $commands_ref->{$_}->{args},
194
+ $commands_ref->{$_}->{desc}
195
+ );
196
+ if ( defined $commands_ref->{$_}->{childs} ) {
197
+ usage_commands( " $i", $commands_ref->{$_}->{childs} );
198
+ }
199
+ }
200
+ }
201
+
Binary file
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kamukabi/kash/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kamukabi-kash"
8
+ spec.version = Kamukabi::Kash::VERSION
9
+ spec.authors = ["Marek Polewski", "Marcin Wierzbicki"]
10
+ spec.email = ["marek.polewski@kamukabi.com", "marcin.wierzbicki@kamukabi.com"]
11
+
12
+ spec.summary = %q{Kamukabi Commandline Toolkit}
13
+ spec.description = %q{The following toolbox is specially designed to interact with Kamukabi hosting. We hope it will meet your expectations. In case of any problems, please create issue or contact us by email: tech AT kamukabi.com}
14
+ spec.homepage = "https://kamukabi.com/kash"
15
+ spec.license = "MIT"
16
+
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = ["kash"]
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+ end
@@ -0,0 +1,5 @@
1
+ module Kamukabi
2
+ module Kash
3
+ VERSION = "0.1.1"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "kamukabi/kash/version"
2
+
3
+ module Kamukabi
4
+ module Kash
5
+ # Your code goes here...
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kamukabi-kash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Marek Polewski
8
+ - Marcin Wierzbicki
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2016-05-06 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.10'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.10'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description: 'The following toolbox is specially designed to interact with Kamukabi
57
+ hosting. We hope it will meet your expectations. In case of any problems, please
58
+ create issue or contact us by email: tech AT kamukabi.com'
59
+ email:
60
+ - marek.polewski@kamukabi.com
61
+ - marcin.wierzbicki@kamukabi.com
62
+ executables:
63
+ - kash
64
+ extensions: []
65
+ extra_rdoc_files: []
66
+ files:
67
+ - ".gitignore"
68
+ - ".rspec"
69
+ - ".travis.yml"
70
+ - CODE_OF_CONDUCT.md
71
+ - Gemfile
72
+ - LICENSE.txt
73
+ - README.md
74
+ - Rakefile
75
+ - bin/console
76
+ - bin/setup
77
+ - contributors.txt
78
+ - exe/kash
79
+ - kamukabi-kash-0.1.0.gem
80
+ - kamukabi-kash.gemspec
81
+ - lib/kamukabi/kash.rb
82
+ - lib/kamukabi/kash/version.rb
83
+ homepage: https://kamukabi.com/kash
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.2.2
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Kamukabi Commandline Toolkit
107
+ test_files: []