sbsm 1.3.1 → 1.3.2

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: 9709fd562058b81d1408b0bc88142076bddad4f5
4
- data.tar.gz: 2976e9b526e9112093bd5aab2993abd5e385eec1
3
+ metadata.gz: 195e691643098516de7272f4711801f6bbfb012d
4
+ data.tar.gz: 6b57c1b95ac68366e1317d3ed0c4d1416d675b9f
5
5
  SHA512:
6
- metadata.gz: ddcbee6256f6fe7d1c19512b7c03c4291988968c0730e8cf53717f2b59f5a2b004cc9abfe21ea124030d7f36c1522f4f399d9936b265db2e7fb50566cda7d29c
7
- data.tar.gz: 1d5e713387d3a460bd6beccf6003836f438d7c65dbd2ea84ea4213e2c6b593ee3a1ea14b3825912e57c1ed4e97f03139f43e630562ecf7031ba3d51328d709d7
6
+ metadata.gz: aa5411f5e681b34778dd6b9e0f8af3c5b02b4ecb75e531e7d7c566bf12ebae590893d46cb229e8b2bca152f79f365cf577c5fcef05109b6149fbd797fd9ce47e
7
+ data.tar.gz: 7c5f4d61ec5221ab3ec5e99234977d62c71dc3b4d987bd8f97e4bb1dab798ce98d91e126d9db53d7764a3c3a45f84176e89b634f6825b9de4c1ceab28447ad87
@@ -1,3 +1,7 @@
1
+ === 1.3.2 / 15.11.2016
2
+ * Requires the drb_uri-parameter when creating an app
3
+ * Determine the MIME-Type of all returned files by their ending using gem mimemagic
4
+
1
5
  === 1.3.1 / 9.11.2016
2
6
  * Moved from mod_ruby to using webrick/rack interface
3
7
  * Incompatible changes to 1.3.0 are that all trans_handlers must be fixed, as the parameters are
@@ -28,6 +28,8 @@ require 'cgi/session'
28
28
  require 'sbsm/cgi'
29
29
  require 'cgi/drbsession'
30
30
  require 'sbsm/drbserver'
31
+ require 'mimemagic'
32
+
31
33
  module SBSM
32
34
  ###
33
35
  # App a base class for Webrick server
@@ -36,7 +38,7 @@ module SBSM
36
38
  PERSISTENT_COOKIE_NAME = "cookie-persistent-sbsm-1.3.1"
37
39
  SBSM.info "PERSISTENT_COOKIE_NAME #{PERSISTENT_COOKIE_NAME}"
38
40
 
39
- attr_reader :sbsm, :my_self, :validator
41
+ attr_reader :sbsm, :my_self, :trans_handler, :validator, :drb_uri
40
42
 
41
43
  OPTIONS = [ :app, :config_file, :trans_handler, :validator, :persistence_layer, :server_uri, :session, :unknown_user ]
42
44
  COOKIE_ID = 'sbsm-persistent-cookie-id'
@@ -58,11 +60,12 @@ module SBSM
58
60
  # Look at steinwies.ch
59
61
  # * https://github.com/zdavatz/steinwies.ch (simple, mostly static files, one form, no persistence layer)
60
62
  #
61
- def initialize(app:, validator:, trans_handler:, persistence_layer: nil)
63
+ def initialize(app:, validator:, trans_handler:, drb_uri:, persistence_layer: nil)
62
64
  @app = app
65
+ @drb_uri = drb_uri
63
66
  @trans_handler = trans_handler
64
67
  @validator = validator
65
- SBSM.info "initialize @app is now #{@app.class} validator #{validator} th #{trans_handler} "
68
+ SBSM.info "initialize @app is now #{@app.class} validator #{validator} th #{trans_handler} drb_uri #{drb_uri}"
66
69
  super(persistence_layer)
67
70
  end
68
71
 
@@ -74,13 +77,12 @@ module SBSM
74
77
  else
75
78
  session_id = rand((2**(0.size * 8 -2) -1)*10240000000000).to_s(16)
76
79
  end
80
+
77
81
  file_name = File.expand_path(File.join('doc', request.path))
78
82
  if File.file?(file_name)
79
- if /css/i.match(File.basename(file_name))
80
- response.set_header('Content-Type', 'text/css')
81
- else
82
- response.set_header('Content-Type', 'text/plain')
83
- end
83
+ mime_type = MimeMagic.by_extension(File.extname(file_name)).type
84
+ SBSM.info "file_name is #{file_name} checkin base #{File.basename(file_name)} MIME #{mime_type}"
85
+ response.set_header('Content-Type', mime_type)
84
86
  response.write(File.open(file_name, File::RDONLY){|file| file.read})
85
87
  return response
86
88
  end
@@ -25,8 +25,7 @@
25
25
  require 'chrono_logger'
26
26
  require 'sbsm/version'
27
27
  module SBSM
28
- @@logger = ChronoLogger.new("/tmp/sbsm_#{VERSION}.log.%Y%m%d")
29
- @@logger.level= :warn
28
+ @@logger = nil
30
29
  def self.logger=(logger)
31
30
  @@logger = logger
32
31
  end
@@ -103,7 +103,7 @@ module SBSM
103
103
  @variables = {}
104
104
  @mutex = Mutex.new
105
105
  @cgi = CGI.initialize_without_offline_prompt('html4')
106
- SBSM.debug "session initialized #{self} key #{key} app #{app.class} #{validator.class} with @cgi #{@cgi}"
106
+ SBSM.debug "session initialized #{self} key #{key} app #{app.class} #{@validator.class} th #{@trans_handler.class} with @cgi #{@cgi}"
107
107
  super(app)
108
108
  end
109
109
  def age(now=Time.now)
@@ -1,3 +1,3 @@
1
1
  module SBSM
2
- VERSION = '1.3.1'
2
+ VERSION = '1.3.2'
3
3
  end
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency 'rack'
24
24
  spec.add_dependency 'mail'
25
25
  spec.add_dependency 'hpricot'
26
+ spec.add_dependency 'mimemagic'
26
27
  spec.add_dependency 'chrono_logger'
27
28
 
28
29
  spec.add_development_dependency "bundler"
@@ -201,7 +201,7 @@ module Demo
201
201
  def initialize
202
202
  @drb_uri = SERVER_URI
203
203
  SBSM.info "SimpleSBSM.new"
204
- super(:app => self, :validator => Validator.new, :trans_handler => SBSM::TransHandler.instance)
204
+ super(:app => self, :validator => Validator.new, :trans_handler => SBSM::TransHandler.instance, :drb_uri => SERVER_URI)
205
205
  end
206
206
  end
207
207
  end
@@ -38,10 +38,11 @@ class MyTest < MiniTest::Unit::TestCase
38
38
  last_response.set_cookie SBSM::App::PERSISTENT_COOKIE_NAME, :value => "second_cookie"
39
39
  end
40
40
  assert last_response.ok?
41
- skip 'We must add here an input form or we cannot continue testing'
42
41
  assert_match FEEDBACK_HTML_CONTENT, last_response.body
43
42
  page = Nokogiri::HTML(last_response.body)
44
43
  x = page.css('div')
44
+ skip 'We must add here an input form or we cannot continue testing'
45
+
45
46
  assert page.css('input').find{|x| x.attributes['name'].value.eql?('state_id') }.attributes['value'].value
46
47
  state_id = page.css('input').find{|x| x.attributes['name'].value.eql?('state_id') }.attributes['value'].value.to_i
47
48
  assert state_id > 0
@@ -27,6 +27,7 @@
27
27
 
28
28
  require 'minitest/autorun'
29
29
  require 'fileutils'
30
+ require 'tempfile'
30
31
  require 'sbsm/logger'
31
32
  begin
32
33
  require 'pry'
@@ -34,43 +35,25 @@ rescue LoadError
34
35
  end
35
36
  class TestLogger < Minitest::Test
36
37
  def setup
37
- @saved_loger = SBSM.logger.clone
38
- @default_name = Time.now.strftime("/tmp/sbsm_#{SBSM::VERSION}.log.%Y%m%d")
39
- FileUtils.rm_f(@default_name)
38
+ @saved_loger = SBSM.logger ? SBSM.logger : nil
39
+ @temp_file = Tempfile.new('foo')
40
+ @temp_file.write("TestLogger TempFile")
41
+ @temp_file.flush
42
+ @default_name = @temp_file.path
40
43
  # we reload the logger class as it initializes the logger to a default value
41
44
  load 'sbsm/logger.rb'
42
- assert(File.exist?(@default_name))
43
45
  end
44
46
  def teardown
45
47
  SBSM.logger= @saved_loger
48
+ @temp_file.unlink
46
49
  end
47
50
 
48
- def test_default_levels
51
+ def test_default_levels_with_no_loggin
49
52
  saved_length = File.size(@default_name)
50
53
  SBSM.debug("debug #{__LINE__}")
51
54
  assert_equal(saved_length, File.size(@default_name))
52
55
  SBSM.info("info #{__LINE__}")
53
56
  assert_equal(saved_length, File.size(@default_name))
54
-
55
- SBSM.logger.level = :info
56
- SBSM.info("info #{__LINE__}")
57
- assert(saved_length < File.size(@default_name))
58
- saved_length = File.size(@default_name)
59
- SBSM.debug("debug #{__LINE__}")
60
- saved_length = File.size(@default_name)
61
-
62
- SBSM.logger.level = :debug
63
- SBSM.info("info #{__LINE__}")
64
- assert(saved_length < File.size(@default_name))
65
- saved_length = File.size(@default_name)
66
- SBSM.debug("debug #{__LINE__}")
67
- assert(saved_length < File.size(@default_name))
68
-
69
- saved_length = File.size(@default_name)
70
- SBSM.logger.level = :warn
71
- SBSM.info("info #{__LINE__}")
72
- SBSM.debug("debug #{__LINE__}")
73
- assert_equal(saved_length, File.size(@default_name))
74
57
  end
75
58
 
76
59
  def test_change_logger
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sbsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaomi Hatakeyama, Zeno R.R. Davatz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-09 00:00:00.000000000 Z
11
+ date: 2016-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mimemagic
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: chrono_logger
57
71
  requirement: !ruby/object:Gem::Requirement