knjrbfw 0.0.113 → 0.0.115

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
- SHA1:
3
- metadata.gz: 66637edb9c36f0d7ea2b74ef01525eac6504e558
4
- data.tar.gz: 0618414f52721e98c76b6a87d2f1bbd30dfb948a
2
+ SHA256:
3
+ metadata.gz: 6a5be1f9cec88387a3f22d11d086d874af8e86cea2f7e24596957b6ac8bede40
4
+ data.tar.gz: '01838b41b901833125a7e13ebbf294c0cc084327e6c878a9052d923ecf8af661'
5
5
  SHA512:
6
- metadata.gz: 90be6e975266b2179b6689ff362b150afbb4871ccb9eb175fc1a1bc8b2bf1c823ebc8e36389db3387697fcf07ea45d6ae1bc4aabbacf8051c82532d052b0c13e
7
- data.tar.gz: 212fa35ff3ea29a7bc6186be6a1df13dd1ab1d405db62979e6d4407f3203a3e0a0f73b1c978e34e013a996bdd9e627a66a037ac58a8d0432b279594e6a2c52b6
6
+ metadata.gz: c07835d6c2365d107aeb2bf8ce0d57879069b1cadbd3c97035ef11cd2585de4787e5a82974a48a5901f1cb620f267d6e39bf6c22c042161a88db1aecbe5e4ff1
7
+ data.tar.gz: c8f5d705a4cf5e46906fa52aa4ce615755f12cb83eb4e5414e571756fd972fca61ce61ede18a6ec8c550ec747db5fa5df0b6ad58c6ed9e0e56cd94e4ca97f803
data/Rakefile CHANGED
@@ -11,20 +11,6 @@ rescue Bundler::BundlerError => e
11
11
  end
12
12
  require 'rake'
13
13
 
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
16
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
- gem.name = "knjrbfw"
18
- gem.homepage = "http://github.com/kaspernj/knjrbfw"
19
- gem.license = "MIT"
20
- gem.summary = %Q{A framework with lots of stuff for Ruby.}
21
- gem.description = %Q{Including stuff for HTTP, SSH and much more.}
22
- gem.email = "k@spernj.org"
23
- gem.authors = ["Kasper Johansen"]
24
- # dependencies defined in Gemfile
25
- end
26
- Jeweler::RubygemsDotOrgTasks.new
27
-
28
14
  require 'rspec/core'
29
15
  require 'rspec/core/rake_task'
30
16
  RSpec::Core::RakeTask.new(:spec) do |spec|
@@ -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/image.rb CHANGED
@@ -113,7 +113,7 @@ class Knj::Image
113
113
  else
114
114
  pixels = pic.get_pixels(x_from, y_from, 1, y_to)
115
115
  pixels.each do |pixel|
116
- pixel.opacity = ::Magick::TransparentOpacity
116
+ pixel.alpha = ::Magick::QuantumRange
117
117
  end
118
118
  pic.store_pixels(x_from, y_from, 1, y_to, pixels)
119
119
  end
@@ -159,8 +159,6 @@ class Knj::Image
159
159
  end
160
160
  end
161
161
  end
162
-
163
- pic.matte = true
164
162
  end
165
163
 
166
164
  #Returns the width relative to the height.
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.113
4
+ version: 0.0.115
5
5
  platform: ruby
6
6
  authors:
7
- - Kasper Johansen
7
+ - Kasper Stöckel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-21 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
@@ -186,16 +186,9 @@ extra_rdoc_files:
186
186
  - LICENSE.txt
187
187
  - README.rdoc
188
188
  files:
189
- - ".document"
190
- - ".rspec"
191
- - Gemfile
192
- - Gemfile.lock
193
189
  - LICENSE.txt
194
190
  - README.rdoc
195
191
  - Rakefile
196
- - VERSION
197
- - knjrbfw.gemspec
198
- - lib/knj/.gitignore
199
192
  - lib/knj/amixer.rb
200
193
  - lib/knj/arrayext.rb
201
194
  - lib/knj/autoload.rb
@@ -365,8 +358,6 @@ files:
365
358
  - lib/knj/scripts/svn_merge.rb
366
359
  - lib/knj/scripts/upgrade_knjrbfw_checker.rb
367
360
  - lib/knj/sms.rb
368
- - lib/knj/sshrobot.rb
369
- - lib/knj/sshrobot/sshrobot.rb
370
361
  - lib/knj/strings.rb
371
362
  - lib/knj/sysuser.rb
372
363
  - lib/knj/table_writer.rb
@@ -389,16 +380,6 @@ files:
389
380
  - lib/knj/x11vnc.rb
390
381
  - lib/knj/youtube.rb
391
382
  - lib/knjrbfw.rb
392
- - spec/amixer_spec.rb
393
- - spec/arrayext_spec.rb
394
- - spec/autoload_spec.rb
395
- - spec/cmd_parser_spec.rb
396
- - spec/knjrbfw_spec.rb
397
- - spec/locales_spec.rb
398
- - spec/spec_helper.rb
399
- - spec/strings_spec.rb
400
- - spec/web_spec.rb
401
- - testfiles/image.jpg
402
383
  homepage: http://github.com/kaspernj/knjrbfw
403
384
  licenses:
404
385
  - MIT
@@ -418,8 +399,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
418
399
  - !ruby/object:Gem::Version
419
400
  version: '0'
420
401
  requirements: []
421
- rubyforge_project:
422
- rubygems_version: 2.4.0
402
+ rubygems_version: 3.3.7
423
403
  signing_key:
424
404
  specification_version: 4
425
405
  summary: A framework with lots of stuff for Ruby.
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color
data/Gemfile DELETED
@@ -1,22 +0,0 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
- gem "wref", ">= 0.0.8"
6
- gem "tsafe"
7
- gem "datet"
8
- gem "http2"
9
- gem "php4r"
10
- gem "ruby_process"
11
-
12
- # Add dependencies to develop your gem here.
13
- # Include everything needed to run rake, tests, features, etc.
14
- group :development do
15
- gem "rspec"
16
- gem "bundler"
17
- gem "jeweler"
18
- gem "sqlite3" if RUBY_ENGINE != "jruby"
19
- gem "rmagick" if RUBY_ENGINE != "jruby"
20
- gem "rmagick4j" if RUBY_ENGINE == "jruby"
21
- gem "array_enumerator"
22
- end
data/Gemfile.lock DELETED
@@ -1,90 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- addressable (2.3.6)
5
- array_enumerator (0.0.3)
6
- builder (3.2.2)
7
- datet (0.0.25)
8
- descendants_tracker (0.0.4)
9
- thread_safe (~> 0.3, >= 0.3.1)
10
- diff-lcs (1.2.5)
11
- faraday (0.9.0)
12
- multipart-post (>= 1.2, < 3)
13
- git (1.2.6)
14
- github_api (0.11.3)
15
- addressable (~> 2.3)
16
- descendants_tracker (~> 0.0.1)
17
- faraday (~> 0.8, < 0.10)
18
- hashie (>= 1.2)
19
- multi_json (>= 1.7.5, < 2.0)
20
- nokogiri (~> 1.6.0)
21
- oauth2
22
- hashie (2.1.1)
23
- highline (1.6.21)
24
- http2 (0.0.23)
25
- jeweler (2.0.1)
26
- builder
27
- bundler (>= 1.0)
28
- git (>= 1.2.5)
29
- github_api
30
- highline (>= 1.6.15)
31
- nokogiri (>= 1.5.10)
32
- rake
33
- rdoc
34
- json (1.8.1)
35
- jwt (0.1.11)
36
- multi_json (>= 1.5)
37
- mini_portile (0.5.3)
38
- multi_json (1.9.2)
39
- multi_xml (0.5.5)
40
- multipart-post (2.0.0)
41
- nokogiri (1.6.1)
42
- mini_portile (~> 0.5.0)
43
- oauth2 (0.9.3)
44
- faraday (>= 0.8, < 0.10)
45
- jwt (~> 0.1.8)
46
- multi_json (~> 1.3)
47
- multi_xml (~> 0.5)
48
- rack (~> 1.2)
49
- php4r (0.0.4)
50
- datet
51
- http2
52
- string-strtr
53
- rack (1.5.2)
54
- rake (10.3.2)
55
- rdoc (4.1.1)
56
- json (~> 1.4)
57
- rmagick (2.13.2)
58
- rspec (2.14.1)
59
- rspec-core (~> 2.14.0)
60
- rspec-expectations (~> 2.14.0)
61
- rspec-mocks (~> 2.14.0)
62
- rspec-core (2.14.8)
63
- rspec-expectations (2.14.5)
64
- diff-lcs (>= 1.1.3, < 2.0)
65
- rspec-mocks (2.14.6)
66
- ruby_process (0.0.9)
67
- tsafe
68
- wref
69
- sqlite3 (1.3.9)
70
- string-strtr (0.0.3)
71
- thread_safe (0.3.3)
72
- tsafe (0.0.11)
73
- wref (0.0.8)
74
-
75
- PLATFORMS
76
- ruby
77
-
78
- DEPENDENCIES
79
- array_enumerator
80
- bundler
81
- datet
82
- http2
83
- jeweler
84
- php4r
85
- rmagick
86
- rspec
87
- ruby_process
88
- sqlite3
89
- tsafe
90
- wref (>= 0.0.8)
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.113