wire-framework 0.1.5.1 → 0.1.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 92621fc1ec6c39754a7cdf8aa7ba7180f04f03e7
4
- data.tar.gz: 732f884d1680027efcaab41faf3bb7e650a7a1e2
3
+ metadata.gz: ec09ae1db5056dace28e0d574e44b42f96b54558
4
+ data.tar.gz: a47551aae8e917c6e48e417931fad6a7c11b5af7
5
5
  SHA512:
6
- metadata.gz: a9dcf07be1af9b4278057de3431c815959b025cc69d5bc2a66f6c3ef834d2ead9d210d619b0f854e2fad52c6fb898e6efeb6d1d5a0f578e2c30188e0aa167ddd
7
- data.tar.gz: 23f89e3fecdc342e8e3a86a6a478a9bab47d4c7936083af564fa13769ef0c920cd643ade852b0c65e9d23fbcd598d2baa0d1d0b4e035387dd75bba9a99f4ca5a
6
+ metadata.gz: 3547a7e673112f1adaf7264511afcc1c350bf00bbd981d31393858bcbbba240bc2b36db37146bf033c3bf7f4ab5331d3405ff35bc12e8a3d16ecfc5280f1a09e
7
+ data.tar.gz: a6b7b0cfa9a7e5a688a1a799b2c2d935d92cd49ec802c294ecb28c1013d908e8c4ff5447684bebf83e3da1240892d9c3eacc4a8b227b44faf08086dda98b8e3b
data/lib/app/db.rb CHANGED
@@ -109,7 +109,7 @@ module DB
109
109
  if model
110
110
  hash = '[ '
111
111
  model.each do |e|
112
- hash << (e.to_json)
112
+ hash << e.to_json
113
113
  hash << ','
114
114
  end
115
115
  hash = hash[0...-1]
data/lib/app/login.rb CHANGED
@@ -23,7 +23,7 @@ module Login
23
23
  # @param [Hash] context the context for this request
24
24
  # @return [Response] a redirect message returning to the previous page
25
25
  def self.invoke(actions, context)
26
- [307, { 'Location': context.referer.join('/') }, ['Login Redirect']]
26
+ [307, { 'Location' => context.referer.join('/') }, ['Login Redirect']]
27
27
  end
28
28
 
29
29
  end
@@ -25,26 +25,26 @@ module Render
25
25
  # @param [Tilt::Template] template a pre-loaded Tilt template to render
26
26
  # @param [String] content the content to render into the page
27
27
  # @return [Response] a Rack Response triplet, or status code
28
- def render_template(actions, context, template, content)
28
+ def self.render_template(actions, context, template, content)
29
29
  if template['file']
30
30
  hash = { actions: actions, context: context, content: content }
31
31
  template['sources'].each do |k, s|
32
- uri = "http://#{context.app[:remote_host]}"
32
+ uri = "http://#{context.config['remote'].split('/')[0]}"
33
33
  go_ahead = true
34
34
  if s.is_a? Hash
35
- uri += "/#{hash['uri']}"
35
+ uri += "/#{s['uri']}"
36
36
  case s['key']
37
37
  when 'user'
38
38
  go_ahead = (context.user and !context.user.empty?)
39
39
  uri += "/#{context.user}"
40
40
  when 'resource'
41
- go_ahead = (context.uri[2] and !context.uri[2].empty?)
42
- uri += "/#{context.uri[2]}"
41
+ go_ahead = (context.resource and !context.resource.empty?)
42
+ uri += "/#{context.resource}"
43
43
  else
44
44
  # do nothing
45
45
  end
46
46
  else
47
- uri += s
47
+ uri += "#{s}"
48
48
  end
49
49
  temp = []
50
50
  if go_ahead
@@ -52,15 +52,15 @@ module Render
52
52
  end
53
53
  if temp[0] == 200
54
54
  begin
55
- hash[k] = JSON.parse_clean(temp[2])
55
+ hash[k.to_sym] = JSON.parse_clean(temp[2])
56
56
  rescue
57
- hash[k] = temp[2]
57
+ hash[k.to_sym] = temp[2]
58
58
  end
59
59
  end
60
60
  end
61
61
  message = template[:path].render(self, hash)
62
62
  if template['use_layout']
63
- message = render_template(actions, context, $wire_apps[:global][:template], message)
63
+ message = render_template(actions, context, $wire_templates['layout'], message)
64
64
  end
65
65
  else
66
66
  message = 'Invalid Template'
@@ -73,11 +73,12 @@ module Render
73
73
  # @param [Hash] context the context for this request
74
74
  # @param [Symbol] specific the kind of read to perform
75
75
  # @return [Response] a Rack Response triplet, or status code
76
- def do_read(actions, context, specific)
76
+ def self.do_read(actions, context, specific)
77
77
  if context.resource
78
78
  result = context.forward(specific)
79
79
  #TODO: fix lookup
80
- template = context.app[:template]
80
+ name = context.config['template']
81
+ template = $wire_templates[name]
81
82
  if template
82
83
  result[1]['Content-Type'] = 'text/html'
83
84
  result[2] = render_template(actions, context, template, result[2])
@@ -97,7 +98,7 @@ module Render
97
98
  when :create, :update, :delete
98
99
  context.forward(context.action)
99
100
  when :read
100
- if context.uri[3]
101
+ if context.id
101
102
  do_read(actions, context, :read)
102
103
  else
103
104
  do_read(actions, context, :readAll)
@@ -35,9 +35,8 @@ module Render
35
35
  # @param [Hash] context the context for this request
36
36
  # @return [Response] a Rack Response triplet, or status code
37
37
  def self.do_read_all(context)
38
- resource = context.uri[2]
39
- template = context.app['styles'][resource]
40
- headers = {'Cache-Control': 'public,max-age=3600'}
38
+ template = context.config['styles'][context.resource]
39
+ headers = {'Cache-Control' => 'public,max-age=3600'}
41
40
  if template
42
41
  headers['Content-Type'] = 'text/css'
43
42
  [200, headers, [template]]
@@ -102,7 +102,7 @@ module Wire
102
102
  if @config
103
103
  @app = @uri[1]
104
104
  @resource = @uri[2]
105
- @id = @uri[3...@uri.length].join('/')
105
+ @id = @uri.length > 3 ? @uri[3...@uri.length].join('/') : nil
106
106
  else
107
107
  throw Exception.new("App: #{@uri[1]} is Undefined")
108
108
  end
@@ -137,9 +137,9 @@ module Wire
137
137
  headers = { referer: @referer.join('/'),
138
138
  remote_user: @user }
139
139
  verb = CONVERT[method]
140
- uri = "http://#{@app['remote']}/#{@uri[2]}"
140
+ uri = "http://#{@config['remote']}/#{@resource}"
141
141
  if [:update, :read, :delete].include?(method)
142
- uri += "/#{@uri[3...@uri.length].join('/')}"
142
+ uri += "/#{@id}"
143
143
  end
144
144
  uri += '?' + @query_string
145
145
  body = [:create, :update].include?(method) ? @body : nil
data/lib/wire.rb CHANGED
@@ -33,7 +33,7 @@ end
33
33
  # @author Bryan T. Meyers
34
34
  module Wire
35
35
  # Current version of the Wire Gem
36
- VERSION = '0.1.5.1'
36
+ VERSION = '0.1.5.2'
37
37
  end
38
38
 
39
39
  require_relative 'app'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wire-framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5.1
4
+ version: 0.1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan T. Meyers