platform1 0.0.1 → 0.0.2

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.
Files changed (4) hide show
  1. data/bin/p1 +2 -103
  2. data/bin/platform1 +106 -0
  3. data/platform1.gemspec +1 -1
  4. metadata +3 -1
data/bin/p1 CHANGED
@@ -1,106 +1,5 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
- require 'clamp'
4
- require 'launchy'
5
- require 'fileutils'
6
- require 'yaml'
3
+ # Just an alias for "platform1"
7
4
 
8
- class Platform1Command < Clamp::Command
9
-
10
- self.description = %{
11
- Platform1 helps you serve your Rails/Rack app using Passenger Standalone.
12
- }
13
-
14
- subcommand "init", "Prepare to serve a new app." do
15
-
16
- self.description = %{
17
- Configure Platform1 to serve the app in the current directory.
18
- }
19
-
20
- parameter "PORT", "the port to be used for this app"
21
-
22
- def execute
23
- update_configuration do |config|
24
- config["port"] = port
25
- end
26
- end
27
-
28
- end
29
-
30
- subcommand "start", "Start Passenger Standalone." do
31
-
32
- def execute
33
- sh("passenger start -p #{passenger_port} -d")
34
- end
35
-
36
- end
37
-
38
- subcommand "stop", "Stop Passenger Standalone." do
39
-
40
- def execute
41
- sh("passenger stop -p #{passenger_port}")
42
- end
43
-
44
- end
45
-
46
- subcommand "status", "Show Passenger status." do
47
-
48
- def execute
49
- sh("passenger status -p #{passenger_port}")
50
- end
51
-
52
- end
53
-
54
- subcommand "open", "Open app in a browser." do
55
-
56
- def execute
57
- Launchy.open(application_url)
58
- end
59
-
60
- end
61
-
62
- subcommand "restart", "Ask app to restart" do
63
-
64
- def execute
65
- FileUtils.touch("tmp/restart.txt")
66
- end
67
-
68
- end
69
-
70
- private
71
-
72
- def passenger_port
73
- configuration["port"] || signal_usage_error("port not defined: please run 'init' first")
74
- end
75
-
76
- def application_url
77
- "http://localhost:#{passenger_port}/"
78
- end
79
-
80
- def sh(command)
81
- system(command) || raise("Error running: #{command.inspect}")
82
- end
83
-
84
- def config_file
85
- ".platform1.yml"
86
- end
87
-
88
- def configuration
89
- @config ||= if File.exist?(config_file)
90
- YAML.load_file(config_file)
91
- else
92
- {}
93
- end
94
- end
95
-
96
- def update_configuration
97
- config = configuration
98
- yield config
99
- File.open(config_file, 'w') do |out|
100
- YAML.dump(config, out)
101
- end
102
- end
103
-
104
- end
105
-
106
- Platform1Command.run
5
+ load File.join(File.dirname(File.realpath(__FILE__)), "platform1")
data/bin/platform1 ADDED
@@ -0,0 +1,106 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'clamp'
4
+ require 'launchy'
5
+ require 'fileutils'
6
+ require 'yaml'
7
+
8
+ class Platform1Command < Clamp::Command
9
+
10
+ self.description = %{
11
+ Platform1 helps you serve your Rails/Rack app using Passenger Standalone.
12
+ }
13
+
14
+ subcommand "init", "Prepare to serve a new app." do
15
+
16
+ self.description = %{
17
+ Configure Platform1 to serve the app in the current directory.
18
+ }
19
+
20
+ parameter "PORT", "the port to be used for this app"
21
+
22
+ def execute
23
+ update_configuration do |config|
24
+ config["port"] = port
25
+ end
26
+ end
27
+
28
+ end
29
+
30
+ subcommand "start", "Start Passenger Standalone." do
31
+
32
+ def execute
33
+ sh("passenger start -p #{passenger_port} -d")
34
+ end
35
+
36
+ end
37
+
38
+ subcommand "stop", "Stop Passenger Standalone." do
39
+
40
+ def execute
41
+ sh("passenger stop -p #{passenger_port}")
42
+ end
43
+
44
+ end
45
+
46
+ subcommand "status", "Show Passenger status." do
47
+
48
+ def execute
49
+ sh("passenger status -p #{passenger_port}")
50
+ end
51
+
52
+ end
53
+
54
+ subcommand "open", "Open app in a browser." do
55
+
56
+ def execute
57
+ Launchy.open(application_url)
58
+ end
59
+
60
+ end
61
+
62
+ subcommand "restart", "Ask app to restart" do
63
+
64
+ def execute
65
+ FileUtils.touch("tmp/restart.txt")
66
+ end
67
+
68
+ end
69
+
70
+ private
71
+
72
+ def passenger_port
73
+ configuration["port"] || signal_usage_error("port not defined: please run 'init' first")
74
+ end
75
+
76
+ def application_url
77
+ "http://localhost:#{passenger_port}/"
78
+ end
79
+
80
+ def sh(command)
81
+ system(command) || raise("Error running: #{command.inspect}")
82
+ end
83
+
84
+ def config_file
85
+ ".platform1.yml"
86
+ end
87
+
88
+ def configuration
89
+ @config ||= if File.exist?(config_file)
90
+ YAML.load_file(config_file)
91
+ else
92
+ {}
93
+ end
94
+ end
95
+
96
+ def update_configuration
97
+ config = configuration
98
+ yield config
99
+ File.open(config_file, 'w') do |out|
100
+ YAML.dump(config, out)
101
+ end
102
+ end
103
+
104
+ end
105
+
106
+ Platform1Command.run
data/platform1.gemspec CHANGED
@@ -4,7 +4,7 @@ $:.push File.expand_path("../lib", __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
 
6
6
  gem.name = "platform1"
7
- gem.version = "0.0.1"
7
+ gem.version = "0.0.2"
8
8
  gem.platform = Gem::Platform::RUBY
9
9
 
10
10
  gem.authors = ["Mike Williams"]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: platform1
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Mike Williams
@@ -51,6 +51,7 @@ email:
51
51
  - mdub@dogbiscuit.org
52
52
  executables:
53
53
  - p1
54
+ - platform1
54
55
  extensions: []
55
56
 
56
57
  extra_rdoc_files: []
@@ -60,6 +61,7 @@ files:
60
61
  - Gemfile
61
62
  - Rakefile
62
63
  - bin/p1
64
+ - bin/platform1
63
65
  - platform1.gemspec
64
66
  has_rdoc: true
65
67
  homepage: