papertrail-provisioner 0.0.1

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.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1 @@
1
+ 1.9.2-p320
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in papertrail-provisioner.gemspec
4
+ gemspec
5
+ gem 'rake'
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Simon Menke
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,29 @@
1
+ # Papertrail::Provisioner
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'papertrail-provisioner'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install papertrail-provisioner
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'papertrail-provisioner'
4
+
5
+ provisioner = Papertrail::Provisioner.new(ENV['PAPERTRAIL_EMAIL'], ENV['PAPERTRAIL_PASSWORD'])
6
+ puts provisioner.add_heroku_system(ARGV[0])
@@ -0,0 +1,92 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require "papertrail-provisioner/version"
3
+
4
+ module Papertrail
5
+ class Provisioner
6
+ require 'uri'
7
+ require 'net/http'
8
+ require 'json'
9
+
10
+ require 'capybara'
11
+ require 'capybara/dsl'
12
+ require 'capybara/poltergeist'
13
+
14
+ Capybara.register_driver :poltergeist do |app|
15
+ Capybara::Poltergeist::Driver.new(
16
+ lambda{|e|},
17
+ :js_errors => false,
18
+ :phantomjs_options => ['--load-images=no', '--ignore-ssl-errors=yes']
19
+ )
20
+ end
21
+
22
+ Capybara.current_driver = :poltergeist
23
+ Capybara.app_host = 'https://papertrailapp.com'
24
+ Capybara.run_server = false
25
+
26
+ include Capybara::DSL
27
+
28
+ def initialize(email, password)
29
+ @account_email = email
30
+ @account_password = password
31
+ end
32
+
33
+ def login!
34
+ visit('/sessions/new')
35
+ click_on('Sign In')
36
+
37
+ fill_in('Email', :with => @account_email)
38
+ fill_in('Password', :with => @account_password)
39
+ click_on('Login')
40
+
41
+ unless current_path == '/dashboard' or current_path == '/start'
42
+ raise "Failed to login"
43
+ end
44
+
45
+ @logged_in = true
46
+ end
47
+
48
+ def add_heroku_system(name)
49
+ uri = URI("https://papertrailapp.com/api/v1/systems/#{name}.json")
50
+ Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
51
+ request = Net::HTTP::Get.new uri.request_uri
52
+ request.basic_auth @account_email, @account_password
53
+ response = http.request request
54
+ if response.code == '200'
55
+ body = JSON.load(response.body)
56
+ if syslog = body['syslog']
57
+ return "#{syslog["hostname"]}:#{syslog["port"]}"
58
+ end
59
+ end
60
+ end
61
+
62
+ login! unless @logged_in
63
+
64
+ visit('/dashboard')
65
+
66
+ unless current_path == '/dashboard'
67
+ raise "Failed to visit the dashboard"
68
+ end
69
+
70
+ click_on('Add Systems')
71
+ click_on('Alternatives')
72
+
73
+ unless current_path == '/systems/new'
74
+ raise 'Failed to load new system page'
75
+ end
76
+
77
+ find('li[data-formid="form2"]').click
78
+
79
+ within('div#form2') do
80
+ fill_in('What should we call it?', :with => name)
81
+ click_on('Save →')
82
+ end
83
+
84
+ unless current_path == "/systems/#{name}/events"
85
+ raise "Failed to create system"
86
+ end
87
+
88
+ find('div.quick-help').find('strong').text
89
+ end
90
+
91
+ end
92
+ end
@@ -0,0 +1,5 @@
1
+ module Papertrail
2
+ class Provisioner
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'papertrail-provisioner/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "papertrail-provisioner"
8
+ gem.version = Papertrail::Provisioner::VERSION
9
+ gem.authors = ["Simon Menke"]
10
+ gem.email = ["simon.menke@gmail.com"]
11
+ gem.description = %q{Papertrail + Heroku + Poltergeist}
12
+ gem.summary = %q{Easy}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_runtime_dependency 'json'
21
+ gem.add_runtime_dependency 'capybara'
22
+ gem.add_runtime_dependency 'poltergeist'
23
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: papertrail-provisioner
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Simon Menke
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-08-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: capybara
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: poltergeist
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Papertrail + Heroku + Poltergeist
63
+ email:
64
+ - simon.menke@gmail.com
65
+ executables:
66
+ - papertrail-provisioner
67
+ extensions: []
68
+ extra_rdoc_files: []
69
+ files:
70
+ - .gitignore
71
+ - .rbenv-version
72
+ - Gemfile
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - bin/papertrail-provisioner
77
+ - lib/papertrail-provisioner.rb
78
+ - lib/papertrail-provisioner/version.rb
79
+ - papertrail-provisioner.gemspec
80
+ homepage: ''
81
+ licenses: []
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ segments:
93
+ - 0
94
+ hash: -1266278102317859200
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ segments:
102
+ - 0
103
+ hash: -1266278102317859200
104
+ requirements: []
105
+ rubyforge_project:
106
+ rubygems_version: 1.8.23
107
+ signing_key:
108
+ specification_version: 3
109
+ summary: Easy
110
+ test_files: []