cocos 0.0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0c0c91a32d9421aa68462fe03987ffd9c0e7ec6b8ef56acb4d3ed2b8f148ed6d
4
- data.tar.gz: a7fa42e171cd6480f264cadeb196b287f2a9f46af1b0fa4a284295fee030bfdc
3
+ metadata.gz: 805a278e6d9393cd8d8dc34993735c77656e0dd35cbc8639f231fd2379b9633d
4
+ data.tar.gz: f29c8e08820c5cf7c7e852d081466bd49532a0fd7b6edd790bdbd3bb6c329ec9
5
5
  SHA512:
6
- metadata.gz: 5aa60909fb45f952871b8a7f0fb1afac09bbf73bda390d3f1a1ca51a4f91454621dffc44cad32552ec5ce3d9f731168b7a659a3529d564650b3902fc57eac07f
7
- data.tar.gz: 0ee9fde4d05b4a82101cc023e01833b1a946579fbf5ec321076e6247e1b1387516830e847a0bccc4070f1c34772dd53d47f7e7029e06fd300fcf8a5c9e7c6413
6
+ metadata.gz: 58806d72f9e21997a77d5b5ef7ef066367929e73bda712939c20508244be6774686a10df3de213298f1a61711607590d4cb4665946dcaebc46bc75b402767cca
7
+ data.tar.gz: 28e6e3f7cb54a18d179c3f5ef3cf15f4a100324f371b16ddb85a58019abb4d80be42611dad2bebd3f9e84d49c41185bc6b08b1b0074debac24e2098977913658
data/LICENSE.md ADDED
@@ -0,0 +1,116 @@
1
+ CC0 1.0 Universal
2
+
3
+ Statement of Purpose
4
+
5
+ The laws of most jurisdictions throughout the world automatically confer
6
+ exclusive Copyright and Related Rights (defined below) upon the creator and
7
+ subsequent owner(s) (each and all, an "owner") of an original work of
8
+ authorship and/or a database (each, a "Work").
9
+
10
+ Certain owners wish to permanently relinquish those rights to a Work for the
11
+ purpose of contributing to a commons of creative, cultural and scientific
12
+ works ("Commons") that the public can reliably and without fear of later
13
+ claims of infringement build upon, modify, incorporate in other works, reuse
14
+ and redistribute as freely as possible in any form whatsoever and for any
15
+ purposes, including without limitation commercial purposes. These owners may
16
+ contribute to the Commons to promote the ideal of a free culture and the
17
+ further production of creative, cultural and scientific works, or to gain
18
+ reputation or greater distribution for their Work in part through the use and
19
+ efforts of others.
20
+
21
+ For these and/or other purposes and motivations, and without any expectation
22
+ of additional consideration or compensation, the person associating CC0 with a
23
+ Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
24
+ and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
25
+ and publicly distribute the Work under its terms, with knowledge of his or her
26
+ Copyright and Related Rights in the Work and the meaning and intended legal
27
+ effect of CC0 on those rights.
28
+
29
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
30
+ protected by copyright and related or neighboring rights ("Copyright and
31
+ Related Rights"). Copyright and Related Rights include, but are not limited
32
+ to, the following:
33
+
34
+ i. the right to reproduce, adapt, distribute, perform, display, communicate,
35
+ and translate a Work;
36
+
37
+ ii. moral rights retained by the original author(s) and/or performer(s);
38
+
39
+ iii. publicity and privacy rights pertaining to a person's image or likeness
40
+ depicted in a Work;
41
+
42
+ iv. rights protecting against unfair competition in regards to a Work,
43
+ subject to the limitations in paragraph 4(a), below;
44
+
45
+ v. rights protecting the extraction, dissemination, use and reuse of data in
46
+ a Work;
47
+
48
+ vi. database rights (such as those arising under Directive 96/9/EC of the
49
+ European Parliament and of the Council of 11 March 1996 on the legal
50
+ protection of databases, and under any national implementation thereof,
51
+ including any amended or successor version of such directive); and
52
+
53
+ vii. other similar, equivalent or corresponding rights throughout the world
54
+ based on applicable law or treaty, and any national implementations thereof.
55
+
56
+ 2. Waiver. To the greatest extent permitted by, but not in contravention of,
57
+ applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
58
+ unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
59
+ and Related Rights and associated claims and causes of action, whether now
60
+ known or unknown (including existing as well as future claims and causes of
61
+ action), in the Work (i) in all territories worldwide, (ii) for the maximum
62
+ duration provided by applicable law or treaty (including future time
63
+ extensions), (iii) in any current or future medium and for any number of
64
+ copies, and (iv) for any purpose whatsoever, including without limitation
65
+ commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
66
+ the Waiver for the benefit of each member of the public at large and to the
67
+ detriment of Affirmer's heirs and successors, fully intending that such Waiver
68
+ shall not be subject to revocation, rescission, cancellation, termination, or
69
+ any other legal or equitable action to disrupt the quiet enjoyment of the Work
70
+ by the public as contemplated by Affirmer's express Statement of Purpose.
71
+
72
+ 3. Public License Fallback. Should any part of the Waiver for any reason be
73
+ judged legally invalid or ineffective under applicable law, then the Waiver
74
+ shall be preserved to the maximum extent permitted taking into account
75
+ Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
76
+ is so judged Affirmer hereby grants to each affected person a royalty-free,
77
+ non transferable, non sublicensable, non exclusive, irrevocable and
78
+ unconditional license to exercise Affirmer's Copyright and Related Rights in
79
+ the Work (i) in all territories worldwide, (ii) for the maximum duration
80
+ provided by applicable law or treaty (including future time extensions), (iii)
81
+ in any current or future medium and for any number of copies, and (iv) for any
82
+ purpose whatsoever, including without limitation commercial, advertising or
83
+ promotional purposes (the "License"). The License shall be deemed effective as
84
+ of the date CC0 was applied by Affirmer to the Work. Should any part of the
85
+ License for any reason be judged legally invalid or ineffective under
86
+ applicable law, such partial invalidity or ineffectiveness shall not
87
+ invalidate the remainder of the License, and in such case Affirmer hereby
88
+ affirms that he or she will not (i) exercise any of his or her remaining
89
+ Copyright and Related Rights in the Work or (ii) assert any associated claims
90
+ and causes of action with respect to the Work, in either case contrary to
91
+ Affirmer's express Statement of Purpose.
92
+
93
+ 4. Limitations and Disclaimers.
94
+
95
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
96
+ surrendered, licensed or otherwise affected by this document.
97
+
98
+ b. Affirmer offers the Work as-is and makes no representations or warranties
99
+ of any kind concerning the Work, express, implied, statutory or otherwise,
100
+ including without limitation warranties of title, merchantability, fitness
101
+ for a particular purpose, non infringement, or the absence of latent or
102
+ other defects, accuracy, or the present or absence of errors, whether or not
103
+ discoverable, all to the greatest extent permissible under applicable law.
104
+
105
+ c. Affirmer disclaims responsibility for clearing rights of other persons
106
+ that may apply to the Work or any use thereof, including without limitation
107
+ any person's Copyright and Related Rights in the Work. Further, Affirmer
108
+ disclaims responsibility for obtaining any necessary consents, permissions
109
+ or other rights required for any use of the Work.
110
+
111
+ d. Affirmer understands and acknowledges that Creative Commons is not a
112
+ party to this document and has no duty or obligation with respect to this
113
+ CC0 or use of the Work.
114
+
115
+ For more information, please see
116
+ <http://creativecommons.org/publicdomain/zero/1.0/>
data/Manifest.txt CHANGED
@@ -1,4 +1,5 @@
1
1
  CHANGELOG.md
2
+ LICENSE.md
2
3
  Manifest.txt
3
4
  README.md
4
5
  Rakefile
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # cocos (code commons) - auto-incude quick-starter prelude & prolog
1
+ # cocos (code commons) - auto-include quick-starter prelude & prolog
2
2
 
3
3
 
4
4
  * home :: [github.com/rubycocos/cococs](https://github.com/rubycocos/cococs)
@@ -8,10 +8,121 @@
8
8
 
9
9
 
10
10
 
11
+ ## Intro - Why?
12
+
13
+
14
+ **Reason No. 1**
15
+
16
+ After starting of too many scripts (hundreds?) with
17
+ adding more and always repeating the same dozen modules with require e.g.:
18
+
19
+ ``` ruby
20
+ require 'pp'
21
+ require 'time'
22
+ require 'date'
23
+ require 'json'
24
+ require 'yaml'
25
+ require 'fileutils'
26
+
27
+ require 'uri'
28
+ require 'net/http'
29
+ require 'net/https'
30
+
31
+ ...
32
+ ```
33
+
34
+ why not use a more "inclusive" prelude & prolog and
35
+ replace the above with a one-liner:
36
+
37
+ ``` ruby
38
+ require 'cocos' # auto-include code commons quick-starter prelude & prolog
39
+ ```
40
+
41
+
42
+ **Reason No. 2**
43
+
44
+ After reading too many text files in utf-8 and always repeating the same open / read and code block dance e.g.:
45
+
46
+ ``` ruby
47
+ txt = File.read( "history.txt" )
48
+ # sorry - will NOT guarantee unicode utf8-encoding
49
+ # (e.g. on microsoft windows it is ISO Code Page (CP-1252
50
+ # or something - depending on your locale/culture/language)
51
+
52
+ txt = File.open( "history.txt", "r:utf-8" ) do |f|
53
+ f.read
54
+ end
55
+ ```
56
+
57
+ Or after reading and parsing too many json files
58
+ (by default always required utf-8 encoding)
59
+ and always repeating the same open / read and code block dance
60
+ again and again e.g.:
61
+
62
+ ``` ruby
63
+ txt = File.open( "history.json", "r:utf-8" ) do |f|
64
+ f.read
65
+ end
66
+ data = JSON.parse( txt )
67
+ ```
68
+
69
+ Why not use read convenience / short-cut helpers such as:
70
+
71
+ ``` ruby
72
+ txt = read_txt( "history.txt" )
73
+ data = read_json( "history.json" )
74
+ ```
75
+
76
+
77
+ And so on.
78
+
79
+
80
+
81
+
82
+
11
83
  ## Usage
12
84
 
85
+ ### Read / Parse
86
+
87
+ _Read / parse convenience short-cut helpers_
88
+
89
+
90
+ `read_text( path )` <br>
91
+ also known as `read_txt`
92
+
93
+
94
+ `read_lines( path )`
95
+
96
+
97
+ `read_json( path )` / `parse_json( str )`
98
+
99
+
100
+ `read_yaml( path )` / `parse_yaml( str )`
101
+
102
+
103
+ `read_csv( path, headers: true )` / `parse_csv( str, headers: true )`
104
+
105
+ note: comma-separated values (.csv) reading & parsing service
106
+ brought to you by the [**csvreader library / gem »**](https://github.com/rubycocos/csvreader/tree/master/csvreader)
107
+
108
+
109
+ `read_tab( path )` / `parse_tab( str )`
110
+
111
+ note: tabulator (`\t`)-separated values (.tab) reading & parsing service
112
+ brought to you by the [**tabreader library / gem »**](https://github.com/rubycocos/csvreader/tree/master/tabreader)
113
+
114
+
115
+
116
+
117
+ `read_ini( path )` / `parse_ini( str )` <br>
118
+ also known as `read_conf / parse_conf`
119
+
120
+ note: ini / conf(ig) reading & parsing service
121
+ brought to you by the [**iniparser library / gem »**](https://github.com/rubycocos/core/tree/master/iniparser)
122
+
123
+
13
124
 
14
- To be done
125
+ That's it for now.
15
126
 
16
127
 
17
128
 
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ Hoe.spec 'cocos' do
6
6
 
7
7
  self.version = Cocos::VERSION
8
8
 
9
- self.summary = "cocos (code commons) - auto-incude quick-starter prelude & prolog"
9
+ self.summary = "cocos (code commons) - auto-include quick-starter prelude & prolog"
10
10
  self.description = summary
11
11
 
12
12
  self.urls = { home: 'https://github.com/rubycocos/cocos' }
@@ -20,7 +20,11 @@ Hoe.spec 'cocos' do
20
20
 
21
21
  self.licenses = ['Public Domain']
22
22
 
23
- self.extra_deps = []
23
+ self.extra_deps = [
24
+ ['csvreader', '>= 1.2.5'],
25
+ ['tabreader', '>= 1.0.1'],
26
+ ['iniparser', '>= 1.0.1'],
27
+ ]
24
28
 
25
29
  self.spec_extras = {
26
30
  required_ruby_version: '>= 2.2.2'
data/lib/cocos/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Cocos
3
3
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
4
- MINOR = 0
4
+ MINOR = 1
5
5
  PATCH = 1
6
6
  VERSION = [MAJOR,MINOR,PATCH].join('.')
7
7
 
data/lib/cocos.rb CHANGED
@@ -16,12 +16,112 @@ require 'net/https'
16
16
  require 'optparse' ## used by monofile (built-in test/debug) command line tool
17
17
 
18
18
 
19
+ ###
20
+ # 3rd party gems
21
+ require 'csvreader'
22
+ require 'tabreader'
23
+ require 'iniparser'
24
+
19
25
 
20
26
  #####################
21
27
  # our own code
22
28
  require 'cocos/version' # note: let version always go first
23
29
 
24
30
 
31
+ ###
32
+ ## read/parse convenience/helper shortcuts
33
+
34
+
35
+ module Kernel
36
+
37
+
38
+
39
+ ## todo: add symbolize options a la read_json
40
+ ## add sep options
41
+ def read_csv( path, headers: true )
42
+ if headers
43
+ CsvHash.read( path )
44
+ else
45
+ Csv.read( path )
46
+ end
47
+ end
48
+
49
+ def parse_csv( str, headers: true )
50
+ if headers
51
+ CsvHash.parse( str )
52
+ else
53
+ Csv.parse( str )
54
+ end
55
+ end
56
+
57
+
58
+ def read_tab( path )
59
+ Tab.read( path )
60
+ end
61
+
62
+ def parse_tab( str )
63
+ Tab.parse( str )
64
+ end
65
+
66
+
67
+ ## todo: add symbolize options ???
68
+ def read_json( path )
69
+ JSON.parse( read_text( path ))
70
+ end
71
+
72
+ def parse_json( str )
73
+ JSON.parse( str )
74
+ end
75
+
76
+ ### todo/check: use parse_safeyaml or such? (is default anyway?) - why? why not?
77
+ def read_yaml( path )
78
+ YAML.load( read_text( path ))
79
+ end
80
+
81
+ def parse_yaml( str )
82
+ YAML.load( str )
83
+ end
84
+
85
+
86
+ def read_ini( path )
87
+ INI.load( read_text( path ))
88
+ end
89
+
90
+ def parse_ini( str )
91
+ INI.load( str )
92
+ end
93
+
94
+ alias_method :read_conf, :read_ini
95
+ alias_method :parse_conf, :parse_ini
96
+
97
+
98
+
99
+
100
+ def read_text( path )
101
+ txt = File.open( path, 'r:utf-8' ) do |f|
102
+ f.read
103
+ end
104
+ txt
105
+ end
106
+ alias_method :read_txt, :read_text
107
+
108
+
109
+ def read_lines( path )
110
+ lines = File.open( path, 'r:utf-8' ) do |f|
111
+ f.readlines
112
+ end
113
+ lines
114
+ end
115
+
116
+
117
+ end # module Kernel
118
+
119
+
120
+
121
+
122
+
123
+
124
+
25
125
  ####
26
126
  # convenience alias (use plural or singual)
27
127
  Coco = Cocos
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
@@ -10,6 +10,48 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2022-08-01 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: csvreader
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.2.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: tabreader
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: iniparser
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.0.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.0.1
13
55
  - !ruby/object:Gem::Dependency
14
56
  name: rdoc
15
57
  requirement: !ruby/object:Gem::Requirement
@@ -44,16 +86,18 @@ dependencies:
44
86
  - - "~>"
45
87
  - !ruby/object:Gem::Version
46
88
  version: '3.23'
47
- description: cocos (code commons) - auto-incude quick-starter prelude & prolog
89
+ description: cocos (code commons) - auto-include quick-starter prelude & prolog
48
90
  email: opensport@googlegroups.com
49
91
  executables: []
50
92
  extensions: []
51
93
  extra_rdoc_files:
52
94
  - CHANGELOG.md
95
+ - LICENSE.md
53
96
  - Manifest.txt
54
97
  - README.md
55
98
  files:
56
99
  - CHANGELOG.md
100
+ - LICENSE.md
57
101
  - Manifest.txt
58
102
  - README.md
59
103
  - Rakefile
@@ -83,5 +127,5 @@ requirements: []
83
127
  rubygems_version: 3.3.7
84
128
  signing_key:
85
129
  specification_version: 4
86
- summary: cocos (code commons) - auto-incude quick-starter prelude & prolog
130
+ summary: cocos (code commons) - auto-include quick-starter prelude & prolog
87
131
  test_files: []