pakyow-core 0.8rc1 → 0.8.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/pakyow-core/lib/core/app.rb +448 -0
  3. data/pakyow-core/lib/core/base.rb +35 -12
  4. data/pakyow-core/lib/core/{configuration → config}/app.rb +38 -35
  5. data/pakyow-core/lib/core/config/base.rb +30 -0
  6. data/pakyow-core/lib/core/config/cookies.rb +21 -0
  7. data/pakyow-core/lib/core/config/logger.rb +37 -0
  8. data/pakyow-core/lib/core/{configuration → config}/server.rb +3 -1
  9. data/pakyow-core/lib/core/exceptions.rb +3 -0
  10. data/pakyow-core/lib/core/helpers.rb +20 -16
  11. data/pakyow-core/lib/core/loader.rb +1 -1
  12. data/pakyow-core/lib/core/middleware/logger.rb +170 -16
  13. data/pakyow-core/lib/core/middleware/static.rb +20 -8
  14. data/pakyow-core/lib/core/multilog.rb +19 -0
  15. data/pakyow-core/lib/core/request.rb +52 -30
  16. data/pakyow-core/lib/core/route_eval.rb +390 -0
  17. data/pakyow-core/lib/core/route_lookup.rb +17 -5
  18. data/pakyow-core/lib/core/route_set.rb +17 -210
  19. data/pakyow-core/lib/core/route_template_defaults.rb +18 -12
  20. data/pakyow-core/lib/core/router.rb +41 -31
  21. data/pakyow-core/lib/utils/dir.rb +19 -0
  22. data/pakyow-core/lib/utils/hash.rb +14 -4
  23. data/pakyow-core/lib/views/errors/404.html +77 -0
  24. data/pakyow-core/lib/views/errors/500.html +56 -0
  25. metadata +30 -53
  26. data/pakyow-core/bin/pakyow +0 -18
  27. data/pakyow-core/lib/commands/USAGE +0 -9
  28. data/pakyow-core/lib/commands/USAGE-CONSOLE +0 -12
  29. data/pakyow-core/lib/commands/USAGE-NEW +0 -11
  30. data/pakyow-core/lib/commands/USAGE-SERVER +0 -12
  31. data/pakyow-core/lib/commands/console.rb +0 -18
  32. data/pakyow-core/lib/commands/server.rb +0 -8
  33. data/pakyow-core/lib/core/application.rb +0 -330
  34. data/pakyow-core/lib/core/cache.rb +0 -25
  35. data/pakyow-core/lib/core/configuration/base.rb +0 -31
  36. data/pakyow-core/lib/core/fn_context.rb +0 -5
  37. data/pakyow-core/lib/core/log.rb +0 -39
  38. data/pakyow-core/lib/core/middleware/not_found.rb +0 -40
  39. data/pakyow-core/lib/core/middleware/presenter.rb +0 -25
  40. data/pakyow-core/lib/core/middleware/router.rb +0 -33
  41. data/pakyow-core/lib/core/middleware/setup.rb +0 -15
  42. data/pakyow-core/lib/core/presenter_base.rb +0 -11
  43. data/pakyow-core/lib/core/route_template.rb +0 -77
  44. data/pakyow-core/lib/generators/pakyow/app/app_generator.rb +0 -36
  45. data/pakyow-core/lib/generators/pakyow/app/templates/README +0 -54
  46. data/pakyow-core/lib/generators/pakyow/app/templates/app.rb +0 -12
  47. data/pakyow-core/lib/generators/pakyow/app/templates/config.ru +0 -3
  48. data/pakyow-core/lib/generators/pakyow/app/templates/public/favicon.ico +0 -0
  49. data/pakyow-core/lib/generators/pakyow/app/templates/rakefile +0 -2
  50. data/pakyow-core/lib/generators/pakyow/app/templates/views/main.html +0 -1
  51. data/pakyow-core/lib/generators/pakyow/app/templates/views/pakyow.html +0 -12
@@ -1,27 +1,33 @@
1
1
  module Pakyow
2
2
  class RouteTemplateDefaults
3
- def self.register
4
- Pakyow::Router.instance.set(:default) {
3
+ def self.defaults
4
+ lambda {
5
5
  template(:restful) {
6
- get '/', :index, fn(:index)
6
+ unnested_path = path.dup
7
+ nested_path { |group, path|
8
+ File.join(path, ":#{group}_id")
9
+ }
7
10
 
11
+ default fn(:default) if fn(:default)
12
+
13
+ get '/new', :new, fn(:new) if fn(:new)
14
+
8
15
  # special case for show (view path is overridden)
9
16
  if show_fns = fn(:show)
10
- show_fns = [show_fns] unless show_fns.is_a?(Array)
11
- get '/:id', :show, show_fns.unshift(
17
+ get '/:id', :show, Array(show_fns).unshift(
12
18
  lambda {
13
- presenter.view_path = File.join(self.path, 'show') if Configuration::Base.app.presenter
19
+ #TODO would like to move this reference out of core
20
+ presenter.view_path = File.join(unnested_path, 'show') if @presenter
14
21
  }
15
22
  )
16
23
  end
24
+
25
+ post '/', :create, fn(:create) if fn(:create)
17
26
 
18
- get '/new', :new, fn(:new)
19
- post '/', :create, fn(:create)
20
-
21
- get '/:id/edit', :edit, fn(:edit)
22
- put '/:id', :update, fn(:update)
27
+ get '/:id/edit', :edit, fn(:edit) if fn(:edit)
28
+ put '/:id', :update, fn(:update) if fn(:update)
23
29
 
24
- delete '/:id', :delete, fn(:delete)
30
+ delete '/:id', :delete, fn(:delete) if fn(:delete)
25
31
  }
26
32
  }
27
33
  end
@@ -6,20 +6,23 @@ module Pakyow
6
6
  class Router
7
7
  include Singleton
8
8
 
9
+ attr_reader :sets
10
+
9
11
  def initialize
12
+ @sets = {}
10
13
  end
11
14
 
15
+ #TODO want to do this for all sets?
12
16
  def reset
13
17
  @sets = {}
14
- RouteTemplateDefaults.register
15
18
  self
16
19
  end
17
20
 
18
- # Creates a new set (or appends to a set if it exists).
21
+ # Creates a new set.
19
22
  #
20
23
  def set(name, &block)
21
- @sets[name] ||= RouteSet.new
22
- @sets[name].instance_exec(&block)
24
+ @sets[name] = RouteSet.new
25
+ @sets[name].eval(&block)
23
26
  end
24
27
 
25
28
  # Iterates through route sets and returns the first matching route.
@@ -36,32 +39,33 @@ module Pakyow
36
39
 
37
40
  # Performs the initial routing for a request.
38
41
  #
39
- def route!(request)
40
- self.trampoline(self.match(request))
42
+ def perform(request, ctx = Pakyow.app, &after_match)
43
+ fns = match(request)
44
+ after_match.call if block_given?
45
+
46
+ trampoline(fns, ctx)
41
47
  end
42
48
 
43
49
  # Reroutes a request.
44
50
  #
45
- def reroute!(request)
51
+ def reroute(request)
46
52
  throw :fns, self.match(request)
47
53
  end
48
54
 
49
55
  # Finds and invokes a handler by name or by status code.
50
56
  #
51
- def handle!(name_or_code, from_logic = false)
57
+ def handle(name_or_code, app = Pakyow.app, from_logic = false)
58
+ app.response.status = name_or_code if name_or_code.is_a?(Integer)
59
+
52
60
  @sets.each { |set|
53
61
  if h = set[1].handle(name_or_code)
54
- Pakyow.app.response.status = h[0]
55
- from_logic ? throw(:fns, h[2]) : self.trampoline(h[2])
62
+ app.response.status = h[1]
63
+ from_logic ? throw(:fns, h[2]) : self.trampoline(h[2], app)
56
64
  break
57
65
  end
58
66
  }
59
67
  end
60
68
 
61
- def routed?
62
- @routed
63
- end
64
-
65
69
  # Looks up and populates a path with data
66
70
  #
67
71
  def path(name, data = nil)
@@ -74,28 +78,31 @@ module Pakyow
74
78
  RouteLookup.new.group(name)
75
79
  end
76
80
 
77
- protected
78
-
79
- # Calls a list of route functions in order (each in a separate context).
81
+ # Calls a defined fn
80
82
  #
81
- def call_fns(fns)
82
- fns.each {|fn| self.context.instance_exec(&fn)}
83
+ def fn(name)
84
+ @sets.each { |set|
85
+ if fn = set[1].fn(name)
86
+ fn.call
87
+ break
88
+ end
89
+ }
83
90
  end
84
91
 
85
- # Creates a context in which to evaluate a route function.
92
+ protected
93
+
94
+ # Calls a list of route functions in order (in a shared context).
86
95
  #
87
- def context
88
- FnContext.new
96
+ def call_fns(fns, app)
97
+ fns.each {|fn| app.instance_exec(&fn)}
89
98
  end
90
99
 
91
100
  # Finds the first matching route for the request path/method and
92
101
  # returns the list of route functions for that route.
93
102
  #
94
103
  def match(request)
95
- path = StringUtils.normalize_path(request.working_path)
96
- method = request.working_method
97
-
98
- @routed = false
104
+ path = StringUtils.normalize_path(request.path)
105
+ method = request.method
99
106
 
100
107
  match, data = nil
101
108
  @sets.each { |set|
@@ -121,10 +128,11 @@ module Pakyow
121
128
  # Calls route functions and catches new functions as
122
129
  # they're thrown (e.g. by reroute).
123
130
  #
124
- def trampoline(fns)
131
+ def trampoline(fns, ctx)
132
+ routed = false
125
133
  until fns.empty?
126
134
  fns = catch(:fns) {
127
- self.call_fns(fns)
135
+ self.call_fns(fns, ctx)
128
136
 
129
137
  # Getting here means that call() returned normally (not via a throw)
130
138
  :fall_through
@@ -133,11 +141,13 @@ module Pakyow
133
141
  # If reroute! or invoke_handler! was called in the block, block will have a new value (nil or block).
134
142
  # If neither was called, block will be :fall_through
135
143
 
136
- @routed = case fns
144
+ routed = case fns
137
145
  when [] then false
138
146
  when :fall_through then fns = [] and true
139
147
  end
140
148
  end
149
+
150
+ return routed
141
151
  end
142
152
 
143
153
  # Extracts the data from a path.
@@ -146,8 +156,8 @@ module Pakyow
146
156
  data = {}
147
157
  return data unless matches
148
158
 
149
- vars.each {|v|
150
- data[v[:var]] = matches[v[:position]]
159
+ matches.names.each {|var|
160
+ data[var.to_sym] = matches[var]
151
161
  }
152
162
 
153
163
  data
@@ -14,5 +14,24 @@ module Pakyow
14
14
  dirs.each{|d| walk_dir("#{dir}/#{d}", &block) unless d.start_with?(".")}
15
15
  end
16
16
 
17
+ def self.print_dir(dir)
18
+ puts "/#{dir}"
19
+ DirUtils.walk_dir(dir) {|full_path|
20
+ path = full_path.gsub(Regexp.new("#{dir}\/?"), '')
21
+ next if path.empty?
22
+
23
+ prefix = "|"
24
+ path.scan(/\//).size.times do
25
+ prefix += " |"
26
+ end
27
+
28
+ path.gsub!(/^.*\//, '')
29
+ puts "#{prefix}-- #{path}"
30
+ }
31
+ end
32
+
33
+ def self.dir_within_dir?(dir1, dir2)
34
+ (dir1.split('/') - dir2.split('/')).empty?
35
+ end
17
36
  end
18
37
  end
@@ -11,18 +11,28 @@ module Pakyow
11
11
  def self.strhash(hash)
12
12
  indifferentize(hash)
13
13
  end
14
-
14
+
15
+ # Converts keys to symbols.
16
+ def self.symbolize_keys(hash)
17
+ Hash[hash.map{|(k,v)| [k.to_sym,v]}]
18
+ end
19
+
20
+ # Converts keys/values to symbols.
21
+ def self.symbolize(hash)
22
+ Hash[hash.map{|(k,v)| [k.to_sym,v.to_sym]}]
23
+ end
24
+
15
25
  protected
16
-
26
+
17
27
  # (see {strhash})
18
28
  def self.indifferentize(hash)
19
29
  hash.each_pair do |key, value|
20
30
  hash[key] = indifferentize(value) if value.is_a? Hash
21
31
  end
22
-
32
+
23
33
  indifferent_hash.merge(hash)
24
34
  end
25
-
35
+
26
36
  # (see {strhash})
27
37
  def self.indifferent_hash
28
38
  Hash.new { |hash,key| hash[key.to_s] if Symbol === key }
@@ -0,0 +1,77 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>
5
+ Pakyow: 404
6
+ </title>
7
+
8
+ <style>
9
+ body {
10
+ font:13px Helvetica Neue, Helvetica, sans-serif;
11
+ line-height:1.35em;
12
+ color:#333;
13
+ }
14
+
15
+ h1 {
16
+ font-size:20px;
17
+ color:#333;
18
+ }
19
+
20
+ h2 {
21
+ font-weight:normal;
22
+ font-size:13px;
23
+ color:#FF0000;
24
+ }
25
+
26
+ code {
27
+ font-size:13px;
28
+ display:block;
29
+ margin:20px;
30
+ color:#333;
31
+ }
32
+
33
+ hr {
34
+ height:1px;
35
+ background:#ccc;
36
+ border:0;
37
+ }
38
+
39
+ .wrapper {
40
+ width:700px;
41
+ margin:60px auto 0;
42
+ }
43
+
44
+ .instruct {
45
+ font-size:15px;
46
+ margin:30px 0;
47
+ color:#777;
48
+ }
49
+ </style>
50
+ </head>
51
+ <body>
52
+ <div class="wrapper">
53
+ <h1>
54
+ Pakyow couldn't find a route or view for this request path.
55
+ </h1>
56
+
57
+ <p class="instruct">
58
+ For Pakyow to fulfill this request, create a view at '{view_path}'.
59
+ </p>
60
+
61
+ <hr>
62
+
63
+ <p class="instruct">
64
+ If you want back-end code to execute for this path, create
65
+ a route; maybe something like this:
66
+
67
+ <code>
68
+ get '{route_path}' do
69
+ <br>
70
+ &nbsp;&nbsp;# your code goes here
71
+ <br>
72
+ end
73
+ </code>
74
+ </p>
75
+ </div>
76
+ </body>
77
+ </html>
@@ -0,0 +1,56 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>
5
+ Pakyow: 500
6
+ </title>
7
+
8
+ <style>
9
+ body {
10
+ font:13px Helvetica Neue, Helvetica, sans-serif;
11
+ line-height:1.35em;
12
+ color:#333;
13
+ }
14
+
15
+ h1 {
16
+ font-size:20px;
17
+ color:#333;
18
+ }
19
+
20
+ h2 {
21
+ font-weight:normal;
22
+ font-size:13px;
23
+ color:#FF0000;
24
+ }
25
+
26
+ .wrapper {
27
+ width:900px;
28
+ margin:60px auto 0;
29
+ }
30
+
31
+ .instruct {
32
+ font-size:15px;
33
+ margin:30px 0;
34
+ color:#777;
35
+ }
36
+ </style>
37
+ </head>
38
+ <body>
39
+ <div class="wrapper">
40
+ <h1>
41
+ Pakyow found something wrong.
42
+ </h1>
43
+
44
+ <p class="instruct">
45
+ The error originated on line {line} of '{file}'
46
+ and generated the following stack trace:
47
+ </p>
48
+
49
+ <h2>
50
+ {msg}
51
+ </h2>
52
+
53
+ {trace}
54
+ </div>
55
+ </body>
56
+ </html>
metadata CHANGED
@@ -1,125 +1,102 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pakyow-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8rc1
5
- prerelease: 3
4
+ version: 0.8.rc4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bryan Powell
9
8
  - Bret Young
10
9
  autorequire:
11
- bindir: pakyow-core/bin
10
+ bindir: bin
12
11
  cert_chain: []
13
- date: 2013-02-11 00:00:00.000000000 Z
12
+ date: 2013-10-26 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: rack
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ~>
21
19
  - !ruby/object:Gem::Version
22
- version: '1.3'
20
+ version: '1.5'
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
25
  - - ~>
29
26
  - !ruby/object:Gem::Version
30
- version: '1.3'
27
+ version: '1.5'
31
28
  - !ruby/object:Gem::Dependency
32
- name: turn
29
+ name: minitest
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
32
  - - ~>
37
33
  - !ruby/object:Gem::Version
38
- version: '0.9'
34
+ version: '5.0'
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
39
  - - ~>
45
40
  - !ruby/object:Gem::Version
46
- version: '0.9'
47
- description: pakyow-core
41
+ version: '5.0'
42
+ description: Core functionality for Pakyow applications, including routing and middleware.
48
43
  email: bryan@metabahn.com
49
- executables:
50
- - pakyow
44
+ executables: []
51
45
  extensions: []
52
46
  extra_rdoc_files: []
53
47
  files:
54
48
  - pakyow-core/CHANGES
55
49
  - pakyow-core/README
56
50
  - pakyow-core/MIT-LICENSE
57
- - pakyow-core/lib/commands/console.rb
58
- - pakyow-core/lib/commands/server.rb
59
- - pakyow-core/lib/commands/USAGE
60
- - pakyow-core/lib/commands/USAGE-CONSOLE
61
- - pakyow-core/lib/commands/USAGE-NEW
62
- - pakyow-core/lib/commands/USAGE-SERVER
63
- - pakyow-core/lib/core/application.rb
51
+ - pakyow-core/lib/core/app.rb
64
52
  - pakyow-core/lib/core/base.rb
65
- - pakyow-core/lib/core/cache.rb
66
- - pakyow-core/lib/core/configuration/app.rb
67
- - pakyow-core/lib/core/configuration/base.rb
68
- - pakyow-core/lib/core/configuration/server.rb
69
- - pakyow-core/lib/core/fn_context.rb
53
+ - pakyow-core/lib/core/config/app.rb
54
+ - pakyow-core/lib/core/config/base.rb
55
+ - pakyow-core/lib/core/config/cookies.rb
56
+ - pakyow-core/lib/core/config/logger.rb
57
+ - pakyow-core/lib/core/config/server.rb
58
+ - pakyow-core/lib/core/exceptions.rb
70
59
  - pakyow-core/lib/core/helpers.rb
71
60
  - pakyow-core/lib/core/loader.rb
72
- - pakyow-core/lib/core/log.rb
73
61
  - pakyow-core/lib/core/middleware/logger.rb
74
- - pakyow-core/lib/core/middleware/not_found.rb
75
- - pakyow-core/lib/core/middleware/presenter.rb
76
62
  - pakyow-core/lib/core/middleware/reloader.rb
77
- - pakyow-core/lib/core/middleware/router.rb
78
- - pakyow-core/lib/core/middleware/setup.rb
79
63
  - pakyow-core/lib/core/middleware/static.rb
80
- - pakyow-core/lib/core/presenter_base.rb
64
+ - pakyow-core/lib/core/multilog.rb
81
65
  - pakyow-core/lib/core/request.rb
82
66
  - pakyow-core/lib/core/response.rb
67
+ - pakyow-core/lib/core/route_eval.rb
83
68
  - pakyow-core/lib/core/route_lookup.rb
84
69
  - pakyow-core/lib/core/route_set.rb
85
- - pakyow-core/lib/core/route_template.rb
86
70
  - pakyow-core/lib/core/route_template_defaults.rb
87
71
  - pakyow-core/lib/core/router.rb
88
- - pakyow-core/lib/generators/pakyow/app/app_generator.rb
89
- - pakyow-core/lib/generators/pakyow/app/templates/app.rb
90
- - pakyow-core/lib/generators/pakyow/app/templates/config.ru
91
- - pakyow-core/lib/generators/pakyow/app/templates/public/favicon.ico
92
- - pakyow-core/lib/generators/pakyow/app/templates/rakefile
93
- - pakyow-core/lib/generators/pakyow/app/templates/README
94
- - pakyow-core/lib/generators/pakyow/app/templates/views/main.html
95
- - pakyow-core/lib/generators/pakyow/app/templates/views/pakyow.html
96
72
  - pakyow-core/lib/pakyow-core.rb
97
73
  - pakyow-core/lib/utils/dir.rb
98
74
  - pakyow-core/lib/utils/hash.rb
99
75
  - pakyow-core/lib/utils/string.rb
100
- - pakyow-core/bin/pakyow
76
+ - pakyow-core/lib/views/errors/404.html
77
+ - pakyow-core/lib/views/errors/500.html
101
78
  homepage: http://pakyow.com
102
- licenses: []
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
103
82
  post_install_message:
104
83
  rdoc_options: []
105
84
  require_paths:
106
85
  - pakyow-core/lib
107
86
  required_ruby_version: !ruby/object:Gem::Requirement
108
- none: false
109
87
  requirements:
110
- - - ! '>='
88
+ - - '>='
111
89
  - !ruby/object:Gem::Version
112
- version: 1.8.7
90
+ version: 1.9.3
113
91
  required_rubygems_version: !ruby/object:Gem::Requirement
114
- none: false
115
92
  requirements:
116
- - - ! '>'
93
+ - - '>'
117
94
  - !ruby/object:Gem::Version
118
95
  version: 1.3.1
119
96
  requirements: []
120
97
  rubyforge_project: pakyow-core
121
- rubygems_version: 1.8.23
98
+ rubygems_version: 2.0.0
122
99
  signing_key:
123
- specification_version: 3
124
- summary: pakyow-core
100
+ specification_version: 4
101
+ summary: Core functionality for Pakyow applications.
125
102
  test_files: []
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- CORE_PATH = File.expand_path('../../lib', __FILE__)
4
-
5
- case ARGV.first
6
- when 'new'
7
- ARGV.shift
8
- require 'generators/pakyow/app/app_generator'
9
- Pakyow::Generators::AppGenerator.start
10
- when 'server', 's'
11
- ARGV.shift
12
- require File.join(CORE_PATH, 'commands/server')
13
- when 'console', 'c'
14
- ARGV.shift
15
- require File.join(CORE_PATH, 'commands/console')
16
- when '--help', '-h', nil
17
- puts File.open(File.join(CORE_PATH, 'commands/USAGE')).read
18
- end
@@ -1,9 +0,0 @@
1
- Usage:
2
- pakyow command
3
-
4
- There are three commands:
5
- new Create a new Pakyow application
6
- server Start the application server
7
- console Start the application console
8
-
9
- Run a command with -h for more information.
@@ -1,12 +0,0 @@
1
- Usage:
2
- pakyow console [environment]
3
-
4
- Description:
5
- The 'pakyow console' command stages the application and starts an interactive
6
- session. If environment is not specified, the default_environment defined by
7
- your application will be used.
8
-
9
- Example:
10
- pakyow console development
11
-
12
- This starts the console with the 'development' configuration.
@@ -1,11 +0,0 @@
1
- Usage:
2
- pakyow new application
3
-
4
- Description:
5
- The 'pakyow new' command creates a new Pakyow application at the path
6
- specified.
7
-
8
- Example:
9
- pakyow new path/to/application
10
-
11
- This generates a new Pakyow application in path/to/application.
@@ -1,12 +0,0 @@
1
- Usage:
2
- pakyow server [environment]
3
-
4
- Description:
5
- The 'pakyow server' command starts the application server. If environment
6
- is not specified, the default_environment defined by your application
7
- will be used.
8
-
9
- Example:
10
- pakyow server development
11
-
12
- This starts the application server with the 'development' configuration.
@@ -1,18 +0,0 @@
1
- if ARGV.first == '--help' || ARGV.first == '-h'
2
- puts File.open(File.join(CORE_PATH, 'commands/USAGE-CONSOLE')).read
3
- else
4
- $:.unshift(Dir.pwd)
5
-
6
- require 'app'
7
- PakyowApplication::Application.stage(ARGV.first)
8
-
9
- def reload
10
- puts "Reloading..."
11
- Pakyow.app.reload
12
- end
13
-
14
- require 'irb'
15
- ARGV.clear
16
- IRB.start
17
- end
18
-
@@ -1,8 +0,0 @@
1
- if ARGV.first == '--help' || ARGV.first == '-h'
2
- puts File.open(File.join(CORE_PATH, 'commands/USAGE-SERVER')).read
3
- else
4
- $:.unshift(Dir.pwd)
5
-
6
- require 'app'
7
- PakyowApplication::Application.run(ARGV.first)
8
- end