nezaman 1.0.0

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 (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/README.md +16 -0
  4. data/lib/Nezaman.rb +76 -0
  5. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7eadc92b594baf1e4b1982aca1d5a361469765c6
4
+ data.tar.gz: 26ee81b7a57a42e744185829cf16fb62ac4147a0
5
+ SHA512:
6
+ metadata.gz: 496fe7608a4848b4d3585931606dfa3acae86e06226bf9c5f174f14c4b2b0d99317e60dbc44c90c9e52aa3de206dfd46437d9facbd38a96eb384e01373336292
7
+ data.tar.gz: 0511ca160af3b6031028521193ef4f7532dface3892170ac622fe5b9e4f5fb86672ec564e6eea03f9af2011fd84da722d675c797de24af539544bb6e10a6a0e0
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Mehmet Cetin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,16 @@
1
+ Nezaman
2
+ =======
3
+
4
+ EN: Nezaman is a basic ruby gem which turns Time object as a 1h ago, 1w ago, etc. in Turkish language.
5
+
6
+ TR:
7
+
8
+ Nezaman, bir zaman öğesi (Time class) yada Timestamp objesinden (örn: ActiveRecord object.created_at) şu ana kadar geçen zamanı yazı dilinde sunan basit bir ruby gem'dir.
9
+
10
+ Örnek olarak,
11
+
12
+ Nezaman.basit(Object.created_at) => "1 saat" dönüşünü,
13
+
14
+ Nezaman.uzun(Object.created_at) => "1 saat önce" dönüşünü yapmaktadır.
15
+
16
+ Geliştirdiğim uygulamalarda çokça kullandığım bu gösterim şeklini, güzel Türkçemiz ile beraber basit bir gem şeklinde sunmak istedim. Umarım işinize yarar.
data/lib/Nezaman.rb ADDED
@@ -0,0 +1,76 @@
1
+ class Nezaman
2
+
3
+ def self.basit(time)
4
+
5
+ if time.is_a?(Time)
6
+ elapsed = Time.now - time
7
+ else
8
+ raise 'TR: Lütfen Time classına ait bir obje giriniz. EN: Please provide a Time object. '
9
+ end
10
+
11
+ result = ""
12
+
13
+ case elapsed
14
+
15
+ when 0..60
16
+ result = elapsed.round.to_s + "sn"
17
+ when 61..3600
18
+ elapsed = (elapsed / 60).round
19
+ result = elapsed.to_s + "dkk"
20
+ when 3601..86400
21
+ elapsed = (elapsed / 3600).round
22
+ result = elapsed.to_s + "s"
23
+ when 86401..2592000
24
+ elapsed = (elapsed / 86400).round
25
+ result = elapsed.to_s + "g"
26
+ when 2592001..31104000
27
+ elapsed = (elapsed / 2592000).round
28
+ result = elapsed.to_s + "a"
29
+ else
30
+ elapsed = (elapsed / 31104000).round
31
+ result = elapsed.to_s + "y"
32
+ end
33
+
34
+ return result
35
+ end
36
+
37
+ def self.normal(time)
38
+
39
+ if time.is_a?(Time)
40
+ elapsed = Time.now - time
41
+ else
42
+ raise 'TR: Lütfen Time classına ait bir obje giriniz. EN: Please provide a Time object. '
43
+ end
44
+
45
+ result = ""
46
+
47
+ case elapsed
48
+
49
+ when 0..60
50
+ result = elapsed.round.to_s + " saniye"
51
+ when 61..3600
52
+ elapsed = (elapsed / 60).round
53
+ result = elapsed.to_s + " dakika"
54
+ when 3601..86400
55
+ elapsed = (elapsed / 3600).round
56
+ result = elapsed.to_s + " saat"
57
+ when 86401..2592000
58
+ elapsed = (elapsed / 86400).round
59
+ result = elapsed.to_s + " gün"
60
+ when 2592001..31104000
61
+ elapsed = (elapsed / 2592000).round
62
+ result = elapsed.to_s + " ay"
63
+ else
64
+ elapsed = (elapsed / 31104000).round
65
+ result = elapsed.to_s + " yıl"
66
+ end
67
+
68
+ return result
69
+ end
70
+
71
+ def self.uzun(time)
72
+ return normal(time) + " önce"
73
+ end
74
+
75
+
76
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nezaman
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Mehmet Cetin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-11 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A simple gem for turning time objects into strings in Turkish
14
+ email: mcetin.cm@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - LICENSE
20
+ - README.md
21
+ - lib/Nezaman.rb
22
+ homepage: http://github.com/manorie/nezaman
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.2.2
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: Turns time objects into strings like 1 hour ago, 1 week ago, etc. in Turkish.
46
+ test_files: []