homesteading 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 80cc70869c0c40d888be826da79f68efb60dcc82
4
- data.tar.gz: 7446c3c1e779f5276c52d33931e942bfe9993eae
3
+ metadata.gz: 5db8d5777b4eb5e818b9ad741685e209816188a4
4
+ data.tar.gz: 9aa46f5c71d19ee16c7b579f97d24f26acd9e122
5
5
  SHA512:
6
- metadata.gz: 125f9e637252325d7172ac199a2ac15ccd7524f4484eb357f8978fb6081ee233a1bd4d065e3d6c25e6f7c976abef3560134125aacf7a1fb8654f764d4520501b
7
- data.tar.gz: 975451048996a019f038cff05f74593356113902e35fb8eeeef84ed735c6a081a73c80ceccaa8efe29789e54ca61f66706af22c2212416e11d2fc5426501076c
6
+ metadata.gz: 2c2149e2198269d10702779fbbc6d749e6cb97aa005ee75164fb676d98a3598407d3ef884b4f48eba712bd152bd9564623d1049e08b363ae3810ab83f4e4437c
7
+ data.tar.gz: 3b444776f3aa5ee0eb4336b22c9bd0a7bfd7fe4f0771e523692afdf230cd92d3c9a7a630c91eac3e5f22585ad8037cb3b2661c445cab7894c4e4d52df92bcd16
data/README.md CHANGED
@@ -12,7 +12,7 @@ See the [/help](https://github.com/homesteading/homesteading/tree/master/help) d
12
12
 
13
13
  ## Current Version
14
14
 
15
- 0.0.8
15
+ 0.0.9
16
16
 
17
17
 
18
18
  ## Requirements
data/help/apps-reroute.md CHANGED
@@ -1,5 +1,3 @@
1
- # TODO
2
-
3
1
  Usage: homesteading apps:reroute
4
2
 
5
3
  change the directory name of a homesteading app
@@ -7,5 +5,6 @@ Usage: homesteading apps:reroute
7
5
  Example:
8
6
 
9
7
  $ apps:reroute statuses --app note
8
+
10
9
  * Rerouting note to /statuses...
11
10
  * ...done
data/help/server-stop.md CHANGED
@@ -1,4 +1,4 @@
1
- # TODO
1
+ # TODO:
2
2
 
3
3
  Usage: homesteading server:stop
4
4
 
data/help/server.md CHANGED
@@ -1,5 +1,3 @@
1
- # TODO
2
-
3
1
  Usage: homesteading server
4
2
 
5
3
  start a server for constellation of homesteading apps
@@ -9,19 +7,32 @@ Usage: homesteading server
9
7
  Example:
10
8
 
11
9
  $ homesteading server
12
- Homesteading starting...
10
+ * Homesteading: 0.0.9, codename: Rooftop
11
+ * Puma: 2.10.2 (ruby 2.1.5-p273), codename: Robots on Comets
12
+ * Ruby: 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
13
+ * Environment: development
14
+ * Running on: http://0.0.0.0:3000
15
+
16
+ * Homesteading servers starting...
13
17
 
14
- * Homesteading: 1.0.1, codename: Rooftop
15
- * Puma: 2.10.2 (ruby 2.1.5-p273), codename: Robots on Comets
16
- * Ruby: 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
17
- * Environment: development
18
- * Running on: http://0.0.0.0:3000
18
+ * Starting on port 3002 : article
19
+ * Starting on port 3003 : bookmark
20
+ * Starting on port 3004 : event
21
+ * Starting on port 3005 : feed
22
+ * Starting on port 3006 : note
23
+ * Starting on port 3007 : photo
24
+ * Starting on port 3009 : sound
25
+ * Starting on port 3010 : video
26
+ * Starting on port 3011 : walk
27
+ * Starting on port 3012 : weight
19
28
 
20
- Use Ctrl-C to stop
29
+ * To stop Homesteading servers:
30
+ ctrl-c
31
+ homesteading server:stop
21
32
 
22
33
 
23
34
  Additional commands, type "homesteading help COMMAND" for more details:
24
35
 
25
36
  * server:list # list the currently running homesteading apps
26
- * server:stop [--app APP] # stop a constellation or a specific app
27
- * server:urls [--app APP] # list the urls of running apps
37
+ * server:stop [--app APP] # stop running homesteading apps
38
+ * server:urls [--app APP] # list the urls of running homesteading apps
@@ -244,6 +244,54 @@ class Homesteading
244
244
  end
245
245
 
246
246
  def reroute
247
+ puts
248
+ options = parse_options
249
+
250
+ if options[:app].nil?
251
+ puts "* '--app APP' is required for this command"
252
+ puts
253
+ exit
254
+ end
255
+
256
+ new_route = ARGV.shift
257
+ if new_route.nil?
258
+ puts "* New app route is required for this command"
259
+ puts "* Example:"
260
+ puts " homesteading apps:reroute statuses --app note"
261
+ puts
262
+ exit
263
+ end
264
+
265
+ app = options[:app].downcase
266
+ constellation_path = Dir.pwd
267
+ app_dir = "#{constellation_path}/homesteading-#{app}/"
268
+ app_file_path = app_dir + "app.json"
269
+
270
+ if File.exist?(app_dir)
271
+ if File.exist?(app_file_path)
272
+ app_file = JSON.parse(File.read(app_file_path))
273
+ app_file["routes"]["path"] = new_route
274
+
275
+ puts "* Rerouting note to /statuses..."
276
+ new_app_file = JSON.pretty_generate(app_file)
277
+ File.write(app_file_path, new_app_file)
278
+ puts "* ...done"
279
+ else
280
+ puts "* No app.json found for #{app}"
281
+ puts
282
+ exit
283
+ end
284
+ else
285
+ puts "* #{app} does not exist"
286
+ puts "* Did you mean one of these?"
287
+ Dir.glob("#{Dir.pwd}/homesteading-*/").each do |ff|
288
+ puts " - #{ff.split("/").last.sub(/homesteading-/, "")}"
289
+ end
290
+ puts
291
+ exit
292
+ end
293
+
294
+ puts
247
295
  end
248
296
 
249
297
  private
@@ -3,6 +3,93 @@ class Homesteading
3
3
  class << self
4
4
 
5
5
  def default
6
+ puts
7
+ options = parse_options
8
+
9
+ router_port = options[:port] || 3000
10
+
11
+ # Kill all Homesteading apps when `hs server` is stopped
12
+ servers = []
13
+ Signal.trap("INT") do
14
+ servers.each do |io|
15
+ puts "Stopping HS:Publisher app at PID: #{io.pid}"
16
+ Process.kill "SIGINT", io.pid
17
+ end
18
+
19
+ system("homesteading server:stop")
20
+ exit
21
+ end
22
+
23
+ # TODO
24
+ homesteading_info = "0.0.9, codename: Rooftop"
25
+ ruby_info = RUBY_VERSION
26
+ puma_info = "2.10.2 (ruby 2.1.5-p273), codename: Robots on Comets"
27
+ env_info = "development"
28
+
29
+ puts "* Homesteading: #{homesteading_info}"
30
+ puts "* Puma: #{puma_info}"
31
+ puts "* Ruby: #{RUBY_VERSION}"
32
+ puts "* Environment: #{env_info}"
33
+ puts "* Running on: http://0.0.0.0:#{router_port}"
34
+ puts
35
+
36
+ puts "* Homesteading servers starting..."
37
+ puts
38
+
39
+ routes = []
40
+
41
+ app_port = 3000
42
+ Dir.glob("#{Dir.pwd}/homesteading-*/").each_with_index do |directory, index|
43
+ app_file_path = directory + "app.json"
44
+
45
+ if File.exist?(app_file_path)
46
+ app_file = JSON.parse(File.read(app_file_path))
47
+ app_route = app_file["routes"]
48
+
49
+ if app_route
50
+ app_name = directory.split("/").last
51
+
52
+ app_path = app_route["path"]
53
+ if app_name =~ /feed/
54
+ app_path = "feed"
55
+ end
56
+
57
+ unless app_name == "homesteading-router-rack"
58
+ app_port += 1
59
+ routes << "#{app_path}:#{app_port}"
60
+ end
61
+
62
+ if app_name =~ /homesteading-assets|homesteading-router-rack/
63
+ # TODO TEMP FIXME serve assets from hub
64
+ # skipping assets and router
65
+ elsif app_name == "homesteading-feed"
66
+ # TODO TEMP FIXME no bin/rails
67
+ puts "* Starting on port #{app_port} : #{app_name.sub(/homesteading-/, "")}"
68
+ servers << IO.popen("cd #{directory} && rails server -p #{app_port}", "w")
69
+ else
70
+ puts "* Starting on port #{app_port} : #{app_name.sub(/homesteading-/, "")}"
71
+ servers << IO.popen("cd #{directory} && bin/rails server -d --port #{app_port}", "w")
72
+ end
73
+ end
74
+
75
+ end
76
+ end
77
+
78
+ # TODO write routes to an env var for hs:router's routes table
79
+ ENV["HOMESTEADING_ROUTES"] = routes.join(",")
80
+
81
+ # start up router after ENV var is set
82
+ # elsif app_name == "homesteading-router-rack"
83
+ puts
84
+ puts "* Starting on port #{router_port} : router"
85
+ servers << IO.popen("cd #{Dir.pwd}/homesteading-router-rack/ && rackup -p #{router_port}", "w")
86
+
87
+
88
+ puts
89
+ puts "* To stop Homesteading servers:"
90
+ puts " ctrl-c"
91
+ puts " homesteading server:stop"
92
+ puts
6
93
  end
7
94
 
8
95
  def list
@@ -10,13 +97,28 @@ class Homesteading
10
97
 
11
98
  def stop
12
99
  # TEMP HACK TODO FIXME
13
- # This is overly aggressive, but the above kill isn't working
100
+ # This is overly aggressive, but Signal.trap isn't working
14
101
  system "killall ruby"
15
102
  end
16
103
 
17
104
  def urls
18
105
  end
19
106
 
107
+ private
108
+ def parse_options
109
+ # Parse command line options
110
+ options = {}
111
+
112
+ optparse = OptionParser.new do |opts|
113
+ opts.on("-p", "--port PORT", "Run homesteading site on a specific port (default: 3000)") do |port|
114
+ options[:port] = port
115
+ end
116
+ end
117
+
118
+ optparse.parse!
119
+ options
120
+ end
121
+
20
122
  end
21
123
  end
22
124
  end
@@ -5,7 +5,7 @@ class Homesteading
5
5
  def default
6
6
  # TODO load in *actual* VERSION and CODENAME from homesteading/version
7
7
  # puts "Homesteading #{Homesteading::VERSION}, codename: #{Homesteading::CODENAME}"
8
- puts "Homesteading 0.0.8, codename: Rooftop"
8
+ puts "Homesteading 0.0.9, codename: Rooftop"
9
9
  end
10
10
 
11
11
  end
@@ -1,4 +1,4 @@
1
1
  module Homesteading
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  CODENAME = "Rooftop"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: homesteading
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Becker