Module: Yast::SquidHelperFunctionsInclude
- Defined in:
- ../../src/include/squid/helper_functions.rb
Instance Method Summary (collapse)
- - (Object) initialize_squid_helper_functions(include_target)
- - (Object) isCorrectHost(host)
- - (Object) isCorrectPathnameOfLogFile(str)
- - (Object) isHostName(str)
- - (Object) isIPAddr(str)
-
- (Object) sizeUnitWidget(id)
Returns a widget with setting of units.
-
- (Object) timeUnitWidget(id)
Returns a widget with setting of units.
-
- (Object) unitToMultiple(unit)
Returns multiple which equals to given parameter.
Instance Method Details
- (Object) initialize_squid_helper_functions(include_target)
30 31 32 33 34 |
# File '../../src/include/squid/helper_functions.rb', line 30 def initialize_squid_helper_functions(include_target) textdomain "squid" Yast.import "FileUtils" end |
- (Object) isCorrectHost(host)
103 104 105 106 |
# File '../../src/include/squid/helper_functions.rb', line 103 def isCorrectHost(host) return false if !isIPAddr(host) && !isHostName(host) true end |
- (Object) isCorrectPathnameOfLogFile(str)
65 66 67 68 69 70 71 72 |
# File '../../src/include/squid/helper_functions.rb', line 65 def isCorrectPathnameOfLogFile(str) ok = Builtins.regexpmatch(str, "^/([^/]+/)*[^/]+$") if ok dir = Builtins.regexptokenize(str, "^(.+)/[^/]+$") ok = false if !FileUtils.IsDirectory(Ops.get(dir, 0, "/")) end ok end |
- (Object) isHostName(str)
97 98 99 100 101 |
# File '../../src/include/squid/helper_functions.rb', line 97 def isHostName(str) #max 22 chars length #see http://www.no-ip.com/support/faq/EN/dynamic_ddns/what_is_a_valid_hostname.html Builtins.regexpmatch(str, "^[a-zA-Z0-9][a-zA-Z0-9-]{0,21}$") end |
- (Object) isIPAddr(str)
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File '../../src/include/squid/helper_functions.rb', line 74 def isIPAddr(str) ok = true l = Builtins.regexptokenize( str, "^([0-9]+)\\.([0-9]+)\\.([0-9]+)\\.([0-9]+)$" ) if Builtins.size(l) != 4 ok = false else i = 0 Builtins.foreach(l) do |value| i = Builtins.tointeger(value) if Ops.less_than(i, 0) || Ops.greater_than(i, 255) ok = false raise Break end end end ok end |
- (Object) sizeUnitWidget(id)
Returns a widget with setting of units
37 38 39 |
# File '../../src/include/squid/helper_functions.rb', line 37 def sizeUnitWidget(id) ComboBox(Id(id), _("&Units"), [Item("KB"), Item("MB")]) end |
- (Object) timeUnitWidget(id)
Returns a widget with setting of units
51 52 53 54 55 56 57 58 59 60 61 62 |
# File '../../src/include/squid/helper_functions.rb', line 51 def timeUnitWidget(id) ComboBox( Id(id), " ", [ Item(Id("seconds"), _("seconds")), Item(Id("minutes"), _("minutes")), Item(Id("hours"), _("hours")), Item(Id("days"), _("days")) ] ) end |
- (Object) unitToMultiple(unit)
Returns multiple which equals to given parameter.
42 43 44 45 46 47 |
# File '../../src/include/squid/helper_functions.rb', line 42 def unitToMultiple(unit) return 1024 if unit == "KB" return 1024 * 1024 if unit == "MB" nil end |