sysadmin 0.1.1 → 0.1.2

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
data/doc/ChangeLog CHANGED
@@ -1,3 +1,10 @@
1
+ === 0.1.2 / 2012-09-27
2
+
3
+ * Add Methods
4
+
5
+ * Time.strict_parse
6
+
7
+
1
8
  === 0.1.1 / 2012-09-06
2
9
 
3
10
  * Add Class
data/doc/README CHANGED
@@ -30,6 +30,10 @@ Module
30
30
 
31
31
  Extend the Dir class.
32
32
 
33
+ - Sysadmin::TimeExtension
34
+
35
+ Extend the Time class.
36
+
33
37
 
34
38
  =====
35
39
  Class
@@ -69,4 +73,8 @@ Method
69
73
 
70
74
  Return the file lists in the directory.
71
75
 
76
+ * Time.strict_parse(str)
77
+
78
+ Return nil when Time.parse failed in ruby 1.8.
79
+
72
80
 
data/doc/README.ja CHANGED
@@ -30,6 +30,10 @@ $ gem install sysadmin
30
30
 
31
31
  Dir クラスを拡張する
32
32
 
33
+ - Sysadmin::TimeExtension
34
+
35
+ Time クラスを拡張する
36
+
33
37
 
34
38
  ======
35
39
  クラス
@@ -69,4 +73,8 @@ $ gem install sysadmin
69
73
 
70
74
  ディレクトリ内のファイル一覧を配列で返す
71
75
 
76
+ * Time.strict_parse(str)
77
+
78
+ Ruby 1.8 でも日付を表現できない時に nil を返す parse メソッド
79
+
72
80
 
@@ -0,0 +1,21 @@
1
+ # Name:: Sysadmin::TimeExtension
2
+ # Author:: 774 <http://id774.net>
3
+ # Created:: Sep 27, 2012
4
+ # Updated:: Sep 27, 2012
5
+ # Copyright:: 774 Copyright (c) 2012
6
+ # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
7
+
8
+ require "time"
9
+
10
+ module Sysadmin
11
+ module TimeExtension
12
+
13
+ def Time.strict_parse(str)
14
+ unix_epoch = Time.local(1970,1,1,0,0,0)
15
+ time = Time.parse(str, nil) rescue nil
16
+ time = nil if time == unix_epoch
17
+ time
18
+ end
19
+
20
+ end
21
+ end
data/lib/sysadmin.rb CHANGED
@@ -7,7 +7,7 @@
7
7
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
8
 
9
9
  module Sysadmin
10
- VERSION = "0.1.1"
10
+ VERSION = "0.1.2"
11
11
  USER_DIR = "/."
12
12
  ROOT_DIR = File.expand_path("..", File.dirname(__FILE__))
13
13
  $:.unshift ROOT_DIR
@@ -17,4 +17,5 @@ module Sysadmin
17
17
  require 'file_ext'
18
18
  require 'dir_ext'
19
19
  require 'directory'
20
+ require 'time_ext'
20
21
  end
@@ -0,0 +1,20 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/../../spec_helper'
4
+
5
+ describe Sysadmin::TimeExtension, 'Time クラス拡張' do
6
+ context 'で strict_parse メソッドを呼ぶ場合' do
7
+ describe '有効な日付を指定すると' do
8
+ it "日付が返却される" do
9
+ expect = Time.parse("2012/09/27 11:45:00")
10
+ Time.strict_parse("2012/09/27 11:45:00").should == expect
11
+ end
12
+ end
13
+
14
+ describe '無効な日付を指定すると' do
15
+ it "nil が返却される" do
16
+ Time.strict_parse("hoge").should be_nil
17
+ end
18
+ end
19
+ end
20
+ end
@@ -5,7 +5,7 @@ require File.dirname(__FILE__) + '/../spec_helper'
5
5
  describe Sysadmin, 'sysadmin' do
6
6
  context 'のバージョンを参照した場合' do
7
7
  it "バージョンが正しく表示される" do
8
- expect = '0.1.1'
8
+ expect = '0.1.2'
9
9
  Sysadmin.const_get(:VERSION).should be_true
10
10
  Sysadmin.const_get(:VERSION).should == expect
11
11
  end
data/sysadmin.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "sysadmin"
8
- s.version = "0.1.1"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["id774"]
12
- s.date = "2012-09-06"
12
+ s.date = "2012-09-27"
13
13
  s.description = "System Administration General Library"
14
14
  s.email = "idnanashi@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -31,11 +31,13 @@ Gem::Specification.new do |s|
31
31
  "lib/sysadmin/dir_ext.rb",
32
32
  "lib/sysadmin/directory.rb",
33
33
  "lib/sysadmin/file_ext.rb",
34
+ "lib/sysadmin/time_ext.rb",
34
35
  "script/.gitkeep",
35
36
  "script/build",
36
37
  "spec/lib/sysadmin/dir_ext_spec.rb",
37
38
  "spec/lib/sysadmin/directory_spec.rb",
38
39
  "spec/lib/sysadmin/file_ext_spec.rb",
40
+ "spec/lib/sysadmin/time_ext_spec.rb",
39
41
  "spec/lib/sysadmin_spec.rb",
40
42
  "spec/spec_helper.rb",
41
43
  "spec/test_dir/.dir1/.file6",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sysadmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-06 00:00:00.000000000 Z
12
+ date: 2012-09-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber
@@ -81,11 +81,13 @@ files:
81
81
  - lib/sysadmin/dir_ext.rb
82
82
  - lib/sysadmin/directory.rb
83
83
  - lib/sysadmin/file_ext.rb
84
+ - lib/sysadmin/time_ext.rb
84
85
  - script/.gitkeep
85
86
  - script/build
86
87
  - spec/lib/sysadmin/dir_ext_spec.rb
87
88
  - spec/lib/sysadmin/directory_spec.rb
88
89
  - spec/lib/sysadmin/file_ext_spec.rb
90
+ - spec/lib/sysadmin/time_ext_spec.rb
89
91
  - spec/lib/sysadmin_spec.rb
90
92
  - spec/spec_helper.rb
91
93
  - spec/test_dir/.dir1/.file6