knjrbfw 0.0.114 → 0.0.115

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
  SHA256:
3
- metadata.gz: 07fe0af5b28cf7ca05f3046d0790968c1296b06bd7cb62d5c66736824f08e7c8
4
- data.tar.gz: b2e0be27b9cc06223b8a87439b6d676d611f8220038a1b95fba83de9dda51688
3
+ metadata.gz: 6a5be1f9cec88387a3f22d11d086d874af8e86cea2f7e24596957b6ac8bede40
4
+ data.tar.gz: '01838b41b901833125a7e13ebbf294c0cc084327e6c878a9052d923ecf8af661'
5
5
  SHA512:
6
- metadata.gz: ad7ecf818020effd32d3d8bf4efd2c87f1f3672dee5fbaf23970cd497bd89f031bbb4bb2803e483b5c32b16daf33c863e2b5317448ab0d0c601e99c1c1ff3efb
7
- data.tar.gz: 16085e10575051841201d32398601aecd47c9134788b52e97555d0b5d9671f83d8660571dee7d11a1da45f4236a250d605e11dd596c52b2c83c51f21d036c196
6
+ metadata.gz: c07835d6c2365d107aeb2bf8ce0d57879069b1cadbd3c97035ef11cd2585de4787e5a82974a48a5901f1cb620f267d6e39bf6c22c042161a88db1aecbe5e4ff1
7
+ data.tar.gz: c8f5d705a4cf5e46906fa52aa4ce615755f12cb83eb4e5414e571756fd972fca61ce61ede18a6ec8c550ec747db5fa5df0b6ad58c6ed9e0e56cd94e4ca97f803
@@ -1,6 +1,6 @@
1
1
  begin
2
- require "RMagick"
2
+ require "rmagick"
3
3
  rescue LoadError
4
4
  require "rubygems"
5
- require "RMagick"
5
+ require "rmagick"
6
6
  end
@@ -5,7 +5,7 @@
5
5
  # events.connect(:test_event) do |*args|
6
6
  # print "Test-event called!\n"
7
7
  # end
8
- #
8
+ #
9
9
  # events.call(:test_event) #=> prints "Test-event called!\n"
10
10
  class Knj::Event_handler
11
11
  #Sets various used variables.
@@ -13,13 +13,13 @@ class Knj::Event_handler
13
13
  @args = args
14
14
  @events = {}
15
15
  end
16
-
16
+
17
17
  #Adds information about a new event.
18
18
  #===Examples
19
19
  # events.add_event(:name => :test_event)
20
20
  def add_event(event)
21
21
  raise "No name given." if !event[:name]
22
-
22
+
23
23
  @events[event[:name]] = [] if !@events.key?(event[:name])
24
24
  @events[event[:name]] = {
25
25
  :event => event,
@@ -27,7 +27,7 @@ class Knj::Event_handler
27
27
  :callbacks_count => 0
28
28
  }
29
29
  end
30
-
30
+
31
31
  #Adds multiple events.
32
32
  #===Examples
33
33
  # events.add_events(:test_event, :another_event, :a_third_event)
@@ -36,28 +36,28 @@ class Knj::Event_handler
36
36
  self.add_event(:name => event)
37
37
  end
38
38
  end
39
-
39
+
40
40
  #Connects the given block to a given event.
41
41
  #===Examples
42
42
  # events.connect(:test_event){ |*args| print "Test event!\n"}
43
43
  def connect(name, &block)
44
44
  raise "No such event: '#{name}'." if !@events.key?(name)
45
-
45
+
46
46
  event = @events[name]
47
-
47
+
48
48
  if event[:event].key?(:connections_max) and event[:callbacks].length >= event[:event][:connections_max].to_i
49
49
  raise "The event '#{name}' has reached its maximum connections of '#{event[:event][:connections_max]}'"
50
50
  end
51
-
51
+
52
52
  event[:callbacks_count] += 1
53
53
  count = event[:callbacks_count]
54
54
  event[:callbacks][count] = {
55
55
  :block => block
56
56
  }
57
-
57
+
58
58
  return count
59
59
  end
60
-
60
+
61
61
  #Returns true if the given event is connected.
62
62
  #===Examples
63
63
  # print "Test-event is connected!" if events.connected?(:test_event)
@@ -65,7 +65,7 @@ class Knj::Event_handler
65
65
  raise "No such event." if !@events.key?(name)
66
66
  return !@events[name][:callbacks].empty?
67
67
  end
68
-
68
+
69
69
  #Disconnects an event.
70
70
  #===Examples
71
71
  # connection_id = events.connect(:test_event){print "test event!}
@@ -77,7 +77,7 @@ class Knj::Event_handler
77
77
  @events[name][:callbacks][callback_id].clear
78
78
  @events[name][:callbacks].delete(callback_id)
79
79
  end
80
-
80
+
81
81
  #Returns how many blocks have been connected to an event.
82
82
  #===Examples
83
83
  # print "More than five connections to test-event!" if events.count_events(:test_event) > 5
@@ -85,18 +85,18 @@ class Knj::Event_handler
85
85
  raise "No such event." if !@events.key?(name)
86
86
  return @events[name][:callbacks].length
87
87
  end
88
-
88
+
89
89
  #Calls an added event.
90
90
  #===Examples
91
91
  # events.call(:test_event, {:data => 1})
92
- def call(name, *args)
92
+ def call(name, *args, **opts)
93
93
  raise "No such event: '#{name}'." if !@events.key?(name)
94
94
  event = @events[name]
95
95
  ret = nil
96
96
  event[:callbacks].clone.each do |callback_id, callback_hash|
97
- ret = callback_hash[:block].call(name, *args)
97
+ ret = callback_hash.fetch(:block).call(name, *args, **opts)
98
98
  end
99
-
99
+
100
100
  return ret
101
101
  end
102
102
  end
data/lib/knj/web.rb CHANGED
@@ -919,13 +919,3 @@ class Symbol
919
919
  return self.to_s.sql
920
920
  end
921
921
  end
922
-
923
- class Fixnum
924
- def sql
925
- return self.to_s.sql
926
- end
927
-
928
- def html
929
- return self.to_s.html
930
- end
931
- end
@@ -5,17 +5,17 @@
5
5
  rescue NameError
6
6
  appsrv = _kas
7
7
  end
8
-
8
+
9
9
  #Support for the PHP-version... Comes handy when converting PHP to Ruby...
10
10
  if !_get["path"]
11
11
  trans = {
12
12
  "picture" => "path"
13
13
  }
14
-
14
+
15
15
  if _get["edgesize"]
16
16
  _get["rounded_corners"] = (_get["edgesize"].to_f / 3.0).to_i
17
17
  end
18
-
18
+
19
19
  if _get["edgeborder"]
20
20
  if _get["edgeborder"].length == 6
21
21
  _get["border_color"] = "##{_get["edgeborder"]}"
@@ -23,104 +23,104 @@
23
23
  _get["border_color"] = _get["edbeborder"]
24
24
  end
25
25
  end
26
-
26
+
27
27
  if _get["edgeborder"]
28
28
  _get["border"] = 1
29
29
  end
30
-
30
+
31
31
  trans.each do |key, val|
32
32
  _get[val] = _get[key] if _get[key]
33
33
  end
34
34
  end
35
-
35
+
36
36
  #Base64-encoding of path.
37
37
  if _get["path64"]
38
38
  require "base64"
39
39
  _get["path"] = Base64.decode64(_get["path64"])
40
40
  end
41
-
41
+
42
42
  require "digest/md5"
43
43
  idstr = Digest::MD5.hexdigest("#{_get["path"]}_#{_get["smartsize"].to_i}_#{_get["width"].to_i}_#{_get["height"].to_i}_#{_get["maxwidth"].to_i}_#{_get["maxheight"].to_i}_#{_get["rounded_corners"].to_i}_#{_get["border"].to_i}_#{_get["border_color"]}")
44
-
44
+
45
45
  if !_get["path"] or !File.exists?(_get["path"])
46
46
  print "File does not exist: '#{_get["path"]}'.\n"
47
47
  exit
48
48
  end
49
-
49
+
50
50
  time_orig = File.mtime(_get["path"])
51
-
51
+
52
52
  tmp_write = false
53
53
  if Knj::CONFIG["webscripts_image"]
54
54
  tmp_path = "#{Knj::CONFIG["webscripts_image"]["tmp_path"]}/#{idstr}"
55
55
  else
56
56
  tmp_path = "#{Knj::Os.tmpdir}/knjrbfw_image_#{idstr}"
57
57
  end
58
-
58
+
59
59
  tmp_exists = File.exists?(tmp_path)
60
60
  tmp_write = true if !tmp_exists
61
-
61
+
62
62
  if !tmp_write and tmp_exists
63
63
  time_cache = File.mtime(tmp_path)
64
-
64
+
65
65
  if time_orig > time_cache
66
66
  tmp_write = true
67
67
  end
68
68
  end
69
-
69
+
70
70
  if _get["force"] == "true" or _get["force"] == "1"
71
71
  force = true
72
72
  else
73
73
  force = false
74
74
  end
75
-
75
+
76
76
  notchanged = false
77
-
77
+
78
78
  if _httpsession.handler.modified_since and time_cache and _httpsession.handler.modified_since.utc.to_s == time_cache.utc.to_s
79
79
  notchanged = true
80
80
  elsif _httpsession.handler.modified_since and _httpsession.handler.modified_since.utc.to_s == time_orig.utc.to_s
81
81
  notchanged = true
82
82
  end
83
-
83
+
84
84
  if notchanged and !force
85
85
  _httpsession.resp.status = 304
86
86
  exit
87
87
  end
88
-
88
+
89
89
  if tmp_write or force
90
90
  blob_cont = nil
91
-
91
+
92
92
  require "ruby_process"
93
93
  Ruby_process::Cproxy.run do |data|
94
94
  subproc = data[:subproc]
95
95
  subproc.static(:Object, :require, "rubygems")
96
96
  subproc.static(:Object, :require, "#{Knj.knjrbfw_path}/../knjrbfw.rb")
97
- subproc.static(:Object, :require, "RMagick")
97
+ subproc.static(:Object, :require, "rmagick")
98
98
  subproc.static(:Dir, :chdir, File.dirname(__FILE__))
99
-
99
+
100
100
  pic = subproc.static("Magick::Image", :read, _get["path"]).first
101
-
101
+
102
102
  if !pic
103
103
  print "Could not open image from '#{_get["path"]}'."
104
104
  exit
105
105
  end
106
-
106
+
107
107
  pic.format = "png"
108
-
108
+
109
109
  pic_columns = pic.columns.__rp_marshal
110
110
  pic_rows = pic.rows.__rp_marshal
111
-
111
+
112
112
  width = pic_columns
113
113
  height = pic_rows
114
-
114
+
115
115
  height = _get["height"].to_i if _get["height"]
116
116
  width = _get["width"].to_i if _get["width"]
117
-
117
+
118
118
  if _get["width"] && !_get["height"]
119
119
  height = (pic_rows.to_f / (pic_columns.to_f / width.to_f)).to_i
120
120
  elsif _get["height"] && !_get["width"]
121
121
  width = (pic_columns.to_f / (pic_rows.to_f / height.to_f)).to_i
122
122
  end
123
-
123
+
124
124
  if _get["smartsize"]
125
125
  if pic_columns > pic_rows
126
126
  width = _get["smartsize"].to_i
@@ -130,50 +130,50 @@
130
130
  width = (pic_columns.to_f / (pic_rows.to_f / height.to_f)).to_i
131
131
  end
132
132
  end
133
-
133
+
134
134
  if _get["maxwidth"]
135
135
  maxwidth = _get["maxwidth"].to_i
136
-
136
+
137
137
  if width > maxwidth
138
138
  height = (pic_rows.to_f / (pic_columns.to_f / maxwidth.to_f)).to_i
139
139
  width = maxwidth
140
140
  end
141
141
  end
142
-
142
+
143
143
  if _get["maxheight"]
144
144
  maxheight = _get["maxheight"].to_i
145
-
145
+
146
146
  if height > maxheight
147
147
  width = (pic_columns.to_f / (pic_rows.to_f / maxheight.to_f)).to_i
148
148
  height = maxheight
149
149
  end
150
150
  end
151
-
151
+
152
152
  if _get["width"] and _get["height"]
153
153
  width = _get["width"].to_i
154
154
  height = _get["height"].to_i
155
155
  end
156
-
156
+
157
157
  if height != pic_rows or width != pic_columns
158
158
  pic = pic.resize_to_fill(width.to_i, height.to_i)
159
159
  end
160
-
160
+
161
161
  if _get["rounded_corners"]
162
162
  args = {:img => pic, :radius => _get["rounded_corners"].to_i}
163
-
163
+
164
164
  if _get["border"] and _get["border_color"]
165
165
  args[:border] = _get["border"].to_i
166
166
  args[:border_color] = _get["border_color"]
167
167
  end
168
-
168
+
169
169
  #Call rounded_corners with the proxy-hash.
170
170
  subproc.static("Knj::Image", :rounded_corners, args)
171
171
  end
172
-
172
+
173
173
  pic.write(tmp_path) if tmp_write or force
174
174
  end
175
175
  end
176
-
176
+
177
177
  appsrv.header("Last-Modified", "#{time_orig.httpdate} GMT") if time_orig
178
178
  appsrv.header("Content-Type", "image/png")
179
179
  _httpsession.force_fileread(tmp_path)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knjrbfw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.114
4
+ version: 0.0.115
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Stöckel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-13 00:00:00.000000000 Z
11
+ date: 2022-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: wref
@@ -399,7 +399,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
399
399
  - !ruby/object:Gem::Version
400
400
  version: '0'
401
401
  requirements: []
402
- rubygems_version: 3.2.32
402
+ rubygems_version: 3.3.7
403
403
  signing_key:
404
404
  specification_version: 4
405
405
  summary: A framework with lots of stuff for Ruby.