docman 0.0.3 → 0.0.4
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.
- checksums.yaml +4 -4
- data/lib/docman/builders/builder.rb +5 -22
- data/lib/docman/builders/git_builder.rb +2 -10
- data/lib/docman/deployers/deployer.rb +2 -2
- data/lib/docman/deployers/local_deployer.rb +1 -1
- data/lib/docman/docroot_config.rb +2 -1
- data/lib/docman/docroot_controller.rb +2 -1
- data/lib/docman/info.rb +21 -8
- data/lib/docman/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05cf8e4e48f3caf7169aa6a3d492bc6bcd2d57ff
|
4
|
+
data.tar.gz: 9d41372a3eaf9c7983919c98d505ebdb26e7339b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f282d5d035f25df19ea05bed2fbe2929cf98ccd124b9ad098ae8a557fb06cccf5f0673709640e4c434f1c312893a23633757a6a47c8021151f64666496b2e77
|
7
|
+
data.tar.gz: 46574cf8a6815bdbe9c93177a0123c8bbd4e0d3b992a02774de5644f428246d27fad0b3f2c572877595ba1fd1fab1e330481441b5334743bd51e48eeafd0a19b
|
@@ -5,10 +5,10 @@ module Docman
|
|
5
5
|
class Builder
|
6
6
|
@@subclasses = {}
|
7
7
|
|
8
|
-
def self.create(type, root, build_type,
|
8
|
+
def self.create(type, root, build_type, info)
|
9
9
|
c = @@subclasses[type]
|
10
10
|
if c
|
11
|
-
c.new(root, build_type,
|
11
|
+
c.new(root, build_type, info)
|
12
12
|
else
|
13
13
|
raise "Bad builder type: #{type}"
|
14
14
|
end
|
@@ -18,10 +18,9 @@ module Docman
|
|
18
18
|
@@subclasses[name] = self
|
19
19
|
end
|
20
20
|
|
21
|
-
def initialize(root, build_type,
|
21
|
+
def initialize(root, build_type, info)
|
22
22
|
@root = root
|
23
23
|
@build_type = build_type
|
24
|
-
@state = state
|
25
24
|
@info = info
|
26
25
|
@before_build_actions = @build_type['before_build_actions'].nil? ? [] : @build_type['before_build_actions']
|
27
26
|
@after_build_actions = @build_type['after_build_actions'].nil? ? [] : @build_type['after_build_actions']
|
@@ -37,26 +36,10 @@ module Docman
|
|
37
36
|
def do
|
38
37
|
perform(@before_build_actions, 'before_build_action')
|
39
38
|
# Dispatch to corresponding method.
|
40
|
-
write_info
|
39
|
+
@info.write_info(self.send("#{@build_type['type']}"))
|
41
40
|
perform(@after_build_actions, 'after_build_action')
|
42
41
|
end
|
43
42
|
|
44
|
-
def write_info(result)
|
45
|
-
to_save = {}
|
46
|
-
# to_save = @info.clone
|
47
|
-
to_save['state'] = @state
|
48
|
-
to_save['version_type'] = @info.version_type(@state) unless @info.version_type(@state).nil?
|
49
|
-
to_save['version'] = @info.version(@state) unless @info.version(@state).nil?
|
50
|
-
to_save['ref'] = result
|
51
|
-
to_save['build_type'] = @build_type['type']
|
52
|
-
# to_save.delete('full_build_path')
|
53
|
-
# to_save.delete('full_path')
|
54
|
-
# to_save.delete('temp_path')
|
55
|
-
# to_save.delete('repo')
|
56
|
-
# to_save.delete('states')
|
57
|
-
File.open("#{@info['full_build_path']}/info.yaml", 'w') {|f| f.write to_save.to_yaml}
|
58
|
-
end
|
59
|
-
|
60
43
|
def perform(actions, method_prefix)
|
61
44
|
unless actions.nil?
|
62
45
|
actions.each do |action|
|
@@ -71,7 +54,7 @@ module Docman
|
|
71
54
|
end
|
72
55
|
|
73
56
|
def after_build_action_git_commit
|
74
|
-
message = "name: #{@info['name']} updated, state: #{@state}"
|
57
|
+
message = "name: #{@info['name']} updated, state: #{@info['state']}"
|
75
58
|
GitUtil.commit(@root['full_build_path'], @info['full_build_path'], message)
|
76
59
|
end
|
77
60
|
end
|
@@ -8,27 +8,19 @@ module Docman
|
|
8
8
|
|
9
9
|
def direct
|
10
10
|
puts 'Do direct'
|
11
|
-
GitUtil.get(@info['repo'], @info['full_build_path'], version_type, version)
|
11
|
+
GitUtil.get(@info['repo'], @info['full_build_path'], @info.version_type, @info.version)
|
12
12
|
end
|
13
13
|
|
14
14
|
def strip
|
15
15
|
puts 'Do strip'
|
16
16
|
FileUtils.rm_r(@info['full_build_path']) if File.directory? @info['full_build_path']
|
17
|
-
result = GitUtil.get(@info['repo'], @info['temp_path'], version_type, version)
|
17
|
+
result = GitUtil.get(@info['repo'], @info['temp_path'], @info.version_type, @info.version)
|
18
18
|
FileUtils.mkdir_p(@info['full_build_path'])
|
19
19
|
FileUtils.cp_r(Dir["#{@info['temp_path']}/."], @info['full_build_path'])
|
20
20
|
FileUtils.rm_r(File.join(@info['full_build_path'], '.git'))
|
21
21
|
result
|
22
22
|
end
|
23
23
|
|
24
|
-
# TODO: need to refactor into into @info class.
|
25
|
-
def version
|
26
|
-
@info['states'][@state]['version']
|
27
|
-
end
|
28
|
-
|
29
|
-
def version_type
|
30
|
-
@info['states'][@state]['type']
|
31
|
-
end
|
32
24
|
end
|
33
25
|
end
|
34
26
|
end
|
@@ -4,10 +4,10 @@ module Docman
|
|
4
4
|
|
5
5
|
attr_reader :deploy_target
|
6
6
|
|
7
|
-
def build(root,
|
7
|
+
def build(root, info)
|
8
8
|
return if @deployed.include? info['name']
|
9
9
|
build_type = build_type(info['type'])
|
10
|
-
Docman::Builders::Builder.create(build_type['handler'], root, build_type,
|
10
|
+
Docman::Builders::Builder.create(build_type['handler'], root, build_type, info).do()
|
11
11
|
@deployed << info['name']
|
12
12
|
end
|
13
13
|
|
@@ -5,7 +5,7 @@ module Docman
|
|
5
5
|
|
6
6
|
class DocrootConfig
|
7
7
|
|
8
|
-
attr_reader :structure
|
8
|
+
attr_reader :structure, :deploy_target
|
9
9
|
|
10
10
|
def initialize(docroot_dir, deploy_target)
|
11
11
|
@docroot_dir = docroot_dir
|
@@ -27,6 +27,7 @@ module Docman
|
|
27
27
|
name = File.basename path
|
28
28
|
prefix = prefix.size > 0 ? File.join(prefix, name) : name
|
29
29
|
info['full_path'] = path
|
30
|
+
info['docroot_config'] = self
|
30
31
|
info['build_path'] = prefix
|
31
32
|
info['full_build_path'] = File.join(@docroot_dir, prefix)
|
32
33
|
info['temp_path'] = File.join(@docroot_dir, 'tmp', info['build_path'])
|
data/lib/docman/info.rb
CHANGED
@@ -1,20 +1,32 @@
|
|
1
1
|
module Docman
|
2
2
|
class Info < Hash
|
3
|
+
|
3
4
|
def initialize(hash = {})
|
4
5
|
super
|
5
6
|
hash.each_pair do |k, v|
|
6
7
|
self[k] = v
|
7
8
|
end
|
8
|
-
|
9
|
-
# self['rebuild'] = need_rebuild?
|
9
|
+
self['build_type'] = self['docroot_config'].deploy_target['builders'][self['type']]['type']
|
10
10
|
end
|
11
11
|
|
12
|
-
def version
|
13
|
-
self['states'][state].nil? ? nil : self['states'][state]['version']
|
12
|
+
def version
|
13
|
+
self['states'][self['state']].nil? ? nil : self['states'][self['state']]['version']
|
14
14
|
end
|
15
15
|
|
16
|
-
def version_type
|
17
|
-
self['states'][state].nil? ? nil : self['states'][state]['type']
|
16
|
+
def version_type
|
17
|
+
self['states'][self['state']].nil? ? nil : self['states'][self['state']]['type']
|
18
|
+
end
|
19
|
+
|
20
|
+
def write_info(result)
|
21
|
+
to_save = {}
|
22
|
+
to_save['state'] = self['state']
|
23
|
+
to_save['version_type'] = self.version_type unless self.version_type.nil?
|
24
|
+
to_save['version'] = self.version unless self.version.nil?
|
25
|
+
# to_save['ref'] = result
|
26
|
+
to_save['type'] = self['type']
|
27
|
+
to_save['build_type'] = self['build_type']
|
28
|
+
|
29
|
+
File.open("#{self['full_build_path']}/info.yaml", 'w') {|f| f.write to_save.to_yaml}
|
18
30
|
end
|
19
31
|
|
20
32
|
def need_rebuild?
|
@@ -28,8 +40,9 @@ module Docman
|
|
28
40
|
false
|
29
41
|
end
|
30
42
|
|
31
|
-
def
|
32
|
-
|
43
|
+
def state=(state)
|
44
|
+
self['state'] = state
|
33
45
|
end
|
46
|
+
|
34
47
|
end
|
35
48
|
end
|
data/lib/docman/version.rb
CHANGED