sysadmin 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -47,10 +47,8 @@ Author
47
47
  + http://github.com/id774
48
48
 
49
49
 
50
- License
51
- -------
50
+ Copyright and license
51
+ ---------------------
52
52
 
53
- Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
54
-
55
- http://www.gnu.org/copyleft/gpl.html
53
+ See the file doc/LICENSE.
56
54
 
data/Rakefile CHANGED
@@ -59,7 +59,13 @@ namespace :test do
59
59
  desc "Run Tests"
60
60
  require 'rake/testtask'
61
61
  Rake::TestTask.new("test") do |t|
62
- ruby FileList['test/*_test.rb']
63
- ruby FileList['test/**/*_test.rb']
62
+ ruby "test/*_test.rb"
63
+ Dir::glob('test/lib').each do |d|
64
+ Dir::foreach(d) do |f|
65
+ if (FileTest.file?(File.join(d, f)))
66
+ ruby File.join(d, f)
67
+ end
68
+ end
69
+ end
64
70
  end
65
71
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -0,0 +1,165 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
data/doc/ChangeLog CHANGED
@@ -1,3 +1,19 @@
1
+ === 0.0.3 / 2012-05-28
2
+
3
+ * Add docs
4
+
5
+ * Improvement file lock process
6
+
7
+ * Fix Rakefile for CI
8
+
9
+
10
+ === 0.0.2 / 2012-05-24
11
+
12
+ * Add Methods
13
+
14
+ * Sysadmin::FileString.newfile
15
+
16
+
1
17
  === 0.0.1 / 2012-05-23
2
18
 
3
19
  * First release.
data/doc/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ You can redistribute it and/or modify it under either the terms of the GPL
2
+ version 3, or LGPL version 3 (Dual License).
3
+
4
+ See the file doc/COPYING or doc/COPYING.LESSER.
5
+
6
+ Copyright (c) 774 All Rights Reserved.
7
+ Web: http://id774.net
8
+ E-Mail: 774@id774.net, idnanashi@gmail.com
data/doc/README.ja CHANGED
@@ -22,4 +22,26 @@ $ gem install sysadmin
22
22
  モジュール
23
23
  ==========
24
24
 
25
- Sysadmin::FileString
25
+ - Sysadmin::FileString
26
+
27
+
28
+ ========
29
+ メソッド
30
+ ========
31
+
32
+ * Sysadmin::FileString.append(file, str)
33
+
34
+ ファイルに文字列を追記する
35
+
36
+ * Sysadmin::FileString.newfile(file, str)
37
+
38
+ ファイルを新規作成する
39
+
40
+ * Sysadmin::FileString.replace(file, src, out)
41
+
42
+ ファイル内の文字列を置換する
43
+
44
+ * Sysadmin::FileString.delete(file, str)
45
+
46
+ ファイルから文字列にマッチする行を取り除く
47
+
@@ -36,21 +36,25 @@ module Sysadmin
36
36
  end
37
37
 
38
38
  def self.replace(file, src, out)
39
+ file.flock(File::LOCK_EX)
39
40
  open(file, "r+") { |f|
40
- f.flock(File::LOCK_EX)
41
41
  replaceFile(f, src, out)
42
42
  f.truncate(f.tell)
43
43
  }
44
+ file.flock(File::LOCK_UN)
44
45
  end
45
46
 
46
47
  def self.delete(file, str)
47
48
  out = ""
49
+ file.flock(File::LOCK_SH)
48
50
  IO.foreach(file) { |line|
49
51
  out << line unless line.include?(str)
50
52
  }
53
+ file.flock(File::LOCK_EX)
51
54
  open(file, "w") { |f|
52
55
  f.write out
53
56
  }
57
+ file.flock(File::LOCK_UN)
54
58
  end
55
59
  end
56
60
  end
data/lib/sysadmin.rb CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env ruby
2
2
  # Name:: Sysadmin::Ruby
3
3
  # Author:: 774 <http://id774.net>
4
- # Version:: 0.0.2
4
+ # Version:: 0.0.3
5
5
  # Created:: Mar 23, 2012
6
- # Updated:: Mar 24, 2012
6
+ # Updated:: Mar 28, 2012
7
7
  # Copyright:: 774 Copyright (c) 2012
8
8
  # License:: Licensed under the GNU GENERAL PUBLIC LICENSE, Version 3.0.
9
9
 
10
10
  module Sysadmin
11
- VERSION = "0.0.2"
11
+ VERSION = "0.0.3"
12
12
  USER_DIR = "/."
13
13
  ROOT_DIR = File.expand_path("..", File.dirname(__FILE__))
14
14
  $:.unshift ROOT_DIR
data/script/build ADDED
@@ -0,0 +1,27 @@
1
+ #!/bin/sh
2
+ #
3
+ ########################################################################
4
+ # Integration Build Script
5
+ #
6
+ # Maintainer: id774 <idnanashi@gmail.com>
7
+ #
8
+ # v1.0 3/16,2012
9
+ # First.
10
+ ########################################################################
11
+
12
+ kickstart() {
13
+ export RACK_ROOT="."
14
+ export RACK_ENV="test"
15
+ }
16
+
17
+ run_tests() {
18
+ rake test
19
+ }
20
+
21
+ main() {
22
+ kickstart
23
+ run_tests
24
+ }
25
+
26
+ set -ex
27
+ main
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.0.2"
8
+ s.version = "0.0.3"
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-05-24"
12
+ s.date = "2012-05-28"
13
13
  s.description = "System Administration General Library"
14
14
  s.email = "idnanashi@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -22,14 +22,17 @@ Gem::Specification.new do |s|
22
22
  "VERSION",
23
23
  "doc/AUTHORS",
24
24
  "doc/COPYING",
25
+ "doc/COPYING.LESSER",
25
26
  "doc/ChangeLog",
27
+ "doc/LICENSE",
26
28
  "doc/README.ja",
27
29
  "lib/sysadmin.rb",
28
30
  "lib/sysadmin/file_string.rb",
29
31
  "script/.gitkeep",
30
- "spec/.gitkeep",
32
+ "script/build",
31
33
  "sysadmin.gemspec",
32
- "test/lib/file_string_test.rb",
34
+ "test/lib/file_string_1_test.rb",
35
+ "test/lib/file_string_2_test.rb",
33
36
  "test/sysadmin_test.rb",
34
37
  "vendor/.gitkeep"
35
38
  ]
@@ -26,21 +26,6 @@ class Test_FileString < Test::Unit::TestCase
26
26
  }
27
27
  end
28
28
 
29
- def test_newfile
30
- init = 'init'
31
- second = 'second'
32
- expect = "second\n"
33
-
34
- Sysadmin::FileString.newfile(@testfile, init)
35
- Sysadmin::FileString.newfile(@testfile, second)
36
-
37
- open(@testfile) { |file|
38
- while line = file.gets
39
- assert_equal(expect, line)
40
- end
41
- }
42
- end
43
-
44
29
  def test_replace
45
30
  src = 'hoge'
46
31
  try = 'fuga'
@@ -58,7 +43,7 @@ class Test_FileString < Test::Unit::TestCase
58
43
  }
59
44
  end
60
45
 
61
- def test_deleteString
46
+ def test_delete
62
47
  src = 'hoge'
63
48
  replace = 'fuga'
64
49
  erase = 'hoge'
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift File.join(File.dirname(__FILE__), '..', '..', 'lib')
3
+
4
+ require 'rubygems'
5
+ require 'test/unit'
6
+ require 'tempfile'
7
+ require 'sysadmin'
8
+
9
+ class Test_FileString < Test::Unit::TestCase
10
+ def setup
11
+ @testfile = Tempfile::new("test.txt")
12
+ end
13
+
14
+ def test_newfile
15
+ init = 'init'
16
+ second = 'second'
17
+ expect = "second\n"
18
+
19
+ Sysadmin::FileString.newfile(@testfile, init)
20
+ Sysadmin::FileString.newfile(@testfile, second)
21
+
22
+ open(@testfile) { |file|
23
+ while line = file.gets
24
+ assert_equal(expect, line)
25
+ end
26
+ }
27
+ end
28
+
29
+ def teardown
30
+ @testfile.close(true)
31
+ end
32
+ end
@@ -8,7 +8,7 @@ require 'sysadmin'
8
8
 
9
9
  class Test_Sysadmin < Test::Unit::TestCase
10
10
  def test_version
11
- expect = '0.0.2'
11
+ expect = '0.0.3'
12
12
  version = Sysadmin.const_get(:VERSION)
13
13
  p "sysadmin #{version}"
14
14
  assert_equal(expect, version)
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.0.2
4
+ version: 0.0.3
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-05-24 00:00:00.000000000 Z
12
+ date: 2012-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber
@@ -72,14 +72,17 @@ files:
72
72
  - VERSION
73
73
  - doc/AUTHORS
74
74
  - doc/COPYING
75
+ - doc/COPYING.LESSER
75
76
  - doc/ChangeLog
77
+ - doc/LICENSE
76
78
  - doc/README.ja
77
79
  - lib/sysadmin.rb
78
80
  - lib/sysadmin/file_string.rb
79
81
  - script/.gitkeep
80
- - spec/.gitkeep
82
+ - script/build
81
83
  - sysadmin.gemspec
82
- - test/lib/file_string_test.rb
84
+ - test/lib/file_string_1_test.rb
85
+ - test/lib/file_string_2_test.rb
83
86
  - test/sysadmin_test.rb
84
87
  - vendor/.gitkeep
85
88
  homepage: http://github.com/id774/sysadmin
data/spec/.gitkeep DELETED
File without changes