time_extended 0.0.5 → 0.0.6

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
  SHA1:
3
- metadata.gz: f35cc2f638cc5be93ec483b943fe5485638a8cf2
4
- data.tar.gz: fb2d33e1aae724dc935176ba4e338fcadc3c4a2a
3
+ metadata.gz: 63389e93f8736b1a327e2e8507fef6495737a3a9
4
+ data.tar.gz: 0f2283f869178f43e1b0df4ed724cde17483cf79
5
5
  SHA512:
6
- metadata.gz: 4f1a2b69e0cbde02028a023f1b5437cc92a4d4d8f70e73ff7c9c5fd5af1413373bae578bd11b17178b3141c3f6a4af3709f4b7dc5a4030c3e0470acb0be03c8c
7
- data.tar.gz: e60d06c7c503a8b10e9a674b9f6b0238d668b85482ab0bc773a40b75b45456f3fd8591f162612be26c7cbb82401637c2bc2ce4aac6b82da9ef7c029e6b972422
6
+ metadata.gz: adeaea5cf88c7e9a50ae31fa176e81125e306ac1f17269c986dd617962c7bb76f0fc4dfcd9e3b3c59ddfdf227aff60a6f1e17ff6fb27c754c61ce211829ce58e
7
+ data.tar.gz: 4f6a5f9da7f81bfc6de3e067e8c102c46b57daca697f7c15f0b8a8422085d6815ac4a329e01d7c974dbb2366338d206d226ac5f1b748493ca1f3f0e52c61e66b
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in time_extended.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Roman Vakulchik
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ [![Gem Version](https://badge.fury.io/rb/time_extended.svg)](http://badge.fury.io/rb/time_extended)
2
+
3
+ # TimeExtended Gem
4
+
5
+ A simple gem for extension the Ruby class `DateTime`
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'time_extended'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install time_extended
22
+
23
+ ## Usage
24
+
25
+ * DateTime.now.ymd => strftime("%y %m %d")
26
+ * DateTime.now.Bd => strftime("%B %d")
27
+ * DateTime.now.M3N => strftime("%M %3N")
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it ( https://github.com/randsina/bsuir-courses-ruby/fork )
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/lib/time_extended.rb CHANGED
@@ -1,4 +1,16 @@
1
- require 'time'
1
+ # Extend and simplify Ruby class `DateTime`
2
+ class DateTime
3
+ def method_missing(method, *args)
4
+ options = ''
2
5
 
3
- module TimeExtended
6
+ params = method.to_s.split('')
7
+ params.each do |el|
8
+ options = "#{options}#{el}"
9
+ options = "#{options} " if el.to_i == 0
10
+ end
11
+ options = "%#{options.split(' ').join(' %')}"
12
+
13
+ self.class.send(:define_method, method) { strftime(options) }
14
+ strftime(options)
15
+ end
4
16
  end
data/run.rb ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'date'
4
+ require_relative 'lib/time_extended'
5
+
6
+ p DateTime.now.ymd # => "14 11 06"
7
+ p DateTime.now.Bd # => "November 06"
8
+ p DateTime.now.M3N # => "51 963"
9
+ p DateTime.now.c # => "Thu Nov 6 00:49:50 2014"
10
+ d = DateTime.new(2007, 11, 19, 8, 37, 48, '-06:00')
11
+ p d.v # => "19-Nov-2007"
@@ -0,0 +1,25 @@
1
+ require 'minitest/autorun'
2
+ require 'date'
3
+ require 'time_extended'
4
+
5
+ class TestTimeExtended < Minitest::Test
6
+ def setup
7
+ @date = DateTime.now
8
+ end
9
+
10
+ def test_with_strftime_ymd
11
+ assert_equal(@date.ymd, @date.strftime("%y %m %d"))
12
+ end
13
+
14
+ def test_with_strftime_Bd
15
+ assert_equal(@date.Bd, @date.strftime("%B %d"))
16
+ end
17
+
18
+ def test_with_strftime_M3N
19
+ assert_equal(@date.M3N, @date.strftime("%M %3N"))
20
+ end
21
+
22
+ def test_with_strftime_S24N
23
+ refute_equal(@date.S21N, @date.strftime("%S %24N"))
24
+ end
25
+ end
@@ -0,0 +1,22 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'time_extended'
7
+ spec.version = '0.0.6'
8
+ spec.authors = ['Roman Vakulchik']
9
+ spec.email = ['rvakulchik@yandex.ru']
10
+ spec.summary = 'Time extended!'
11
+ spec.description = 'A simple gem for extension the Ruby class `DateTime`'
12
+ spec.homepage = 'https://github.com/randsina/bsuir-courses-ruby/tree/master/time_extended'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency 'bundler', '~> 1.7'
21
+ spec.add_development_dependency 'rake', '~> 10.0'
22
+ end
metadata CHANGED
@@ -1,22 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_extended
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman Vakulchik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-07 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
13
41
  description: A simple gem for extension the Ruby class `DateTime`
14
- email: rvakulchik@yandex.ru
42
+ email:
43
+ - rvakulchik@yandex.ru
15
44
  executables: []
16
45
  extensions: []
17
46
  extra_rdoc_files: []
18
47
  files:
48
+ - Gemfile
49
+ - LICENSE.txt
50
+ - README.md
51
+ - Rakefile
19
52
  - lib/time_extended.rb
53
+ - run.rb
54
+ - test/test_time_extended.rb
55
+ - time_extended.gemspec
20
56
  homepage: https://github.com/randsina/bsuir-courses-ruby/tree/master/time_extended
21
57
  licenses:
22
58
  - MIT
@@ -41,4 +77,5 @@ rubygems_version: 2.4.2
41
77
  signing_key:
42
78
  specification_version: 4
43
79
  summary: Time extended!
44
- test_files: []
80
+ test_files:
81
+ - test/test_time_extended.rb