shot_mvc 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,13 +18,13 @@ class ViewController < Controller
18
18
  <div class="span12">
19
19
  <h1>#{view}</h1>
20
20
  <p>This view is simply a placeholder for something amazing! You can edit the view here:</p>
21
- <pre><code>application/views/#{view}.erb</code></pre>
21
+ <pre><code>app/views/#{view}.erb</code></pre>
22
22
  </div>
23
23
  </div>
24
24
  </div>
25
25
  eos
26
26
 
27
- File.write "application/views/#{view}.erb", contents
27
+ File.write "app/views/#{view}.erb", contents
28
28
 
29
29
  get('controller', 'Home').index
30
30
  end
@@ -8,7 +8,7 @@
8
8
  <p>Uh oh! It looks like you tried to render a view that doesn't exist yet.</p>
9
9
 
10
10
  <p>
11
- <a data-shot-click="GemRoot/application/controllers/view_controller.rb#create" data-shot-data="<%=data[:requested_view]%>" class="btn btn-primary btn-large">
11
+ <a data-shot-click="GemRoot/app/controllers/view_controller.rb#create" data-shot-data="<%=data[:requested_view]%>" class="btn btn-primary btn-large">
12
12
  Create View
13
13
  </a>
14
14
  </p>
@@ -38,4 +38,12 @@ class Controller
38
38
  def get(type, name)
39
39
  @app.get type, name
40
40
  end
41
+
42
+ # Instantiate a new Element, assigned to the specified query
43
+ #
44
+ # Note:: Sugary way of writing +get "element", "selector"+
45
+
46
+ def e(selector)
47
+ @app.get 'element', selector
48
+ end
41
49
  end
@@ -29,12 +29,12 @@ end
29
29
  eof
30
30
 
31
31
  template = ERB.new template
32
- File.write "application/controllers/#{controller_name.underscore}_controller.rb", template.result(binding)
32
+ File.write "app/controllers/#{controller_name.underscore}_controller.rb", template.result(binding)
33
33
  end
34
34
 
35
35
  def delete_controller(controller_name)
36
- if File.exists? "application/controllers/#{controller_name.underscore}_controller.rb"
37
- File.unlink "application/controllers/#{controller_name.underscore}_controller.rb"
36
+ if File.exists? "app/controllers/#{controller_name.underscore}_controller.rb"
37
+ File.unlink "app/controllers/#{controller_name.underscore}_controller.rb"
38
38
  else
39
39
  raise ControllerNotFoundException.new "Could not find controller named #{controller_name}"
40
40
  end
@@ -1,7 +1,7 @@
1
1
  # ControllerLoader
2
2
  #
3
- # Adds controller loading functionality to a Shot application. Will attempt to load controllers in the
4
- # 'application/controllers' folder in the local working directory. If the file is not found, or an appropriate
3
+ # Adds controller loading functionality to a Shot app. Will attempt to load controllers in the
4
+ # 'app/controllers' folder in the local working directory. If the file is not found, or an appropriate
5
5
  # filesystem is not set up, a ControllerLoadException will be raised.
6
6
  #
7
7
  # Shot Framework - Copyright (c) Jesse Aaron Dunlap <me@jessedunlap.me>
@@ -48,7 +48,7 @@ class ControllerLoader < Loader
48
48
  controller_instance
49
49
 
50
50
  else
51
- load "application/controllers/#{controller.underscore}_controller.rb"
51
+ load "app/controllers/#{controller.underscore}_controller.rb"
52
52
 
53
53
  controller_class_name = get_controller_class controller
54
54
  controller_object = get_controller_object controller_class_name
@@ -59,14 +59,14 @@ class ControllerLoader < Loader
59
59
  controller_instance
60
60
  end
61
61
  else
62
- raise ControllerLoadException.new "Error loading controller #{controller}. Please verify that it exists at application/controllers/#{controller.underscore}.rb"
62
+ raise ControllerLoadException.new "Error loading controller #{controller}. Please verify that it exists at app/controllers/#{controller.underscore}.rb"
63
63
  end
64
64
  end
65
65
 
66
66
  private
67
67
 
68
68
  def controller_exists?(controller)
69
- File.exists? controller or File.exists? "application/controllers/#{controller.underscore}_controller.rb"
69
+ File.exists? controller or File.exists? "app/controllers/#{controller.underscore}_controller.rb"
70
70
  end
71
71
 
72
72
  def direct_path_to_controller?(controller)
@@ -0,0 +1,7 @@
1
+ class ModelRouter
2
+ def initialize(client)
3
+ if Dir.exists? "app/models"
4
+ Dir.new("app/models").each do |model_file| require_relative "./app/models/#{model_file}" end
5
+ end
6
+ end
7
+ end
@@ -22,7 +22,7 @@ class ApplicationInstance
22
22
  end
23
23
 
24
24
  def session_save
25
- File.write "application/sessions/#{@config[:session_key]}.json", @config[:session].to_json
25
+ File.write "app/sessions/#{@config[:session_key]}.json", @config[:session].to_json
26
26
  end
27
27
  end
28
28
 
@@ -31,11 +31,11 @@ class SessionRouter < Router
31
31
  super(client)
32
32
 
33
33
  client.on 'session_key' do |key|
34
- create_session_folder unless Dir.exists? 'application/sessions'
35
- create_session_file key unless File.exists? "application/sessions/#{key}.json"
34
+ create_session_folder unless Dir.exists? 'app/sessions'
35
+ create_session_file key unless File.exists? "app/sessions/#{key}.json"
36
36
 
37
37
  client.config[:session_key] = key
38
- client.config[:session] = JSON.parse File.read "application/sessions/#{key}.json"
38
+ client.config[:session] = JSON.parse File.read "app/sessions/#{key}.json"
39
39
 
40
40
  client.emit 'session_ready'
41
41
  end
@@ -44,11 +44,11 @@ class SessionRouter < Router
44
44
  session_key = SecureRandom.uuid
45
45
  client.emit 'assign_session_key', :key => session_key, :session_hash => client.config['server']['Security']['SessionHash']
46
46
 
47
- create_session_folder unless Dir.exists? 'application/sessions'
48
- create_session_file session_key unless File.exists? "application/sessions/#{session_key}.json"
47
+ create_session_folder unless Dir.exists? 'app/sessions'
48
+ create_session_file session_key unless File.exists? "app/sessions/#{session_key}.json"
49
49
 
50
50
  client.config[:session_key] = session_key
51
- client.config[:session] = JSON.parse File.read "application/sessions/#{session_key}.json"
51
+ client.config[:session] = JSON.parse File.read "app/sessions/#{session_key}.json"
52
52
 
53
53
  client.emit 'session_ready'
54
54
  end
@@ -59,10 +59,10 @@ class SessionRouter < Router
59
59
  private
60
60
 
61
61
  def create_session_folder
62
- Dir.mkdir 'application/sessions'
62
+ Dir.mkdir 'app/sessions'
63
63
  end
64
64
 
65
65
  def create_session_file(key)
66
- File.write "application/sessions/#{key}.json", '{}'
66
+ File.write "app/sessions/#{key}.json", '{}'
67
67
  end
68
68
  end
@@ -25,19 +25,19 @@ class TemplateLoader < Loader
25
25
  if full_path? name
26
26
  Template.new name
27
27
  else
28
- Template.new "./application/views/#{name}.erb"
28
+ Template.new "./app/views/#{name}.erb"
29
29
  end
30
30
  else
31
31
  if @client.config['server']['Security']['VisualErrors'] then
32
32
  begin
33
- raise TemplateLoadException.new "Could not load #{name}. Verify it exists at application/views/#{name}.erb"
33
+ raise TemplateLoadException.new "Could not load #{name}. Verify it exists at app/views/#{name}.erb"
34
34
  rescue Exception => ex
35
- template = Template.new "#{gem_root}/application/views/view_not_found.erb"
35
+ template = Template.new "#{gem_root}/app/views/view_not_found.erb"
36
36
  template.data = { :requested_view => name, :exception => ex }
37
37
  return template
38
38
  end
39
39
  else
40
- raise TemplateLoadException.new "Could not load #{name}. Verify it exists at application/views/#{name}.erb"
40
+ raise TemplateLoadException.new "Could not load #{name}. Verify it exists at app/views/#{name}.erb"
41
41
  end
42
42
  end
43
43
  end
@@ -53,6 +53,6 @@ class TemplateLoader < Loader
53
53
  end
54
54
 
55
55
  def template_exists?(view_name)
56
- File.exists? view_name or File.exists? "application/views/#{view_name}.erb"
56
+ File.exists? view_name or File.exists? "app/views/#{view_name}.erb"
57
57
  end
58
58
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shot_mvc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-30 00:00:00.000000000 Z
12
+ date: 2013-07-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shot
@@ -59,14 +59,15 @@ files:
59
59
  - lib/shot_mvc/controller_router.rb
60
60
  - lib/shot_mvc/element.rb
61
61
  - lib/shot_mvc/element_loader.rb
62
+ - lib/shot_mvc/model_router.rb
62
63
  - lib/shot_mvc/mvc_application.rb
63
64
  - lib/shot_mvc/session_router.rb
64
65
  - lib/shot_mvc/template.rb
65
66
  - lib/shot_mvc/template_loader.rb
66
67
  - lib/shot_mvc/template_load_exception.rb
67
68
  - lib/shot_mvc.rb
68
- - application/controllers/view_controller.rb
69
- - application/views/view_not_found.erb
69
+ - app/controllers/view_controller.rb
70
+ - app/views/view_not_found.erb
70
71
  - LICENSE.md
71
72
  - README.md
72
73
  homepage: http://github.com/shot/