general 1.4.0 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/gtimeformat.rb +53 -0
  3. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca9ebfe83430fa6d71009c18efe523203f06d1cf
4
- data.tar.gz: 184093b86de685cc61ee89592c210c68abfc26d9
3
+ metadata.gz: d49cd861bc37c7e61423c69040efbecdce41fc5f
4
+ data.tar.gz: 443026a01739601b708586b4d6cb7672ce8e79f3
5
5
  SHA512:
6
- metadata.gz: cffd672f5d65cf8c71c9498c1095085f7377b10e9d51ea77321caa50c539d05644e238a106fad5781a61b468b9f1c05eb178f86855b7c208d5803b0bab6d08a9
7
- data.tar.gz: 20f2a769d5b582fe47eab9a2bda3fc2006f235c897c27a9ac0dca166451bb280eada55b23700d33171d05fcab1426087b256ceafbef5e16080979bc44cb70a1b
6
+ metadata.gz: 81c684e0819f4f5441028225a3fade0c9a78fae93fb5f778b20207c650892f6ac9d9fe22e0eea48d71c42a68de4119ea7177f30d63f924bdc765833a8f11b951
7
+ data.tar.gz: 9dda9feed8a59687a99c73f1c7710767cfa17196b39b20551c3f628505c472d3759ee10ae52abef38bb0327a9cdb4e18a78740a08d8a05952c49841eeb3e2126
@@ -0,0 +1,53 @@
1
+ # General is a templating system in ruby
2
+ # Copyright (C) 2016 Anshul Kharbanda
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require_relative "gtemplate"
18
+ require_relative "gpartials"
19
+
20
+ # General is a templating system in ruby
21
+ #
22
+ # Author: Anshul Kharbanda
23
+ # Created: 3 - 4 - 2016
24
+ module General
25
+ # A special template used for formatting time strings
26
+ #
27
+ # Author: Anshul Kharbanda
28
+ # Created: 7 - 2 - 2016
29
+ class GTimeFormat < GTemplate
30
+ private
31
+
32
+ # Parses the given string into GTimeFormat partials
33
+ #
34
+ # Parameter: string - the string to parse
35
+ def parse_string string
36
+ # While a GTimeFormatPlaceholder remains
37
+ while !(General::GTimeFormatPlaceholder::REGEX =~ string).nil? \
38
+ && (General::GTimeFormatPlaceholder::REGEX =~ string) > -1
39
+
40
+ # Split match and add partials
41
+ match = General::GTimeFormatPlaceholder::REGEX.match string
42
+ @partials << General::GPartialString.new(string, match) \
43
+ << General::GTimeFormatPlaceholder.new(match)
44
+
45
+ # Trim string
46
+ string = string[match.end(0)..-1]
47
+ end
48
+
49
+ # Add end partial of string
50
+ @partials << General::GPartialString.new(string)
51
+ end
52
+ end
53
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: general
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anshul Kharbanda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-14 00:00:00.000000000 Z
11
+ date: 2016-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -38,6 +38,7 @@ files:
38
38
  - lib/goperations.rb
39
39
  - lib/gpartials.rb
40
40
  - lib/gtemplate.rb
41
+ - lib/gtimeformat.rb
41
42
  - spec/gio_spec.rb
42
43
  - spec/gtemplate_spec.rb
43
44
  - spec/spec_require.rb