cocos 0.4.2 → 0.4.3
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 +4 -4
- data/CHANGELOG.md +1 -1
- data/Manifest.txt +1 -0
- data/lib/cocos/find_file.rb +4 -4
- data/lib/cocos/version.rb +1 -1
- data/lib/cocos/words.rb +86 -0
- data/lib/cocos.rb +13 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8bef9f661e35af9a5b936f7e37a27e73d0554e361e4d5f3a722305db037b6dc9
|
|
4
|
+
data.tar.gz: c347765ba3ce339a52541c801bb10fb6ce39800facd619773a6072bddffd16c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f6d70adfcfd0eb010daf8b7a23e8ae402a6186f7242d097e8a1fb99ad6187105567727077c033760b724c9863b6da64efe4a960ac8dd6c9ff961a6b485a9b89
|
|
7
|
+
data.tar.gz: d0b49d70ac8a369ed7d1f1d51b793edcffd468575592a1cb229c09494d16f7ff63b5479e385858d621190981c92e14c307cb7ebab66c62669fc12e94b69ce09b
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
data/lib/cocos/find_file.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
module Cocos
|
|
2
|
+
module Find
|
|
1
3
|
|
|
2
4
|
|
|
3
5
|
##
|
|
@@ -13,8 +15,6 @@
|
|
|
13
15
|
## always return absolute (expanded) path - why? why not?
|
|
14
16
|
|
|
15
17
|
|
|
16
|
-
module Kernel
|
|
17
|
-
|
|
18
18
|
def find_file!( name, path: )
|
|
19
19
|
filepath = find_file( name, path: path )
|
|
20
20
|
raise Errno::ENOENT, "file #{name.inspect} not found; looking in path #{path.inspect}" if filepath.nil?
|
|
@@ -79,5 +79,5 @@ def find_dir( name, path: [] )
|
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
end
|
|
82
|
+
end ## module Find
|
|
83
|
+
end ## module Cocos
|
data/lib/cocos/version.rb
CHANGED
data/lib/cocos/words.rb
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
|
|
2
|
+
###
|
|
3
|
+
##
|
|
4
|
+
## try new style with Cocos::FileUtils or Cocos::IO module
|
|
5
|
+
## and include module into Kernel (instead of directly)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
module Cocos
|
|
9
|
+
module FileUtils
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## "words" or "word array.
|
|
14
|
+
##
|
|
15
|
+
## follows %w[] rules
|
|
16
|
+
## splits on whitespace (space or newline)
|
|
17
|
+
## BUT include support for inline comments!!!!
|
|
18
|
+
##
|
|
19
|
+
## %w[apple banana cherry]
|
|
20
|
+
## => ["apple", "banana", "cherry"]
|
|
21
|
+
## note - allows more than one word on a line!!!!
|
|
22
|
+
##
|
|
23
|
+
## %w[
|
|
24
|
+
## ruby
|
|
25
|
+
## python
|
|
26
|
+
## javascript
|
|
27
|
+
## go
|
|
28
|
+
## ]
|
|
29
|
+
## => ["ruby", "python", "javascript", "go"]
|
|
30
|
+
##
|
|
31
|
+
## %w[] is a shorthand syntax (known as a percent literal)
|
|
32
|
+
## used to create an array of strings.
|
|
33
|
+
## It allows you to write an array of words without typing
|
|
34
|
+
## repetitive quotation marks and commas.
|
|
35
|
+
## Instead, you separate each item using whitespace (spaces or newlines).
|
|
36
|
+
## note - You CANNOT use standard # comments inside %w[].
|
|
37
|
+
## Ruby treats the # character as part of a literal string, which will ruin your array.
|
|
38
|
+
##
|
|
39
|
+
##
|
|
40
|
+
## todo/check:
|
|
41
|
+
## Option 1: The "Strict Space" Rule (Simplest & Safest)
|
|
42
|
+
## In most text/config files, a comment is separated by a space
|
|
43
|
+
## (e.g., key = value # comment).
|
|
44
|
+
## If a # is glued to a word without a space, it is usually part of the data
|
|
45
|
+
## (like a hex color #ffffff or a tag #important).
|
|
46
|
+
## You can modify your code to only remove # if it is preceded by whitespace
|
|
47
|
+
## color#ff0000 # red
|
|
48
|
+
## color = #ff0000 # red
|
|
49
|
+
## check - if this is how # is handled in yaml?
|
|
50
|
+
## - Inline Comments: A # can be placed at the end of a line of data,
|
|
51
|
+
## but it must be preceded by a space.
|
|
52
|
+
## e.g. port: 8080# This will break or fail to parse correctly
|
|
53
|
+
##
|
|
54
|
+
## e.g. use
|
|
55
|
+
## line.sub( ??, '' ).strip
|
|
56
|
+
|
|
57
|
+
def parse_words( txt )
|
|
58
|
+
words = [] ## array of strings
|
|
59
|
+
txt.each_line( chomp: true ) do |line|
|
|
60
|
+
|
|
61
|
+
line = line.strip
|
|
62
|
+
|
|
63
|
+
next if line.empty? || line.start_with?('#')
|
|
64
|
+
|
|
65
|
+
## strip (inline) end-of-line comments (from line) too - keep why? why not?
|
|
66
|
+
## ## (eat-up) REQUIRED leading (preceding) space(s) too - why? why not?
|
|
67
|
+
line = line.sub( /[ \t]+#.*/, '' )
|
|
68
|
+
|
|
69
|
+
## support __END__ marker for inline comments
|
|
70
|
+
break if line == '__END__'
|
|
71
|
+
|
|
72
|
+
words += line.split( /[ \t]+/ )
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
words
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
alias_method :parse_wordarray, :parse_words
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
## todo - add (missing) read_words/wordarray too - why? why not?
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
end # module FileUtils
|
|
86
|
+
end # module Cocos
|
data/lib/cocos.rb
CHANGED
|
@@ -435,6 +435,19 @@ end # module Kernel
|
|
|
435
435
|
|
|
436
436
|
|
|
437
437
|
|
|
438
|
+
require_relative 'cocos/words' ## pulls in parse_words/wordarray
|
|
439
|
+
|
|
440
|
+
###
|
|
441
|
+
## try add kernel global methods via module
|
|
442
|
+
module Kernel
|
|
443
|
+
include Cocos::FileUtils
|
|
444
|
+
include Cocos::Find # e.g. find_file, find_dir, etc.
|
|
445
|
+
end ## module Kernel
|
|
446
|
+
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
|
|
450
|
+
|
|
438
451
|
|
|
439
452
|
####
|
|
440
453
|
# convenience alias (use plural or singual)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cocos
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gerald Bauer
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-09-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: csvreader
|
|
@@ -119,6 +119,7 @@ files:
|
|
|
119
119
|
- lib/cocos/env.rb
|
|
120
120
|
- lib/cocos/find_file.rb
|
|
121
121
|
- lib/cocos/version.rb
|
|
122
|
+
- lib/cocos/words.rb
|
|
122
123
|
homepage: https://github.com/rubycocos/cocos
|
|
123
124
|
licenses:
|
|
124
125
|
- Public Domain
|