sharks 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +15 -0
  2. data/lib/sharks.rb +68 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTdiM2UzMzk4MzVkYWQ0YTc0ZThlZGI1YzE1Yzk3MDQ2OTBmZmI0NA==
5
+ data.tar.gz: !binary |-
6
+ MWFiZGM3M2MzM2QwN2FhOGI3MjNkZDJmZGY2NTkzMmY3MTNkMDg1Yg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YTY5ZmI1ZWRmOTIzNDY1NDg0MzYxZTVkYWM1Mzg0Yjc1OGM0MGViZTc5ZDc2
10
+ Y2Y0ZGQ5MTA5ZDEzODQ0OWQyYTM2ZDY4YjAxNzI3ZTMzYWVhNTQ3NjFlM2Ux
11
+ YTdhN2FmZjg3YTlmZjcwNTczMzFlMTIwYWIxOWViMTZjYzZkOGI=
12
+ data.tar.gz: !binary |-
13
+ ZjhhY2NkMTk5NjhhNGIyOGVkOThiMjc5ODllMmE2YjUzMzZlMTQ2MTkxMmYz
14
+ NzZhMWNhMTI3NDFjYzIxMGVhYTdhMWI4OTgwOWZjY2Y5MzEwYzQ5ZWE4ZDNj
15
+ ZTBmYjA0OWRjMzlmZDZhODhiODA5MWQ5MDM5YmZjYzFiNGYwNGU=
data/lib/sharks.rb ADDED
@@ -0,0 +1,68 @@
1
+ class Time
2
+ def strfjtime(input)
3
+ a = input.split("'")
4
+ chunks = a.values_at(* a.each_index.select {|i| i.even?})
5
+ chunks.map!{|a| a == "" ? "'" : a}
6
+ preserve = a.values_at(* a.each_index.select {|i| i.odd?})
7
+
8
+ final_array = []
9
+ chunks.each do |chunk|
10
+ out_string = ""
11
+ pieces = chunk.scan(/((.)\2*)/).map(&:first)
12
+ pieces.each do |piece|
13
+ if !(piece =~ /[a-zA-Z]/) #skip non-letters
14
+ out_string << piece
15
+ next
16
+ end
17
+ letter = piece[0]
18
+ count = piece.length
19
+ piece = case letter
20
+ when 'G'
21
+ "AD"
22
+ when 'y'
23
+ count > 2 ? "%Y" : "%y"
24
+ when 'M'
25
+ case count
26
+ when 0..3
27
+ "%m"
28
+ when 3...4
29
+ "%b"
30
+ else
31
+ "%B"
32
+ end
33
+ when 'D'
34
+ "%j"
35
+ when 'd'
36
+ "%-d"
37
+ when 'F'
38
+ "%u"
39
+ when 'E'
40
+ count < 4 ? "%a" : "%A"
41
+ when 'a'
42
+ "%p"
43
+ when 'H'
44
+ "%H"
45
+ when 'h'
46
+ "%I"
47
+ when 'm'
48
+ "%M"
49
+ when 's'
50
+ "%S"
51
+ when 'S'
52
+ "%L"
53
+ when 'z'
54
+ "%Z"
55
+ when 'Z'
56
+ "%Z%z"
57
+ else
58
+ ""
59
+ end
60
+ out_string << piece
61
+ end
62
+ final_array << out_string
63
+ end
64
+
65
+ final_string = final_array.zip(preserve).flatten.join("")
66
+ strftime(final_string)
67
+ end
68
+ end
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sharks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Metzler
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Allows Java SimpleDateFormat-style time declarations in Ruby
14
+ email: rmetzler@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/sharks.rb
20
+ homepage: http://github.com/rkmetzl/sharks
21
+ licenses: []
22
+ metadata: {}
23
+ post_install_message:
24
+ rdoc_options: []
25
+ require_paths:
26
+ - lib
27
+ required_ruby_version: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ! '>='
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ required_rubygems_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ! '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ requirements: []
38
+ rubyforge_project:
39
+ rubygems_version: 2.0.3
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: SimpleDateFormat in Ruby
43
+ test_files: []