cocos 0.1.1 → 0.1.2
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/README.md +12 -0
- data/lib/cocos/version.rb +1 -1
- data/lib/cocos.rb +32 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e49de20835fe070c898b36630cfb952e42003b3c280cb4d4bceee2419fd3300a
|
4
|
+
data.tar.gz: b1475a217a8c265c877b7c320d56388a85683aa0cd8d040761c985094fda8ace
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c34680343ab16f40698560573e9aa110194371e4a534ba6b51f8af7d894b0dac2bead33025ce6602b10b4885b43939aec20c0c54ccba95cb11f37d03df46cfd8
|
7
|
+
data.tar.gz: 44c1ffd924648debe95f21b1b448709a817285a8521df50c2e2335ef761d014cbfa6aa42ed812949ecaef4bfa29850273714f6b3d94233c56bade179a3949fce
|
data/README.md
CHANGED
@@ -22,6 +22,7 @@ require 'time'
|
|
22
22
|
require 'date'
|
23
23
|
require 'json'
|
24
24
|
require 'yaml'
|
25
|
+
require 'base64'
|
25
26
|
require 'fileutils'
|
26
27
|
|
27
28
|
require 'uri'
|
@@ -86,6 +87,9 @@ And so on.
|
|
86
87
|
|
87
88
|
_Read / parse convenience short-cut helpers_
|
88
89
|
|
90
|
+
`read_blob( path )` <br>
|
91
|
+
also known as `read_binary` or `read_bin`
|
92
|
+
|
89
93
|
|
90
94
|
`read_text( path )` <br>
|
91
95
|
also known as `read_txt`
|
@@ -94,6 +98,7 @@ also known as `read_txt`
|
|
94
98
|
`read_lines( path )`
|
95
99
|
|
96
100
|
|
101
|
+
|
97
102
|
`read_json( path )` / `parse_json( str )`
|
98
103
|
|
99
104
|
|
@@ -106,6 +111,13 @@ note: comma-separated values (.csv) reading & parsing service
|
|
106
111
|
brought to you by the [**csvreader library / gem »**](https://github.com/rubycocos/csvreader/tree/master/csvreader)
|
107
112
|
|
108
113
|
|
114
|
+
`read_data( path )` / `parse_data( str )`
|
115
|
+
|
116
|
+
note: alternate shortcut / alias for `read_csv( path, headers: false )` / `parse_csv( str, headers: false )`
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
109
121
|
`read_tab( path )` / `parse_tab( str )`
|
110
122
|
|
111
123
|
note: tabulator (`\t`)-separated values (.tab) reading & parsing service
|
data/lib/cocos/version.rb
CHANGED
data/lib/cocos.rb
CHANGED
@@ -6,6 +6,7 @@ require 'time'
|
|
6
6
|
require 'date'
|
7
7
|
require 'json'
|
8
8
|
require 'yaml'
|
9
|
+
require 'base64' ## e.g. Base64.decode64,Base64.encode64,...
|
9
10
|
require 'fileutils'
|
10
11
|
|
11
12
|
require 'uri'
|
@@ -55,6 +56,19 @@ def parse_csv( str, headers: true )
|
|
55
56
|
end
|
56
57
|
|
57
58
|
|
59
|
+
### note: use read_data / parse_data
|
60
|
+
## for alternate shortcut for read_csv / parse_csv w/ headers: false
|
61
|
+
## returning arrays of strings
|
62
|
+
def read_data( path )
|
63
|
+
Csv.read( path )
|
64
|
+
end
|
65
|
+
|
66
|
+
def parse_data( str )
|
67
|
+
Csv.parse( str )
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
|
58
72
|
def read_tab( path )
|
59
73
|
Tab.read( path )
|
60
74
|
end
|
@@ -98,6 +112,9 @@ alias_method :parse_conf, :parse_ini
|
|
98
112
|
|
99
113
|
|
100
114
|
def read_text( path )
|
115
|
+
## todo/check: add universal newline mode or such?
|
116
|
+
## e.g. will always convert all
|
117
|
+
## newline variants (\n|\r|\n\r) to "universal" \n only
|
101
118
|
txt = File.open( path, 'r:utf-8' ) do |f|
|
102
119
|
f.read
|
103
120
|
end
|
@@ -106,6 +123,21 @@ end
|
|
106
123
|
alias_method :read_txt, :read_text
|
107
124
|
|
108
125
|
|
126
|
+
def read_blob( path )
|
127
|
+
blob = File.open( path, 'rb' ) do |f|
|
128
|
+
f.read
|
129
|
+
end
|
130
|
+
blob
|
131
|
+
end
|
132
|
+
alias_method :read_binary, :read_blob
|
133
|
+
alias_method :read_bin, :read_blob
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
## todo/check: remove \n (or\r or \r\n) from line
|
139
|
+
## ruby (by default) keeps the newline - follow tradition? why? why not?
|
140
|
+
##
|
109
141
|
def read_lines( path )
|
110
142
|
lines = File.open( path, 'r:utf-8' ) do |f|
|
111
143
|
f.readlines
|
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.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: csvreader
|