cupper 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4cb1f5ee3842ee97e25770577a390f8547a47e3a
4
- data.tar.gz: c2e64363e16d0d940d9a542fec515b1524d93b1c
3
+ metadata.gz: c5222cb608fedc123c84ca945f2885f4e5609f9f
4
+ data.tar.gz: 0ee85f347f7e47b8b149ae7db5ba0a8e0e3405c9
5
5
  SHA512:
6
- metadata.gz: c4216eeb5b6377d1e1240b15dde4b585fc347a1e34d1188529b0e7ffc0a8337626e80f24dc1cb35153e11080f4b1e4ac267590660591744343a9103499581fda
7
- data.tar.gz: 394040efd699a88b89d51ff7361abc483f93b9b034fb90929d79c033201bdbac469425819c6c15a75274677285b4d5673d25ea404b09f4863e555d1e290bcb84
6
+ metadata.gz: 0631c79f3a2fd563f65f10b7f5eef51fd90a25b885e5044547e767a5e617c2915e84203f2eb53e48ec1c3be35074d5c29cb3de303c9c1d7f857f0fe05a4ac6b6
7
+ data.tar.gz: 7d54800377105f0d8112195e279192a8b5d5aa6d1ce585922136e1d2e0ec04fe40ab3ca0d0e189705c138e935bb72816db5c090b282f90d6ca6be7a2f0de9689
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /*.gem
@@ -10,12 +10,12 @@ module Cupper
10
10
  @cookbook_files_path = "#{@cookbook_path}/files"
11
11
  @cookbook_recipes_path = "#{@cookbook_path}/recipes"
12
12
  @recipe_deps = [ # TODO this is hard code to reflect all_recipes. Refactor this later
13
- "#{cookbookname}::cookbook_file",
13
+ "#{cookbookname}::packages",
14
+ "#{cookbookname}::cookbook_files",
14
15
  "#{cookbookname}::links",
15
16
  "#{cookbookname}::groups",
16
17
  "#{cookbookname}::services",
17
18
  "#{cookbookname}::users",
18
- "#{cookbookname}::packages",
19
19
  ]
20
20
  setup_paths
21
21
  end
@@ -30,7 +30,6 @@ module Cupper
30
30
  collector = Collect.new
31
31
  collector.setup
32
32
  all_recipes(collector)
33
- all_cookbook_files(collector)
34
33
  end
35
34
 
36
35
  def all_recipes(collector)
@@ -42,30 +41,5 @@ module Cupper
42
41
  Recipe.new(@cookbook_recipes_path, collector, '_users', 'users').create
43
42
  Recipe.new(@cookbook_recipes_path, collector, '_package', 'packages').create
44
43
  end
45
-
46
- def all_cookbook_files(collector)
47
- expand_cookbook_files(collector.extract 'files')
48
- end
49
-
50
- def text_type?(file)
51
- file[1]['type'].match('text') or file[1]['type'].match('ASCII')
52
- end
53
-
54
- def expand_cookbook_files(files)
55
- files.each do |attr|
56
- if text_type?(attr) and !(attr[1]['related'].nil?)
57
- source = attr[0].split('/').last
58
- content = attr[1]['content']
59
- CookbookFile.new(@cookbook_files_path, source, content, 'cookbook_file').create
60
- end
61
- # TODO: This is a work around to source list file
62
- # should be replaced for a better logic
63
- if text_type?(attr) and attr[0].include? "/etc/apt/sources.list"
64
- source = attr[0].split('/').last
65
- content = attr[1]['content']
66
- CookbookFile.new(@cookbook_files_path, source, content, 'cookbook_file').create
67
- end
68
- end
69
- end
70
44
  end
71
45
  end
@@ -14,47 +14,22 @@ module Cupper
14
14
  @links = Array.new
15
15
  @directories = Array.new
16
16
  @files = Array.new
17
+ @files_path = "#{dest_path.chomp("recipes")}/files"
17
18
  @collector = collector
18
19
  super(recipe_name, dest_path, erb_file, nil, '.rb')
19
20
  end
20
21
 
21
22
  def create
22
- @sources_list = expand_sources_list(@collector.extract 'files')
23
- @packages = expand_packages(@collector.extract 'packages')
24
- @services = expand_services(@collector.extract 'services')
25
- @users = expand_users(@collector.extract 'users')
26
- @groups = expand_groups(@collector.extract 'groups')
27
- @links = expand_links(@collector.extract 'files')
28
- @files = expand_files(@collector.extract 'files')
23
+ @sources_list = expand_sources_list(@collector.extract 'files')
24
+ @packages = expand_packages(@collector.extract 'packages')
25
+ @services = expand_services(@collector.extract 'services')
26
+ @users = expand_users(@collector.extract 'users')
27
+ @groups = expand_groups(@collector.extract 'groups')
28
+ @links = expand_links(@collector.extract 'files')
29
+ @files = expand_files(@collector.extract 'files')
29
30
  super
30
31
  end
31
32
 
32
- def expand_sources_list(files)
33
- att = Array.new
34
- files.each do |attr|
35
- # TODO: Doesn't works for arch, this should be a plugin responsability
36
- if attr[0].include?("/etc/apt/sources.list") and (convert_mode(attr[1]['mode']) != 'Unknown') and text_type?(attr)
37
- path = attr[0]
38
- group = attr[1]['group']
39
- mode = attr[1]['mode']
40
- owner = attr[1]['owner']
41
- att.push(new_file(group, mode, owner, path))
42
- end
43
- end
44
- att
45
- end
46
-
47
- def expand_packages(packages)
48
- att = Array.new
49
- packages.each do |attr|
50
- pkg = attr[0]
51
- version = attr[1]['version']
52
-
53
- att.push(new_package(pkg,version))
54
- end
55
- att
56
- end
57
-
58
33
  def link_type?(file)
59
34
  (file[1]['type'].split.first(2).join(' ').match('symbolic link'))
60
35
  end
@@ -82,6 +57,33 @@ module Cupper
82
57
  result
83
58
  end
84
59
 
60
+
61
+ def expand_sources_list(files)
62
+ att = Array.new
63
+ files.each do |attr|
64
+ # TODO: Doesn't works for arch, this should be a plugin responsability
65
+ if attr[0].include?("/etc/apt/sources.list") and (convert_mode(attr[1]['mode']) != 'Unknown') and text_type?(attr)
66
+ path = attr[0]
67
+ group = attr[1]['group']
68
+ mode = attr[1]['mode']
69
+ owner = attr[1]['owner']
70
+ att.push(new_file(group, mode, owner, path))
71
+ end
72
+ end
73
+ att
74
+ end
75
+
76
+ def expand_packages(packages)
77
+ att = Array.new
78
+ packages.each do |attr|
79
+ pkg = attr[0]
80
+ version = attr[1]['version']
81
+
82
+ att.push(new_package(pkg,version))
83
+ end
84
+ att
85
+ end
86
+
85
87
  def expand_services(services)
86
88
  att = Array.new
87
89
  services.each do |attr|
@@ -138,13 +140,17 @@ module Cupper
138
140
  def expand_files(files)
139
141
  att = Array.new
140
142
  files.each do |attr|
141
- if text_type?(attr) and !(attr[1]['related'].nil?)
143
+ if text_type?(attr) and (!(attr[1]['related'].nil?) or attr[0].include? "/etc/apt/sources.list")
142
144
  path = attr[0]
143
145
  group = attr[1]['group']
144
146
  mode = attr[1]['mode']
145
147
  owner = attr[1]['owner']
146
-
147
148
  att.push(new_file(group, mode, owner, path))
149
+
150
+ # Related file
151
+ source = attr[0].split('/').last
152
+ content = attr[1]['content']
153
+ CookbookFile.new(@files_path, source, content, 'cookbook_file').create
148
154
  end
149
155
  end
150
156
  att
@@ -1,7 +1,7 @@
1
1
  # Cookbook_file Session
2
2
 
3
3
  <% for @cbf in @files %>
4
- cookbook_file '<%= @cbf.path %>'
4
+ cookbook_file '<%= @cbf.path %>' do
5
5
  owner '<%= @cbf.owner %>'
6
6
  group '<%= @cbf.group %>'
7
7
  mode '<%= @cbf.mode %>'
@@ -1,3 +1,3 @@
1
1
  module Cupper
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cupper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paulo Tada