minimart 0.0.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 +15 -0
- data/.gitignore +21 -0
- data/.rspec +3 -0
- data/.travis.yml +13 -0
- data/Gemfile +3 -0
- data/README.md +198 -0
- data/Rakefile +45 -0
- data/bin/minimart +4 -0
- data/lib/minimart.rb +15 -0
- data/lib/minimart/cli.rb +93 -0
- data/lib/minimart/commands/mirror.rb +30 -0
- data/lib/minimart/commands/web.rb +91 -0
- data/lib/minimart/configuration.rb +46 -0
- data/lib/minimart/cookbook.rb +173 -0
- data/lib/minimart/download/cookbook.rb +70 -0
- data/lib/minimart/download/git_cache.rb +60 -0
- data/lib/minimart/download/git_repository.rb +41 -0
- data/lib/minimart/error.rb +32 -0
- data/lib/minimart/inventory_requirement/base_requirement.rb +81 -0
- data/lib/minimart/inventory_requirement/git_requirement.rb +87 -0
- data/lib/minimart/inventory_requirement/git_requirements_builder.rb +101 -0
- data/lib/minimart/inventory_requirement/local_path_requirement.rb +45 -0
- data/lib/minimart/inventory_requirement/local_requirements_builder.rb +31 -0
- data/lib/minimart/inventory_requirement/supermarket_requirements_builder.rb +35 -0
- data/lib/minimart/mirror.rb +12 -0
- data/lib/minimart/mirror/dependency_graph.rb +73 -0
- data/lib/minimart/mirror/download_metadata.rb +57 -0
- data/lib/minimart/mirror/inventory_builder.rb +143 -0
- data/lib/minimart/mirror/inventory_configuration.rb +74 -0
- data/lib/minimart/mirror/inventory_requirements.rb +104 -0
- data/lib/minimart/mirror/local_store.rb +107 -0
- data/lib/minimart/mirror/source.rb +57 -0
- data/lib/minimart/mirror/source_cookbook.rb +77 -0
- data/lib/minimart/mirror/sources.rb +37 -0
- data/lib/minimart/output.rb +34 -0
- data/lib/minimart/utils/archive.rb +39 -0
- data/lib/minimart/utils/file_helper.rb +34 -0
- data/lib/minimart/utils/http.rb +60 -0
- data/lib/minimart/version.rb +3 -0
- data/lib/minimart/web.rb +10 -0
- data/lib/minimart/web/cookbook_show_page_generator.rb +78 -0
- data/lib/minimart/web/cookbooks.rb +83 -0
- data/lib/minimart/web/dashboard_generator.rb +46 -0
- data/lib/minimart/web/html_generator.rb +52 -0
- data/lib/minimart/web/markdown_parser.rb +47 -0
- data/lib/minimart/web/template_helper.rb +132 -0
- data/lib/minimart/web/universe_generator.rb +109 -0
- data/minimart.gemspec +36 -0
- data/spec/fixtures/sample_cookbook.tar.gz +0 -0
- data/spec/fixtures/sample_cookbook/Berksfile +3 -0
- data/spec/fixtures/sample_cookbook/CHANGELOG.md +3 -0
- data/spec/fixtures/sample_cookbook/Gemfile +16 -0
- data/spec/fixtures/sample_cookbook/LICENSE +3 -0
- data/spec/fixtures/sample_cookbook/README.md +42 -0
- data/spec/fixtures/sample_cookbook/Thorfile +5 -0
- data/spec/fixtures/sample_cookbook/Vagrantfile +90 -0
- data/spec/fixtures/sample_cookbook/chefignore +94 -0
- data/spec/fixtures/sample_cookbook/metadata.rb +9 -0
- data/spec/fixtures/sample_cookbook/recipes/default.rb +8 -0
- data/spec/fixtures/sample_inventory.yml +16 -0
- data/spec/fixtures/simple_git_inventory.yml +8 -0
- data/spec/fixtures/simple_inventory.yml +6 -0
- data/spec/fixtures/simple_local_path_inventory.yml +5 -0
- data/spec/fixtures/universe.json +42 -0
- data/spec/fixtures/vcr_cassettes/local_path_cookbooks.yml +3316 -0
- data/spec/fixtures/vcr_cassettes/location_specific_cookbooks.yml +3316 -0
- data/spec/fixtures/vcr_cassettes/supermarket_cookbooks_graph.yml +905 -0
- data/spec/fixtures/vcr_cassettes/supermarket_cookbooks_installing_cookbooks.yml +4218 -0
- data/spec/lib/minimart/cli_spec.rb +104 -0
- data/spec/lib/minimart/commands/mirror_spec.rb +37 -0
- data/spec/lib/minimart/commands/web_spec.rb +75 -0
- data/spec/lib/minimart/configuration_spec.rb +54 -0
- data/spec/lib/minimart/cookbook_spec.rb +137 -0
- data/spec/lib/minimart/download/cookbook_spec.rb +135 -0
- data/spec/lib/minimart/download/git_cache_spec.rb +69 -0
- data/spec/lib/minimart/download/git_repository_spec.rb +39 -0
- data/spec/lib/minimart/error_spec.rb +18 -0
- data/spec/lib/minimart/inventory_requirement/base_requirement_spec.rb +38 -0
- data/spec/lib/minimart/inventory_requirement/git_requirement_spec.rb +92 -0
- data/spec/lib/minimart/inventory_requirement/git_requirements_builder_spec.rb +130 -0
- data/spec/lib/minimart/inventory_requirement/local_path_requirement_spec.rb +35 -0
- data/spec/lib/minimart/inventory_requirement/local_requirements_builder_spec.rb +33 -0
- data/spec/lib/minimart/inventory_requirement/supermarket_requirements_builder_spec.rb +69 -0
- data/spec/lib/minimart/mirror/dependency_graph_spec.rb +123 -0
- data/spec/lib/minimart/mirror/download_metadata_spec.rb +73 -0
- data/spec/lib/minimart/mirror/inventory_builder_spec.rb +195 -0
- data/spec/lib/minimart/mirror/inventory_configuration_spec.rb +86 -0
- data/spec/lib/minimart/mirror/inventory_requirements_spec.rb +78 -0
- data/spec/lib/minimart/mirror/local_store_spec.rb +64 -0
- data/spec/lib/minimart/mirror/source_spec.rb +54 -0
- data/spec/lib/minimart/mirror/sources_spec.rb +50 -0
- data/spec/lib/minimart/output_spec.rb +29 -0
- data/spec/lib/minimart/utils/archive_spec.rb +38 -0
- data/spec/lib/minimart/utils/file_helper_spec.rb +43 -0
- data/spec/lib/minimart/utils/http_spec.rb +37 -0
- data/spec/lib/minimart/web/cookbook_show_page_generator_spec.rb +101 -0
- data/spec/lib/minimart/web/cookbooks_spec.rb +70 -0
- data/spec/lib/minimart/web/dashboard_generator_spec.rb +33 -0
- data/spec/lib/minimart/web/html_generator_spec.rb +34 -0
- data/spec/lib/minimart/web/markdown_parser_spec.rb +54 -0
- data/spec/lib/minimart/web/template_helper_spec.rb +86 -0
- data/spec/lib/minimart/web/universe_generator_spec.rb +125 -0
- data/spec/spec_helper.rb +35 -0
- data/spec/support/file_system.rb +22 -0
- data/web/_assets/javascripts/app.js +164 -0
- data/web/_assets/javascripts/backbone.min.js +6 -0
- data/web/_assets/javascripts/jquery.min.js +4 -0
- data/web/_assets/javascripts/jquery.tabslet.min.js +9 -0
- data/web/_assets/javascripts/manifest.js +5 -0
- data/web/_assets/javascripts/underscore.min.js +5 -0
- data/web/_assets/stylesheets/font-awesome.min.css +4 -0
- data/web/_assets/stylesheets/font-mfizz.css +318 -0
- data/web/_assets/stylesheets/main.css +720 -0
- data/web/_assets/stylesheets/manifest.css +4 -0
- data/web/_assets/stylesheets/normalize.css +427 -0
- data/web/assets/fonts/FontAwesome.otf +0 -0
- data/web/assets/fonts/font-mfizz.eot +0 -0
- data/web/assets/fonts/font-mfizz.svg +1344 -0
- data/web/assets/fonts/font-mfizz.ttf +0 -0
- data/web/assets/fonts/font-mfizz.woff +0 -0
- data/web/assets/fonts/fontawesome-webfont.eot +0 -0
- data/web/assets/fonts/fontawesome-webfont.svg +520 -0
- data/web/assets/fonts/fontawesome-webfont.ttf +0 -0
- data/web/assets/fonts/fontawesome-webfont.woff +0 -0
- data/web/assets/images/header-slim.jpg +0 -0
- data/web/assets/images/icon-search.png +0 -0
- data/web/assets/images/mad-glory-logo.png +0 -0
- data/web/assets/images/main-gradient.png +0 -0
- data/web/assets/images/top-bar-logo.png +0 -0
- data/web/assets/javascripts/application.min.js +5 -0
- data/web/assets/stylesheets/application.min.css +4 -0
- data/web/templates/cookbook_show.erb +96 -0
- data/web/templates/dashboard.erb +81 -0
- data/web/templates/layout.erb +38 -0
- metadata +433 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
module Minimart
|
|
2
|
+
module Web
|
|
3
|
+
# Generate the main Minimart HTML dashboard (index.html)
|
|
4
|
+
class DashboardGenerator
|
|
5
|
+
include Minimart::Web::TemplateHelper
|
|
6
|
+
|
|
7
|
+
# @return [String] the directory to put any generated HTML in
|
|
8
|
+
attr_reader :web_directory
|
|
9
|
+
|
|
10
|
+
# @return [Minimart::Web::Cookbooks] the cookbooks to generate HTML for.
|
|
11
|
+
attr_reader :cookbooks
|
|
12
|
+
|
|
13
|
+
# @return [String] The generated HTML content
|
|
14
|
+
attr_reader :template_content
|
|
15
|
+
|
|
16
|
+
# @param [Hash] opts
|
|
17
|
+
# @option opts [String] :web_directory The directory to put any generated HTML in
|
|
18
|
+
# @option opts [String] :cookbooks The cookbooks to generate HTML for
|
|
19
|
+
def initialize(opts = {})
|
|
20
|
+
@web_directory = opts[:web_directory]
|
|
21
|
+
@cookbooks = opts[:cookbooks]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Generate the dashboard!
|
|
25
|
+
def generate
|
|
26
|
+
generate_template_content
|
|
27
|
+
write_template_to_index_file
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def generate_template_content
|
|
33
|
+
@template_content = render_in_base_layout { render_template('dashboard.erb') }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def write_template_to_index_file
|
|
37
|
+
File.open(index_file, 'w+') { |f| f.write(template_content) }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def index_file
|
|
41
|
+
File.join(web_directory, 'index.html')
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require 'minimart/web/dashboard_generator'
|
|
2
|
+
require 'minimart/web/cookbook_show_page_generator'
|
|
3
|
+
|
|
4
|
+
module Minimart
|
|
5
|
+
module Web
|
|
6
|
+
|
|
7
|
+
# HTML generator coordinated building the various HTML pages (dashboard, show pages).
|
|
8
|
+
class HtmlGenerator
|
|
9
|
+
include Minimart::Web::TemplateHelper
|
|
10
|
+
|
|
11
|
+
# @return [String] the directory to put any generated HTML in
|
|
12
|
+
attr_reader :web_directory
|
|
13
|
+
|
|
14
|
+
# @return [Minimart::Web::Cookbooks] the set of cookbooks to generate HTML for
|
|
15
|
+
attr_reader :cookbooks
|
|
16
|
+
|
|
17
|
+
# @param [Hash] opts
|
|
18
|
+
# @option opts [String] :web_directory The directory to put any generated HTML in
|
|
19
|
+
# @option opts [String] :cookbooks The cookbooks to generate HTML for
|
|
20
|
+
def initialize(opts = {})
|
|
21
|
+
@web_directory = opts[:web_directory]
|
|
22
|
+
@cookbooks = opts[:cookbooks]
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Generate any HTML!
|
|
26
|
+
def generate
|
|
27
|
+
copy_assets
|
|
28
|
+
generate_index
|
|
29
|
+
generate_cookbook_show_pages
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def copy_assets
|
|
35
|
+
FileUtils.cp_r(File.join(minimart_web_directory, 'assets'), web_directory)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def generate_index
|
|
39
|
+
DashboardGenerator.new(
|
|
40
|
+
web_directory: web_directory,
|
|
41
|
+
cookbooks: cookbooks).generate
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def generate_cookbook_show_pages
|
|
45
|
+
CookbookShowPageGenerator.new(
|
|
46
|
+
web_directory: web_directory,
|
|
47
|
+
cookbooks: cookbooks).generate
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'redcarpet'
|
|
2
|
+
|
|
3
|
+
module Minimart
|
|
4
|
+
module Web
|
|
5
|
+
# MarkdownParser takes a String of Markdown input, and outputs HTML
|
|
6
|
+
class MarkdownParser
|
|
7
|
+
|
|
8
|
+
# Parse a file as Markdown. If the file does not contain Markdown, it's
|
|
9
|
+
# contents will be returned.
|
|
10
|
+
# @param [String] file The file to parse
|
|
11
|
+
# @return [String] The parsed Markdown content.
|
|
12
|
+
def self.parse(file)
|
|
13
|
+
if %[.md .markdown].include?(File.extname(file))
|
|
14
|
+
return new(File.open(file).read).parse
|
|
15
|
+
else
|
|
16
|
+
return File.open(file).read
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# @return [String] raw Markdown to parse
|
|
21
|
+
attr_reader :raw_markdown
|
|
22
|
+
|
|
23
|
+
# @param [String] raw_markdown Raw Markdown to parse
|
|
24
|
+
def initialize(raw_markdown)
|
|
25
|
+
@raw_markdown = raw_markdown
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Parse the Markdown contents!
|
|
29
|
+
# @return [String] The parsed Markdown content.
|
|
30
|
+
def parse
|
|
31
|
+
renderer.render(raw_markdown)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def renderer
|
|
37
|
+
Redcarpet::Markdown.new(Redcarpet::Render::HTML,
|
|
38
|
+
no_intra_emphasis: true,
|
|
39
|
+
fenced_code_blocks: true,
|
|
40
|
+
autolink: true,
|
|
41
|
+
tables: true,
|
|
42
|
+
link_attributes: {target: '_blank'})
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
require 'erb'
|
|
2
|
+
require 'tilt/erb'
|
|
3
|
+
|
|
4
|
+
require 'minimart/utils/http'
|
|
5
|
+
|
|
6
|
+
module Minimart
|
|
7
|
+
module Web
|
|
8
|
+
# Various methods to help with template rendering
|
|
9
|
+
module TemplateHelper
|
|
10
|
+
|
|
11
|
+
# Render a template
|
|
12
|
+
# @param [String] template_name The name of the template to render
|
|
13
|
+
# @param [Binding] context The context to use while rendering the template
|
|
14
|
+
# @param [Hash] locals Any local variables to use while rendering the template
|
|
15
|
+
# @return [String] The rendered template content
|
|
16
|
+
def render_template(template_name, context = self, locals = {})
|
|
17
|
+
template(template_name).render(context, locals)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Render a template within the base layout (layout.erb)
|
|
21
|
+
# @yield
|
|
22
|
+
def render_in_base_layout(&block)
|
|
23
|
+
template('layout.erb').render self, {}, &block
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Build a template from the provided template name
|
|
27
|
+
# @param [String] template_name The name of the template to build
|
|
28
|
+
# @return [Tilt::ERBTemplate]
|
|
29
|
+
def template(template_name)
|
|
30
|
+
Tilt::ERBTemplate.new(template_file(template_name))
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# The path to a given template file
|
|
34
|
+
# @param [String] template_name The template to build a path for
|
|
35
|
+
# @return [String] The path to the template file
|
|
36
|
+
def template_file(template_name)
|
|
37
|
+
File.join(minimart_web_directory, 'templates', template_name)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# @return [String] The path to the Minimart web directory
|
|
41
|
+
def minimart_web_directory
|
|
42
|
+
File.join(Minimart.root_path, '..', 'web')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Get the path for a web asset (CSS, JS, etc...)
|
|
46
|
+
# @param [String] resource The asset to get a path for.
|
|
47
|
+
# @return [String] The path to the asset within the Minimart web directory
|
|
48
|
+
def asset_path(resource)
|
|
49
|
+
path_to_assets = base_path_to('assets')
|
|
50
|
+
Utils::Http.concat_url_fragment(path_to_assets, resource)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Build a relative path to the given resource
|
|
54
|
+
# @param [String] resource The resource to build a path for.
|
|
55
|
+
# @return [String] The relative path
|
|
56
|
+
def base_path_to(resource = '')
|
|
57
|
+
result = resource
|
|
58
|
+
level.times { result = "../#{result}" }
|
|
59
|
+
result
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# The relative path to download an archived cookbook file.
|
|
63
|
+
# @param [Minimart::Cookbook] cookbook The cookbook to get a download path for
|
|
64
|
+
# @return [String] The path to the archive file
|
|
65
|
+
def cookbook_download_path(cookbook)
|
|
66
|
+
base_path_to "cookbook_files/#{cookbook.name}/#{cookbook.web_friendly_version}/#{cookbook}.tar.gz"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# The relative path to a cookbook show page
|
|
70
|
+
# @param [Minimart::Cookbook] cookbook The cookbook to get a path for
|
|
71
|
+
# @return [String] The path to the show page
|
|
72
|
+
def cookbook_path(cookbook)
|
|
73
|
+
base_path_to(cookbook_file(cookbook))
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# The path to a cookbook show page from the root of the web directory
|
|
77
|
+
# @param [Minimart::Cookbook] cookbook The cookbook to get a path for
|
|
78
|
+
# @return [String] The path to the cookbook show page
|
|
79
|
+
def cookbook_file(cookbook)
|
|
80
|
+
"#{cookbook_dir(cookbook)}/#{cookbook.version}.html"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# The path to a cookbook's HTML files
|
|
84
|
+
# @param [Minimart::Cookbook] cookbook The cookbook to get a path for
|
|
85
|
+
# @return [String] The path to the cookbook directory
|
|
86
|
+
def cookbook_dir(cookbook)
|
|
87
|
+
"cookbooks/#{cookbook.name}"
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
# @return [String] The relative path to the index.html file
|
|
91
|
+
def home_path
|
|
92
|
+
base_path_to 'index.html'
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# @return [Integer] The number of directories nested under the web directory.
|
|
96
|
+
# This is used for building relative paths.
|
|
97
|
+
def level
|
|
98
|
+
0
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# @return [String] The relative path to the cookbook search route
|
|
102
|
+
def search_path
|
|
103
|
+
"#{home_path}#search/"
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Get an icon name for a given platform (amazon, centos, etc...)
|
|
107
|
+
# @param [String] platform The platform to get an icon for
|
|
108
|
+
# @return [String] The icon name
|
|
109
|
+
def platform_icon(platform)
|
|
110
|
+
case platform.downcase
|
|
111
|
+
when /amazon/i then 'aws'
|
|
112
|
+
when /centos/i then 'centos'
|
|
113
|
+
when /debian/i then 'debian'
|
|
114
|
+
when /fedora/i then 'fedora'
|
|
115
|
+
when /freebsd/i then 'freebsd'
|
|
116
|
+
when /linuxmint/i then 'linux-mint'
|
|
117
|
+
when /mac_os_x/i then 'apple'
|
|
118
|
+
when /oracle/i then 'oracle'
|
|
119
|
+
when /raspbian/i then 'raspberrypi'
|
|
120
|
+
when /redhat/i then 'redhat'
|
|
121
|
+
when /solaris/i then 'solaris'
|
|
122
|
+
when /suse/i then 'suse'
|
|
123
|
+
when /ubuntu/i then 'ubuntu'
|
|
124
|
+
when /windows/i then 'windows'
|
|
125
|
+
else
|
|
126
|
+
'laptop'
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
end
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
require 'minimart/utils/archive'
|
|
2
|
+
require 'minimart/utils/http'
|
|
3
|
+
|
|
4
|
+
module Minimart
|
|
5
|
+
module Web
|
|
6
|
+
# This class is responsible for generating the universe.json file, and the
|
|
7
|
+
# related directory structure of gzipped cookbooks.
|
|
8
|
+
class UniverseGenerator
|
|
9
|
+
include TemplateHelper
|
|
10
|
+
|
|
11
|
+
# @return [String] the directory to put the universe.json file in
|
|
12
|
+
attr_reader :web_directory
|
|
13
|
+
|
|
14
|
+
# @return [String] the base URL to use to build paths for cookbook files.
|
|
15
|
+
attr_reader :endpoint
|
|
16
|
+
|
|
17
|
+
# @return [Minimart::Web::Cookbooks] The cookbooks to build a universe for
|
|
18
|
+
attr_reader :cookbooks
|
|
19
|
+
|
|
20
|
+
attr_reader :universe
|
|
21
|
+
|
|
22
|
+
# @param [Hash] opts
|
|
23
|
+
# @option opts [String] web_directory The directory to put the universe.json file in
|
|
24
|
+
# @option opts [String] endpoint The base URL to use to build paths for cookbook files.
|
|
25
|
+
# @option opts [Minimart::Web::Cookbooks] cookbooks The cookbooks to build a universe for
|
|
26
|
+
def initialize(opts = {})
|
|
27
|
+
@web_directory = opts[:web_directory]
|
|
28
|
+
@endpoint = opts[:endpoint]
|
|
29
|
+
@cookbooks = opts[:cookbooks]
|
|
30
|
+
@universe = {}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Generate the universe file!
|
|
34
|
+
def generate
|
|
35
|
+
clean_existing_cookbook_files
|
|
36
|
+
make_cookbook_files_directory
|
|
37
|
+
create_universe
|
|
38
|
+
write_universe_file
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def clean_existing_cookbook_files
|
|
44
|
+
return unless Dir.exists?(cookbook_files_directory)
|
|
45
|
+
FileUtils.remove_entry(cookbook_files_directory)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def make_cookbook_files_directory
|
|
49
|
+
FileUtils.mkdir_p(cookbook_files_directory)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def create_universe
|
|
53
|
+
cookbooks.individual_cookbooks.each do |cookbook|
|
|
54
|
+
make_cookbook_directory(cookbook)
|
|
55
|
+
generate_archive_file(cookbook)
|
|
56
|
+
add_cookbook_to_universe(cookbook)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def make_cookbook_directory(cookbook)
|
|
61
|
+
FileUtils.mkdir_p(cookbook_directory(cookbook.name))
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# /web/cookbook_files/cookbook-name
|
|
65
|
+
def cookbook_directory(cookbook_name)
|
|
66
|
+
File.join(cookbook_files_directory, cookbook_name)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def generate_archive_file(cookbook)
|
|
70
|
+
FileUtils.mkdir_p(archive_directory(cookbook))
|
|
71
|
+
|
|
72
|
+
Utils::Archive.pack_archive(cookbook, archive_name(cookbook))
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def archive_name(cookbook)
|
|
76
|
+
File.join(archive_directory(cookbook), "#{cookbook}.tar.gz")
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# /web/cookbook_files/cookbook-name/cookbook-version
|
|
80
|
+
def archive_directory(cookbook)
|
|
81
|
+
File.join(cookbook_directory(cookbook.name), cookbook.web_friendly_version)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def add_cookbook_to_universe(cookbook)
|
|
85
|
+
universe[cookbook.name] ||= {}
|
|
86
|
+
universe[cookbook.name][cookbook.version.to_s] = {
|
|
87
|
+
location_type: :uri,
|
|
88
|
+
location_path: archive_url(cookbook),
|
|
89
|
+
download_url: archive_url(cookbook),
|
|
90
|
+
dependencies: cookbook.dependencies
|
|
91
|
+
}
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def archive_url(cookbook)
|
|
95
|
+
Utils::Http.build_url(endpoint, cookbook_download_path(cookbook))
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def write_universe_file
|
|
99
|
+
File.open(File.join(web_directory, 'universe'), 'w+') do |f|
|
|
100
|
+
f.write(universe.to_json)
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def cookbook_files_directory
|
|
105
|
+
@cookbook_files_directory ||= File.join(web_directory, '/cookbook_files')
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
data/minimart.gemspec
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'minimart/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "minimart"
|
|
8
|
+
spec.version = Minimart::VERSION
|
|
9
|
+
spec.authors = %w{Author Names}
|
|
10
|
+
spec.email = %w{Email}
|
|
11
|
+
spec.summary = %q{MiniMart is a RubyGem that makes it simple to build a repository of Chef cookbooks using only static files.}
|
|
12
|
+
spec.description = %q{MiniMart is a RubyGem that makes it simple to build a repository of Chef cookbooks using only static files.}
|
|
13
|
+
spec.homepage = ""
|
|
14
|
+
spec.license = ""
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_dependency 'git', '~> 1.2'
|
|
22
|
+
spec.add_dependency 'minitar', '~> 0.5'
|
|
23
|
+
spec.add_dependency 'octokit', '~> 3.7.0'
|
|
24
|
+
spec.add_dependency 'redcarpet', '~> 3.2'
|
|
25
|
+
spec.add_dependency 'rest-client', '~> 1.7'
|
|
26
|
+
spec.add_dependency 'ridley', '~> 4.1'
|
|
27
|
+
spec.add_dependency 'solve', '~> 1.2.1'
|
|
28
|
+
spec.add_dependency 'thor', '~> 0.19'
|
|
29
|
+
spec.add_dependency 'tilt', '~> 2.0'
|
|
30
|
+
|
|
31
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
|
32
|
+
spec.add_development_dependency 'rake', '~> 10.3'
|
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.1'
|
|
34
|
+
spec.add_development_dependency 'webmock', '~> 1.20'
|
|
35
|
+
spec.add_development_dependency 'vcr', '~> 2.9'
|
|
36
|
+
end
|
|
Binary file
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gem 'berkshelf'
|
|
4
|
+
|
|
5
|
+
# Uncomment these lines if you want to live on the Edge:
|
|
6
|
+
#
|
|
7
|
+
# group :development do
|
|
8
|
+
# gem "berkshelf", github: "berkshelf/berkshelf"
|
|
9
|
+
# gem "vagrant", github: "mitchellh/vagrant", tag: "v1.6.3"
|
|
10
|
+
# end
|
|
11
|
+
#
|
|
12
|
+
# group :plugins do
|
|
13
|
+
# gem "vagrant-berkshelf", github: "berkshelf/vagrant-berkshelf"
|
|
14
|
+
# gem "vagrant-omnibus", github: "schisamo/vagrant-omnibus"
|
|
15
|
+
# end
|
|
16
|
+
|