thingfish 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00e3affe84cd08994e0a22ce39677827267f153e
4
- data.tar.gz: c6e302caa8ddc1be3ba8e2aa882714b225318d47
3
+ metadata.gz: 9a0df5e14498c987d01ba054873bcfad3e98c364
4
+ data.tar.gz: b63b33e9f59288acc5d9759a082d13ccfde6b8b0
5
5
  SHA512:
6
- metadata.gz: 9dd4df271c0085c9afd2f989ae30a6083401691dc4bc46cefb7b316503ded390f0dba9642884cb87c5e399f50fc301861e67eeb78b2a739887424e9e3cc5a180
7
- data.tar.gz: e836ef365082a6bad19a32c94f9111e7a87b962210a62c0a72db3aa512c438a3300f0bc8e32e7264b06347edda8722ef7d1e404df853bb6c92bafddb8e704e14
6
+ metadata.gz: 217f66c0d72e2f644516b6e2b35967a61f519c7c848849d6b3a721721628415e50c95ef9630aba0dde4a9afbd789a52aa16ba4252387f18b872f7246e080b373
7
+ data.tar.gz: a68b9ffaa68472217321e300962486cb8ad72cd0658f995e7158e5e6c36d3622f700fadc226d15b1152c7160174efe8ec657e5ba9ea2cd045bfa7354b562c983
Binary file
data.tar.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,9 +1,57 @@
1
+ 2017-09-13 Mahlon E. Smith <mahlon@laika.com>
2
+
3
+ * .hgtags:
4
+ Added tag v0.7.0 for changeset c8bfee4b3f80
5
+ [60864d37774f] [tip]
6
+
7
+ 2017-09-13 Mahlon E. Smith <mahlon@martini.nu>
8
+
9
+ * lib/thingfish.rb:
10
+ Bunp version.
11
+ [c8bfee4b3f80] [v0.7.0]
12
+
13
+ 2017-09-13 Mahlon E. Smith <mahlon@laika.com>
14
+
15
+ * lib/thingfish/handler.rb:
16
+ Explicitly set the HTTP status when returning resources.
17
+ [15b877ef492e]
18
+
19
+ * lib/thingfish/handler.rb, spec/thingfish/handler_spec.rb:
20
+ Add Last-Modified/If-None-Match support.
21
+
22
+ This allows caching to still take place even if not using the
23
+ checksum plugin.
24
+ [bf37a1852e61]
25
+
26
+ 2017-06-28 Michael Granger <ged@FaerieMUD.org>
27
+
28
+ * .ruby-version, README.rdoc, Rakefile, thingfish.gemspec:
29
+ Update build files, bump Strelka dependency
30
+ [6665c33cf990]
31
+
32
+ 2017-05-31 Mahlon E. Smith <mahlon@martini.nu>
33
+
34
+ * lib/thingfish/handler.rb, spec/thingfish/handler_spec.rb:
35
+ Move the configure() method to help support deferred configuration.
36
+ Fix tests for CZTop.
37
+ [30905f58ff2e]
38
+
39
+ 2017-01-16 Mahlon E. Smith <mahlon@laika.com>
40
+
41
+ * .hgtags:
42
+ Added tag v0.6.0 for changeset dfcb639cbbe7
43
+ [fd014c3361f2]
44
+
45
+ * .hgsigs:
46
+ Added signature for changeset 2bc8257c7537
47
+ [dfcb639cbbe7] [v0.6.0]
48
+
1
49
  2017-01-16 Mahlon E. Smith <mahlon@martini.nu>
2
50
 
3
51
  * .gems, .ruby-gemset, .ruby-version, .rvmrc, History.rdoc, Rakefile,
4
52
  lib/thingfish.rb:
5
53
  Bump Configurability dependency, migrate away from .rvmrc.
6
- [2bc8257c7537] [tip]
54
+ [2bc8257c7537]
7
55
 
8
56
  2016-11-14 Michael Granger <ged@FaerieMUD.org>
9
57
 
@@ -1,6 +1,6 @@
1
1
  = Thingfish
2
2
 
3
- * https://thing.fish/
3
+ * https://thing.fish
4
4
 
5
5
  == Description
6
6
 
data/Rakefile CHANGED
@@ -26,7 +26,7 @@ hoespec = Hoe.spec 'thingfish' do
26
26
  self.developer 'Mahlon E. Smith', 'mahlon@martini.nu'
27
27
  self.license "BSD"
28
28
 
29
- self.dependency 'strelka', '~> 0.13'
29
+ self.dependency 'strelka', '~> 0.14'
30
30
 
31
31
  self.dependency 'hoe-deveiate', '~> 0.3', :development
32
32
  self.dependency 'simplecov', '~> 0.7', :development
@@ -36,7 +36,7 @@ hoespec = Hoe.spec 'thingfish' do
36
36
  self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
37
37
  spec.check_history_on_release = true if spec.respond_to?( :check_history_on_release= )
38
38
 
39
- self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
39
+ self.rdoc_locations << "deveiate:/usr/local/thingfish/api"
40
40
  end
41
41
 
42
42
  ENV['VERSION'] ||= hoespec.spec.version.to_s
@@ -67,7 +67,7 @@ if File.directory?( '.hg' )
67
67
  rdoc.main = "README.rdoc"
68
68
  rdoc.markup = 'markdown'
69
69
  rdoc.rdoc_files.include( "*.rdoc", "ChangeLog", "lib/**/*.rb" )
70
- rdoc.generator = :fivefish
70
+ rdoc.generator = :sixfish
71
71
  rdoc.title = 'Thingfish'
72
72
  rdoc.rdoc_dir = 'doc'
73
73
  end
@@ -79,8 +79,8 @@ task GEMSPEC do |task|
79
79
  spec = $hoespec.spec
80
80
  spec.files.delete( '.gemtest' )
81
81
  spec.signing_key = nil
82
- spec.cert_chain = ['certs/ged.pem']
83
- spec.version = "#{spec.version}.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
82
+ spec.cert_chain = Dir.glob( 'certs/*.pem' )
83
+ spec.version = "#{spec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
84
84
  File.open( task.name, 'w' ) do |fh|
85
85
  fh.write( spec.to_ruby )
86
86
  end
@@ -12,10 +12,10 @@ module Thingfish
12
12
 
13
13
 
14
14
  # Package version
15
- VERSION = '0.6.0'
15
+ VERSION = '0.7.0'
16
16
 
17
17
  # Version control revision
18
- REVISION = %q$Revision: 2bc8257c7537 $
18
+ REVISION = %q$Revision: c8bfee4b3f80 $
19
19
 
20
20
 
21
21
  ### Get the library version. If +include_buildnum+ is true, the version string will
@@ -74,22 +74,6 @@ class Thingfish::Handler < Strelka::App
74
74
  singleton_attr_accessor :processors
75
75
 
76
76
 
77
- ### Configurability API -- install the configuration
78
- def self::configure( config=nil )
79
- config = self.defaults.merge( config || {} )
80
-
81
- self.datastore = config[:datastore]
82
- self.metastore = config[:metastore]
83
- self.event_socket_uri = config[:event_socket_uri]
84
-
85
- self.processors = self.load_processors( config[:processors] )
86
- self.processors.each do |processor|
87
- self.filter( :request, &processor.method(:process_request) )
88
- self.filter( :response, &processor.method(:process_response) )
89
- end
90
- end
91
-
92
-
93
77
  ### Load the Thingfish::Processors in the given +processor_list+ and return an instance
94
78
  ### of each one.
95
79
  def self::load_processors( processor_list )
@@ -110,6 +94,24 @@ class Thingfish::Handler < Strelka::App
110
94
  end
111
95
 
112
96
 
97
+ ### Configurability API -- install the configuration
98
+ def self::configure( config=nil )
99
+ config = self.defaults.merge( config || {} )
100
+
101
+ self.datastore = config[:datastore]
102
+ self.metastore = config[:metastore]
103
+ self.event_socket_uri = config[:event_socket_uri]
104
+
105
+ self.plugin( :filters ) # pre-load the filters plugin for deferred config
106
+
107
+ self.processors = self.load_processors( config[:processors] )
108
+ self.processors.each do |processor|
109
+ self.filter( :request, &processor.method(:process_request) )
110
+ self.filter( :response, &processor.method(:process_response) )
111
+ end
112
+ end
113
+
114
+
113
115
  ### Set up the metastore, datastore, and event socket when the handler is
114
116
  ### created.
115
117
  def initialize( * ) # :notnew:
@@ -145,8 +147,8 @@ class Thingfish::Handler < Strelka::App
145
147
  ### Set up the event socket.
146
148
  def setup_event_socket
147
149
  if self.class.event_socket_uri && ! @event_socket
148
- @event_socket = Mongrel2.zmq_context.socket( :PUB )
149
- @event_socket.linger = 0
150
+ @event_socket = CZTop::Socket::PUB.new
151
+ @event_socket.options.linger = 0
150
152
  @event_socket.bind( self.class.event_socket_uri )
151
153
  end
152
154
  end
@@ -331,11 +333,12 @@ class Thingfish::Handler < Strelka::App
331
333
  metadata = self.metastore.fetch( uuid )
332
334
 
333
335
  res = req.response
334
- self.add_etag_headers( req, metadata )
336
+ self.add_cache_headers( req, metadata )
335
337
  self.add_content_disposition( res, metadata )
336
338
 
337
339
  res.body = object
338
340
  res.content_type = metadata['format']
341
+ res.status = HTTP::OK
339
342
 
340
343
  return res
341
344
  end
@@ -354,7 +357,7 @@ class Thingfish::Handler < Strelka::App
354
357
  res = req.response
355
358
  res.content_type = metadata['format']
356
359
 
357
- self.add_etag_headers( req, metadata )
360
+ self.add_cache_headers( req, metadata )
358
361
  self.add_content_disposition( res, metadata )
359
362
 
360
363
  if object.respond_to?( :path )
@@ -367,6 +370,7 @@ class Thingfish::Handler < Strelka::App
367
370
  res.body = object
368
371
  end
369
372
 
373
+ res.status = HTTP::OK
370
374
  return res
371
375
  end
372
376
 
@@ -714,9 +718,9 @@ class Thingfish::Handler < Strelka::App
714
718
  ### Return a Hash of default metadata extracted from the given +request+.
715
719
  def extract_default_metadata( request )
716
720
  return self.extract_connection_metadata( request ).merge(
717
- 'extent' => request.headers.content_length,
718
- 'format' => request.content_type,
719
- 'created' => Time.now.getgm
721
+ 'extent' => request.headers.content_length,
722
+ 'format' => request.content_type,
723
+ 'created' => Time.now.getgm
720
724
  )
721
725
  end
722
726
 
@@ -781,24 +785,34 @@ class Thingfish::Handler < Strelka::App
781
785
  def send_event( type, msg )
782
786
  esock = self.event_socket or return
783
787
  self.log.debug "Publishing %p event: %p" % [ type, msg ]
784
- esock.sendm( type.to_s )
785
- esock.send( Yajl.dump(msg) )
788
+ esock << CZTop::Message.new([ type.to_s, Yajl.dump(msg) ])
786
789
  end
787
790
 
788
791
 
789
- ### Add browser cache headers for resources. This requires the sha256
792
+ ### Add browser cache headers for resources.
793
+ ### Last-Modified is always added. ETag support requires the sha256
790
794
  ### processor plugin to be enabled for stored resources.
791
- def add_etag_headers( request, metadata )
795
+ ###
796
+ def add_cache_headers( request, metadata )
792
797
  response = request.response
793
- checksum = metadata[ 'checksum' ]
794
- return unless checksum
795
798
 
796
- if (( match = request.headers[ :if_none_match ] ))
797
- match = match.gsub( '"', '' ).split( /,\s*/ )
798
- finish_with( HTTP::NOT_MODIFIED ) if match.include?( checksum )
799
+ # ETag takes precedence if available.
800
+ #
801
+ if (( checksum = metadata['checksum'] ))
802
+ if (( match = request.headers[ :if_none_match ] ))
803
+ match = match.gsub( '"', '' ).split( /,\s*/ )
804
+ finish_with( HTTP::NOT_MODIFIED ) if match.include?( checksum )
805
+ end
806
+ response.headers[ :etag ] = checksum
807
+ end
808
+
809
+ return unless metadata[ 'created' ]
810
+
811
+ if (( modified = request.headers[ :if_modified_since ] ))
812
+ finish_with( HTTP::NOT_MODIFIED ) if Time.parse( modified ) <= metadata['created'].round
799
813
  end
814
+ response.headers[ :last_modified ] = metadata[ 'created' ].httpdate
800
815
 
801
- response.headers[ :etag ] = checksum
802
816
  return
803
817
  end
804
818
 
@@ -9,7 +9,7 @@ require 'thingfish/processor'
9
9
 
10
10
  describe Thingfish::Handler do
11
11
 
12
- EVENT_SOCKET_URI = 'tcp://127.0.0.1:0'
12
+ EVENT_SOCKET_URI = 'tcp://127.0.0.1:*'
13
13
 
14
14
  before( :all ) do
15
15
  Thingfish::Handler.configure( :event_socket_uri => EVENT_SOCKET_URI )
@@ -359,7 +359,20 @@ describe Thingfish::Handler do
359
359
  end
360
360
 
361
361
 
362
- it "adds browser cache headers to resources with a checksum attribute" do
362
+ it "adds date cache headers to resources" do
363
+ created = Time.now
364
+ uuid = @handler.datastore.save( @png_io )
365
+ @handler.metastore.save( uuid, 'format' => 'image/png', 'created' => created )
366
+
367
+ req = factory.get( "/#{uuid}" )
368
+ result = @handler.handle( req )
369
+
370
+ expect( result.status_line ).to match( /200 ok/i )
371
+ expect( result.headers.last_modified ).to eq( created.httpdate )
372
+ end
373
+
374
+
375
+ it "adds content cache headers to resources with a checksum attribute" do
363
376
  uuid = @handler.datastore.save( @png_io )
364
377
  @handler.metastore.save( uuid, 'format' => 'image/png', 'checksum' => '123456' )
365
378
 
@@ -385,7 +398,21 @@ describe Thingfish::Handler do
385
398
  end
386
399
 
387
400
 
388
- it "returns a 304 not modified for unchanged client cache requests" do
401
+ it "returns a 304 not modified for unchanged date cache requests" do
402
+ created = Time.now
403
+ uuid = @handler.datastore.save( @png_io )
404
+ @handler.metastore.save( uuid, 'format' => 'image/png', 'created' => created )
405
+
406
+ req = factory.get( "/#{uuid}" )
407
+ req.headers[ :if_modified_since ] = ( Time.now - 300 ).httpdate
408
+ result = @handler.handle( req )
409
+
410
+ expect( result.status_line ).to match( /304 not modified/i )
411
+ expect( result.body.read ).to be_empty
412
+ end
413
+
414
+
415
+ it "returns a 304 not modified for unchanged content cache requests" do
389
416
  uuid = @handler.datastore.save( @png_io )
390
417
  @handler.metastore.save( uuid, 'format' => 'image/png', 'checksum' => '123456' )
391
418
 
@@ -398,7 +425,6 @@ describe Thingfish::Handler do
398
425
  end
399
426
 
400
427
 
401
-
402
428
  it "can remove everything associated with an object id" do
403
429
  uuid = @handler.datastore.save( @png_io )
404
430
  @handler.metastore.save( uuid, {
@@ -865,10 +891,10 @@ describe Thingfish::Handler do
865
891
  before( :each ) do
866
892
  @handler.setup_event_socket
867
893
 
868
- @subsock = Mongrel2.zmq_context.socket( :SUB )
869
- @subsock.linger = 0
894
+ @subsock = CZTop::Socket::SUB.new
895
+ @subsock.options.linger = 0
870
896
  @subsock.subscribe( '' )
871
- @subsock.connect( @handler.event_socket.endpoint )
897
+ @subsock.connect( @handler.event_socket.last_endpoint )
872
898
  end
873
899
 
874
900
  after( :each ) do
@@ -878,20 +904,20 @@ describe Thingfish::Handler do
878
904
  it "publishes notifications about uploaded assets to a PUBSUB socket" do
879
905
  req = factory.post( '/', TEST_TEXT_DATA, content_type: 'text/plain' )
880
906
  req.headers.content_length = TEST_TEXT_DATA.bytesize
907
+
908
+ poller = CZTop::Poller.new
909
+ poller.add_reader( @subsock )
910
+
881
911
  res = @handler.handle( req )
912
+ event = poller.wait( 500 )
882
913
 
883
- handles = ZMQ.select( [@subsock], nil, nil, 0 )
884
- expect( handles ).to be_an( Array )
885
- expect( handles[0].size ).to eq( 1 )
886
- expect( handles[0].first ).to be( @subsock )
914
+ expect( event ).to_not be_nil
887
915
 
888
- event = @subsock.recv
889
- expect( @subsock.rcvmore? ).to be_truthy
890
- expect( event ).to eq( 'created' )
916
+ message = event.socket.receive
917
+ expect( message.frames.count ).to be( 2 )
891
918
 
892
- resource = @subsock.recv
893
- expect( @subsock.rcvmore? ).to be_falsey
894
- expect( resource ).to match( /^\{"uuid":"#{UUID_PATTERN}"\}$/ )
919
+ expect( message.frames.first.to_s ).to eq( 'created' )
920
+ expect( message.frames.last.to_s ).to match( /^\{"uuid":"#{UUID_PATTERN}"\}$/ )
895
921
  end
896
922
  end
897
923
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thingfish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -31,7 +31,7 @@ cert_chain:
31
31
  DHE5pl144V24tqxZb65WTup/ov22SCXmpU8/wTeZVL3rePGRfwTJNpm+6iYszl7A
32
32
  SixmX0X3SOeYg4FRkblUIA==
33
33
  -----END CERTIFICATE-----
34
- date: 2017-01-16 00:00:00.000000000 Z
34
+ date: 2017-09-13 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: strelka
@@ -39,14 +39,14 @@ dependencies:
39
39
  requirements:
40
40
  - - "~>"
41
41
  - !ruby/object:Gem::Version
42
- version: '0.13'
42
+ version: '0.14'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - "~>"
48
48
  - !ruby/object:Gem::Version
49
- version: '0.13'
49
+ version: '0.14'
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: hoe-mercurial
52
52
  requirement: !ruby/object:Gem::Requirement
@@ -67,14 +67,14 @@ dependencies:
67
67
  requirements:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: '0.8'
70
+ version: '0.9'
71
71
  type: :development
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  requirements:
75
75
  - - "~>"
76
76
  - !ruby/object:Gem::Version
77
- version: '0.8'
77
+ version: '0.9'
78
78
  - !ruby/object:Gem::Dependency
79
79
  name: hoe-highline
80
80
  requirement: !ruby/object:Gem::Requirement
@@ -123,14 +123,14 @@ dependencies:
123
123
  requirements:
124
124
  - - "~>"
125
125
  - !ruby/object:Gem::Version
126
- version: '3.15'
126
+ version: '3.16'
127
127
  type: :development
128
128
  prerelease: false
129
129
  version_requirements: !ruby/object:Gem::Requirement
130
130
  requirements:
131
131
  - - "~>"
132
132
  - !ruby/object:Gem::Version
133
- version: '3.15'
133
+ version: '3.16'
134
134
  description: |-
135
135
  Thingfish is a extensible, web-based digital asset manager. It can be used to
136
136
  store chunks of data on the network in an application-independent way, link the
@@ -188,7 +188,7 @@ files:
188
188
  - spec/thingfish/processor/sha256_spec.rb
189
189
  - spec/thingfish/processor_spec.rb
190
190
  - spec/thingfish_spec.rb
191
- homepage: https://thing.fish/
191
+ homepage: https://thing.fish
192
192
  licenses:
193
193
  - BSD-3-Clause
194
194
  - BSD
@@ -211,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
211
211
  version: '0'
212
212
  requirements: []
213
213
  rubyforge_project:
214
- rubygems_version: 2.5.1
214
+ rubygems_version: 2.6.12
215
215
  signing_key:
216
216
  specification_version: 4
217
217
  summary: Thingfish is a extensible, web-based digital asset manager
metadata.gz.sig CHANGED
Binary file