altprintf 0.3.2 → 0.3.3

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: e7e5b126835ddd39ea0e84a6af5f43c54dd7016f392b539ed97e08ccaab9841a
4
- data.tar.gz: e168cbfef10fcabfdc8ed1f7b29be4ac0674bbc17fed5e06efa7d0e8d068fbc8
3
+ metadata.gz: 134617d2a0afa2d1fcbcc02b7e83421b625ed740e80a02869d73fd9c32f9bff9
4
+ data.tar.gz: 2ff6cc05cd95897746fbdbad9a8d1c7c98ec9ad3430ce6dfcb58de5eea4508ce
5
5
  SHA512:
6
- metadata.gz: 0f27dd11f63071be3acfe161bbb71ff4bd081031892125d83dc7c97b3734c325c23e707ca197dc4890f0f5234c902515b8ee60d25269c4d924470c7c004e41ba
7
- data.tar.gz: 752769a18da696a2ea25d413cdb37648e8373eead3bd60bce0a205a973913277e622a508b2ae222b03ea7d89d48b42243edd16212ac893e5f125549d8a9736b9
6
+ metadata.gz: 1c6fbb933675cdf58684849b252a61da79241bb86c9da851bc01f9abfeac3e7fa1cfc0211753fd6d0701c68085091c739853a1972d7f3f527ea4a6e89293df3c
7
+ data.tar.gz: 2542ed5e8d4417a9858c11b9fab94e61c2582827ee0976c261bc87e3ea8450a4eae9d3fa1e45d2ec955de0067717e88e9739d4e2fe5f8d09e857c4d2005d941e
@@ -1,6 +1,6 @@
1
1
  #ifndef ALTPRINTF_H_
2
2
  #define ALTPRINTF_H_
3
- #define ALTPRINTF_VERSION "0.3.2"
3
+ #define ALTPRINTF_VERSION "0.3.3"
4
4
 
5
5
  #include <altprintf/fmt.h>
6
6
  #include <altprintf/fmte.h>
@@ -14,8 +14,6 @@
14
14
  #include <altprintf/altprintf.h>
15
15
  #include <altprintf/log.h>
16
16
 
17
- #define MODNAME "Altprintf"
18
-
19
17
  rb_encoding *enc;
20
18
 
21
19
  char *rbstocs(VALUE *rbstr)
@@ -209,11 +207,44 @@ VALUE rb_altprintf(long passes, size_t argc, VALUE *argv, VALUE self)
209
207
  return final;
210
208
  }
211
209
 
210
+ /*
211
+ * call-seq:
212
+ * fmt(format_string [, arguments...]) -> String
213
+ *
214
+ * Formats a `format_string` with `arguments`. `format_string` may be any
215
+ * vaild altprintf format string .
216
+ * Additionally, a hash may be specified as the last argument, or as keyword
217
+ * arguments and the values of the hash may be directly accessed in the format
218
+ * string using < and >.
219
+ *
220
+ * For example:
221
+ * fmt("hello %<name>", name: "John") #=> "hello John"
222
+ *
223
+ * Note that the keys within <> are always assumed to be symbols, so the
224
+ * following would not work
225
+ * fmt("hello %<name>", { "name" => "John" }) #=> "hello John"
226
+ */
212
227
  VALUE rb_altprintf_single_pass(size_t argc, VALUE *argv, VALUE self)
213
228
  {
214
229
  return rb_altprintf(1, argc, argv, self);
215
230
  }
216
231
 
232
+
233
+
234
+ /*
235
+ * call-seq:
236
+ * fmtm(passes, format_string [, arguments...]) -> String
237
+ *
238
+ * Same as #fmt, but takes an additional argument, passes, which specifies the
239
+ * number of passes to go over the format string.
240
+ *
241
+ * For example:
242
+ * fmtm(0, "%%%%%%%%") #=> "%%%%%%%%"
243
+ * fmtm(1, "%%%%%%%%") #=> "%%%%"
244
+ * fmtm(2, "%%%%%%%%") #=> "%%"
245
+ * fmtm(3, "%%%%%%%%") #=> "%"
246
+ * fmtm(4, "%%%%%%%%") #=> ""
247
+ */
217
248
  VALUE rb_altprintf_multi_pass(size_t argc, VALUE *argv, VALUE self)
218
249
  {
219
250
  long passes;
@@ -233,10 +264,19 @@ void Init_altprintf()
233
264
  size_t len;
234
265
 
235
266
  enc = rb_enc_find("UTF-8");
236
- mod = rb_define_module(MODNAME);
267
+
268
+ /*
269
+ * The base module for *Altprintf*. For documentation on the syntax of
270
+ * the format string, see https://github.com/annacrombie/altprintf
271
+ */
272
+ mod = rb_define_module("Altprintf");
237
273
 
238
274
  len = strlen(ALTPRINTF_VERSION);
239
275
  ver = rb_external_str_new_with_enc(ALTPRINTF_VERSION, len, enc);
276
+
277
+ /*
278
+ * The version of libaltprintf that this extension was compiled against.
279
+ */
240
280
  rb_define_const(mod, "LIB_VERSION", ver);
241
281
 
242
282
  rb_define_module_function(mod, "fmt", rb_altprintf_single_pass, -1);
@@ -1,3 +1,3 @@
1
1
  module Altprintf
2
- VERSION ||= "0.3.2"
2
+ VERSION ||= "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: altprintf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stone Tickle