rubyment 0.6.25535011 → 0.6.25539312

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rubyment.rb +258 -66
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b3bf33d8dfd18d9b8da23e205233274baf4248f
4
- data.tar.gz: 14d1d282699c9976f36e26c69d10bd1c837c79b5
3
+ metadata.gz: 064b22e2b33400a6dcc11e12796afa85f3b1e8d7
4
+ data.tar.gz: ef785677c15bb6ca87d24c3fe3a34ab277c5b989
5
5
  SHA512:
6
- metadata.gz: ddedfdd92d9e9fc379c6a06e6fd2d4f5755c61a7c9baeca65e6f6ed73fa1e2f9636e451a51a6f0b5c4ad06edc0d3825b791de4ac59b8cf6e08152d73e44c8bf6
7
- data.tar.gz: 4000290e456744382005e58531029242aa21326188279cd781a4af7f6a2938d1c34386c63b7f92c6a51d17727ce26af39fb52810b4fd3a73bd1c52adc66bec4b
6
+ metadata.gz: 783dc274768fd88809eb43f38a4d544b9a0730108ebfd674fc8fc0e176f0abda6804eb73e6cd2b37fe03d670863fa6f27935296ba2c99bdfadfae837c8e394d7
7
+ data.tar.gz: 0b2a700200bb24bff7aac1954a55888ffe9cb6ac954d647c669f5e019388a5128ad2505483881729c6e4de7c7e1e2b5fe7d9d4f98fb809f182a5254223028411
data/lib/rubyment.rb CHANGED
@@ -2004,18 +2004,59 @@ require '#{gem_name}'
2004
2004
  end
2005
2005
 
2006
2006
 
2007
+ # forces the uninstallation of a gem in all the ways we can
2008
+ # mostly for internal tests that needs to ensure a gem wasn't
2009
+ # installed before a test.
2010
+ def test__gem_uninstall_extreme_force args=ARGV
2011
+ stderr = @memory[:stderr]
2012
+ gem_spec, user_install, quiet = args
2013
+ quiet = quiet.nne
2014
+ debug = quiet.negate_me
2015
+ command="gem uninstall -a -x #{gem_spec}"
2016
+ debug && (stderr.puts "command=#{command}")
2017
+ `#{command}`
2018
+ command="gem uninstall -a -x --user-install #{gem_spec}"
2019
+ debug && (stderr.puts "command=#{command}")
2020
+ `#{command}`
2021
+ command="sudo gem uninstall -a -x #{gem_spec}"
2022
+ debug && (stderr.puts "command=#{command}")
2023
+ `#{command}`
2024
+ command="sudo gem uninstall -a -x --user-install #{gem_spec}"
2025
+ debug && (stderr.puts "command=#{command}")
2026
+ `#{command}`
2027
+
2028
+ command="gem uninstall -x #{gem_spec}"
2029
+ debug && (stderr.puts "command=#{command}")
2030
+ `#{command}`
2031
+ command="gem uninstall -x --user-install #{gem_spec}"
2032
+ debug && (stderr.puts "command=#{command}")
2033
+ `#{command}`
2034
+ command="sudo gem uninstall -x #{gem_spec}"
2035
+ debug && (stderr.puts "command=#{command}")
2036
+ `#{command}`
2037
+ command="sudo gem uninstall -x --user-install #{gem_spec}"
2038
+ debug && (stderr.puts "command=#{command}")
2039
+ `#{command}`
2040
+ []
2041
+ end
2042
+
2007
2043
  # gem_build
2008
2044
  # args:
2009
2045
  # [gem_spec_path (String), gem_spec_contents (String), gem_is_current_file, gem_name]
2010
2046
  # returns:
2011
2047
  # console output of gem build (String)
2012
2048
  def gem_build args=ARGV
2049
+ stderr = @memory[:stderr]
2013
2050
  gem_spec_path,
2014
2051
  gem_spec_contents,
2015
2052
  gem_is_current_file,
2016
2053
  gem_name,
2017
2054
  gem_bin_generate,
2018
- gem_bin_contents = args
2055
+ gem_bin_contents,
2056
+ quiet,
2057
+ reserved = args
2058
+ quiet = quiet.nne
2059
+ debug = quiet.negate_me
2019
2060
  require 'fileutils'
2020
2061
 
2021
2062
  # this supposes that the current file is listed by the
@@ -2024,7 +2065,8 @@ require '#{gem_name}'
2024
2065
  gem_is_current_file && (
2025
2066
  FileUtils.mkdir_p 'lib'
2026
2067
  file_backup "lib/#{gem_name}.rb", "lib/"
2027
- # FIX ME: accept true
2068
+ # quick hack for backwards compatibility
2069
+ gem_is_current_file = gem_is_current_file.kind_of?(TrueClass) && __FILE__ || gem_is_current_file
2028
2070
  save_file gem_is_current_file, "lib/#{gem_name}.rb"
2029
2071
  )
2030
2072
 
@@ -2040,7 +2082,9 @@ require '#{gem_name}'
2040
2082
 
2041
2083
  FileUtils.mkdir_p File.dirname gem_spec_path
2042
2084
  File.write gem_spec_path, gem_spec_contents || (File.read gem_spec_path)
2043
- `gem build #{gem_spec_path}`
2085
+ command="gem build #{gem_spec_path}"
2086
+ debug && (stderr.puts "command=#{command}")
2087
+ `#{command}`
2044
2088
  end
2045
2089
 
2046
2090
 
@@ -2066,10 +2110,15 @@ require '#{gem_name}'
2066
2110
  # returns:
2067
2111
  # console output of gem install (String)
2068
2112
  def gem_install args=ARGV
2113
+ stderr = @memory[:stderr]
2069
2114
  system_user_is_super = @memory[:system_user_is_super]
2070
- gem_spec, user_install = args
2115
+ gem_spec, user_install, quiet = args
2116
+ quiet = quiet.nne
2117
+ debug = quiet.negate_me
2071
2118
  user_install ||= (!system_user_is_super) && "--user-install" || ""
2072
- `gem install #{user_install} #{gem_spec}`
2119
+ command="gem install #{user_install} #{gem_spec}"
2120
+ debug && (stderr.puts "command=#{command}")
2121
+ `#{command}`
2073
2122
  end
2074
2123
 
2075
2124
  # gem_push
@@ -2078,20 +2127,48 @@ require '#{gem_name}'
2078
2127
  # returns:
2079
2128
  # console output of gem push (String)
2080
2129
  def gem_push args=ARGV
2081
- gem_spec, future_arg = args
2082
- `gem push #{gem_spec}`
2130
+ stderr = @memory[:stderr]
2131
+ gem_spec, future_arg, quiet = args
2132
+ quiet = quiet.nne
2133
+ debug = quiet.negate_me
2134
+ command="gem push #{gem_spec}"
2135
+ debug && (stderr.puts "command=#{command}")
2136
+ `#{command}`
2083
2137
  end
2084
2138
 
2139
+
2140
+ # uninstall all versions of a specific gem
2141
+ # @param [Array] +args+, an +Array+ whose elements are expected to be:
2142
+ # +gem_spect+:: [String]
2143
+ # +user_install+:: [Object]
2144
+ # +quiet+:: [Object] if calling the object +nne+ method returns a +false+ value, will print debug information
2145
+ # @return [String] console output of gem uninstall
2146
+ def gem_uninstall_all args=[]
2147
+ stderr = @memory[:stderr]
2148
+ gem_spec, user_install, quiet, all = args
2149
+ all = "-a"
2150
+ gem_uninstall [gem_spec, user_install, quiet, all]
2151
+ end
2152
+
2153
+
2085
2154
  # gem_uninstall
2086
2155
  # args:
2087
2156
  # [gem_spec (String)]
2088
2157
  # returns:
2089
2158
  # console output of gem uninstall (String)
2090
2159
  def gem_uninstall args=ARGV
2160
+ stderr = @memory[:stderr]
2091
2161
  system_user_is_super = @memory[:system_user_is_super]
2092
- gem_spec, user_install = args
2162
+ gem_spec, user_install, quiet, all = args
2163
+ quiet = quiet.nne
2164
+ debug = quiet.negate_me
2165
+ all = all.nne ""
2093
2166
  user_install ||= (!system_user_is_super) && "--user-install" || ""
2094
- `gem uninstall -x #{user_install} #{gem_spec}`
2167
+ command="gem uninstall #{all} -x #{user_install} #{gem_spec}"
2168
+ debug && (stderr.puts "command=#{command}")
2169
+ `#{command}`
2170
+ #stdin, stdout, stderr, wait_thr = Open3.popen3(":;" + command)
2171
+ #stdout
2095
2172
  end
2096
2173
 
2097
2174
  # gem_list
@@ -2100,8 +2177,15 @@ require '#{gem_name}'
2100
2177
  # returns:
2101
2178
  # console output of gem install (String)
2102
2179
  def gem_list args=ARGV
2103
- gem_spec, future_arg = args
2104
- `gem list | grep #{gem_spec}`
2180
+ stderr = @memory[:stderr]
2181
+ gem_spec,
2182
+ quiet,
2183
+ reserved = args
2184
+ quiet = quiet.nne
2185
+ debug = quiet.negate_me
2186
+ command="gem list | grep #{gem_spec}"
2187
+ debug && (stderr.puts "command=#{command}")
2188
+ `#{command}`
2105
2189
  end
2106
2190
 
2107
2191
  # validate_require
@@ -2265,7 +2349,7 @@ require '#{gem_name}'
2265
2349
  validate_require gem_validate_args gem_defaults
2266
2350
  )
2267
2351
  sleep 1
2268
- already_installed && (gem_uninstall [gem_name])
2352
+ already_installed && (gem_uninstall_all [gem_name])
2269
2353
  puts gem_list [gem_name]
2270
2354
  p (gem_path [gem_name, gem_version])
2271
2355
  gem_install [(gem_path [gem_name, gem_version])]
@@ -2273,7 +2357,7 @@ require '#{gem_name}'
2273
2357
  v = (
2274
2358
  validate_require gem_validate_args gem_defaults
2275
2359
  )
2276
- gem_uninstall [gem_name]
2360
+ gem_uninstall_all [gem_name]
2277
2361
  already_installed && (gem_install [gem_name])
2278
2362
  v
2279
2363
  end
@@ -2493,6 +2577,44 @@ require '#{gem_name}'
2493
2577
  end
2494
2578
 
2495
2579
 
2580
+ # returns an HTTP response
2581
+ # @param [Array] +args+, an +Array+ whose elements are expected to be:
2582
+ # +response+:: [String, nil] response payload
2583
+ # +content_type+:: [String, nil] mime type of payload
2584
+ # +version+:: [String, nil] http protocol version
2585
+ # +code+:: [String, nil] response code
2586
+ # +keep_alive+:: [Boolean] right not unsupported, always close the connection
2587
+ # +debug+:: [Object] if calling the object +nne+ method returns a +false+ value, won't print debug information
2588
+ # +eol+:: [String, nil] string to attach to the end of each line in the response
2589
+ #
2590
+ # @return [String] response with headers
2591
+ def http_response_base args = []
2592
+ payload,
2593
+ content_type,
2594
+ code,
2595
+ version,
2596
+ keep_alive,
2597
+ debug,
2598
+ eol,
2599
+ reserved = args
2600
+ stderr = @memory[:stderr]
2601
+ debug.nne && (stderr.puts "#{__method__} starting")
2602
+ debug.nne && (stderr.puts args.inspect)
2603
+ rv = [
2604
+ "HTTP/#{version} #{code}",
2605
+ "Content-Type: #{content_type};" +
2606
+ " charset=#{payload.encoding.name.downcase}",
2607
+ "Content-Length: #{payload.bytesize}",
2608
+ keep_alive.negate_me && "Connection: close",
2609
+ "",
2610
+ "#{payload}"
2611
+ ]
2612
+ debug.nne && (stderr.puts "#{__method__} will return #{rv}")
2613
+ debug.nne && (stderr.puts "#{__method__} returning")
2614
+ rv.join eol
2615
+ end
2616
+
2617
+
2496
2618
  # returns an HTTP response (1.1 200 OK by default)
2497
2619
  # @param [Array] +args+, an +Array+ whose elements are expected to be:
2498
2620
  # +response+:: [String, nil] response payload (default empty)
@@ -2500,6 +2622,7 @@ require '#{gem_name}'
2500
2622
  # +version+:: [String, nil] http protocol version (+1.1+ by default)
2501
2623
  # +code+:: [String, nil] response code (+"200 OK"+ by default)
2502
2624
  # +keep_alive+:: [Boolean] right not unsupported, always close the connection
2625
+ # +debug+:: [Object] if calling the object +nne+ method returns a +false+ value, won't print debug information
2503
2626
  # +eol+:: [String, nil] response code (+"\r\n"+ by default/on +nil+)
2504
2627
  #
2505
2628
  # @return [Array] response with proper headers in an array where each element is a response line
@@ -2514,17 +2637,17 @@ require '#{gem_name}'
2514
2637
  version ||= "1.1"
2515
2638
  code ||= "200 OK"
2516
2639
  eol ||= "\r\n"
2517
- rv = [
2518
- "HTTP/#{version} #{code}",
2519
- "Content-Type: #{content_type};" +
2520
- " charset=#{payload.encoding.name.downcase}",
2521
- "Content-Length: #{payload.bytesize}",
2522
- keep_alive.negate_me && "Connection: close",
2523
- "",
2524
- "#{payload}"
2640
+ rv = http_response_base [
2641
+ payload,
2642
+ content_type,
2643
+ code,
2644
+ version,
2645
+ keep_alive,
2646
+ debug,
2647
+ eol,
2525
2648
  ]
2526
2649
  debug.nne && (stderr.puts "#{__method__} returning")
2527
- rv.join eol
2650
+ rv
2528
2651
  end
2529
2652
 
2530
2653
 
@@ -3427,6 +3550,70 @@ n8mFEtUKobsK
3427
3550
  end
3428
3551
 
3429
3552
 
3553
+ # tests test__tcp_ssl_server__io_method, creating two
3554
+ # servers, one ssl and another plain, redirecting to
3555
+ # the ssl one. then, opens a client thread with a client
3556
+ # connecting to the root document of the plain server
3557
+ # (and in the end being served by the root document of
3558
+ # the ssl server).
3559
+ # another thread for the client
3560
+ def test__tcp_ssl_server__get_root__plain_redirect args = ARGV
3561
+ stderr = @memory[:stderr]
3562
+ tcp_ssl_server_method,
3563
+ http_processing_method,
3564
+ http_processing_method_args,
3565
+ http_server_port,
3566
+ http_ip_addr,
3567
+ priv_pemfile,
3568
+ cert_pem_file,
3569
+ extra_cert_pem_files,
3570
+ ssl_cert_pkey_chain_method,
3571
+ debug_tcp_ssl_server_method,
3572
+ happy_with_request,
3573
+ io_method,
3574
+ io_method_debug,
3575
+ domain,
3576
+ admit_non_ssl,
3577
+ no_debug_client,
3578
+ reserved = args
3579
+ tcp_ssl_server_method = tcp_ssl_server_method.nne :test__tcp_ssl_server__io_method
3580
+ domain = domain.nne "localhost"
3581
+ http_server_port = http_server_port.nne 8003
3582
+ no_debug_client = no_debug_client.nne
3583
+ server_thread = send tcp_ssl_server_method,
3584
+ [
3585
+ http_processing_method,
3586
+ http_processing_method_args,
3587
+ http_server_port,
3588
+ http_ip_addr,
3589
+ priv_pemfile,
3590
+ cert_pem_file,
3591
+ extra_cert_pem_files,
3592
+ ssl_cert_pkey_chain_method,
3593
+ debug_tcp_ssl_server_method,
3594
+ happy_with_request,
3595
+ io_method,
3596
+ io_method_debug,
3597
+ admit_non_ssl,
3598
+ ]
3599
+
3600
+ thread_2 = Thread.new {
3601
+ loop {
3602
+ response = test__file_read__uri_root [
3603
+ domain,
3604
+ http_server_port,
3605
+ admit_non_ssl,
3606
+ no_debug_client.negate_me,
3607
+ ]
3608
+ sleep 2
3609
+ }
3610
+ }
3611
+ server_thread.first.join
3612
+
3613
+ true
3614
+ end
3615
+
3616
+
3430
3617
  # tests test__tcp_ssl_server__io_method and opens
3431
3618
  # another thread for the client
3432
3619
  def test__tcp_ssl_server__get_root args = ARGV
@@ -4113,6 +4300,55 @@ n8mFEtUKobsK
4113
4300
  ],
4114
4301
  ],
4115
4302
 
4303
+ [
4304
+ "base_case_double_inverse", [ :a, "[", "[", :b, "]", "]", :c], [
4305
+ :array_unflatten_base, [
4306
+ [:a, [[ :b, ]], :c],
4307
+ :shallow.negate_me,
4308
+ :debug.negate_me,
4309
+ :reserved_tokens.to_nil,
4310
+ :inverse,
4311
+ ]
4312
+ ],
4313
+ ],
4314
+
4315
+ [
4316
+ "base_escape_case_inverse", [ :a, "[[", :b, "]]", :c], [
4317
+ :array_unflatten_base, [
4318
+ [:a, "[", :b, "]", :c],
4319
+ :shallow.negate_me,
4320
+ :debug.negate_me,
4321
+ :reserved_tokens.to_nil,
4322
+ :inverse,
4323
+ ]
4324
+ ],
4325
+ ],
4326
+
4327
+ [
4328
+ "base_mixed_case_inverse", [ :a, "[[", "[", :b, "]", "]]", :c], [
4329
+ :array_unflatten_base, [
4330
+ [:a, "[", [ :b ], "]", :c],
4331
+ :shallow.negate_me,
4332
+ :debug.negate_me,
4333
+ :reserved_tokens.to_nil,
4334
+ :inverse,
4335
+ ]
4336
+ ],
4337
+ ],
4338
+
4339
+
4340
+ [
4341
+ "open_left_base_mixed_case_inverse", [ :a, "]]", "[[", "[", :b, "]", "]]", :c], [
4342
+ :array_unflatten_base, [
4343
+ [:a, "]", "[", [ :b ], "]", :c],
4344
+ :shallow.negate_me,
4345
+ :debug.negate_me,
4346
+ :reserved_tokens.to_nil,
4347
+ :inverse,
4348
+ ]
4349
+ ],
4350
+ ],
4351
+
4116
4352
 
4117
4353
  ]
4118
4354
  test__tester test_cases
@@ -4217,50 +4453,6 @@ n8mFEtUKobsK
4217
4453
  }.map(&method("expect_equal")).all?
4218
4454
  end
4219
4455
 
4220
- # test #rest_request
4221
- # for now, the parameters must still be hardcoded.
4222
- def test__rest_request__with_ayt args=ARGV
4223
- require 'json'
4224
- stderr = @memory[:stderr]
4225
-
4226
- url = "https://owl.loftweb.nl:55031/4/3-roOomydev"
4227
- json =<<-ENDHEREDOC
4228
- {
4229
- "operation" : "AYT",
4230
- "version" : {
4231
- "client" : "X",
4232
- "protocol" : {
4233
- "domain_model" : "4",
4234
- "API" : "3"
4235
- }
4236
- }
4237
- }
4238
- ENDHEREDOC
4239
- payload = "#{json}"
4240
-
4241
- auth_user = "web"
4242
- password = "vadim"
4243
- method = :post
4244
- method = :get
4245
- timeout = 600
4246
- verify_ssl = true
4247
- payload = "#{json}"
4248
- headers = ""
4249
- request_execution = send :rest_response__request_base, [
4250
- url,
4251
- payload,
4252
- verify_ssl,
4253
- headers,
4254
- method,
4255
- auth_user,
4256
- password,
4257
- timeout,
4258
- ]
4259
- parsed_json = JSON.parse request_execution.first.to_s
4260
- [parsed_json]
4261
- end
4262
-
4263
-
4264
4456
 
4265
4457
 
4266
4458
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.25535011
4
+ version: 0.6.25539312
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribamar Santarosa