nrser 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,55 +1,5 @@
1
1
  module NRSER
2
2
  refine String do
3
- def squish
4
- NRSER.squish self
5
- end
6
-
7
-
8
- def unblock
9
- NRSER.unblock self
10
- end
11
-
12
-
13
- def dedent
14
- NRSER.dedent self
15
- end
16
-
17
-
18
- def indent *args
19
- NRSER.indent self, *args
20
- end
21
-
22
-
23
- def truncate *args
24
- NRSER.truncate self, *args
25
- end
26
-
27
-
28
- # See {NRSER.constantize}
29
- def constantize
30
- NRSER.constantize self
31
- end
32
-
33
- alias_method :to_const, :constantize
34
-
35
-
36
- # @return [Pathname]
37
- # Convert self into a {Pathname}
38
- #
39
- def to_pn
40
- Pathname.new self
41
- end
42
-
43
-
44
- def whitespace?
45
- NRSER.whitespace? self
46
- end
47
-
48
-
49
- # Calls {NRSER.ellipsis} on `self`.
50
- def ellipsis *args
51
- NRSER.ellipsis self, *args
52
- end
53
-
3
+ include NRSER::Ext::String
54
4
  end # refine String
55
5
  end # NRSER
@@ -59,6 +59,26 @@ module NRSER::RSpex::ExampleGroup
59
59
  file, line = instance_method.source_location
60
60
 
61
61
  name = "#{ klass.name }##{ metadata[:instance_method] }"
62
+
63
+ elsif metadata[:method]
64
+ # Class method
65
+ meth = metadata[:class].method metadata[:method]
66
+ file, line = meth.source_location
67
+ path = Pathname.new file
68
+ loc = "./#{ path.relative_path_from Pathname.getwd }:#{ line }"
69
+
70
+ spec_rel_path = \
71
+ "./#{ Pathname.new( spec_path ).relative_path_from Pathname.getwd }"
72
+
73
+ desc = [
74
+ "#{ metadata[:class].name }.#{ metadata[:method] }",
75
+ "(#{ loc })",
76
+ description,
77
+ "Spec (#{ spec_rel_path})"
78
+ ].compact.join " "
79
+
80
+ subj = meth
81
+
62
82
  else
63
83
  name = klass.name
64
84
 
@@ -1,5 +1,25 @@
1
+ require 'pathname'
2
+
1
3
  module NRSER
2
- VERSION = "0.1.3"
4
+ # Absolute, expanded path to the gem's root directory.
5
+ #
6
+ # Here in `//lib/nrser/version` so that it can be used via
7
+ #
8
+ # require 'nrser/version'
9
+ #
10
+ # without loading the entire module.
11
+ #
12
+ # @return [Pathname]
13
+ #
14
+ ROOT = ( Pathname.new( __FILE__ ).dirname / '..' / '..' ).expand_path
15
+
16
+
17
+ # String version of the gem.
18
+ #
19
+ # @return [String]
20
+ #
21
+ VERSION = "0.1.4"
22
+
3
23
 
4
24
  module Version
5
25
 
@@ -0,0 +1,28 @@
1
+ describe_spec_file(
2
+ spec_path: __FILE__,
3
+ module: NRSER,
4
+ method: :slice?,
5
+ ) do
6
+
7
+ it_behaves_like "function",
8
+ mapping: {
9
+ [ [1, 2, 3], [] ] => true,
10
+ [ [1, 2, 3], [1] ] => true,
11
+ [ [1, 2, 3], [1, 2] ] => true,
12
+ [ [1, 2, 3], [1, 2, 3] ] => true,
13
+ [ [1, 2, 3], [2] ] => true,
14
+ [ [1, 2, 3], [2, 3] ] => true,
15
+ [ [1, 2, 3], [3] ] => true,
16
+ [ [1, 2, 1, 2, 3], [1, 2, 3] ] => true,
17
+
18
+ [ [1, 2, 3], [1, 3] ] => false,
19
+ [ [1, 2, 3], [1, 2, 3, 4] ] => false,
20
+
21
+ [ [1, 2, 3], [4] ] => false,
22
+ [ [1, 2, 3], [4, 5] ] => false,
23
+
24
+ # Doesn't work for now...
25
+ # [(1..5), (2..3)] => true,
26
+ }
27
+
28
+ end # spec file
@@ -0,0 +1,17 @@
1
+ describe_spec_file(
2
+ spec_path: __FILE__,
3
+ module: NRSER,
4
+ method: :words,
5
+ ) do
6
+ it_behaves_like "function",
7
+ mapping: {
8
+ 'some-words' => ['some', 'words'],
9
+ 'NRSER' => ['NRSER'],
10
+ 'NRSER::Text' => ['NRSER', 'Text'],
11
+
12
+ # Doesn't de-camel
13
+ 'NRSER::RSpex' => ['NRSER', 'RSpex'],
14
+
15
+
16
+ }
17
+ end
@@ -0,0 +1,61 @@
1
+ require 'nrser/labs/globlin'
2
+
3
+ describe_spec_file(
4
+ spec_path: __FILE__,
5
+ class: NRSER::Labs::Globlin,
6
+ labs: true, # run with `LABS=1 rspec ...` to include
7
+ ) do
8
+ it "scratch" do
9
+
10
+ items = [
11
+ 'qb/git/ignore',
12
+ 'qb/call',
13
+ 'qb/dev/ref/repo/git',
14
+ 'qb/dump/vars',
15
+ 'qb/facts',
16
+ 'qb/git/check/clean',
17
+ 'qb/git/repo',
18
+ 'qb/github/pages/setup',
19
+ 'qb/osx/git/change_case',
20
+ 'qb/osx/notif',
21
+ 'qb/pkg/bump',
22
+ 'qb/project',
23
+ 'qb/role',
24
+ 'qb/role/qb',
25
+ 'qb/rspex/generate',
26
+ 'qb/rspex/issue',
27
+ 'qb/ruby/bundler',
28
+ 'qb/ruby/dependency',
29
+ 'qb/ruby/gem/bin_stubs',
30
+ 'qb/ruby/gem/build',
31
+ 'qb/ruby/gem/install',
32
+ 'qb/ruby/gem/new',
33
+ 'qb/ruby/gem/release',
34
+ 'qb/ruby/rspec/setup',
35
+ 'qb/ruby/yard/clean',
36
+ 'qb/ruby/yard/config',
37
+ 'qb/ruby/yard/setup',
38
+ 'qb/yarn/setup',
39
+ 'qb.git_submodule_update',
40
+ 'qb.hack_npm',
41
+ 'qb.install',
42
+ 'qb.npm_package',
43
+ 'qb.package_json_info',
44
+ 'qb.qb_setup',
45
+ 'qb.read_json',
46
+ 'qb.unhack_gem',
47
+ 'qb.yarn_release',
48
+ ]
49
+
50
+ def split_item item
51
+ item.split( /[\.\/]/ )
52
+ end
53
+
54
+ g = NRSER::Globlin.new \
55
+ split: [/[\/\.]/, :words],
56
+ ignore: [:case]
57
+
58
+ g.find_only! 'git/repo'
59
+
60
+ end
61
+ end
@@ -0,0 +1,87 @@
1
+ require 'nrser/labs/index'
2
+
3
+ describe_spec_file(
4
+ spec_path: __FILE__,
5
+ class: NRSER::Labs::Index,
6
+ labs: true, # run with `LABS=1 rspec ...` to include
7
+ ) do
8
+ it "scratch" do
9
+
10
+ items = [
11
+ 'qb/git/ignore',
12
+ 'qb/call',
13
+ 'qb/dev/ref/repo/git',
14
+ 'qb/dump/vars',
15
+ 'qb/facts',
16
+ 'qb/git/check/clean',
17
+ 'qb/git/repo',
18
+ 'qb/github/pages/setup',
19
+ 'qb/osx/git/change_case',
20
+ 'qb/osx/notif',
21
+ 'qb/pkg/bump',
22
+ 'qb/project',
23
+ 'qb/role',
24
+ 'qb/role/qb',
25
+ 'qb/rspex/generate',
26
+ 'qb/rspex/issue',
27
+ 'qb/ruby/bundler',
28
+ 'qb/ruby/dependency',
29
+ 'qb/ruby/gem/bin_stubs',
30
+ 'qb/ruby/gem/build',
31
+ 'qb/ruby/gem/install',
32
+ 'qb/ruby/gem/new',
33
+ 'qb/ruby/gem/release',
34
+ 'qb/ruby/rspec/setup',
35
+ 'qb/ruby/yard/clean',
36
+ 'qb/ruby/yard/config',
37
+ 'qb/ruby/yard/setup',
38
+ 'qb/yarn/setup',
39
+ 'qb.git_submodule_update',
40
+ 'qb.hack_npm',
41
+ 'qb.install',
42
+ 'qb.npm_package',
43
+ 'qb.package_json_info',
44
+ 'qb.qb_setup',
45
+ 'qb.read_json',
46
+ 'qb.unhack_gem',
47
+ 'qb.yarn_release',
48
+ ]
49
+
50
+ def split_item item
51
+ item.split( /[\.\/]/ )
52
+ end
53
+
54
+ expect( split_item 'qb/git/repo' ).to eq ['qb', 'git', 'repo']
55
+ expect( split_item 'qb/git/repo' ).to have_attributes length: 3
56
+
57
+ # Index one thing
58
+ index = described_class.new( items ) { |item|
59
+ split_item( item ).length
60
+ }
61
+
62
+ expect( index.key_for 'qb/git/repo' ).to be 3
63
+
64
+ expect( index.keys ).to include 2, 3, 4, 5
65
+
66
+ expect( index[3] ).to include 'qb/role/qb'
67
+
68
+ expect( index[3] ).to eq Set.new items.select { |item|
69
+ split_item( item ).length == 3
70
+ }
71
+
72
+ expect( true ).to be false
73
+
74
+ # # Index multiple things
75
+ # names_index = NRSER::Index.new( items ) { |item|
76
+ # seg = item.split( /\.\// ).length,
77
+ #
78
+ # {
79
+ # seg_count: segs.length,
80
+ # namespace: segs.first,
81
+ # }
82
+ # }
83
+ #
84
+ # names_index[:seg_count]
85
+
86
+ end
87
+ end
@@ -7,6 +7,12 @@ require 'nrser'
7
7
  require 'nrser/logger'
8
8
  require 'nrser/rspex'
9
9
 
10
+ RSpec.configure do |config|
11
+ unless ENV['LABS']
12
+ config.filter_run_excluding labs: true
13
+ end
14
+ end
15
+
10
16
 
11
17
  # Dumping ground for classes and modules that we need to create for tests.
12
18
  #
@@ -30,6 +36,16 @@ LOG_LEVELS = {
30
36
 
31
37
  BAD_LOG_LEVELS = [:blah, -1, 6, "BLAH"]
32
38
 
39
+
40
+ if ENV['DEBUG']
41
+ SemanticLogger.default_level = :debug
42
+ SemanticLogger.add_appender(
43
+ io: $stderr,
44
+ formatter: { color: {ap: { multiline: true } }}
45
+ )
46
+ end
47
+
48
+
33
49
  def expect_to_log &block
34
50
  expect(&block).to output.to_stderr_from_any_process
35
51
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nrser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - nrser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-31 00:00:00.000000000 Z
11
+ date: 2018-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hamster
@@ -227,6 +227,7 @@ files:
227
227
  - lib/nrser/ext.rb
228
228
  - lib/nrser/ext/enumerable.rb
229
229
  - lib/nrser/ext/pathname.rb
230
+ - lib/nrser/ext/string.rb
230
231
  - lib/nrser/ext/tree.rb
231
232
  - lib/nrser/functions.rb
232
233
  - lib/nrser/functions/array.rb
@@ -234,6 +235,8 @@ files:
234
235
  - lib/nrser/functions/enumerable.rb
235
236
  - lib/nrser/functions/enumerable/find_all_map.rb
236
237
  - lib/nrser/functions/enumerable/find_map.rb
238
+ - lib/nrser/functions/enumerable/include_slice.rb
239
+ - lib/nrser/functions/enumerable/include_slice/array_include_slice.rb
237
240
  - lib/nrser/functions/exception.rb
238
241
  - lib/nrser/functions/git.rb
239
242
  - lib/nrser/functions/hash.rb
@@ -259,6 +262,7 @@ files:
259
262
  - lib/nrser/functions/text/indentation.rb
260
263
  - lib/nrser/functions/text/lines.rb
261
264
  - lib/nrser/functions/text/word_wrap.rb
265
+ - lib/nrser/functions/text/words.rb
262
266
  - lib/nrser/functions/tree.rb
263
267
  - lib/nrser/functions/tree/each_branch.rb
264
268
  - lib/nrser/functions/tree/leaves.rb
@@ -266,6 +270,11 @@ files:
266
270
  - lib/nrser/functions/tree/map_leaves.rb
267
271
  - lib/nrser/functions/tree/map_tree.rb
268
272
  - lib/nrser/functions/tree/transform.rb
273
+ - lib/nrser/labs.rb
274
+ - lib/nrser/labs/globlin.rb
275
+ - lib/nrser/labs/index.rb
276
+ - lib/nrser/labs/unicode_math.rb
277
+ - lib/nrser/labs/where.rb
269
278
  - lib/nrser/logger.rb
270
279
  - lib/nrser/mean_streak.rb
271
280
  - lib/nrser/mean_streak/document.rb
@@ -300,8 +309,6 @@ files:
300
309
  - lib/nrser/rspex/example_group/describe_x.rb
301
310
  - lib/nrser/rspex/format.rb
302
311
  - lib/nrser/rspex/shared_examples.rb
303
- - lib/nrser/temp/unicode_math.rb
304
- - lib/nrser/temp/where.rb
305
312
  - lib/nrser/types.rb
306
313
  - lib/nrser/types/any.rb
307
314
  - lib/nrser/types/array.rb
@@ -337,6 +344,7 @@ files:
337
344
  - spec/nrser/functions/enumerable/find_bounded_spec.rb
338
345
  - spec/nrser/functions/enumerable/find_map_spec.rb
339
346
  - spec/nrser/functions/enumerable/find_only_spec.rb
347
+ - spec/nrser/functions/enumerable/include_slice_spec.rb
340
348
  - spec/nrser/functions/enumerable/to_h_by_spec.rb
341
349
  - spec/nrser/functions/exception/format_exception_spec.rb
342
350
  - spec/nrser/functions/hash/bury_spec.rb
@@ -351,12 +359,15 @@ files:
351
359
  - spec/nrser/functions/text/dedent/gotchas_spec.rb
352
360
  - spec/nrser/functions/text/dedent_spec.rb
353
361
  - spec/nrser/functions/text/indent_spec.rb
362
+ - spec/nrser/functions/text/words_spec.rb
354
363
  - spec/nrser/functions/tree/each_branch_spec.rb
355
364
  - spec/nrser/functions/tree/leaves_spec.rb
356
365
  - spec/nrser/functions/tree/map_branch_spec.rb
357
366
  - spec/nrser/functions/tree/map_tree_spec.rb
358
367
  - spec/nrser/functions/tree/transform_spec.rb
359
368
  - spec/nrser/functions/tree/transformer_spec.rb
369
+ - spec/nrser/labs/globlin_spec.rb
370
+ - spec/nrser/labs/index_spec.rb
360
371
  - spec/nrser/logger/dest_spec.rb
361
372
  - spec/nrser/logger/die_spec.rb
362
373
  - spec/nrser/logger/install_spec.rb
@@ -425,6 +436,7 @@ test_files:
425
436
  - spec/nrser/functions/enumerable/find_bounded_spec.rb
426
437
  - spec/nrser/functions/enumerable/find_map_spec.rb
427
438
  - spec/nrser/functions/enumerable/find_only_spec.rb
439
+ - spec/nrser/functions/enumerable/include_slice_spec.rb
428
440
  - spec/nrser/functions/enumerable/to_h_by_spec.rb
429
441
  - spec/nrser/functions/exception/format_exception_spec.rb
430
442
  - spec/nrser/functions/hash/bury_spec.rb
@@ -439,12 +451,15 @@ test_files:
439
451
  - spec/nrser/functions/text/dedent/gotchas_spec.rb
440
452
  - spec/nrser/functions/text/dedent_spec.rb
441
453
  - spec/nrser/functions/text/indent_spec.rb
454
+ - spec/nrser/functions/text/words_spec.rb
442
455
  - spec/nrser/functions/tree/each_branch_spec.rb
443
456
  - spec/nrser/functions/tree/leaves_spec.rb
444
457
  - spec/nrser/functions/tree/map_branch_spec.rb
445
458
  - spec/nrser/functions/tree/map_tree_spec.rb
446
459
  - spec/nrser/functions/tree/transform_spec.rb
447
460
  - spec/nrser/functions/tree/transformer_spec.rb
461
+ - spec/nrser/labs/globlin_spec.rb
462
+ - spec/nrser/labs/index_spec.rb
448
463
  - spec/nrser/logger/dest_spec.rb
449
464
  - spec/nrser/logger/die_spec.rb
450
465
  - spec/nrser/logger/install_spec.rb