cocos 0.1.2 → 0.2.0

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: e49de20835fe070c898b36630cfb952e42003b3c280cb4d4bceee2419fd3300a
4
- data.tar.gz: b1475a217a8c265c877b7c320d56388a85683aa0cd8d040761c985094fda8ace
3
+ metadata.gz: ed017038dd37ce27a71bb2835900c893dc916643e1f07e3809a18eca3f626265
4
+ data.tar.gz: 77f8a74da6add1f4af968364c3eecfbae7cb1dfd88bce89bb04490ad3932df44
5
5
  SHA512:
6
- metadata.gz: c34680343ab16f40698560573e9aa110194371e4a534ba6b51f8af7d894b0dac2bead33025ce6602b10b4885b43939aec20c0c54ccba95cb11f37d03df46cfd8
7
- data.tar.gz: 44c1ffd924648debe95f21b1b448709a817285a8521df50c2e2335ef761d014cbfa6aa42ed812949ecaef4bfa29850273714f6b3d94233c56bade179a3949fce
6
+ metadata.gz: c74889afd4f26afd75e8bcd306920f916646787cf3a85e3d94e2e67b0aed81bea4747c7e924d0dde40c2aa22661a61eed59c656ca1f57842ffd4d6f9099ae00b
7
+ data.tar.gz: f25f050d937978cf344530b6f347716f79f137b1e467518be2c5d506a39eedbe7f5bf16163047685cf18d4e34d7cf501cc200db6b1c876e0406b35f4d0968edc
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # cocos (code commons) - auto-include quick-starter prelude & prolog
2
2
 
3
3
 
4
- * home :: [github.com/rubycocos/cococs](https://github.com/rubycocos/cococs)
5
- * bugs :: [github.com/rubycocos/cococs/issues](https://github.com/rubycocos/cococs/issues)
4
+ * home :: [github.com/rubycocos/cocos](https://github.com/rubycocos/cocos)
5
+ * bugs :: [github.com/rubycocos/cocos/issues](https://github.com/rubycocos/cocos/issues)
6
6
  * gem :: [rubygems.org/gems/cocos](https://rubygems.org/gems/cocos)
7
7
  * rdoc :: [rubydoc.info/gems/cocos](http://rubydoc.info/gems/cocos)
8
8
 
data/Rakefile CHANGED
@@ -24,6 +24,7 @@ Hoe.spec 'cocos' do
24
24
  ['csvreader', '>= 1.2.5'],
25
25
  ['tabreader', '>= 1.0.1'],
26
26
  ['iniparser', '>= 1.0.1'],
27
+ ['webclient', '>= 0.2.2'],
27
28
  ]
28
29
 
29
30
  self.spec_extras = {
data/lib/cocos/version.rb CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  module Cocos
3
3
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
4
- MINOR = 1
5
- PATCH = 2
4
+ MINOR = 2
5
+ PATCH = 0
6
6
  VERSION = [MAJOR,MINOR,PATCH].join('.')
7
7
 
8
8
  def self.version
data/lib/cocos.rb CHANGED
@@ -12,7 +12,7 @@ require 'fileutils'
12
12
  require 'uri'
13
13
  require 'net/http'
14
14
  require 'net/https'
15
-
15
+ require 'cgi'
16
16
 
17
17
  require 'optparse' ## used by monofile (built-in test/debug) command line tool
18
18
 
@@ -23,6 +23,9 @@ require 'csvreader'
23
23
  require 'tabreader'
24
24
  require 'iniparser'
25
25
 
26
+ require 'webclient'
27
+
28
+
26
29
 
27
30
  #####################
28
31
  # our own code
@@ -146,9 +149,69 @@ def read_lines( path )
146
149
  end
147
150
 
148
151
 
149
- end # module Kernel
150
152
 
151
153
 
154
+ ######
155
+ # add writers
156
+
157
+ def write_json( path, data )
158
+ ###
159
+ ## todo/check: check if data is Webclient.Response?
160
+ ## if yes use res.json - why? why not?
161
+
162
+ dirname = File.dirname( path )
163
+ FileUtils.mkdir_p( dirname ) unless Dir.exist?( dirname )
164
+
165
+ ## note: pretty print/reformat json
166
+ File.open( path, "w:utf-8" ) do |f|
167
+ f.write( JSON.pretty_generate( data ))
168
+ end
169
+ end
170
+
171
+
172
+ def write_blob( path, blob )
173
+ ###
174
+ ## todo/check: check if data is Webclient.Response?
175
+ ## if yes use res.blob/body - why? why not?
176
+
177
+ dirname = File.dirname( path )
178
+ FileUtils.mkdir_p( dirname ) unless Dir.exist?( dirname )
179
+
180
+ File.open( path, "wb" ) do |f|
181
+ f.write( blob )
182
+ end
183
+ end
184
+ alias_method :write_binary, :write_blob
185
+ alias_method :write_bin, :write_blob
186
+
187
+
188
+ def write_text( path, text )
189
+ ###
190
+ ## todo/check: check if data is Webclient.Response?
191
+ ## if yes use res.text - why? why not?
192
+
193
+ dirname = File.dirname( path )
194
+ FileUtils.mkdir_p( dirname ) unless Dir.exist?( dirname )
195
+
196
+ File.open( path, "w:utf-8" ) do |f|
197
+ f.write( text )
198
+ end
199
+ end
200
+ alias_method :write_txt, :write_text
201
+
202
+
203
+
204
+ ######
205
+ # world wide web (www) support
206
+
207
+ def wget( url, **kwargs )
208
+ Webclient.get( url, **kwargs )
209
+ end
210
+ ## add alias www_get or web_get - why? why not?
211
+
212
+
213
+
214
+ end # module Kernel
152
215
 
153
216
 
154
217
 
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.2
4
+ version: 0.2.0
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-20 00:00:00.000000000 Z
11
+ date: 2022-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: csvreader
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.0.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: webclient
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 0.2.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 0.2.2
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rdoc
57
71
  requirement: !ruby/object:Gem::Requirement