fab 0.0.0 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/MIT-LICENSE +19 -0
- data/README.md +30 -0
- data/Rakefile +6 -0
- data/fab.gemspec +15 -0
- data/lib/fab.rb +3 -0
- data/pool/fab.cut +16 -0
- data/pool/fab.jar +0 -0
- data/ruby/Fab.rb +18 -0
- data/ruby/Fab/Directory.rb +98 -0
- data/spec/spec_helper.rb +1 -0
- metadata +55 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c4a70d090fc44bb7da72f1d48eed240339321d3
|
4
|
+
data.tar.gz: 8c06c42de6fe2f6f1c9cb4085000264098e71c23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6863e71f3082eb987683a3597752939e213d5852ca539319ea944d76b17d393a9d286b1958f5c43956adc647f3b56b09cff53ad6487b4865733b85cd0f8d2be
|
7
|
+
data.tar.gz: 65060f13db97f1430fbe7807eb1687b4aaaf614a1fce4fe3826095efb2549dde0517fc954176ac431d2a423ff77c5be413bc567bc35f7806ec56d4de8adb8fd8
|
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (C) 2011-2015 InfraRuby Vision
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
4
|
+
copy of this software and associated documentation files (the "Software"),
|
5
|
+
to deal in the Software without restriction, including without limitation
|
6
|
+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
7
|
+
and/or sell copies of the Software, and to permit persons to whom the
|
8
|
+
Software is furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
18
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
19
|
+
DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
InfraRuby fab
|
2
|
+
=============
|
3
|
+
|
4
|
+
This gem provides the InfraRuby fabrication plant.
|
5
|
+
|
6
|
+
|
7
|
+
Example
|
8
|
+
-------
|
9
|
+
|
10
|
+
require "fab"
|
11
|
+
|
12
|
+
d = Fab::Directory.new
|
13
|
+
d.instance_eval do
|
14
|
+
mkdir("hello") {
|
15
|
+
write("README.md", <<-END)
|
16
|
+
hello, world
|
17
|
+
END
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
Support
|
23
|
+
-------
|
24
|
+
|
25
|
+
InfraRuby Vision
|
26
|
+
rubygems@infraruby.com
|
27
|
+
|
28
|
+
http://infraruby.com/
|
29
|
+
https://github.com/InfraRuby
|
30
|
+
https://twitter.com/InfraRuby
|
data/Rakefile
ADDED
data/fab.gemspec
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.platform = "ruby"
|
3
|
+
s.name = "fab"
|
4
|
+
s.version = "0.1.0"
|
5
|
+
s.licenses = ["MIT"]
|
6
|
+
s.author = "InfraRuby Vision"
|
7
|
+
s.email = "rubygems@infraruby.com"
|
8
|
+
s.homepage = "http://infraruby.com/"
|
9
|
+
s.summary = "A fabrication plant"
|
10
|
+
s.description = "A fabrication plant"
|
11
|
+
s.files = Dir["**/*"]
|
12
|
+
s.add_runtime_dependency "infraruby-base", "~> 3.6"
|
13
|
+
s.add_development_dependency "infraruby-task", "~> 3.6"
|
14
|
+
s.add_development_dependency "rspec", "~> 3.0"
|
15
|
+
end
|
data/lib/fab.rb
ADDED
data/pool/fab.cut
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
## <>
|
2
|
+
## .join: String?, String -> String
|
3
|
+
module Fab
|
4
|
+
end
|
5
|
+
|
6
|
+
## <>
|
7
|
+
## :initialize: -> void
|
8
|
+
## :initialize: String -> void
|
9
|
+
## :mkdir: String -> void
|
10
|
+
## :mkdir: String, &#{self -> void} -> void
|
11
|
+
## :mkdir_p: String -> void
|
12
|
+
## :mkdir_p: String, &#{self -> void} -> void
|
13
|
+
## :write: String, String -> void
|
14
|
+
class Fab::Directory < Object
|
15
|
+
end
|
16
|
+
|
data/pool/fab.jar
ADDED
Binary file
|
data/ruby/Fab.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
## <>
|
2
|
+
module Fab
|
3
|
+
class << self
|
4
|
+
## String?, String -> String
|
5
|
+
def join(root, name)
|
6
|
+
if name.empty?
|
7
|
+
raise ArgumentError
|
8
|
+
end
|
9
|
+
if name.start_with?("/")
|
10
|
+
return name
|
11
|
+
end
|
12
|
+
if root.nil?
|
13
|
+
return name
|
14
|
+
end
|
15
|
+
return File.join(root, name)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module Fab
|
2
|
+
## <>
|
3
|
+
## @__root: String?
|
4
|
+
class Directory
|
5
|
+
## -> void
|
6
|
+
## String -> void
|
7
|
+
def initialize(root = nix)
|
8
|
+
super()
|
9
|
+
if root.nix?
|
10
|
+
@__root = nil
|
11
|
+
else
|
12
|
+
@__root = root
|
13
|
+
end
|
14
|
+
return
|
15
|
+
end
|
16
|
+
|
17
|
+
## String, &#{self -> void} -> void
|
18
|
+
def __with_root(new_root, &block)
|
19
|
+
old_root = @__root
|
20
|
+
@__root = new_root
|
21
|
+
begin
|
22
|
+
instance_eval(&block)
|
23
|
+
return
|
24
|
+
ensure
|
25
|
+
@__root = old_root
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
## String -> Array<String>
|
30
|
+
def __stack(name)
|
31
|
+
names = []
|
32
|
+
while name != "."
|
33
|
+
names.push(name)
|
34
|
+
name = File.dirname(name)
|
35
|
+
end
|
36
|
+
return names
|
37
|
+
end
|
38
|
+
|
39
|
+
## String -> void
|
40
|
+
## String, &#{self -> void} -> void
|
41
|
+
def mkdir(name, &block)
|
42
|
+
path = Fab.join(@__root, name)
|
43
|
+
STDOUT.puts "\t" + "mkdir #{path}"
|
44
|
+
begin
|
45
|
+
Dir.mkdir(path)
|
46
|
+
rescue Errno::EEXIST
|
47
|
+
# ...
|
48
|
+
end
|
49
|
+
if block_given?
|
50
|
+
__with_root(path, &block)
|
51
|
+
end
|
52
|
+
return
|
53
|
+
end
|
54
|
+
|
55
|
+
## String -> void
|
56
|
+
## String, &#{self -> void} -> void
|
57
|
+
def mkdir_p(name, &block)
|
58
|
+
if name.empty?
|
59
|
+
raise ArgumentError
|
60
|
+
end
|
61
|
+
names = __stack(name)
|
62
|
+
if names.empty?
|
63
|
+
if block_given?
|
64
|
+
instance_eval(&block)
|
65
|
+
end
|
66
|
+
return
|
67
|
+
end
|
68
|
+
while true
|
69
|
+
path = Fab.join(@__root, names.pop!)
|
70
|
+
STDOUT.puts "\t" + "mkdir #{path}"
|
71
|
+
begin
|
72
|
+
Dir.mkdir(path)
|
73
|
+
rescue Errno::EEXIST
|
74
|
+
# ...
|
75
|
+
end
|
76
|
+
if names.empty?
|
77
|
+
if block_given?
|
78
|
+
__with_root(path, &block)
|
79
|
+
end
|
80
|
+
return
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
## String, String -> void
|
86
|
+
def write(name, s)
|
87
|
+
path = Fab.join(@__root, name)
|
88
|
+
STDOUT.puts "\t" + "write #{path}"
|
89
|
+
f = File.open(path, mode: IO::BINARY | IO::CREAT | IO::TRUNC | IO::WRONLY)
|
90
|
+
begin
|
91
|
+
f.write(s)
|
92
|
+
return
|
93
|
+
ensure
|
94
|
+
f.close
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "fab"
|
metadata
CHANGED
@@ -1,22 +1,74 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- InfraRuby Vision
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
12
|
-
dependencies:
|
11
|
+
date: 2015-03-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: infraruby-base
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: infraruby-task
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
13
55
|
description: A fabrication plant
|
14
56
|
email: rubygems@infraruby.com
|
15
57
|
executables: []
|
16
58
|
extensions: []
|
17
59
|
extra_rdoc_files: []
|
18
60
|
files:
|
61
|
+
- Gemfile
|
62
|
+
- MIT-LICENSE
|
19
63
|
- README.md
|
64
|
+
- Rakefile
|
65
|
+
- fab.gemspec
|
66
|
+
- lib/fab.rb
|
67
|
+
- pool/fab.cut
|
68
|
+
- pool/fab.jar
|
69
|
+
- ruby/Fab.rb
|
70
|
+
- ruby/Fab/Directory.rb
|
71
|
+
- spec/spec_helper.rb
|
20
72
|
homepage: http://infraruby.com/
|
21
73
|
licenses:
|
22
74
|
- MIT
|