app_fog 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.DS_Store ADDED
Binary file
data/README.md ADDED
@@ -0,0 +1,13 @@
1
+ Usage:
2
+
3
+ task :default do
4
+ username = 'jimmysaville'
5
+ password = 'nowthennowthen'
6
+ app_name = 'yewtree'
7
+
8
+ credentials = Credentials.new(username, password)
9
+
10
+ appfog = AppFog.new(credentials)
11
+ appfog.update(app-name)
12
+ appfog.start(app-name)
13
+ end
data/app_fog.gemspec ADDED
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'app_fog'
3
+ s.version = '1.0.2'
4
+ s.date = '2013-06-07'
5
+ s.summary = "A wrapper for the app fog command line interface."
6
+ s.description = "Wrapping the app fog CLI into a gem to help you deploy more easily using your rake script. Fixed issues with first version."
7
+ s.authors = ["@ruby_gem"]
8
+ s.email = 'gemma.cameron@gmail.com'
9
+ s.files = `git ls-files`.split("\n")
10
+ s.require_paths = ['lib']
11
+ s.test_files = ['test/test_app_fog.rb', 'test/test_shell_command_wrapper.rb']
12
+ s.homepage = 'http://rubygems.org/gems/app_fog'
13
+
14
+ end
data/lib/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,22 @@
1
+ require 'open3'
2
+
3
+ class ShellCommandWrapper
4
+ def initialize(open3 = Open3)
5
+ @open3 = open3
6
+ end
7
+
8
+ def perform(command)
9
+ stdin, stdout, stderr = @open3.popen3 command
10
+ output = stdout.read unless stdout == nil
11
+
12
+ puts output
13
+
14
+ if (output != nil && output.include?('Problem with login, invalid account or password when attempting to login to'))
15
+ raise LoginError.new(output)
16
+ end
17
+ end
18
+ end
19
+
20
+ class LoginError < StandardError
21
+
22
+ end
data/lib/app_fog.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+ require 'open3'
3
+ require 'app_fog/shell_command_wrapper.rb'
4
+
5
+ class AppFog
6
+ def initialize(parameters)
7
+ @shell_command = parameters[:shell_command] || ShellCommandWrapper.new()
8
+ @username = parameters[:username]
9
+ @password = parameters[:password]
10
+ login
11
+ end
12
+
13
+ def login
14
+ @shell_command.perform "af login --email #{@username} --passwd #{@password}"
15
+ end
16
+
17
+ def update(app_name)
18
+ @shell_command.perform "af update #{app_name}"
19
+ end
20
+
21
+ def start(app_name)
22
+ @shell_command.perform "af start #{app_name}"
23
+ end
24
+ end
data/rakefile.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.libs << "lib"
5
+ t.test_files = FileList['test/test*.rb']
6
+ t.verbose = true
7
+ end
data/test/.DS_Store ADDED
Binary file
@@ -0,0 +1,29 @@
1
+ require 'test/unit'
2
+ require 'Open3'
3
+ require '../lib/app_fog.rb'
4
+
5
+ class TestAppFog < Test::Unit::TestCase
6
+ def test_login
7
+ appfog = AppFog.new(username: 'username', password: 'password', shell_command: self)
8
+ assert_equal 'af login --email username --passwd password', @command
9
+ end
10
+
11
+ def test_update
12
+ appfog = AppFog.new(username: 'username', password: 'password', shell_command: self)
13
+ appfog.update('app-name')
14
+ assert_equal 'af update app-name', @command
15
+ end
16
+
17
+ def test_start
18
+ appfog = AppFog.new(username: 'username', password: 'password', shell_command: self)
19
+ appfog.start('app-name')
20
+ assert_equal 'af start app-name', @command
21
+ end
22
+
23
+ def perform(command)
24
+ @command = command
25
+ end
26
+ end
27
+
28
+
29
+
@@ -0,0 +1,36 @@
1
+ require 'test/unit'
2
+ require '../lib/app_fog/shell_command_wrapper.rb'
3
+
4
+ class TestShellCommandWrapper < Test::Unit::TestCase
5
+ def test_send_command
6
+ shell = ShellCommandWrapper.new(self)
7
+ shell.perform('bob')
8
+ assert_equal(@command, 'bob')
9
+ end
10
+
11
+ def test_throws_error_when_cannot_log_in
12
+ @output = FakeStdOut.new('Problem with login, invalid account or password when attempting to login to')
13
+ assert_raise LoginError do
14
+ shell = ShellCommandWrapper.new(self)
15
+ shell.perform('af login --email username --passwd password')
16
+ end
17
+ end
18
+
19
+ def popen3(command)
20
+ @command = command
21
+ stdout = @output
22
+ stdin = nil
23
+ stderr = nil
24
+ return stdin, stdout, stderr
25
+ end
26
+ end
27
+
28
+ class FakeStdOut
29
+ def initialize(output)
30
+ @output = output
31
+ end
32
+
33
+ def read
34
+ return @output
35
+ end
36
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_fog
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -17,13 +17,24 @@ email: gemma.cameron@gmail.com
17
17
  executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
- files: []
20
+ files:
21
+ - .DS_Store
22
+ - README.md
23
+ - app_fog.gemspec
24
+ - lib/.DS_Store
25
+ - lib/app_fog.rb
26
+ - lib/app_fog/.DS_Store
27
+ - lib/app_fog/shell_command_wrapper.rb
28
+ - rakefile.rb
29
+ - test/.DS_Store
30
+ - test/test_app_fog.rb
31
+ - test/test_shell_command_wrapper.rb
21
32
  homepage: http://rubygems.org/gems/app_fog
22
33
  licenses: []
23
34
  post_install_message:
24
35
  rdoc_options: []
25
36
  require_paths:
26
- - liblib/app_fog
37
+ - lib
27
38
  required_ruby_version: !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
@@ -42,4 +53,6 @@ rubygems_version: 1.8.25
42
53
  signing_key:
43
54
  specification_version: 3
44
55
  summary: A wrapper for the app fog command line interface.
45
- test_files: []
56
+ test_files:
57
+ - test/test_app_fog.rb
58
+ - test/test_shell_command_wrapper.rb