kojo 0.3.1 → 0.3.2

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: b8608c2acf1ded769eac7140256f0cd9d7b172cc38c6ccf4c8b0cb5a3ef15fd7
4
- data.tar.gz: 0b94e504f27c2504ce3801b94c81f6b8f94d583189d529ffe6c6f73a00b19216
3
+ metadata.gz: 58d07f01002779c56f713af67a1717936ca02d2d845c2cf3156c598f0977dbc6
4
+ data.tar.gz: 6f36bb1868a7663470a0f20c1d874cc2fc75424b63cad2f4ad93cb45fc03948b
5
5
  SHA512:
6
- metadata.gz: 9086487049e3ddd2a0f4e2ce912ca451a1b67c1812301a967893e9bd701b762598343d7aef04a2d0a90dbfddb46e2da7eabfec48400a5a96ab152033d1860d73
7
- data.tar.gz: e9c040bd31fd36cca5ec7be5285a1098d42a26d216a4edb26bfb41dc9ea0b227f49e3ca435bd19c8427b89a313cf6fd1df631e332e519fb62924d968d95856c2
6
+ metadata.gz: 298d26612f5f151b46c93301195e5ed3e23ea1554f471ce229f501c3d332108964ef9e295041c0458afc879ace070bb458e61da2639c4e21762ce91c76da3e27
7
+ data.tar.gz: f9bb7831a3865f87ed2a87df8cd209e408bdb0c38ccac56080eb366aed7e9577fc82161ea698473d3bbdf58949ac52c51f11edcc3b22d7f9d4071f8f78e9efda
data/README.md CHANGED
@@ -31,6 +31,7 @@ Table of Contents
31
31
  - [Conditions and Loops with ERB](#conditions-and-loops-with-erb)
32
32
  - [Interactive Mode](#interactive-mode)
33
33
  - [Using from Ruby Code](#using-from-ruby-code)
34
+ - [Contributing / Support](#contributing--support)
34
35
 
35
36
  ---
36
37
 
@@ -248,6 +249,28 @@ params = { version: '0.1.1' }
248
249
  result = template.render params do |path, content|
249
250
  # code to handle results here
250
251
  end
252
+ ```
253
+
254
+ In addition, Kojo extends Ruby's `File` class with the `File.deep_write`
255
+ method, which lets you write the file and create the directory structure as
256
+ needed. You may use it in your code like this:
257
+
258
+ ```ruby
259
+ # Config
260
+ config = Kojo::Config.new 'examples/config-from-file/config.yml'
261
+ config.import_base = "examples/config-from-file/imports"
251
262
 
263
+ config.generate do |path, content|
264
+ File.deep_write path, content
265
+ end
252
266
  ```
253
267
 
268
+ Contributing / Support
269
+ --------------------------------------------------
270
+
271
+ If you experience any issue, have a question or a suggestion, or if you wish
272
+ to contribute, feel free to [open an issue][issues].
273
+
274
+ ---
275
+
276
+ [issues]: https://github.com/DannyBen/kojo/issues
@@ -5,9 +5,7 @@ module Kojo
5
5
  class CommandBase < MisterBin::Command
6
6
  def save(file, output)
7
7
  outpath = "#{outdir}/#{file}"
8
- dir = File.dirname outpath
9
- FileUtils.mkdir_p dir unless Dir.exist? dir
10
- File.write outpath, output
8
+ File.deep_write outpath, output
11
9
  say "Saved #{outpath}"
12
10
  end
13
11
  end
@@ -0,0 +1,6 @@
1
+ class File
2
+ def self.deep_write(path, content)
3
+ FileUtils.mkdir_p File.dirname(path)
4
+ File.write path, content
5
+ end
6
+ end
data/lib/kojo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Kojo
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
data/lib/kojo.rb CHANGED
@@ -2,6 +2,7 @@ require 'requires'
2
2
  require 'byebug' if ENV['BYEBUG']
3
3
 
4
4
  requires 'kojo/refinements'
5
+ requires 'kojo/extensions'
5
6
 
6
7
  require 'kojo/exceptions'
7
8
  require 'kojo/template'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kojo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-03 00:00:00.000000000 Z
11
+ date: 2020-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mister_bin
@@ -72,6 +72,7 @@ files:
72
72
  - lib/kojo/commands/single.rb
73
73
  - lib/kojo/config.rb
74
74
  - lib/kojo/exceptions.rb
75
+ - lib/kojo/extensions/file.rb
75
76
  - lib/kojo/front_matter_template.rb
76
77
  - lib/kojo/refinements/array.rb
77
78
  - lib/kojo/refinements/hash.rb