okay 10.0.0 → 11.0.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: 3abf8b39842bc201721061189ca61e036198780c60e1d01a1c6b5434b8c6796c
4
- data.tar.gz: effbb2d734973d1c0c0c33e59f027246212d3f79fd734c524274a5454a27e14b
3
+ metadata.gz: 644512c8f6e9711f699eb2dcc1b140afb21942035549aaf78c6324205d17ca42
4
+ data.tar.gz: 5401ca57ba69b8a35b3e37acbf52645cb9571aa0fa0a3608be07b160952550db
5
5
  SHA512:
6
- metadata.gz: faf52f42bc463b31b73e4b8ccaa680d971c1a4b874cb27321248ee4e337da88e0b73ae330693c64ee740ea23229e22a36ed833f412a7bee77e1bf2aaa3823a4c
7
- data.tar.gz: c43961b19116e262ce15cd514a2f4e8212031fe2aa9d8454e68327ecf40e2b9c9dfe775b2159889478a40932d89ce1b11a04376da694643615e1dcd759107a9d
6
+ metadata.gz: 6f41a2ede17a3af2d5c8dae9e3f26747c3c3739a3be23f619d934247eac3a8a2600125561224d9b263d23f49c633afc40dfc588ff9307ce273edf6221472b9f9
7
+ data.tar.gz: d9b54ddcd04277369c0aa0ea80c23a1157c84d9f8c3555314446f1a981abf0eba2245968dc5ed16cfb4cd36b220be5c7c140f5fb08ff9edfbe70f8cb743f685c
data/README.md CHANGED
@@ -108,6 +108,26 @@ response.body.from_json
108
108
 
109
109
  ```
110
110
 
111
+ ### Template Engine
112
+
113
+ Okay also provides a basic templating engine.
114
+
115
+ It is literally just a wrapper around `Kernel.format()` and `Pathname`.
116
+
117
+ Assuming a `./templates/example.html` containing: `a %{foo} c %{bar} e`
118
+
119
+ ```ruby
120
+ require "okay/template"
121
+
122
+ template = Okay::Template.new("./templates/")
123
+ template.apply("example.html", {foo: "b", bar: "d"}) #=> "a b c d e"
124
+ ```
125
+
126
+ ### SimpleOpts (OptionParser improvements)
127
+
128
+ See the [example usage in
129
+ HowIs](https://github.com/how-is/how_is/blob/ad81620/lib/how_is/cli.rb#L39-L74).
130
+
111
131
  ## Development
112
132
 
113
133
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,28 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "okay/version"
3
4
  require "optparse"
4
5
 
5
- ##
6
- # An OptionParser wrapper providing a few convenience functions.
7
- class SimpleOpts < OptionParser
8
- def initialize(*args, defaults: nil)
9
- super(*args)
10
- @okay_options = defaults || {}
11
- end
6
+ module Okay
7
+ ##
8
+ # An OptionParser wrapper providing a few convenience functions.
9
+ class SimpleOpts < OptionParser
10
+ def initialize(*args, defaults: nil)
11
+ super(*args)
12
+ @okay_options = defaults || {}
13
+ end
12
14
 
13
- # simple(..., :a)
14
- # simple(..., :b)
15
- # ==
16
- # options = {}
17
- # on(...) { |val| options[:a] = val }
18
- # on(...) { |val| options[:b] = val }
19
- def simple(*args)
20
- key = args.pop
21
- on(*args) { |*x| @okay_options[key] = x[0] }
22
- end
15
+ # simple(..., :a)
16
+ # simple(..., :b)
17
+ # ==
18
+ # options = {}
19
+ # on(...) { |val| options[:a] = val }
20
+ # on(...) { |val| options[:b] = val }
21
+ def simple(*args)
22
+ key = args.pop
23
+ on(*args) { |*x| @okay_options[key] = x[0] }
24
+ end
23
25
 
24
- def parse(args)
25
- parse!(args.dup)
26
- @okay_options
26
+ def parse(args)
27
+ parse!(args.dup)
28
+ @okay_options
29
+ end
27
30
  end
28
31
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Okay
4
- VERSION = "10.0.0"
4
+ VERSION = "11.0.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: okay
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.0
4
+ version: 11.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ellen Marie Dash