theroku 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 435c845b018606253e959777c2ab9ccdf6d317a4
4
+ data.tar.gz: 2afc3ed1b8525a6ac4b97dd3251e60eb02cc239a
5
+ SHA512:
6
+ metadata.gz: 8a449224017e6d0e21af7ac12beadc3e9a1c23328cb4dd8210592f704dfff80261c733bf6a9e88855d74751eb8d4da3a08901254bd980b819ea77f2d2a094001
7
+ data.tar.gz: 4664a283baea15cc496b416b8cacedf822ed1ccba1dcb772385b398358bef26c450ee997cef06e4b11c54114f78a78a4ee23726f0cece81d430dbc70e2c74358
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
@@ -0,0 +1 @@
1
+ 123
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in theroku.gemspec
4
+ gemspec
5
+
6
+ gem 'byebug'
7
+ gem 'commander', '~> 4.3.4'
8
+ gem 'httparty', '~> 0.13.3'
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 alejoescobar
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Theroku
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'theroku'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install theroku
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/theroku/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,44 @@
1
+ require 'commander/import'
2
+ require 'theroku'
3
+
4
+ # :name is optional, otherwise uses the basename of this executable
5
+ program :name, 'Theroku'
6
+ program :version, '0.0.2'
7
+ program :description, "Awesome gem that'll bring you to balance."
8
+
9
+ command :login do |c|
10
+ c.syntax = 'theroku login'
11
+ c.description = 'Login into theroku awesome app.'
12
+ c.action do |args, options|
13
+ name = ask("Email: ")
14
+ password = ask("Password: ") { |q| q.echo = "*" }
15
+ LoginCommand.new.execute(name, password, "This is a temporal token")
16
+ end
17
+ end
18
+
19
+ command :create do |c|
20
+ c.syntax = 'theroku create [args]'
21
+ c.description = 'theroku create <url_1> <url_2> <app_name>'
22
+ c.action do |args, options|
23
+ CreateCommand.new.execute(*args)
24
+ end
25
+ end
26
+
27
+ command :update do |c|
28
+ c.syntax = 'theroku update [options]'
29
+ c.description = 'theroku update <old_app_name> --app_name <new_app_name> --url1 <new_url1> --url2 <new_url2>'
30
+ c.option '--app_name STRING', String, 'Changes the app_name'
31
+ c.option '--url1 STRING', String, 'Changes the url1'
32
+ c.option '--url2 STRING', String, 'Changes the url2'
33
+ c.action do |args, options|
34
+ UpdateCommand.new.execute(options.app_name, options.url1, options.url2)
35
+ end
36
+ end
37
+
38
+ command :destroy do |c|
39
+ c.syntax = 'theroku create [args]'
40
+ c.description = 'theroku destroy <app_name>'
41
+ c.action do |args, options|
42
+ DestroyCommand.new.execute(*args)
43
+ end
44
+ end
@@ -0,0 +1,11 @@
1
+ module Theroku
2
+ @base_url = 'http://192.168.0.18:3000/api/'
3
+ class << self
4
+ attr_accessor :base_url
5
+ end
6
+ end
7
+
8
+ require 'theroku/create_command.rb'
9
+ require 'theroku/destroy_command.rb'
10
+ require 'theroku/login_command.rb'
11
+ require 'theroku/update_command.rb'
@@ -0,0 +1,21 @@
1
+ class CreateCommand
2
+ require 'httparty'
3
+ def execute(url1, url2, subdomain)
4
+ if File.exists?('.theroku')
5
+ puts "Creating #{subdomain}..."
6
+ file = File.open(".theroku", "rb")
7
+ token = file.read
8
+ response = HTTParty.post("#{Theroku::base_url}apps",
9
+ body: { "url1" => "#{url1}", "url2" => "#{url2}", "subdomain" => "#{subdomain}" }.to_json,
10
+ headers: { 'Authorization' => "Token token=#{token}", 'Content-Type' => 'application/json', 'Accept' => 'application/json'}
11
+ )
12
+ if response.code == 200
13
+ puts "Success!"
14
+ else
15
+ puts "Sorry, something went wrong..."
16
+ end
17
+ else
18
+ puts "You have to login before making any changes you can do that with $ theroku login"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ class DestroyCommand
2
+ def execute(subdomain)
3
+ if File.exists?('.theroku')
4
+ puts "Deleting #{subdomain}..."
5
+ file = File.open(".theroku", "rb")
6
+ token = file.read
7
+ response = HTTParty.delete("#{Theroku::base_url}apps/#{subdomain}",
8
+ headers: { 'Authorization' => "Token token=#{token}", 'Content-Type' => 'application/json', 'Accept' => 'application/json'}
9
+ )
10
+ if response.code == 200
11
+ puts "You have successfully destroyed #{subdomain} app"
12
+ else
13
+ puts "There were the following errors:"
14
+ puts response["errors"].capitalize
15
+ end
16
+ else
17
+ puts "You have to login before making any changes you can do that with $ theroku login"
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ class LoginCommand
2
+ require 'httparty'
3
+ def execute(email, password, token)
4
+ puts "Your email is #{email}, and your password is supposed to be hidden but fuck it here it is #{password}."
5
+ puts "Initiating post method..."
6
+ response = HTTParty.post("#{Theroku::base_url}login",
7
+ body: { "email" => "#{email}", "password" => "#{password}" }.to_json,
8
+ headers: { 'Content-Type' => 'application/json', 'Accept' => 'application/json'}
9
+ )
10
+ puts "Finishing..."
11
+ token = JSON.parse(response.body)["auth_token"]
12
+ token_file = File.new(".theroku", "w")
13
+ #to do: windows relative paths
14
+ token_file.puts(token)
15
+ token_file.close
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module Theroku
2
+ VERSION = "0.0.1"
3
+ end
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 'theroku/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "theroku"
8
+ spec.version = "0.1.0"
9
+ spec.authors = ["alejoescobar", "simon0191", "jasmo2"]
10
+ spec.email = ["alejoescobac@gmail.com"]
11
+ spec.summary = "Awesome Heroku load balancer."
12
+ spec.description = "Gem to balance heroku servers."
13
+ spec.homepage = "https://github.com/alejoescobar/theroku"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+ spec.bindir = 'bin'
21
+ spec.add_development_dependency('rdoc', '4.2.0')
22
+ spec.add_runtime_dependency('docopt', '0.5.0')
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.7"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: theroku
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - alejoescobar
8
+ - simon0191
9
+ - jasmo2
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2015-05-17 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rdoc
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 4.2.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - '='
27
+ - !ruby/object:Gem::Version
28
+ version: 4.2.0
29
+ - !ruby/object:Gem::Dependency
30
+ name: docopt
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - '='
34
+ - !ruby/object:Gem::Version
35
+ version: 0.5.0
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - '='
41
+ - !ruby/object:Gem::Version
42
+ version: 0.5.0
43
+ - !ruby/object:Gem::Dependency
44
+ name: bundler
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.7'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '1.7'
57
+ - !ruby/object:Gem::Dependency
58
+ name: rake
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '10.0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '10.0'
71
+ description: Gem to balance heroku servers.
72
+ email:
73
+ - alejoescobac@gmail.com
74
+ executables:
75
+ - theroku
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - ".gitignore"
80
+ - ".theroku"
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/theroku
86
+ - lib/theroku.rb
87
+ - lib/theroku/create_command.rb
88
+ - lib/theroku/destroy_command.rb
89
+ - lib/theroku/login_command.rb
90
+ - lib/theroku/version.rb
91
+ - theroku-0.0.1.gem
92
+ - theroku.gemspec
93
+ homepage: https://github.com/alejoescobar/theroku
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.4.5
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Awesome Heroku load balancer.
117
+ test_files: []