tonka 0.0.4 → 0.0.5

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tonka.rb +25 -1
  3. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03da4a022809e7159288945d16e7c2dfcdd4ad09
4
- data.tar.gz: cae7de061ed44daa11720a6b2c597f8966a34b8a
3
+ metadata.gz: ba1aa8d09a66bf1c6d2e9e99968fdcf1815b62cb
4
+ data.tar.gz: 5b22ff47176e0760f8aeb11c4ca5c08077fbe466
5
5
  SHA512:
6
- metadata.gz: d182869c5e2079eb8c72076b4cf8cf2d660c653455f6b72e919cf3394e1d949a6a554bb557847d686adad43089096ff0c17812f1db862ed03fed37dbd59b429b
7
- data.tar.gz: 69a14b5ade385298a2ee9c095f2857fab977868ff19f7b47003597141e544189257c98f3f058138fcf0f1f229f3e8d99ee53217536bb1e1f83ef1f51ffec2814
6
+ metadata.gz: 84d04882770f1e806f11b981eed9f60ea3cf7b5af6ac914b985fe0c6c3b1735fdc03c0715713250a61ffe9810c7602efd1fcd2f0f60cf69fc924a83ce47b7ca0
7
+ data.tar.gz: 337ee62b145c138c4dde186d1eef000e188570aa44bdb8581fd9a50407a21ab78712f5e82fbdafeae2fa2cf4f50bc2d2975e5ac0d7ada2b2e1a388ab6280c1fc
data/lib/tonka.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  require 'net/http'
2
+ require 'webrick'
3
+ include WEBrick
2
4
 
3
5
  class Tonka
4
6
 
@@ -20,6 +22,13 @@ class Tonka
20
22
  end
21
23
  end
22
24
 
25
+ def serve(port)
26
+ puts "Starting server: http://#{Socket.gethostname}:#{port}"
27
+ server = HTTPServer.new(:Port=>port,:DocumentRoot=>Dir::pwd )
28
+ trap("INT"){ server.shutdown }
29
+ server.start
30
+ end
31
+
23
32
  def make_directories
24
33
  if !Dir.exist? $SITE_NAME
25
34
  Dir.mkdir $SITE_NAME
@@ -76,14 +85,29 @@ class Tonka
76
85
  when "add"
77
86
  #handles the 'add' command
78
87
 
88
+ when "serve"
89
+ port_string = @options[1] || "2000"
90
+
91
+ serve(port_string)
79
92
  else
80
93
  puts "Oops! I don't know that one."
81
94
  display_usage
82
95
  end
96
+
83
97
  end
84
98
 
85
99
  def display_usage
86
- puts "usage: tonka <action> SITE_NAME [-options] BODY_TEXT\n\nThe most common actions:\n\nbuild\s\t\t\tbuilds a basic static site with the name passed in as SITE_NAME\n\nThe most common options:\n\n-jquery \t\tadds jquery to index.html file.\n-underscore \t\tadds underscore.js to the javascripts folder and the index.html file.\n-backbone \t\tadds backbone.js to the javascripts folder and the index.html file."
100
+ usage_array = ["usage: tonka <action> SITE_NAME [-options] BODY_TEXT\n\n",
101
+
102
+ "The most common actions:\n\n",
103
+ "build\s\t\t\tbuilds a basic static site with the name passed in as SITE_NAME\n\n",
104
+ "destroy\s\t\t\tdestroys a previously built site with the name passed in as SITE_NAME\n\n",
105
+ "serve\s\t\t\tserves your files using WEBrick on port 2000 (a different port can be passed in as an argument)\n\n",
106
+ "The most common options:\n\n","
107
+ -jquery \t\tadds jquery to index.html file.\n",
108
+ "-underscore \t\tadds underscore.js to the javascripts folder and the index.html file.\n",
109
+ "-backbone \t\tadds backbone.js to the javascripts folder and the index.html file."]
110
+ puts usage_array.join("")
87
111
  end
88
112
 
89
113
  end
metadata CHANGED
@@ -1,16 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tonka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Omar Delarosa
8
+ - Eric Streske
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-10-06 00:00:00.000000000 Z
12
+ date: 2014-02-16 00:00:00.000000000 Z
12
13
  dependencies: []
13
- description: A static site builder.
14
+ description: A static site builder, destroy and server.
14
15
  email: thedelarosa@gmail.com
15
16
  executables:
16
17
  - tonka