powser 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ tmp
6
+ .rvmrc
7
+ log/*
8
+ lib/powser/app
9
+ lib/powser/tmp
@@ -0,0 +1,5 @@
1
+ ## 0.0.1 (July 10, 2010)
2
+
3
+ Features:
4
+
5
+ - initial import of this dummy gem
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in powder.gemspec
4
+ gemspec
5
+ gem "sinatra"
6
+ gem "thor"
7
+ gem "powder"
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Phil Monroe
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,36 @@
1
+ ### Powser
2
+ A simple web server interface to powder CLI for pow! This gives you the ability to create a bookmark button in your browser that will restart your development app and redirect to the root url.
3
+
4
+ ### Features
5
+ * Application Restart
6
+ * Restarts a linked application and redirects to it's root url
7
+ * Browse to `http://prowser.dev/restart`
8
+ * Redirect to a custom url by passing in the `redirect` parameter to the action
9
+ * `http://prowser.dev/restart?redirect=www.appname.dev`
10
+
11
+ ### How do I setup Prowser?
12
+ From scratch:
13
+
14
+ ```sh
15
+ cd path/to/pow/app
16
+ gem install prowser
17
+ prowser start
18
+ ```
19
+
20
+ Link prowser to an app with a custom appname:
21
+
22
+ ```sh
23
+ prowser start appname
24
+ ```
25
+
26
+ Stop the prowser server
27
+
28
+ ```sh
29
+ prowser stop
30
+ ```
31
+
32
+ Restart the prowser server
33
+
34
+ ```sh
35
+ prowser restart
36
+ ```
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,102 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'rubygems'
4
+ require 'thor'
5
+ require 'fileutils'
6
+ require 'net/https'
7
+ require 'powder/version'
8
+
9
+ module Powder
10
+ class CLI < Thor
11
+ include Thor::Actions
12
+ default_task :help
13
+
14
+ SERVER_PATH = File.dirname(__FILE__) + "/../lib/powser"
15
+ POWDER_CONFIG = ".powder"
16
+
17
+ desc "start", "Start a webserver to provide powder functionality from your browser. The server is located at http://powser.dev. Pass the name of the pow link that you want powser to monitor."
18
+ def start(app = nil)
19
+ return unless is_powable?
20
+ app ||= get_pow_name
21
+ Dir.chdir(SERVER_PATH) do
22
+ `powder link powser`
23
+ File.open("app", "w") do |f|
24
+ f.puts(app)
25
+ end
26
+ say "Powser is now active for #{app}."
27
+ end
28
+ end
29
+
30
+ desc "stop", "Kill the powser server."
31
+ def stop(app = nil)
32
+ app ||= get_pow_name
33
+ Dir.chdir(SERVER_PATH) do
34
+ `powder unlink`
35
+ say "Powser is no longer active for #{app}."
36
+ end
37
+ end
38
+
39
+ desc "restart", "Restart the powser server."
40
+ def restart
41
+ Dir.chdir(SERVER_PATH) do
42
+ `powder restart`
43
+ say "Powser will restart."
44
+ end
45
+ end
46
+
47
+ desc "version", "Shows the version."
48
+ def version
49
+ say "powser #{Powder::VERSION}"
50
+ end
51
+
52
+ private
53
+
54
+ def current_dir_name
55
+ File.basename(%x{pwd}.chomp)
56
+ end
57
+
58
+ def configured_pow_name
59
+ return nil unless File.exists?(POWDER_CONFIG)
60
+
61
+ File.foreach(POWDER_CONFIG) do |line|
62
+ next if line =~ /^($|#)/
63
+ return line.chomp
64
+ end
65
+
66
+ return nil
67
+ end
68
+
69
+ def current_dir_pow_name
70
+ current_dir_name.tr('_', '-')
71
+ end
72
+
73
+ def get_pow_name
74
+ configured_pow_name || current_dir_pow_name
75
+ end
76
+
77
+ def is_powable?
78
+ if File.exists?('config.ru') || File.exists?('public/index.html')
79
+ true
80
+ elsif legacy = (is_rails2_app? || is_radiant_app?)
81
+ say "This appears to be a #{legacy} application. You need a config.ru file."
82
+ if yes? "Do you want to autogenerate a basic config.ru for #{legacy}?"
83
+ uri = URI.parse("https://raw.github.com/gist/909308")
84
+ http = Net::HTTP.new(uri.host, uri.port)
85
+ http.use_ssl = true
86
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
87
+ request = Net::HTTP::Get.new(uri.request_uri)
88
+ create_file "config.ru", http.request(request).body
89
+ return true
90
+ else
91
+ say "Did not create config.ru"
92
+ return false
93
+ end
94
+ else
95
+ say "This does not appear to be a rack app as there is no config.ru."
96
+ say "Pow can also host static apps if there is an index.html in public/"
97
+ return false
98
+ end
99
+ end
100
+ end
101
+ end
102
+ Powder::CLI.start
@@ -0,0 +1,2 @@
1
+ require "powser/server"
2
+ require "powser/version"
@@ -0,0 +1 @@
1
+ powser
@@ -0,0 +1,3 @@
1
+ Dir["./*.rb"].each {|file| require file }
2
+
3
+ run Powser::Server
@@ -0,0 +1,48 @@
1
+ require 'sinatra'
2
+
3
+ module Powser
4
+ class Server < Sinatra::Base
5
+ POW_PATH = `powder config | grep hostRoot | sed s/hostRoot//`.strip
6
+
7
+ before do
8
+ @pow_app = `cat app`.strip
9
+ end
10
+
11
+ # Routes ------------------------------------------------------------------
12
+ get '/restart' do
13
+ to_url = redirect_url(params[:redirect])
14
+ pow_dir(@pow_app) do
15
+ `powder restart`
16
+ to_url ||= pow_url(@pow_app)
17
+ end
18
+ redirect to_url
19
+ end
20
+
21
+ # Helpers -------------------------------------------------------------------
22
+ def pow_dir(app_name, &block)
23
+ path = POW_PATH + '/' + app_name
24
+ Dir.chdir(path) do
25
+ yield
26
+ end
27
+ end
28
+
29
+ def pow_url(app_name)
30
+ 'http://' + app_name + '.' + domain
31
+ end
32
+
33
+ def redirect_url(to)
34
+ "http://" + to if to
35
+ end
36
+
37
+ def domain
38
+ if File.exists? File.expand_path('~/.powconfig')
39
+ returned_domain = %x{source ~/.powconfig; echo $POW_DOMAINS}.gsub("\n", "").split(",").first
40
+ returned_domain = %x{source ~/.powconfig; echo $POW_DOMAIN}.gsub("\n", "") if returned_domain.nil? || returned_domain.empty?
41
+ returned_domain = 'dev' if returned_domain.nil? || returned_domain.empty?
42
+ returned_domain
43
+ else
44
+ 'dev'
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,3 @@
1
+ module Powser
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "powser"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "powser"
7
+ s.version = Powser::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Phil Monroe"]
10
+ s.email = ["phil@philmonroe.com.com"]
11
+ s.homepage = "http://github.com/phil-monroe/powser"
12
+ s.summary = "Powder from your browser."
13
+ s.description = "A simple web server interface to Powder."
14
+ s.rubyforge_project = s.name
15
+
16
+ s.required_rubygems_version = ">= 1.3.6"
17
+
18
+ # If you have runtime dependencies, add them here
19
+ s.add_dependency 'thor', '>=0.11.5'
20
+ s.add_dependency "sinatra", '>=1.3.1'
21
+ s.add_dependency "powder", '>=0.1.7'
22
+
23
+ # The list of files to be contained in the gem
24
+ s.files = `git ls-files`.split("\n")
25
+ s.executables = ["powser"]
26
+ s.require_paths = ["lib"]
27
+ end
File without changes
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: powser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Phil Monroe
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-27 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: &70148590837580 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.11.5
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70148590837580
25
+ - !ruby/object:Gem::Dependency
26
+ name: sinatra
27
+ requirement: &70148590836900 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.3.1
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70148590836900
36
+ - !ruby/object:Gem::Dependency
37
+ name: powder
38
+ requirement: &70148590836240 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 0.1.7
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70148590836240
47
+ description: A simple web server interface to Powder.
48
+ email:
49
+ - phil@philmonroe.com.com
50
+ executables:
51
+ - powser
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - CHANGELOG.md
57
+ - Gemfile
58
+ - LICENSE
59
+ - README.md
60
+ - Rakefile
61
+ - bin/powser
62
+ - lib/powser.rb
63
+ - lib/powser/.powder
64
+ - lib/powser/config.ru
65
+ - lib/powser/server.rb
66
+ - lib/powser/version.rb
67
+ - powser.gemspec
68
+ - test/test_helper.rb
69
+ homepage: http://github.com/phil-monroe/powser
70
+ licenses: []
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: 1.3.6
87
+ requirements: []
88
+ rubyforge_project: powser
89
+ rubygems_version: 1.8.10
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: Powder from your browser.
93
+ test_files: []