sysadmin 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 28af9c9c22c9750679a8935519abcd2e634600f9
4
+ data.tar.gz: 1e321e887af1710d69eeacccbe3fab108fb66473
5
+ SHA512:
6
+ metadata.gz: 39cdce494b486ae6df720629167a74fb3ba7b1beb8179dc9cc97d5736feb5e8686b882f6e67ba0328ae7b84d33cfc402fc18a3f4754eae996dbc7a6ad347700e
7
+ data.tar.gz: 6b37752ad61df612725174a3f030dca6f53f25d9505e150fce678d933a7fe04f890b264a9a470fe7e9d7caaa622fd9bf373ec5872371b43da8e05d651ca8165f
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- Sysadmin Ruby
2
- =============
1
+ Sysadmin
2
+ ========
3
3
 
4
- **System Administration General Library**
4
+ **The general-purpose library for system administrations.**
5
5
 
6
6
 
7
7
  What is This?
@@ -9,11 +9,7 @@ What is This?
9
9
 
10
10
  The collection of libraries for managing the system.
11
11
 
12
-
13
- Environment
14
- -----------
15
-
16
- After ruby 1.8.
12
+ See doc/README(.ja).
17
13
 
18
14
 
19
15
  Development
@@ -26,6 +22,12 @@ We need your help.
26
22
  + https://github.com/id774/sysadmin
27
23
 
28
24
 
25
+ Environment
26
+ -----------
27
+
28
+ After ruby 1.8.
29
+
30
+
29
31
  ChangeLog
30
32
  ---------
31
33
 
data/Rakefile CHANGED
@@ -1,18 +1,29 @@
1
- # encoding: utf-8
2
-
1
+ # -*- mode: ruby; coding: utf-8 -*-
3
2
  require 'rubygems'
4
-
3
+ require 'bundler'
4
+ require 'rake'
5
+ require 'rake/clean'
6
+ require 'rubygems/package_task'
7
+ require 'rdoc/task'
5
8
  require 'rspec/core'
6
9
  require 'rspec/core/rake_task'
7
10
 
8
- task :spec do
9
- RSpec::Core::RakeTask.new(:spec) do |spec|
10
- spec.rspec_opts = ["-c","-fs"]
11
- spec.pattern = FileList['spec/**/*_spec.rb']
11
+ # Bundler::GemHelper.install_tasks
12
+
13
+ RSpec::Core::RakeTask.new(:spec) do |spec|
14
+ spec.rspec_opts = ["-c", "-fs"]
15
+ spec.pattern = FileList['spec/lib/**/*_spec.rb']
16
+ end
17
+
18
+ namespace :spec do
19
+ desc "Run RSpec for main procedure"
20
+ RSpec::Core::RakeTask.new(:sysadmin) do |spec|
21
+ spec.rspec_opts = ["-c", "-fs"]
22
+ spec.pattern = FileList['spec/lib/sysadmin/**/*_spec.rb']
12
23
  end
13
24
  end
14
25
 
15
- if /^1\.9\./ =~ RUBY_VERSION
26
+ if RUBY_VERSION >= '1.9.0'
16
27
  desc "Run RSpec code examples with simplecov"
17
28
  task :simplecov do
18
29
  ENV['COVERAGE'] = "on"
@@ -21,7 +32,7 @@ if /^1\.9\./ =~ RUBY_VERSION
21
32
  else
22
33
  desc "Run RSpec code examples with rcov"
23
34
  RSpec::Core::RakeTask.new(:rcov) do |spec|
24
- spec.pattern = FileList['spec/lib/**/*_spec.rb']
35
+ spec.pattern = FileList['spec/**/*_spec.rb']
25
36
  exclude_files = [
26
37
  "gems",
27
38
  ]
@@ -30,14 +41,25 @@ else
30
41
  end
31
42
  end
32
43
 
44
+ task :default => :spec
45
+
46
+ desc 'Generate documentation for the sysadmin.'
47
+ RDoc::Task.new do |rdoc|
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "sysadmin"
50
+ rdoc.options << '--line-numbers' << '--inline-source'
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
54
+
33
55
  require 'jeweler'
34
56
  Jeweler::Tasks.new do |gem|
35
57
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
36
58
  gem.name = "sysadmin"
37
59
  gem.homepage = "http://github.com/id774/sysadmin"
38
60
  gem.license = "GPL"
39
- gem.summary = %Q{Sysadmin Ruby}
40
- gem.description = %Q{System Administration General Library}
61
+ gem.summary = %Q{Sysadmin}
62
+ gem.description = %Q{The general-purpose library for system administrations}
41
63
  gem.email = "idnanashi@gmail.com"
42
64
  gem.authors = ["id774"]
43
65
  # dependencies defined in Gemfile
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -1,3 +1,12 @@
1
+ === 0.1.4 / 2013-08-20
2
+
3
+ * Add Class Extension
4
+
5
+ * Array#average
6
+ * Array#variance
7
+ * Array#standard_devitation
8
+
9
+
1
10
  === 0.1.3 / 2012-10-25
2
11
 
3
12
  * Add Class
data/doc/README CHANGED
@@ -1,7 +1,7 @@
1
1
  sysadmin
2
2
 
3
3
  Name
4
- sysadmin - general-purpose library for system management
4
+ sysadmin - The general-purpose library for system administrations.
5
5
 
6
6
  Syntax
7
7
  require 'sysadmin'
@@ -18,72 +18,11 @@ Installation
18
18
  $ gem install sysadmin
19
19
 
20
20
 
21
- ======
22
- Module
23
- ======
21
+ ======================
22
+ Class, Module, Methods
23
+ ======================
24
24
 
25
- - Sysadmin::FileExtension
26
-
27
- Extend the File class.
28
-
29
- - Sysadmin::DirExtension
30
-
31
- Extend the Dir class.
32
-
33
- - Sysadmin::TimeExtension
34
-
35
- Extend the Time class.
36
-
37
-
38
- =====
39
- Class
40
- =====
41
-
42
- - Sysadmin::Util
43
-
44
- General methods.
45
-
46
- - Sysadmin::Directory
47
-
48
- Enumerable Dir class.
49
-
50
-
51
- ======
52
- Method
53
- ======
54
-
55
-
56
- * Sysadmin::Util.create_multi_dimensional_hash
57
-
58
- Return new Multi Dimensional Hash object.
59
-
60
- * File.zread (file)
61
-
62
- Referred by Sysadmin::FileHandler.
63
- Read the file regardless of the uncompressed / compressed gz.
64
-
65
- * File.append_line(file, str)
66
-
67
- Append a string to a file.
68
-
69
- * File.new_line(file, str)
70
-
71
- Create a new file.
72
-
73
- * File.replace_line(file, src, out)
74
-
75
- Replace the string in the file.
76
-
77
- * FileString.remove_line(file, str)
78
-
79
- Remove the rows that match the string from the file.
80
-
81
- * Dir.filelist(dir, subdirectory=false)
82
-
83
- Return the file lists in the directory.
84
-
85
- * Time.strict_parse(str)
86
-
87
- Return nil when Time.parse failed in ruby 1.8.
25
+ $ rdoc lib -o rdoc
88
26
 
27
+ View rdoc/index.html
89
28
 
@@ -1,13 +1,13 @@
1
1
  sysadmin
2
2
 
3
3
  名前
4
- sysadmin - システム管理用の汎用ライブラリ
4
+ sysadmin - システム管理者用の汎用ライブラリ
5
5
 
6
6
  書式
7
7
  require 'sysadmin'
8
8
 
9
9
  説明
10
- これはシステム管理用のスクリプトでよく利用する
10
+ これはシステム管理のスクリプトでよく利用する
11
11
  汎用的な処理を集めたライブラリである。
12
12
 
13
13
 
@@ -18,71 +18,60 @@ sysadmin
18
18
  $ gem install sysadmin
19
19
 
20
20
 
21
- ==========
22
- モジュール
23
- ==========
21
+ ============================
22
+ クラス、モジュール、メソッド
23
+ ============================
24
24
 
25
25
  - Sysadmin::FileExtension
26
-
27
26
  File クラスを拡張する
28
27
 
29
- - Sysadmin::DirExtension
28
+ * File#zread(file)
29
+ Sysadmin::FileHandler を呼ぶと追加される
30
+ gz 圧縮 / 非圧縮に関わらずファイルを読み込む
30
31
 
31
- Dir クラスを拡張する
32
+ * File#append_line(:file => FILENAME, :str => STR)
33
+ ファイルに文字列を追記する
32
34
 
33
- - Sysadmin::TimeExtension
35
+ * File#new_line(:file => FILENAME, :str => STR)
36
+ ファイルを新規作成する
34
37
 
35
- Time クラスを拡張する
38
+ * File#replace_line(:file => FILENAME, :src => SRC, :dst => DST)
39
+ ファイル内の文字列を置換する
40
+
41
+ * File#remove_line(:file => FILENAME, :str => STR)
42
+ ファイルから文字列にマッチする行を取り除く
36
43
 
44
+ - Sysadmin::DirExtension
45
+ Dir クラスを拡張する
37
46
 
38
- ======
39
- クラス
40
- ======
47
+ * Dir#filelist(dir, subdirectory=false)
48
+ ディレクトリ内のファイル一覧を配列で返す
41
49
 
42
- - Sysadmin::Util
50
+ - Sysadmin::TimeExtension
51
+ Time クラスを拡張する
43
52
 
44
- 汎用的なメソッド
53
+ * Time#strict_parse(str)
54
+ Ruby 1.8 でも日付を表現できない時に nil を返す parse メソッド
45
55
 
46
56
  - Sysadmin::Directory
47
-
48
57
  Enumerable な Dir クラス
49
58
 
59
+ - Array
60
+ Array クラスを拡張する
50
61
 
51
- ========
52
- メソッド
53
- ========
54
-
55
- * Sysadmin::Util.create_multi_dimensional_hash
62
+ * Array#average
63
+ 配列の平均を返却する
56
64
 
57
- 多次元ハッシュを生成して返す
65
+ * Array#variance
66
+ 配列の分散を返却する
58
67
 
59
- * File.zread(file)
68
+ * Array#standard_devitation
69
+ 配列の標準偏差を返却する
60
70
 
61
- Sysadmin::FileHandler を呼ぶと追加される
62
- gz 圧縮 / 非圧縮に関わらずファイルを読み込む
63
-
64
- * File.append_line(file, str)
65
-
66
- ファイルに文字列を追記する
67
-
68
- * File.new_line(file, str)
69
-
70
- ファイルを新規作成する
71
-
72
- * File.replace_line(file, src, out)
73
-
74
- ファイル内の文字列を置換する
75
-
76
- * File.remove_line(file, str)
77
-
78
- ファイルから文字列にマッチする行を取り除く
79
-
80
- * Dir.filelist(dir, subdirectory=false)
81
-
82
- ディレクトリ内のファイル一覧を配列で返す
83
-
84
- * Time.strict_parse(str)
71
+ - Sysadmin::Util
72
+ 汎用的なメソッド
85
73
 
86
- Ruby 1.8 でも日付を表現できない時に nil を返す parse メソッド
74
+ * Sysadmin::Util.create_multi_dimensional_hash
75
+ 多次元ハッシュを生成して返す
87
76
 
88
77
 
@@ -2,13 +2,14 @@
2
2
  # Name:: Sysadmin
3
3
  # Author:: 774 <http://id774.net>
4
4
  # Created:: Mar 23, 2012
5
- # Updated:: Sep 27, 2012
5
+ # Updated:: Aug 20, 2013
6
6
  # Copyright:: 774 Copyright (c) 2012
7
7
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
8
8
 
9
9
  module Sysadmin
10
- VERSION = "0.1.3"
10
+ VERSION = "0.1.4"
11
11
  require File.dirname(__FILE__) + "/sysadmin/util"
12
+ require File.dirname(__FILE__) + "/sysadmin/array_ext"
12
13
  require File.dirname(__FILE__) + "/sysadmin/file_ext"
13
14
  require File.dirname(__FILE__) + "/sysadmin/dir_ext"
14
15
  require File.dirname(__FILE__) + "/sysadmin/directory"
@@ -0,0 +1,23 @@
1
+ # Name:: Sysadmin::ArrayExtension
2
+ # Author:: 774 <http://id774.net>
3
+ # Created:: Aug 20, 2013
4
+ # Updated:: Aug 20, 2013
5
+ # Copyright:: 774 Copyright (c) 2013
6
+ # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
7
+
8
+ class Array
9
+
10
+ def average
11
+ inject(0.0) { |sum, i| sum += i } / size
12
+ end
13
+
14
+ def variance
15
+ ave = self.average
16
+ inject(0.0) { |sum, i| sum += (i - ave)**2 } / size
17
+ end
18
+
19
+ def standard_devitation
20
+ Math::sqrt(self.variance)
21
+ end
22
+
23
+ end
@@ -5,6 +5,10 @@
5
5
  #
6
6
  # Maintainer: id774 <idnanashi@gmail.com>
7
7
  #
8
+ # v1.2 3/15,2013
9
+ # Change rake task to simplecov.
10
+ # v1.1 3/14,2013
11
+ # Show ruby version.
8
12
  # v1.0 3/16,2012
9
13
  # First.
10
14
  ########################################################################
@@ -12,10 +16,11 @@
12
16
  kickstart() {
13
17
  export RACK_ROOT="."
14
18
  export RACK_ENV="test"
19
+ ruby -v
15
20
  }
16
21
 
17
22
  run_tests() {
18
- rake spec
23
+ rake simplecov
19
24
  }
20
25
 
21
26
  main() {
@@ -0,0 +1,26 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/../../spec_helper'
4
+
5
+ describe Sysadmin, 'Array クラス拡張' do
6
+ context 'で average メソッドを呼ぶ場合' do
7
+ it "平均が返却される" do
8
+ a = [88, 99, 77, 66, 55, 40]
9
+ a.average.should == 70.83333333333333
10
+ end
11
+ end
12
+
13
+ context 'で variance メソッドを呼ぶ場合' do
14
+ it "分散が返却される" do
15
+ a = [88, 99, 77, 66, 55, 40]
16
+ a.variance.should == 391.8055555555556
17
+ end
18
+ end
19
+
20
+ context 'で standard_devitation メソッドを呼ぶ場合' do
21
+ it "標準偏差が返却される" do
22
+ a = [88, 99, 77, 66, 55, 40]
23
+ a.standard_devitation.should == 19.79407880037754
24
+ end
25
+ end
26
+ end
@@ -3,7 +3,7 @@
3
3
  require File.dirname(__FILE__) + '/../../spec_helper'
4
4
 
5
5
  describe Sysadmin::Util do
6
- context 'で multi_dimensional_hash メソッドを呼ぶ場合' do
6
+ context 'で create_multi_dimensional_hash メソッドを呼ぶ場合' do
7
7
  describe '引数を付けずに呼ぶと' do
8
8
  it "多次元ハッシュが返る" do
9
9
  h = Sysadmin::Util.create_multi_dimensional_hash
@@ -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.3'
8
+ expect = '0.1.4'
9
9
  Sysadmin.const_get(:VERSION).should be_true
10
10
  Sysadmin.const_get(:VERSION).should == expect
11
11
  end
@@ -4,8 +4,7 @@ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), ".."))
4
4
  $LOAD_PATH.unshift APP_ROOT
5
5
  $LOAD_PATH.unshift File.join(APP_ROOT)
6
6
  $LOAD_PATH.unshift File.join(APP_ROOT, 'lib')
7
-
8
- require 'sysadmin'
7
+ require File.dirname(__FILE__) + '/../lib/sysadmin'
9
8
 
10
9
  if ENV['COVERAGE'] == 'on'
11
10
  require 'simplecov'
@@ -18,7 +17,7 @@ if ENV['COVERAGE'] == 'on'
18
17
  end
19
18
  end
20
19
 
21
- unless /^1\.9\./ =~ RUBY_VERSION
20
+ unless /^1\.8\./ =~ RUBY_VERSION
22
21
  require 'rspec'
23
22
  end
24
23
 
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "sysadmin"
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
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-10-25"
13
- s.description = "System Administration General Library"
12
+ s.date = "2013-08-20"
13
+ s.description = "The general-purpose library for system administrations"
14
14
  s.email = "idnanashi@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "README.md"
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  "doc/README",
29
29
  "doc/README.ja",
30
30
  "lib/sysadmin.rb",
31
+ "lib/sysadmin/array_ext.rb",
31
32
  "lib/sysadmin/dir_ext.rb",
32
33
  "lib/sysadmin/directory.rb",
33
34
  "lib/sysadmin/file_ext.rb",
@@ -35,6 +36,7 @@ Gem::Specification.new do |s|
35
36
  "lib/sysadmin/util.rb",
36
37
  "script/.gitkeep",
37
38
  "script/build",
39
+ "spec/lib/sysadmin/array_ext_spec.rb",
38
40
  "spec/lib/sysadmin/dir_ext_spec.rb",
39
41
  "spec/lib/sysadmin/directory_spec.rb",
40
42
  "spec/lib/sysadmin/file_ext_spec.rb",
@@ -57,11 +59,11 @@ Gem::Specification.new do |s|
57
59
  s.homepage = "http://github.com/id774/sysadmin"
58
60
  s.licenses = ["GPL"]
59
61
  s.require_paths = ["lib"]
60
- s.rubygems_version = "1.8.24"
61
- s.summary = "Sysadmin Ruby"
62
+ s.rubygems_version = "2.0.6"
63
+ s.summary = "Sysadmin"
62
64
 
63
65
  if s.respond_to? :specification_version then
64
- s.specification_version = 3
66
+ s.specification_version = 4
65
67
 
66
68
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
67
69
  s.add_development_dependency(%q<cucumber>, [">= 0"])
metadata CHANGED
@@ -1,65 +1,58 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sysadmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
5
- prerelease:
4
+ version: 0.1.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - id774
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-10-25 00:00:00.000000000 Z
11
+ date: 2013-08-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: cucumber
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: jeweler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
- description: System Administration General Library
55
+ description: The general-purpose library for system administrations
63
56
  email: idnanashi@gmail.com
64
57
  executables: []
65
58
  extensions: []
@@ -78,6 +71,7 @@ files:
78
71
  - doc/README
79
72
  - doc/README.ja
80
73
  - lib/sysadmin.rb
74
+ - lib/sysadmin/array_ext.rb
81
75
  - lib/sysadmin/dir_ext.rb
82
76
  - lib/sysadmin/directory.rb
83
77
  - lib/sysadmin/file_ext.rb
@@ -85,6 +79,7 @@ files:
85
79
  - lib/sysadmin/util.rb
86
80
  - script/.gitkeep
87
81
  - script/build
82
+ - spec/lib/sysadmin/array_ext_spec.rb
88
83
  - spec/lib/sysadmin/dir_ext_spec.rb
89
84
  - spec/lib/sysadmin/directory_spec.rb
90
85
  - spec/lib/sysadmin/file_ext_spec.rb
@@ -106,26 +101,25 @@ files:
106
101
  homepage: http://github.com/id774/sysadmin
107
102
  licenses:
108
103
  - GPL
104
+ metadata: {}
109
105
  post_install_message:
110
106
  rdoc_options: []
111
107
  require_paths:
112
108
  - lib
113
109
  required_ruby_version: !ruby/object:Gem::Requirement
114
- none: false
115
110
  requirements:
116
- - - ! '>='
111
+ - - '>='
117
112
  - !ruby/object:Gem::Version
118
113
  version: '0'
119
114
  required_rubygems_version: !ruby/object:Gem::Requirement
120
- none: false
121
115
  requirements:
122
- - - ! '>='
116
+ - - '>='
123
117
  - !ruby/object:Gem::Version
124
118
  version: '0'
125
119
  requirements: []
126
120
  rubyforge_project:
127
- rubygems_version: 1.8.24
121
+ rubygems_version: 2.0.6
128
122
  signing_key:
129
- specification_version: 3
130
- summary: Sysadmin Ruby
123
+ specification_version: 4
124
+ summary: Sysadmin
131
125
  test_files: []