brick_and_mortar 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.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.gitattributes +17 -0
  3. data/.gitignore +35 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +22 -0
  6. data/README.md +68 -0
  7. data/Rakefile +18 -0
  8. data/bin/mortar +39 -0
  9. data/brick_and_mortar.gemspec +29 -0
  10. data/docs/Makefile +39 -0
  11. data/docs/html.template.pandoc +61 -0
  12. data/docs/pdf.template.pandoc +206 -0
  13. data/docs/references.bib +9 -0
  14. data/docs/tex.template.pandoc +213 -0
  15. data/lib/brick_and_mortar/brick.rb +150 -0
  16. data/lib/brick_and_mortar/config.rb +131 -0
  17. data/lib/brick_and_mortar/coverage/.last_run.json +5 -0
  18. data/lib/brick_and_mortar/coverage/.resultset.json +7 -0
  19. data/lib/brick_and_mortar/coverage/.resultset.json.lock +0 -0
  20. data/lib/brick_and_mortar/coverage/assets/0.10.0/application.css +799 -0
  21. data/lib/brick_and_mortar/coverage/assets/0.10.0/application.js +1707 -0
  22. data/lib/brick_and_mortar/coverage/assets/0.10.0/colorbox/border.png +0 -0
  23. data/lib/brick_and_mortar/coverage/assets/0.10.0/colorbox/controls.png +0 -0
  24. data/lib/brick_and_mortar/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
  25. data/lib/brick_and_mortar/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
  26. data/lib/brick_and_mortar/coverage/assets/0.10.0/favicon_green.png +0 -0
  27. data/lib/brick_and_mortar/coverage/assets/0.10.0/favicon_red.png +0 -0
  28. data/lib/brick_and_mortar/coverage/assets/0.10.0/favicon_yellow.png +0 -0
  29. data/lib/brick_and_mortar/coverage/assets/0.10.0/loading.gif +0 -0
  30. data/lib/brick_and_mortar/coverage/assets/0.10.0/magnify.png +0 -0
  31. data/lib/brick_and_mortar/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  32. data/lib/brick_and_mortar/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  33. data/lib/brick_and_mortar/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  34. data/lib/brick_and_mortar/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  35. data/lib/brick_and_mortar/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  36. data/lib/brick_and_mortar/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  37. data/lib/brick_and_mortar/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  38. data/lib/brick_and_mortar/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  39. data/lib/brick_and_mortar/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
  40. data/lib/brick_and_mortar/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  41. data/lib/brick_and_mortar/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
  42. data/lib/brick_and_mortar/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
  43. data/lib/brick_and_mortar/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  44. data/lib/brick_and_mortar/coverage/index.html +72 -0
  45. data/lib/brick_and_mortar/download.rb +99 -0
  46. data/lib/brick_and_mortar/git.rb +12 -0
  47. data/lib/brick_and_mortar/project.rb +33 -0
  48. data/lib/brick_and_mortar/svn.rb +19 -0
  49. data/lib/brick_and_mortar/version.rb +3 -0
  50. data/lib/brick_and_mortar.rb +10 -0
  51. data/spec/config_spec.rb +277 -0
  52. data/spec/download_spec.rb +38 -0
  53. data/spec/git_spec.rb +38 -0
  54. data/spec/mortar_spec.rb +6 -0
  55. data/spec/project_spec.rb +34 -0
  56. data/spec/support/mocks.rb +23 -0
  57. data/spec/support/network_mocks.rb +34 -0
  58. data/spec/support/spec_helper.rb +18 -0
  59. data/spec/support/test_files/git_https_brickfile.yml +6 -0
  60. data/spec/support/test_files/git_ssh_brickfile.yml +6 -0
  61. data/spec/support/test_files/hg_brickfile.yml +6 -0
  62. data/spec/support/test_files/local_project/README.md +1 -0
  63. data/spec/support/test_files/local_project_brickfile.yml +4 -0
  64. data/spec/support/test_files/svn_brickfile.yml +6 -0
  65. data/spec/support/test_files/test_project/Brickfile +22 -0
  66. data/spec/support/test_files/url_brickfile.yml +4 -0
  67. data/spec/svn_spec.rb +38 -0
  68. metadata +227 -0
@@ -0,0 +1,72 @@
1
+ <!DOCTYPE html>
2
+ <html xmlns='http://www.w3.org/1999/xhtml'>
3
+ <head>
4
+ <title>Code coverage for BrickAndMortar</title>
5
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6
+ <script src='./assets/0.10.0/application.js' type='text/javascript'></script>
7
+ <link href='./assets/0.10.0/application.css' media='screen, projection, print' rel='stylesheet' type='text/css'>
8
+ <link rel="shortcut icon" type="image/png" href="./assets/0.10.0/favicon_green.png" />
9
+ <link rel="icon" type="image/png" href="./assets/0.10.0/favicon.png" />
10
+ </head>
11
+
12
+ <body>
13
+ <div id="loading">
14
+ <img src="./assets/0.10.0/loading.gif" alt="loading"/>
15
+ </div>
16
+ <div id="wrapper" style="display:none;">
17
+ <div class="timestamp">Generated <abbr class="timeago" title="2015-08-29T17:04:05-06:00">2015-08-29T17:04:05-06:00</abbr></div>
18
+ <ul class="group_tabs"></ul>
19
+
20
+ <div id="content">
21
+ <div class="file_list_container" id="AllFiles">
22
+ <h2>
23
+ <span class="group_name">All Files</span>
24
+ (<span class="covered_percent"><span class="green">100.0%</span></span>
25
+ covered at
26
+ <span class="covered_strength">
27
+ <span class="red">
28
+ 0.0
29
+ </span>
30
+ </span> hits/line)
31
+ </h2>
32
+ <a name="AllFiles"></a>
33
+ <div>
34
+ <b>0</b> files in total.
35
+ <b>0.0</b> relevant lines.
36
+ <span class="green"><b>0.0</b> lines covered</span> and
37
+ <span class="red"><b>0.0</b> lines missed </span>
38
+ </div>
39
+ <table class="file_list">
40
+ <thead>
41
+ <tr>
42
+ <th>File</th>
43
+ <th>% covered</th>
44
+ <th>Lines</th>
45
+ <th>Relevant Lines</th>
46
+ <th>Lines covered</th>
47
+ <th>Lines missed</th>
48
+ <th>Avg. Hits / Line</th>
49
+ </tr>
50
+ </thead>
51
+ <tbody>
52
+
53
+ </tbody>
54
+ </table>
55
+ </div>
56
+
57
+
58
+
59
+ </div>
60
+
61
+ <div id="footer">
62
+ Generated by <a href="http://github.com/colszowka/simplecov">simplecov</a> v0.10.0
63
+ and simplecov-html v0.10.0<br/>
64
+ using MiniTest
65
+ </div>
66
+
67
+ <div class="source_files">
68
+
69
+ </div>
70
+ </div>
71
+ </body>
72
+ </html>
@@ -0,0 +1,99 @@
1
+ require 'open-uri'
2
+ # Thanks to WinstonYW
3
+ # http://winstonyw.com/2013/10/02/openuris_open_tempfile_and_stringio/
4
+ # for this.
5
+ # Don't allow downloaded files to be created as StringIO. Force a tempfile to be created.
6
+ OpenURI::Buffer.send :remove_const, 'StringMax' if OpenURI::Buffer.const_defined?('StringMax')
7
+ OpenURI::Buffer.const_set 'StringMax', 0
8
+ require 'zip'
9
+ require 'zlib'
10
+ require 'rubygems/package'
11
+
12
+ module BrickAndMortar
13
+ module Download
14
+ TAR_LONGLINK = '././@LongLink'
15
+
16
+ def self.name_from_path(url)
17
+ File.basename(url, File.extname(url))
18
+ end
19
+ def self.unzip(zip_file)
20
+ root_dir_name = nil
21
+ Zip::File.open(zip_file) do |z|
22
+ z.each do |entry|
23
+ next unless entry.file?
24
+ fpath = entry.to_s
25
+ unless root_dir_name
26
+ root_dir_name = File.dirname fpath
27
+ end
28
+ unless File.exist?(entry.name)
29
+ FileUtils::mkdir_p(File.dirname(entry.name))
30
+ # puts "Extracting #{entry.name} to #{fpath}"
31
+ entry.extract(entry.name)
32
+ end
33
+ end
34
+ end
35
+ root_dir_name
36
+ end
37
+ # Thanks to TomCZ
38
+ # http://stackoverflow.com/questions/856891/unzip-zip-tar-tag-gz-files-with-ruby
39
+ # for this
40
+ def self.deflate_tar_gz(tar_gz_archive, destination = Dir.pwd)
41
+ first_directory = nil
42
+ Gem::Package::TarReader.new(Zlib::GzipReader.open(tar_gz_archive)) do |tar|
43
+ dest = nil
44
+ tar.each do |entry|
45
+ if entry.full_name == TAR_LONGLINK
46
+ dest = File.join destination, entry.read.strip
47
+ next
48
+ end
49
+ dest ||= File.join destination, entry.full_name
50
+ if entry.directory?
51
+ FileUtils.rm_rf dest unless File.directory? dest
52
+ FileUtils.mkdir_p dest, :mode => entry.header.mode, :verbose => false
53
+ first_directory = dest unless first_directory
54
+ elsif entry.file?
55
+ FileUtils.rm_rf dest unless File.file? dest
56
+ dir = File.dirname dest
57
+ unless File.exist?(dir)
58
+ FileUtils.mkpath dir
59
+ first_directory = dir unless first_directory
60
+ end
61
+ File.open dest, "wb" do |f|
62
+ f.print entry.read
63
+ end
64
+ FileUtils.chmod entry.header.mode, dest, :verbose => false
65
+ unless first_directory
66
+ puts "WARNING: File \"#{dest}\" created before a root directory"
67
+ end
68
+ elsif entry.header.typeflag == '2' #Symlink!
69
+ dir = File.dirname dest
70
+ unless File.exist?(dir)
71
+ FileUtils.mkpath dir
72
+ first_directory = dir unless first_directory
73
+ end
74
+ File.symlink entry.header.linkname, dest
75
+ unless first_directory
76
+ puts "WARNING: Symlink \"#{dest}\" to \"#{entry.header.linkname}\" created before a root directory"
77
+ end
78
+ end
79
+ dest = nil
80
+ end
81
+ end
82
+ first_directory
83
+ end
84
+ def self.get_and_unpack_zip(url, name = nil, options = {})
85
+ unless name
86
+ name = name_from_path url
87
+ end
88
+ unzipped_dir_name = unzip(open(url))
89
+ FileUtils.mv unzipped_dir_name, name
90
+ end
91
+ def self.get_and_unpack_tar_gz(url, name = nil, options = {})
92
+ unless name
93
+ name = name_from_path url
94
+ end
95
+ uncompressed_dir_name = deflate_tar_gz(open(url))
96
+ FileUtils.mv uncompressed_dir_name, name
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,12 @@
1
+ require 'git'
2
+
3
+ module BrickAndMortar
4
+ module Git
5
+ def self.clone_repo(url, name = nil, options = {})
6
+ unless name
7
+ name = File.basename(url, File.extname(url))
8
+ end
9
+ ::Git.clone(url, name, options)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,33 @@
1
+ require 'fileutils'
2
+ require 'brick_and_mortar/config'
3
+
4
+ module BrickAndMortar
5
+ class Project
6
+ attr_reader :project_root, :config, :bricks
7
+
8
+ DEFAULT_BRICK_STORE = File.join(Dir.home, '.bricks')
9
+
10
+ def initialize(brickfile, brick_store = DEFAULT_BRICK_STORE)
11
+ @config = Config.new brick_store
12
+ @config.create_store!
13
+ @bricks = @config.parse_file! brickfile
14
+ @project_root = File.dirname(brickfile)
15
+ end
16
+
17
+ def vendor
18
+ File.join(@project_root, 'vendor')
19
+ end
20
+
21
+ def laid?
22
+ @bricks.reduce(File.exist?(vendor)) do |has_been_laid, brick|
23
+ break has_been_laid unless has_been_laid
24
+ has_been_laid && brick.laid?(vendor)
25
+ end
26
+ end
27
+
28
+ def lay!
29
+ FileUtils.mkpath vendor
30
+ @bricks.each { |b| b.lay! vendor }
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,19 @@
1
+ module BrickAndMortar
2
+ module Svn
3
+ def self.checkout_repo(url, name = nil, options = {})
4
+ unless name
5
+ split_url = url.split '/'
6
+ name = if split_url.last == 'trunk'
7
+ split_url.last
8
+ else
9
+ split_url[-2]
10
+ end
11
+ end
12
+
13
+ # @todo This doesn't set the working directory properly for svn, but it's needed to handle the case where the user needs to interact with svn (for password, for instance)
14
+ # IO.popen "svn co #{url} #{name}"
15
+
16
+ system "svn co #{url} #{name}"
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module BrickAndMortar
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,10 @@
1
+ require 'brick_and_mortar/version'
2
+ require 'brick_and_mortar/brick'
3
+ require 'brick_and_mortar/download'
4
+ require 'brick_and_mortar/project'
5
+ require 'brick_and_mortar/config'
6
+ require 'brick_and_mortar/git'
7
+ require 'brick_and_mortar/svn'
8
+
9
+ module BrickAndMortar
10
+ end
@@ -0,0 +1,277 @@
1
+ require_relative 'support/spec_helper'
2
+
3
+ require_relative '../lib/brick_and_mortar/config'
4
+ require_relative 'support/network_mocks'
5
+
6
+ BRICK_STORE = File.expand_path('../.test_brick_store', __FILE__)
7
+
8
+ def test_git_https_config(patient)
9
+ patient.length.must_equal 1
10
+ patient[0].name.must_equal 'brick_and_mortar'
11
+ patient[0].version.must_equal '0.0.1'
12
+ patient[0].location.method.must_equal 'git'
13
+ patient[0].location.format.must_equal 'plain'
14
+ patient[0].location.url.must_equal 'https://github.com/dmorrill10/brick_and_mortar.git'
15
+ File.basename(patient[0].destination).must_equal 'brick_and_mortar-0.0.1'
16
+ patient[0].destination.must_equal File.join(BRICK_STORE, 'brick_and_mortar-0.0.1')
17
+ patient[0].exists?.must_equal false
18
+ patient[0].create!
19
+ patient[0].exists?.must_equal true
20
+ patient[0].destroy!
21
+ patient[0].exists?.must_equal false
22
+ end
23
+
24
+ def test_git_ssh_config(patient)
25
+ patient.length.must_equal 1
26
+ patient[0].name.must_equal 'brick_and_mortar'
27
+ patient[0].version.must_equal '0.0.1'
28
+ patient[0].location.method.must_equal 'git'
29
+ patient[0].location.format.must_equal 'plain'
30
+ patient[0].location.url.must_equal 'git@github.com:dmorrill10/brick_and_mortar.git'
31
+ File.basename(patient[0].destination).must_equal 'brick_and_mortar-0.0.1'
32
+ patient[0].destination.must_equal File.join(BRICK_STORE, 'brick_and_mortar-0.0.1')
33
+ patient[0].exists?.must_equal false
34
+ patient[0].create!
35
+ patient[0].exists?.must_equal true
36
+ patient[0].destroy!
37
+ patient[0].exists?.must_equal false
38
+ end
39
+
40
+ def test_zip_url_config(patient)
41
+ patient.length.must_equal 1
42
+ patient[0].name.must_equal 'brick_and_mortar'
43
+ patient[0].version.must_equal '0.0.1'
44
+ patient[0].location.method.must_equal 'download'
45
+ patient[0].location.format.must_equal 'zip'
46
+ patient[0].location.url.must_equal 'https://github.com/dmorrill10/brick_and_mortar/archive/master.zip'
47
+ File.basename(patient[0].destination).must_equal 'brick_and_mortar-0.0.1'
48
+ patient[0].destination.must_equal File.join(BRICK_STORE, 'brick_and_mortar-0.0.1')
49
+ patient[0].exists?.must_equal false
50
+ patient[0].create!
51
+ patient[0].exists?.must_equal true
52
+ end
53
+
54
+ def test_tar_gz_url_config(patient, brick_store = BRICK_STORE)
55
+ patient.length.must_equal 1
56
+ patient[0].name.must_equal 'brick_and_mortar'
57
+ patient[0].version.must_equal '0.0.1'
58
+ patient[0].location.method.must_equal 'download'
59
+ patient[0].location.format.must_equal 'tar.gz'
60
+ patient[0].location.url.must_equal 'https://github.com/dmorrill10/brick_and_mortar/archive/master.tar.gz'
61
+ File.basename(patient[0].destination).must_equal 'brick_and_mortar-0.0.1'
62
+ patient[0].destination.must_equal File.join(brick_store, 'brick_and_mortar-0.0.1')
63
+ patient[0].exists?.must_equal false
64
+ patient[0].create!
65
+ patient[0].exists?.must_equal true
66
+ end
67
+
68
+ describe BrickAndMortar::Config do
69
+
70
+ before do
71
+ FileUtils.rm_rf BRICK_STORE
72
+ end
73
+
74
+ after do
75
+ FileUtils.rm_rf BRICK_STORE
76
+ end
77
+
78
+ let(:patient) { BrickAndMortar::Config.new(BRICK_STORE) }
79
+
80
+ it 'detects whether or not the brick store exists' do
81
+ patient.store.must_equal BRICK_STORE
82
+ patient.store_exists?.must_equal false
83
+ patient.store = File.expand_path '..', __FILE__
84
+ patient.store.must_equal File.expand_path('..', __FILE__)
85
+ patient.store_exists?.must_equal true
86
+ end
87
+ it 'can create and destroy the brick store' do
88
+ patient.store.must_equal BRICK_STORE
89
+ patient.store_exists?.must_equal false
90
+ patient.create_store!
91
+ patient.store_exists?.must_equal true
92
+ patient.destroy_store!
93
+ patient.store_exists?.must_equal false
94
+ end
95
+ describe 'parses Brickfile.yml configuration with' do
96
+ describe 'git https' do
97
+ it 'from string' do
98
+ test_brickfile_config = <<-END
99
+ -
100
+ name: brick_and_mortar
101
+ version: 0.0.1
102
+ location:
103
+ method: git
104
+ url: https://github.com/dmorrill10/brick_and_mortar.git
105
+ END
106
+ test_git_https_config BrickAndMortar::Config.new(BRICK_STORE).parse!(test_brickfile_config)
107
+ end
108
+
109
+ it 'from file' do
110
+ test_git_https_config(
111
+ BrickAndMortar::Config.new(BRICK_STORE).parse_file!(
112
+ File.expand_path(
113
+ '../support/test_files/git_https_brickfile.yml',
114
+ __FILE__
115
+ )
116
+ )
117
+ )
118
+ end
119
+
120
+ it 'where the method is not explicitly specified' do
121
+ test_brickfile_config = <<-END
122
+ -
123
+ name: brick_and_mortar
124
+ version: 0.0.1
125
+ location: https://github.com/dmorrill10/brick_and_mortar.git
126
+ END
127
+ test_git_https_config BrickAndMortar::Config.new(BRICK_STORE).parse!(test_brickfile_config)
128
+ end
129
+ end
130
+
131
+ describe 'git ssh' do
132
+ it 'from string' do
133
+ test_brickfile_config = <<-END
134
+ -
135
+ name: brick_and_mortar
136
+ version: 0.0.1
137
+ location:
138
+ method: git
139
+ url: git@github.com:dmorrill10/brick_and_mortar.git
140
+ END
141
+ test_git_ssh_config BrickAndMortar::Config.new(BRICK_STORE).parse!(test_brickfile_config)
142
+ end
143
+
144
+ it 'from file' do
145
+ test_git_ssh_config(
146
+ BrickAndMortar::Config.new(BRICK_STORE).parse_file!(
147
+ File.expand_path(
148
+ '../support/test_files/git_ssh_brickfile.yml',
149
+ __FILE__
150
+ )
151
+ )
152
+ )
153
+ end
154
+
155
+ it 'where the method is not specified explicitly' do
156
+ test_brickfile_config = <<-END
157
+ -
158
+ name: brick_and_mortar
159
+ version: 0.0.1
160
+ location: git@github.com:dmorrill10/brick_and_mortar.git
161
+ END
162
+ test_git_ssh_config BrickAndMortar::Config.new(BRICK_STORE).parse!(test_brickfile_config)
163
+ end
164
+ end
165
+
166
+ describe 'svn' do
167
+ it 'from string' do
168
+ test_brickfile_config = <<-END
169
+ -
170
+ name: brick_and_mortar
171
+ version: 0.0.1
172
+ location:
173
+ method: svn
174
+ url: https://github.com/dmorrill10/brick_and_mortar
175
+ END
176
+ patient = BrickAndMortar::Config.new(BRICK_STORE).parse!(test_brickfile_config)
177
+ patient.length.must_equal 1
178
+ patient[0].name.must_equal 'brick_and_mortar'
179
+ patient[0].version.must_equal '0.0.1'
180
+ patient[0].location.method.must_equal 'svn'
181
+ patient[0].location.format.must_equal 'plain'
182
+ patient[0].location.url.must_equal 'https://github.com/dmorrill10/brick_and_mortar'
183
+ File.basename(patient[0].destination).must_equal 'brick_and_mortar-0.0.1'
184
+ patient[0].destination.must_equal File.join(BRICK_STORE, 'brick_and_mortar-0.0.1')
185
+ patient[0].exists?.must_equal false
186
+ patient[0].create!
187
+ patient[0].exists?.must_equal true
188
+ patient[0].destroy!
189
+ patient[0].exists?.must_equal false
190
+ end
191
+
192
+ it 'from file' do
193
+ patient = BrickAndMortar::Config.new(BRICK_STORE).parse_file!(
194
+ File.expand_path(
195
+ '../support/test_files/svn_brickfile.yml',
196
+ __FILE__
197
+ )
198
+ )
199
+ patient.length.must_equal 1
200
+ patient[0].name.must_equal 'brick_and_mortar'
201
+ patient[0].version.must_equal '0.0.1'
202
+ patient[0].location.method.must_equal 'svn'
203
+ patient[0].location.format.must_equal 'plain'
204
+ patient[0].location.url.must_equal 'https://github.com/dmorrill10/brick_and_mortar'
205
+ File.basename(patient[0].destination).must_equal 'brick_and_mortar-0.0.1'
206
+ patient[0].destination.must_equal File.join(BRICK_STORE, 'brick_and_mortar-0.0.1')
207
+ patient[0].exists?.must_equal false
208
+ patient[0].create!
209
+ patient[0].exists?.must_equal true
210
+ patient[0].destroy!
211
+ patient[0].exists?.must_equal false
212
+ end
213
+
214
+ it 'where the method is not explicitly specified' do
215
+ test_brickfile_config = <<-END
216
+ -
217
+ name: brick_and_mortar
218
+ version: 0.0.1
219
+ location: svn://github.com/dmorrill10/brick_and_mortar
220
+ END
221
+ patient = BrickAndMortar::Config.new(BRICK_STORE).parse!(test_brickfile_config)
222
+ patient.length.must_equal 1
223
+ patient[0].name.must_equal 'brick_and_mortar'
224
+ patient[0].version.must_equal '0.0.1'
225
+ patient[0].location.method.must_equal 'svn'
226
+ patient[0].location.format.must_equal 'plain'
227
+ patient[0].location.url.must_equal 'svn://github.com/dmorrill10/brick_and_mortar'
228
+ File.basename(patient[0].destination).must_equal 'brick_and_mortar-0.0.1'
229
+ patient[0].destination.must_equal File.join(BRICK_STORE, 'brick_and_mortar-0.0.1')
230
+ patient[0].exists?.must_equal false
231
+ patient[0].create!
232
+ patient[0].exists?.must_equal true
233
+ patient[0].destroy!
234
+ patient[0].exists?.must_equal false
235
+ end
236
+ end
237
+
238
+ describe 'zip url' do
239
+ it 'from string' do
240
+ test_brickfile_config = <<-END
241
+ -
242
+ name: brick_and_mortar
243
+ version: 0.0.1
244
+ location: https://github.com/dmorrill10/brick_and_mortar/archive/master.zip
245
+ END
246
+ test_zip_url_config BrickAndMortar::Config.new(BRICK_STORE).parse!(test_brickfile_config)
247
+ end
248
+
249
+ it 'from file' do
250
+ test_zip_url_config(
251
+ BrickAndMortar::Config.new(BRICK_STORE).parse_file!(
252
+ File.expand_path(
253
+ '../support/test_files/url_brickfile.yml',
254
+ __FILE__
255
+ )
256
+ )
257
+ )
258
+ end
259
+ end
260
+
261
+ describe 'tar.gz url' do
262
+ it 'from string' do
263
+ test_brickfile_config = <<-END
264
+ -
265
+ name: brick_and_mortar
266
+ version: 0.0.1
267
+ location: https://github.com/dmorrill10/brick_and_mortar/archive/master.tar.gz
268
+ END
269
+ test_tar_gz_url_config BrickAndMortar::Config.new(BRICK_STORE).parse!(test_brickfile_config)
270
+ end
271
+ end
272
+
273
+ # @todo Copy the above tests, but for hg and local project configurations (see support/test_files for example configurations)
274
+
275
+ # @todo A little more has to be done for local project, since the path to the local project might have to be relative to the brickfile, so I can do that one
276
+ end
277
+ end
@@ -0,0 +1,38 @@
1
+ require_relative 'support/spec_helper'
2
+
3
+ require_relative '../lib/brick_and_mortar/download'
4
+
5
+ describe BrickAndMortar::Download do
6
+ describe 'given zip url brick configuration' do
7
+ zip_url_brick_configruation = MockBrickConfiguration.new(
8
+ 'mock_brick',
9
+ '0.0.1',
10
+ MockBrickLocation.new('download', 'https://github.com/dmorrill10/brick_and_mortar/archive/master.zip')
11
+ )
12
+
13
+ it 'downloads the brick' do
14
+ Dir.mktmpdir do |dir|
15
+ Dir.chdir dir do |d|
16
+ BrickAndMortar::Download.get_and_unpack_zip(zip_url_brick_configruation.location.url, zip_url_brick_configruation.destination)
17
+ File.directory?(File.join(dir, zip_url_brick_configruation.destination)).must_equal true
18
+ end
19
+ end
20
+ end
21
+ end
22
+ describe 'given tar.gz url brick configuration' do
23
+ tar_gz_url_brick_configruation = MockBrickConfiguration.new(
24
+ 'mock_brick',
25
+ '0.0.1',
26
+ MockBrickLocation.new('download', 'https://github.com/dmorrill10/brick_and_mortar/archive/master.tar.gz')
27
+ )
28
+
29
+ it 'downloads the brick' do
30
+ Dir.mktmpdir do |dir|
31
+ Dir.chdir dir do |d|
32
+ BrickAndMortar::Download.get_and_unpack_tar_gz(tar_gz_url_brick_configruation.location.url, tar_gz_url_brick_configruation.destination)
33
+ File.directory?(File.join(dir, tar_gz_url_brick_configruation.destination)).must_equal true
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
data/spec/git_spec.rb ADDED
@@ -0,0 +1,38 @@
1
+ require_relative 'support/spec_helper'
2
+
3
+ require_relative '../lib/brick_and_mortar/git'
4
+
5
+ describe BrickAndMortar::Git do
6
+ describe 'given git ssh brick configuration' do
7
+ git_ssh_brick_configruation = MockBrickConfiguration.new(
8
+ 'mock_brick',
9
+ '0.0.1',
10
+ MockBrickLocation.new('git', 'git@github.com:dmorrill10/brick_and_mortar.git')
11
+ )
12
+
13
+ it 'downloads the brick with git ssh' do
14
+ Dir.mktmpdir do |dir|
15
+ Dir.chdir dir do |d|
16
+ BrickAndMortar::Git.clone_repo(git_ssh_brick_configruation.location.url, git_ssh_brick_configruation.name)
17
+ File.directory?(File.join(dir, git_ssh_brick_configruation.name)).must_equal true
18
+ end
19
+ end
20
+ end
21
+ end
22
+ describe 'given git https brick configuration' do
23
+ git_https_brick_configruation = MockBrickConfiguration.new(
24
+ 'mock_brick',
25
+ '0.0.1',
26
+ MockBrickLocation.new('git', 'https://github.com/dmorrill10/brick_and_mortar.git')
27
+ )
28
+
29
+ it 'downloads the brick with git https' do
30
+ Dir.mktmpdir do |dir|
31
+ Dir.chdir dir do |d|
32
+ BrickAndMortar::Git.clone_repo(git_https_brick_configruation.location.url, git_https_brick_configruation.name)
33
+ File.directory?(File.join(dir, git_https_brick_configruation.name)).must_equal true
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,6 @@
1
+ require_relative 'support/spec_helper'
2
+
3
+ require_relative '../lib/brick_and_mortar'
4
+
5
+ describe BrickAndMortar do
6
+ end