knod 0.7.0 → 0.8.0

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: 8446a5531fc6d08eb78e71e980168a931d1ac919
4
- data.tar.gz: d52ad8908dc15d28be4be47c0730ab173c701209
3
+ metadata.gz: 24db330e2ed1cad1a1765169a47239723f4387da
4
+ data.tar.gz: c744a80528dfeb1dc3e9597299239362a7782aaa
5
5
  SHA512:
6
- metadata.gz: 9b9a3ef52a2dab0171621c4ee32f19b1f6d1e3e0dc46e04ff037b8e7d0274059ccc1801e6b74f49ff4be9d9b30e00a1e52167812117162083b2f1f08606ea432
7
- data.tar.gz: fc1a4437cf870a38032161a4b9159d43e8fbe0e35727cfd826d0b3aafebad05f838918d98ad96515794777f0eed3936f978ebe2b150bf603239e6293c12fd87f
6
+ metadata.gz: a5b9650afbf606e35421ca86390e43812db7fe922e74fae0f8a93d55e9aa8f5624c3839260566ed767c779ba3ed0ae8d0032c6207687b5e4e28814a6aa07ba5f
7
+ data.tar.gz: f4e6215b5e0d7252427c829e1049140ec9158ec762f7e89adbe1c0d1fc006c27efd71bcc62c9b140a0e2be98806e8f56e5d59582942ffc584db0f306f69ae8f8
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- knod (0.7.0)
4
+ knod (0.8.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -6,7 +6,7 @@ require 'knod/version'
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = 'knod'
8
8
  gem.version = Knod::VERSION
9
- gem.date = '2014-06-15'
9
+ gem.date = '2014-06-25'
10
10
  gem.authors = ['Ryan Moser']
11
11
  gem.email = 'ryanpmoser@gmail.com'
12
12
  gem.homepage = 'https://github.com/moserrya/knod'
@@ -16,7 +16,7 @@ module Knod
16
16
  end
17
17
 
18
18
  def concat_json(path)
19
- files = Dir.glob(join_path(path, "*"))
19
+ files = Dir.glob(join_path(path, "*")).sort
20
20
  data = files.map { |f| File.read(f) }
21
21
  json_data = '[' + data.join(',') + ']'
22
22
  end
@@ -102,7 +102,7 @@ module Knod
102
102
 
103
103
  def max_id_in_path(path)
104
104
  records = Dir.glob(path + '/*.json')
105
- records.map { |r| File.basename(r, '.json') }.map(&:to_i).max || 0
105
+ records.map { |r| File.basename(r, '.json').to_i }.max || 0
106
106
  end
107
107
 
108
108
  def merge_json(file, request_body)
@@ -132,6 +132,7 @@ module Knod
132
132
  header = "HTTP/1.1 #{status_code} #{STATUS_CODE_MAPPINGS.fetch(status_code)}\r\n"
133
133
  header << "Content-Type: application/json\r\n" unless message.empty?
134
134
  header << "Content-Length: #{message.size}\r\n"
135
+ header << "Access-Control-Allow-Origin: *\r\n"
135
136
  header << "Connection: close\r\n\r\n"
136
137
  end
137
138
 
@@ -144,6 +145,7 @@ module Knod
144
145
  "HTTP/1.1 200 OK\r\n" \
145
146
  "Content-Type: #{content_type(file)}\r\n" \
146
147
  "Content-Length: #{file.size}\r\n" \
148
+ "Access-Control-Allow-Origin: *\r\n" \
147
149
  "Connection: close\r\n\r\n"
148
150
  end
149
151
 
@@ -1,3 +1,3 @@
1
1
  module Knod
2
- VERSION = '0.7.0'
2
+ VERSION = '0.8.0'
3
3
  end
@@ -62,6 +62,11 @@ describe Knod, "a tiny http server" do
62
62
  response.code.must_equal '204'
63
63
  end
64
64
 
65
+ it 'responds with Cross-Origin Resource Sharing header' do
66
+ response = connection.get @path
67
+ response['Access-Control-Allow-Origin'].must_equal '*'
68
+ end
69
+
65
70
  describe 'contatenates files into a json array' do
66
71
  let(:path) {'index'}
67
72
  let(:data) { 3.times.map { |i| { id: i+1, state: 'squiddy' } } }
@@ -73,7 +78,12 @@ describe Knod, "a tiny http server" do
73
78
 
74
79
  it 'should concatenate file contents into an array' do
75
80
  response = connection.get path
76
- response.body.sort_by { |h| h[:id] }.must_equal data
81
+ response.body.must_equal data
82
+ end
83
+
84
+ it 'responds with Cross-Origin Resource Sharing header' do
85
+ response = connection.get path
86
+ response['Access-Control-Allow-Origin'].must_equal '*'
77
87
  end
78
88
 
79
89
  after do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knod
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Moser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-15 00:00:00.000000000 Z
11
+ date: 2014-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake