brick_and_mortar 0.0.4 → 0.1.0
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/.gitignore +3 -3
- data/.travis.yml +5 -0
- data/LICENSE +1 -2
- data/README.md +8 -6
- data/brick_and_mortar.gemspec +1 -0
- data/lib/brick_and_mortar/brick.rb +14 -7
- data/lib/brick_and_mortar/download.rb +25 -2
- data/lib/brick_and_mortar/version.rb +1 -1
- data/spec/download_spec.rb +20 -0
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ae4d6b7011a033487e95f47f3ee1e96d0219ff4
|
4
|
+
data.tar.gz: c2bf30d10e15d6628bd50400219eb9a9be4ad22b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cda000b1014f4c39fa205037399463588a4783715c89e09578c57a0bc57dba120d814bdc1cdfe0bb30aa277cd545a533f7a3cc86b67f3f1456d5268870614d33
|
7
|
+
data.tar.gz: 6ea7d7d6c5aad4a11db5ec486056cde3142207df44e9aa79db3c4081bd86a3f01c090d213123d9e9cc68ede69213c3233cad660bbbc2d6de7d283a1a894c75eb
|
data/.gitignore
CHANGED
@@ -27,9 +27,9 @@ build/
|
|
27
27
|
|
28
28
|
# for a library or gem, you might want to ignore these files since the code is
|
29
29
|
# intended to run in multiple environments; otherwise, check them in:
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
Gemfile.lock
|
31
|
+
.ruby-version
|
32
|
+
.ruby-gemset
|
33
33
|
|
34
34
|
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
35
|
.rvmrc
|
data/.travis.yml
ADDED
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2015 Dustin Morrill
|
3
|
+
Copyright (c) 2015-2017 Dustin Morrill
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
SOFTWARE.
|
22
|
-
|
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
BrickAndMortar: A Solid Foundation for Software Projects
|
2
2
|
================================================
|
3
3
|
|
4
|
+
[](https://travis-ci.org/dmorrill10/brick_and_mortar)
|
5
|
+
|
4
6
|
What is BrickAndMortar?
|
5
7
|
---------------
|
6
8
|
|
@@ -16,7 +18,7 @@ It is not nearly as fancy a tool as *Bundler* or the like that does dependency c
|
|
16
18
|
Supported Systems
|
17
19
|
-----------------
|
18
20
|
|
19
|
-
Currently only targeted for
|
21
|
+
Currently only targeted for *nix. Tested on Ubuntu and Mac OS X.
|
20
22
|
|
21
23
|
|
22
24
|
Requirements
|
@@ -30,7 +32,7 @@ Usage
|
|
30
32
|
|
31
33
|
1. Install `brick_and_mortar` gem with `gem install brick_and_mortar`
|
32
34
|
2. Write a `Brickfile` in your project's root directory that has the following fields:
|
33
|
-
|
35
|
+
|
34
36
|
`name`
|
35
37
|
~ The name of the dependency. The directory or link that will be present in the `vendor` directory will have this name.
|
36
38
|
|
@@ -38,7 +40,7 @@ Usage
|
|
38
40
|
~ The version of the brick as a string in whatever format is natural for it. This will be appended to the directory name of the copy of the brick downloaded in the `$BRICK_STORE_PREFIX/.brick_store` directory.
|
39
41
|
|
40
42
|
`location`
|
41
|
-
~ Location of the brick. Either local system path, version control repository (*Git*, *Mercurial*, and *Subversion* currently supported), or URL.
|
43
|
+
~ Location of the brick. Either local system path, version control repository (*Git*, *Mercurial*, and *Subversion* currently supported), or URL. *zip*, *tar.gz*, and *tar.bz2* are the only currently supported compressed URL package formats.
|
42
44
|
|
43
45
|
3. Run `mortar` to install bricks to `vendor`, downloading them if necessary to `$BRICK_STORE_PREFIX/.brick_store`.
|
44
46
|
|
@@ -54,8 +56,8 @@ Write a `$HOME/.brick_and_mortarrc` file to specify:
|
|
54
56
|
~ The directory that contains `.brick_store`. As the name suggests, `.brick_store` is where all bricks will be stored before they are linked or copied into the `vendor` directories of individual projects.
|
55
57
|
|
56
58
|
`DEFAULT_BRICK_SHARING_POLICY`
|
57
|
-
~ Specify the default behavior when placing bricks in projects. Accepts either
|
58
|
-
- `copy`, where the brick will be copied into `vendor`, or
|
59
|
+
~ Specify the default behavior when placing bricks in projects. Accepts either
|
60
|
+
- `copy`, where the brick will be copied into `vendor`, or
|
59
61
|
- `link`, where the brick will be symbolically linked into `vendor`.
|
60
62
|
Defaults to `link`.
|
61
63
|
|
@@ -63,6 +65,6 @@ Write a `$HOME/.brick_and_mortarrc` file to specify:
|
|
63
65
|
License
|
64
66
|
-------
|
65
67
|
|
66
|
-
Copyright Dustin Morrill, 2015
|
68
|
+
Copyright Dustin Morrill, 2015-2017
|
67
69
|
|
68
70
|
MIT License
|
data/brick_and_mortar.gemspec
CHANGED
@@ -11,13 +11,20 @@ module BrickAndMortar
|
|
11
11
|
end
|
12
12
|
attr_reader :method, :path, :format
|
13
13
|
|
14
|
-
FORMATS = {
|
14
|
+
FORMATS = {
|
15
|
+
:plain => 'plain',
|
16
|
+
:zip => 'zip',
|
17
|
+
:tar_gz => 'tar.gz',
|
18
|
+
:tar_bz2 => 'tar.bz2'
|
19
|
+
}
|
15
20
|
|
16
21
|
def self.url_to_format(url)
|
17
|
-
if url.match(
|
22
|
+
if url.match(/\.#{FORMATS[:zip]}$/)
|
18
23
|
FORMATS[:zip]
|
19
|
-
elsif url.match(
|
24
|
+
elsif url.match(/\.#{FORMATS[:tar_gz]}$/)
|
20
25
|
FORMATS[:tar_gz]
|
26
|
+
elsif url.match(/\.#{FORMATS[:tar_bz2]}$/)
|
27
|
+
FORMATS[:tar_bz2]
|
21
28
|
else
|
22
29
|
FORMATS[:plain]
|
23
30
|
end
|
@@ -110,10 +117,10 @@ module BrickAndMortar
|
|
110
117
|
end
|
111
118
|
if @location.format == Location::FORMATS[:zip]
|
112
119
|
Download.get_and_unpack_zip(@location.path, @destination)
|
113
|
-
elsif
|
114
|
-
|
115
|
-
|
116
|
-
|
120
|
+
elsif @location.format == Location::FORMATS[:tar_gz]
|
121
|
+
Download.get_and_unpack_tar_gz(@location.path, @destination)
|
122
|
+
elsif @location.format == Location::FORMATS[:tar_bz2]
|
123
|
+
Download.get_and_unpack_tar_bz2(@location.path, @destination)
|
117
124
|
else
|
118
125
|
raise UnrecognizedFormat.new(@location.format)
|
119
126
|
end
|
@@ -8,6 +8,7 @@ OpenURI::Buffer.const_set 'StringMax', 0
|
|
8
8
|
require 'zip'
|
9
9
|
require 'zlib'
|
10
10
|
require 'rubygems/package'
|
11
|
+
require 'bzip2/ffi'
|
11
12
|
|
12
13
|
module BrickAndMortar
|
13
14
|
module Download
|
@@ -37,9 +38,9 @@ module BrickAndMortar
|
|
37
38
|
# Thanks to TomCZ
|
38
39
|
# http://stackoverflow.com/questions/856891/unzip-zip-tar-tag-gz-files-with-ruby
|
39
40
|
# for this
|
40
|
-
def self.
|
41
|
+
def self.deflate_tar(tar_string, destination = Dir.pwd)
|
41
42
|
first_directory = nil
|
42
|
-
Gem::Package::TarReader.new(
|
43
|
+
Gem::Package::TarReader.new(tar_string) do |tar|
|
43
44
|
dest = nil
|
44
45
|
tar.each do |entry|
|
45
46
|
if entry.full_name == TAR_LONGLINK
|
@@ -81,6 +82,21 @@ module BrickAndMortar
|
|
81
82
|
end
|
82
83
|
first_directory
|
83
84
|
end
|
85
|
+
def self.deflate_tar_gz(tar_gz_archive, destination = Dir.pwd)
|
86
|
+
deflate_tar(Zlib::GzipReader.open(tar_gz_archive), destination)
|
87
|
+
end
|
88
|
+
def self.deflate_tar_bz2(archive, destination = Dir.pwd)
|
89
|
+
Bzip2::FFI::Reader.open(archive) do |reader|
|
90
|
+
File.open("#{destination}.tar", 'w') do |tar|
|
91
|
+
tar.write reader.read
|
92
|
+
end
|
93
|
+
end
|
94
|
+
first_directory = File.open("#{destination}.tar", 'r') do |tar|
|
95
|
+
deflate_tar(tar)
|
96
|
+
end
|
97
|
+
FileUtils.rm "#{destination}.tar"
|
98
|
+
first_directory
|
99
|
+
end
|
84
100
|
def self.get_and_unpack_zip(url, name = nil, options = {})
|
85
101
|
unless name
|
86
102
|
name = name_from_path url
|
@@ -95,5 +111,12 @@ module BrickAndMortar
|
|
95
111
|
uncompressed_dir_name = deflate_tar_gz(open(url))
|
96
112
|
FileUtils.mv uncompressed_dir_name, name
|
97
113
|
end
|
114
|
+
def self.get_and_unpack_tar_bz2(url, name = nil, options = {})
|
115
|
+
unless name
|
116
|
+
name = name_from_path url
|
117
|
+
end
|
118
|
+
uncompressed_dir_name = deflate_tar_bz2(open(url))
|
119
|
+
FileUtils.mv uncompressed_dir_name, name
|
120
|
+
end
|
98
121
|
end
|
99
122
|
end
|
data/spec/download_spec.rb
CHANGED
@@ -35,4 +35,24 @@ describe BrickAndMortar::Download do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
describe 'given tar.bz2 url brick configuration' do
|
40
|
+
tar_bz2_url_brick_configruation = MockBrickConfiguration.new(
|
41
|
+
'mock_brick',
|
42
|
+
'0.0.1',
|
43
|
+
MockBrickLocation.new('download', 'http://www.computerpokercompetition.org/downloads/code/competition_server/project_acpc_server_v1.0.41.tar.bz2')
|
44
|
+
)
|
45
|
+
|
46
|
+
it 'downloads the brick' do
|
47
|
+
Dir.mktmpdir do |dir|
|
48
|
+
Dir.chdir dir do |d|
|
49
|
+
BrickAndMortar::Download.get_and_unpack_tar_bz2(
|
50
|
+
tar_bz2_url_brick_configruation.location.url,
|
51
|
+
tar_bz2_url_brick_configruation.destination
|
52
|
+
)
|
53
|
+
File.directory?(File.join(dir, tar_bz2_url_brick_configruation.destination)).must_equal true
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
38
58
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brick_and_mortar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Morrill
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: git
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bzip2-ffi
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,6 +118,7 @@ extra_rdoc_files: []
|
|
104
118
|
files:
|
105
119
|
- ".gitattributes"
|
106
120
|
- ".gitignore"
|
121
|
+
- ".travis.yml"
|
107
122
|
- Gemfile
|
108
123
|
- LICENSE
|
109
124
|
- README.md
|
@@ -188,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
203
|
version: '0'
|
189
204
|
requirements: []
|
190
205
|
rubyforge_project:
|
191
|
-
rubygems_version: 2.
|
206
|
+
rubygems_version: 2.5.1
|
192
207
|
signing_key:
|
193
208
|
specification_version: 4
|
194
209
|
summary: 'BrickAndMortar: A Solid Foundation for Software Projects'
|
@@ -210,4 +225,3 @@ test_files:
|
|
210
225
|
- spec/support/test_files/test_project/Brickfile
|
211
226
|
- spec/support/test_files/url_brickfile.yml
|
212
227
|
- spec/svn_spec.rb
|
213
|
-
has_rdoc:
|