epitools 0.5.129 → 0.5.130

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
2
  SHA256:
3
- metadata.gz: 74b341f10e9697a2d9e93aad5aa91b7f799e75a3cd817d712bce3e15cd18428d
4
- data.tar.gz: bce241006bd3b743410e3b6833145a5e72052637d7e918caa2562564b6ad4f5b
3
+ metadata.gz: d5b52f237d17762dca9dfa53fa0cbdae372f867f84fb455ca97656a9863d6763
4
+ data.tar.gz: 25f2741a4a12dc257ef1d540dcbfea1e6fa7945267de324e1ddba4e860d44334
5
5
  SHA512:
6
- metadata.gz: ef8edebf3480e814c17e90f5c200fe1dc70a45827d8c2e52d2d7834291f61fb67824c5c5b6f869805f8751ea53d0eb95aa83e86daba42eb748d34ea66061ad6a
7
- data.tar.gz: 38abf237811351f91306dd1d1e66e9104040645aa3ff743d13609a155853aa6ffa80b9967961edda5f20e1ad67068ffc298beafac47857210eca9ebb6a4ec87f
6
+ metadata.gz: 264e9ab8322afd8b6e08b3445dde07c4bf214a9da6e0b087e2c1117a5f0366edd5db361afd64a91faa24988618cf6fccf940ab7bfa7e76b63d8d53a905ef32ae
7
+ data.tar.gz: 0bb9e187d248d149e60c05fbf7a5757a79d560e1452a6ccf808294fc0cb0816d6e9de53d997e2fdeba49056c09a0d55bb8de6b06332174bcdfafe2c6fc004fbb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.129
1
+ 0.5.130
@@ -1,31 +1,17 @@
1
1
  class Class
2
2
 
3
- #
4
- # Return a copy of the class with modules mixed into it.
5
- #
6
- def self.using(*args)
7
- if block_given?
8
- yield using(*args)
9
- else
10
- copy = self.dup
11
- args.each { |arg| copy.send(:include, arg) }
12
- copy
13
- end
14
- end
15
-
16
-
17
3
  #
18
4
  # Trace the specified method calls (`meths`, as symbols) to descendends of this class (or all methods if `:*` is supplied).
19
5
  # Output is printed to $stderr.
20
6
  #
21
7
  def trace_messages_to(*meths)
22
8
  return unless $DEBUG
23
-
9
+
24
10
  tracers = Module.new
25
11
  parent = self
26
12
 
27
13
  $stderr.puts "[*] Tracing messages sent to #{parent} (messages: #{meths.join(", ")})"
28
-
14
+
29
15
  meths.each do |meth|
30
16
  case meth
31
17
  when :*
@@ -35,9 +21,9 @@ class Class
35
21
  end
36
22
  else
37
23
  tracers.define_method(meth) do |*args, &block|
38
- args = args.map(&:inspect)
39
- args << "&block" if block
40
- $stderr.puts "[*] #{parent}##{meth}(#{args.join(", ")})"
24
+ arg_names = args.map(&:inspect)
25
+ arg_names << "&block" if block
26
+ $stderr.puts "[*] #{parent}##{meth}(#{arg_names.join(", ")})"
41
27
  if block
42
28
  super(*args, &block)
43
29
  else
@@ -1,5 +1,5 @@
1
1
 
2
- Number = Numeric # "obj.is_a? Number" just sounds better.
2
+ Number = Numeric # because "obj.is_a? Number" sounds better!
3
3
 
4
4
  class Numeric
5
5
 
@@ -84,7 +84,8 @@ class Numeric
84
84
  end
85
85
  end
86
86
 
87
- [:cos,
87
+ [
88
+ :cos,
88
89
  :sin,
89
90
  :tan,
90
91
  :acos,
@@ -186,7 +187,8 @@ class Numeric
186
187
  end
187
188
 
188
189
  BYTE_SIZE_TABLE = {
189
- # power # units
190
+ # power
191
+ # of 1024 # units
190
192
  0 => "",
191
193
  1 => "KB",
192
194
  2 => "MB",
@@ -213,8 +215,8 @@ class Numeric
213
215
  def to_hms
214
216
  seconds = self
215
217
 
216
- days, seconds = seconds.divmod(86400)
217
- hours, seconds = seconds.divmod(3600)
218
+ days, seconds = seconds.divmod(86400)
219
+ hours, seconds = seconds.divmod(3600)
218
220
  minutes, seconds = seconds.divmod(60)
219
221
  seconds, frac = seconds.divmod(1)
220
222
 
@@ -229,8 +231,8 @@ class Numeric
229
231
  def to_hms_in_words
230
232
  seconds = self
231
233
 
232
- days, seconds = seconds.divmod(86400)
233
- hours, seconds = seconds.divmod(3600)
234
+ days, seconds = seconds.divmod(86400)
235
+ hours, seconds = seconds.divmod(3600)
234
236
  minutes, seconds = seconds.divmod(60)
235
237
  seconds, frac = seconds.divmod(1)
236
238
 
@@ -243,6 +245,14 @@ class Numeric
243
245
  result
244
246
  end
245
247
 
248
+ def to_farenheit
249
+ (self * 9.0 / 5.0) + 32
250
+ end
251
+
252
+ def to_celcius
253
+ (self - 32) * 5.0 / 9.0
254
+ end
255
+
246
256
  end
247
257
 
248
258
 
@@ -442,7 +452,8 @@ end
442
452
  class Prime
443
453
 
444
454
  #
445
- # Return an array of prime numbers within the specified range
455
+ # Return an array of prime numbers within the specified range.
456
+ # (It still has to generate all the primes less than the lower bound, so, yeah... be warned.)
446
457
  #
447
458
  def [](range)
448
459
  ubound = range.end
@@ -1,36 +1,38 @@
1
1
  require 'uri'
2
2
 
3
- module URI
3
+ class URI::Generic
4
4
 
5
5
  #
6
- # Return a Hash of the variables in the query string
6
+ # Get the query string
7
7
  #
8
- def params
9
- (@query ? @query.to_params : {})
8
+ def query
9
+ params.to_query
10
10
  end
11
11
 
12
12
  #
13
- # Update all the params at once
13
+ # Return a Hash of the variables in the query string
14
14
  #
15
- def params=(new_params)
16
- self.query = new_params.to_params
15
+ def params
16
+ @params ||= (@query ? @query.to_params : {})
17
17
  end
18
18
 
19
19
  #
20
- # Update one URI parameter
20
+ # Update all the params at once
21
21
  #
22
- def set_param(key, value)
23
- current = params
24
- current[key] = value
25
- self.query = current.to_query
22
+ def params=(new_params)
23
+ # self.query = new_params.to_params
24
+ raise "params must be a Hash" unless new_params.is_a? Hash
25
+ @params = new_params
26
26
  end
27
27
 
28
- #
29
- # Get the query string
30
- #
31
- def query
32
- params.to_query
33
- end
28
+ # #
29
+ # # Update one URI parameter
30
+ # #
31
+ # def set_param(key, value)
32
+ # current = params
33
+ # current[key] = value
34
+ # self.query = current.to_query
35
+ # end
34
36
 
35
37
  #
36
38
  # URIs *are* strings, dammit!
@@ -39,6 +41,10 @@ module URI
39
41
  to_s
40
42
  end
41
43
 
44
+ end
45
+
46
+ module URI
47
+
42
48
  #
43
49
  # Default user agent for the 'get' method
44
50
  #
@@ -4,6 +4,7 @@ require 'epitools/minimal'
4
4
  # Cross-platform operating system functions.
5
5
  # Includes: process listing, platform detection, etc.
6
6
  #
7
+ require 'epitools/sys/os'
7
8
  require 'epitools/sys/ps'
8
9
  require 'epitools/sys/mounts'
9
10
  require 'epitools/sys/misc'
@@ -127,26 +127,6 @@ end
127
127
 
128
128
  describe Class do
129
129
 
130
- it "uses" do
131
- module Test1
132
- def test1; :test1; end
133
- end
134
-
135
- module Test2
136
- def test2; :test2; end
137
- end
138
-
139
- Hash.using(Test1).new.test1.should == :test1
140
- Hash.using(Test2).new.test2.should == :test2
141
- h = Hash.using(Test1, Test2).new
142
- h.test1.should == :test1
143
- h.test2.should == :test2
144
-
145
- Hash.using(Test1) do |h|
146
- h.new.test1.should == :test1
147
- end
148
- end
149
-
150
130
  it "traces messages (when $DEBUG is set)" do
151
131
  $DEBUG = true
152
132
 
@@ -166,10 +146,10 @@ describe Class do
166
146
  class ButtTest
167
147
  trace_messages_to :*
168
148
 
169
- def d
149
+ def a
170
150
  end
171
151
 
172
- def e
152
+ def b
173
153
  end
174
154
  end
175
155
 
@@ -197,7 +177,7 @@ describe Numeric do
197
177
  -12983287123.commatize.should == "-12,983,287,123"
198
178
  -12983287123.4411.commatize.should == "-12,983,287,123.4411"
199
179
  1111.1234567.commatize.should == "1,111.1234567"
200
- BigDecimal.new("1111.1234567").commatize.should == "1,111.1234567"
180
+ BigDecimal("1111.1234567").commatize.should == "1,111.1234567"
201
181
  -1234567.1234567.underscorize.should == "-1_234_567.1234567"
202
182
  end
203
183
 
@@ -237,6 +217,11 @@ describe Numeric do
237
217
  32583128.human_size(2).should == "31.07MB"
238
218
  end
239
219
 
220
+ it "temperatures" do
221
+ t = 18.0
222
+ t.to_farenheit.to_celcius.should be_within(0.001).of(t)
223
+ end
224
+
240
225
  end
241
226
 
242
227
 
@@ -1318,10 +1303,12 @@ describe URI do
1318
1303
  end
1319
1304
 
1320
1305
  it "params=" do
1321
- u = "http://butt.com/?q=1".to_uri
1306
+ u = "http://butt.cx/?q=1".to_uri
1322
1307
  u.query.should == "q=1"
1308
+ u.params.should == {"q" => "1"}
1323
1309
  u.params["q"] = 2
1324
1310
  u.params["q"].should == 2
1311
+ u.params.should == {"q" => 2}
1325
1312
  u.query.should == "q=2"
1326
1313
  end
1327
1314
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: epitools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.129
4
+ version: 0.5.130
5
5
  platform: ruby
6
6
  authors:
7
7
  - epitron
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-25 00:00:00.000000000 Z
11
+ date: 2020-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec