knjrbfw 0.0.98 → 0.0.99

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.98
1
+ 0.0.99
data/knjrbfw.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "knjrbfw"
8
- s.version = "0.0.98"
8
+ s.version = "0.0.99"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kasper Johansen"]
12
- s.date = "2012-09-18"
12
+ s.date = "2012-09-30"
13
13
  s.description = "Including stuff for HTTP, SSH and much more."
14
14
  s.email = "k@spernj.org"
15
15
  s.extra_rdoc_files = [
data/lib/knj/arrayext.rb CHANGED
@@ -13,7 +13,7 @@ module Knj::ArrayExt
13
13
  str = ""
14
14
  first = true
15
15
 
16
- require "php4r"
16
+ require "php4r" if !Kernel.const_defined?(:Php4r)
17
17
  Php4r.foreach(args[:arr]) do |key, value|
18
18
  if first
19
19
  first = false
@@ -212,7 +212,7 @@ module Knj::ArrayExt
212
212
  def self.clone_encode(hash, encoding, args = {})
213
213
  return hash if !hash
214
214
 
215
- require "php4r"
215
+ require "php4r" if !Kernel.const_defined?(:Php4r)
216
216
  hash = hash.clone
217
217
  Php4r.foreach(hash) do |key, val|
218
218
  if val.is_a?(String)
@@ -2,5 +2,5 @@ begin
2
2
  require "wref" if !Kernel.const_defined?(:Wref)
3
3
  rescue LoadError
4
4
  require "rubygems"
5
- require "wref"
5
+ require "wref" if !Kernel.const_defined?(:Wref)
6
6
  end
data/lib/knj/errors.rb CHANGED
@@ -6,6 +6,9 @@ module Knj::Errors
6
6
  #An error that specifies that the caller should retry the operation.
7
7
  class Retry < StandardError; end
8
8
 
9
+ #An error that specifies that the current entry should be skipped.
10
+ class Skip < StandardError; end
11
+
9
12
  #Returns a string describing the given error. Possible arguments can be given if you want the returned string formatted as HTML.
10
13
  #
11
14
  #===Examples
@@ -41,8 +41,8 @@ class Knj::Gettext_threadded
41
41
  cont = fp.read.encode("utf-8")
42
42
  end
43
43
 
44
- cont.scan(/msgid\s+\"(.+)\"\nmsgstr\s+\"(.+)\"\n\n/) do |match|
45
- @langs[file][match[0]] = match[1].to_s.encode("utf-8")
44
+ cont.scan(/msgid\s+\"(.+)\"(\r|)\nmsgstr\s+\"(.+)\"(\r|)\n(\r|)\n/) do |match|
45
+ @langs[file][match[0]] = match[2].to_s.encode("utf-8")
46
46
  end
47
47
  end
48
48
  end
@@ -1,6 +1,8 @@
1
- require "rubygems"
2
- require "wref" if !Kernel.const_defined?(:Wref)
3
- require "datet" if !Kernel.const_defined?(:Datet)
1
+ if !Kernel.const_defined?(:Wref) or !Kernel.const_defined?(:Datet)
2
+ require "rubygems"
3
+ require "wref" if !Kernel.const_defined?(:Wref)
4
+ require "datet" if !Kernel.const_defined?(:Datet)
5
+ end
4
6
 
5
7
  #A wrapper of several possible database-types.
6
8
  #
data/lib/knj/locales.rb CHANGED
@@ -65,7 +65,7 @@ module Knj::Locales
65
65
  def self.number_out(num_str, dec = 2)
66
66
  lc = Knj::Locales.localeconv
67
67
 
68
- require "php4r"
68
+ require "php4r" if !Kernel.const_defined?(:Php4r)
69
69
  return Php4r.number_format(num_str, dec, lc["decimal_point"], lc["thousands_sep"])
70
70
  end
71
71
 
data/lib/knj/objects.rb CHANGED
@@ -124,9 +124,11 @@ class Knj::Objects
124
124
  raise "No object given." if !args["object"]
125
125
  raise "No signals given." if !args.key?("signal") and !args.key?("signals")
126
126
  args["block"] = block if block_given?
127
- @callbacks[args["object"].to_sym] = {} if !@callbacks[args["object"]]
128
- conn_id = @callbacks[args["object"].to_sym].length.to_s
129
- @callbacks[args["object"].to_sym][conn_id] = args
127
+ object = args["object"].to_sym
128
+
129
+ @callbacks[object] = {} if !@callbacks[object]
130
+ conn_id = @callbacks[object].length.to_s
131
+ @callbacks[object][conn_id] = args
130
132
  return conn_id
131
133
  end
132
134
 
@@ -134,11 +136,12 @@ class Knj::Objects
134
136
  def connected?(args)
135
137
  raise "No object given." if !args["object"]
136
138
  raise "No signal given." if !args.key?("signal")
139
+ object = args["object"].to_sym
137
140
 
138
- if @callbacks.key?(args["object"].to_sym)
139
- @callbacks[args["object"].to_sym].clone.each do |ckey, callback|
140
- return true if callback.key?("signal") and callback["signal"] == args["signal"]
141
- return true if callback.key?("signals") and callback["signals"].index(args["signal"]) != nil
141
+ if @callbacks.key?(object)
142
+ @callbacks[object].clone.each do |ckey, callback|
143
+ return true if callback.key?("signal") and callback["signal"].to_s == args["signal"].to_s
144
+ return true if callback.key?("signals") and (callback["signals"].include?(args["signal"].to_s) or callback["signals"].include?(args["signal"].to_sym))
142
145
  end
143
146
  end
144
147
 
@@ -148,7 +151,8 @@ class Knj::Objects
148
151
  #Unconnects a connect by 'object' and 'conn_id'.
149
152
  def unconnect(args)
150
153
  raise ArgumentError, "No object given." if !args["object"]
151
- raise ArgumentError, "Object doesnt exist: '#{args["object"]}'." if !@callbacks.key?(args["object"].to_sym)
154
+ object = args["object"].to_sym
155
+ raise ArgumentError, "Object doesnt exist: '#{object}'." if !@callbacks.key?(object)
152
156
 
153
157
  if args["conn_id"]
154
158
  conn_ids = [args["conn_id"]]
@@ -159,8 +163,8 @@ class Knj::Objects
159
163
  end
160
164
 
161
165
  conn_ids.each do |conn_id|
162
- raise Errno::ENOENT, "Conn ID doest exist: '#{conn_id}' (#{args})." if !@callbacks[args["object"].to_sym].key?(conn_id)
163
- @callbacks[args["object"].to_sym].delete(conn_id)
166
+ raise Errno::ENOENT, "Conn ID doest exist: '#{conn_id}' (#{args})." if !@callbacks[object].key?(conn_id)
167
+ @callbacks[object].delete(conn_id)
164
168
  end
165
169
  end
166
170
 
@@ -172,9 +176,9 @@ class Knj::Objects
172
176
  @callbacks[classstr].clone.each do |callback_key, callback|
173
177
  docall = false
174
178
 
175
- if callback.key?("signal") and args.key?("signal") and callback["signal"] == args["signal"]
179
+ if callback.key?("signal") and args.key?("signal") and callback["signal"].to_s == args["signal"].to_s
176
180
  docall = true
177
- elsif callback["signals"] and args["signal"] and callback["signals"].include?(args["signal"])
181
+ elsif callback["signals"] and args["signal"] and (callback["signals"].include?(args["signal"].to_s) or callback["signals"].include?(args["signal"].to_sym))
178
182
  docall = true
179
183
  end
180
184
 
@@ -193,7 +197,7 @@ class Knj::Objects
193
197
 
194
198
  callback["block"].call(*callargs)
195
199
  elsif callback["callback"]
196
- require "php4r"
200
+ require "php4r" if !Kernel.const_defined?(:Php4r)
197
201
  Php4r.call_user_func(callback["callback"], args)
198
202
  else
199
203
  raise "No valid callback given."
data/lib/knj/os.rb CHANGED
@@ -219,7 +219,7 @@ module Knj::Os
219
219
 
220
220
  #Returns the Ruby executable that is running the current process if possible.
221
221
  def self.executed_executable
222
- return ENV["rvm_ruby_string"] if ENV["rvm_ruby_string"].to_s.length > 0
222
+ return ENV["rvm_ruby_string"] if !ENV["rvm_ruby_string"].to_s.empty?
223
223
 
224
224
  #Try to look the executeable up by command.
225
225
  if self.os == "linux"
@@ -1,5 +1,5 @@
1
1
  require "knj/autoload"
2
- require "php4r"
2
+ require "php4r" if !Kernel.const_defined?(:Php4r)
3
3
  require "#{$knjpath}php_parser/php_parser"
4
4
 
5
5
  module Knj::Php_parser::Functions
@@ -6,8 +6,7 @@ class Knj::Rhodes
6
6
 
7
7
  def initialize(args = {})
8
8
  require "#{$knjpath}arrayext.rb"
9
- require "#{$knjpath}datet.rb"
10
- require "php4r"
9
+ require "php4r" if !Kernel.const_defined?(:Php4r)
11
10
  require "#{$knjpath}objects.rb"
12
11
  require "#{$knjpath}datarow.rb"
13
12
  require "#{$knjpath}event_handler.rb"
@@ -6,7 +6,14 @@
6
6
  </div>
7
7
  <div data-role="content">
8
8
  <ul data-role="listview">
9
- <%if System::get_property('platform') != "APPLE"%>
9
+ <%if System::get_property("platform") == "APPLE"%>
10
+ <li>
11
+ <a href="javascript: knj_rhodes_html_links({'url': iphone_str})">
12
+ <h3><%=_"Open in built-in app. (iPhone)"%></h3>
13
+ <p><%=_"This will trigger the YouTube-app. on iPhone."%></p>
14
+ </a>
15
+ </li>
16
+ <%else%>
10
17
  <li>
11
18
  <a href="javascript: knj_rhodes_html_links({'url': 'vnd.youtube://<%=@params["youtube_id"]%>'})">
12
19
  <h3><%=_"Open in built-in app. (VND)"%></h3>
@@ -15,15 +22,6 @@
15
22
  </li>
16
23
  <%end%>
17
24
 
18
- <%if System::get_property("platform") == "APPLE"%>
19
- <li>
20
- <a href="javascript: knj_rhodes_html_links({'url': iphone_str})">
21
- <h3><%=_"Open in built-in app. (iPhone)"%></h3>
22
- <p><%=_"This will trigger the YouTube-app. on iPhone."%></p>
23
- </a>
24
- </li>
25
- <%end%>
26
-
27
25
  <li>
28
26
  <a href="javascript: knj_rhodes_html_links({'url': 'http://www.youtube.com/watch?v=<%=@params["youtube_id"]%>'})">
29
27
  <h3><%=_"Open YouTube-URL"%></h3>
@@ -38,8 +36,10 @@
38
36
  </li>
39
37
  </ul>
40
38
 
41
- <script>
42
- var iphone_str = "[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@\"http://www.youtube.com/v/oHg5SJYRHA0&f=gdata_videos\"]]; "
43
- </script>
39
+ <%if System::get_property("platform") == "APPLE"%>
40
+ <script>
41
+ var iphone_str = "[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@\"http://www.youtube.com/v/oHg5SJYRHA0&f=gdata_videos\"]]; "
42
+ </script>
43
+ <%end%>
44
44
  </div>
45
45
  </div>
@@ -4,7 +4,7 @@ describe "Cmd_parser" do
4
4
  it "should be able to parse various strings" do
5
5
  require "knjrbfw"
6
6
  require "knj/cmd_parser"
7
- require "php4r"
7
+ require "php4r" if !Kernel.const_defined?(:Php4r)
8
8
 
9
9
  strs = [
10
10
  "-rw-r--r-- 1 admin administ 186.3M Aug 30 18:09 b4u_synoptik_2011_08_30_17_57_32.sql.gz\n",
data/spec/web_spec.rb CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  describe "Web" do
4
4
  it "should be able to parse url and generate hashes" do
5
- require "php4r"
5
+ require "php4r" if !Kernel.const_defined?(:Php4r)
6
6
  require "knj/web"
7
7
 
8
8
  url = "first=test&#{Knj::Web.urlenc("second[trala][]")}=1&#{Knj::Web.urlenc("second[trala][]")}=2&#{Knj::Web.urlenc("second[trala][]")}=3"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: knjrbfw
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.98
5
+ version: 0.0.99
6
6
  platform: ruby
7
7
  authors:
8
8
  - Kasper Johansen
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-09-18 00:00:00 Z
13
+ date: 2012-09-30 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: wref
@@ -390,7 +390,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
390
390
  requirements:
391
391
  - - ">="
392
392
  - !ruby/object:Gem::Version
393
- hash: 73923719738851392
393
+ hash: 1102043670091375693
394
394
  segments:
395
395
  - 0
396
396
  version: "0"