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,213 @@
1
+ \documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$lang$,$endif$$if(papersize)$$papersize$,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}
2
+ $if(fontfamily)$
3
+ \usepackage{$fontfamily$}
4
+ $else$
5
+ \usepackage{lmodern}
6
+ $endif$
7
+ $if(linestretch)$
8
+ \usepackage{setspace}
9
+ \setstretch{$linestretch$}
10
+ $endif$
11
+ \usepackage{amssymb,amsmath}
12
+ \usepackage{mathtools} % Better boxes around math
13
+ \usepackage{ifxetex,ifluatex}
14
+ \usepackage{fixltx2e} % provides \textsubscript
15
+ \ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
16
+ \usepackage[T1]{fontenc}
17
+ \usepackage[utf8]{inputenc}
18
+ $if(euro)$
19
+ \usepackage{eurosym}
20
+ $endif$
21
+ \else % if luatex or xelatex
22
+ \ifxetex
23
+ \usepackage{mathspec}
24
+ \usepackage{xltxtra,xunicode}
25
+ \else
26
+ \usepackage{fontspec}
27
+ \fi
28
+ \defaultfontfeatures{Mapping=tex-text,Scale=MatchLowercase}
29
+ \newcommand{\euro}{€}
30
+ $if(mainfont)$
31
+ \setmainfont{$mainfont$}
32
+ $endif$
33
+ $if(sansfont)$
34
+ \setsansfont{$sansfont$}
35
+ $endif$
36
+ $if(monofont)$
37
+ \setmonofont[Mapping=tex-ansi]{$monofont$}
38
+ $endif$
39
+ $if(mathfont)$
40
+ \setmathfont(Digits,Latin,Greek){$mathfont$}
41
+ $endif$
42
+ \fi
43
+ % use upquote if available, for straight quotes in verbatim environments
44
+ \IfFileExists{upquote.sty}{\usepackage{upquote}}{}
45
+ % use microtype if available
46
+ \IfFileExists{microtype.sty}{\usepackage{microtype}}{}
47
+ $if(geometry)$
48
+ \usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}
49
+ $endif$
50
+ $if(natbib)$
51
+ \usepackage{natbib}
52
+ \bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}
53
+ $endif$
54
+ $if(biblatex)$
55
+ \usepackage{biblatex}
56
+ $if(biblio-files)$
57
+ \bibliography{$biblio-files$}
58
+ $endif$
59
+ $endif$
60
+ $if(listings)$
61
+ \usepackage{listings}
62
+ $endif$
63
+ $if(lhs)$
64
+ \lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}
65
+ $endif$
66
+ $if(highlighting-macros)$
67
+ $highlighting-macros$
68
+ $endif$
69
+ $if(verbatim-in-note)$
70
+ \usepackage{fancyvrb}
71
+ $endif$
72
+ $if(tables)$
73
+ \usepackage{longtable,booktabs}
74
+ $endif$
75
+ $if(graphics)$
76
+ \usepackage{graphicx}
77
+ \makeatletter
78
+ \def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}
79
+ \def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}
80
+ \makeatother
81
+ % Scale images if necessary, so that they will not overflow the page
82
+ % margins by default, and it is still possible to overwrite the defaults
83
+ % using explicit options in \includegraphics[width, height, ...]{}
84
+ \setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}
85
+ $endif$
86
+ \ifxetex
87
+ \usepackage[setpagesize=false, % page size defined by xetex
88
+ unicode=false, % unicode breaks when used with xetex
89
+ xetex]{hyperref}
90
+ \else
91
+ \usepackage[unicode=true]{hyperref}
92
+ \fi
93
+ \hypersetup{breaklinks=true,
94
+ bookmarks=true,
95
+ pdfauthor={$author-meta$},
96
+ pdftitle={$title-meta$},
97
+ colorlinks=true,
98
+ citecolor=$if(citecolor)$$citecolor$$else$blue$endif$,
99
+ urlcolor=$if(urlcolor)$$urlcolor$$else$blue$endif$,
100
+ linkcolor=$if(linkcolor)$$linkcolor$$else$magenta$endif$,
101
+ pdfborder={0 0 0}}
102
+ \urlstyle{same} % don't use monospace font for urls
103
+ $if(links-as-notes)$
104
+ % Make links footnotes instead of hotlinks:
105
+ \renewcommand{\href}[2]{#2\footnote{\url{#1}}}
106
+ $endif$
107
+ $if(strikeout)$
108
+ \usepackage[normalem]{ulem}
109
+ % avoid problems with \sout in headers with hyperref:
110
+ \pdfstringdefDisableCommands{\renewcommand{\sout}{}}
111
+ $endif$
112
+ \setlength{\parindent}{0pt}
113
+ \setlength{\parskip}{6pt plus 2pt minus 1pt}
114
+ \setlength{\emergencystretch}{3em} % prevent overfull lines
115
+ $if(numbersections)$
116
+ \setcounter{secnumdepth}{5}
117
+ $else$
118
+ \setcounter{secnumdepth}{0}
119
+ $endif$
120
+ $if(verbatim-in-note)$
121
+ \VerbatimFootnotes % allows verbatim text in footnotes
122
+ $endif$
123
+ $if(lang)$
124
+ \ifxetex
125
+ \usepackage{polyglossia}
126
+ \setmainlanguage{$mainlang$}
127
+ \else
128
+ \usepackage[$lang$]{babel}
129
+ \fi
130
+ $endif$
131
+
132
+ %%% macros
133
+ \newcommand{\final}{\fbox}
134
+ \newcommand{\bs}{\boldsymbol}
135
+ \newcommand{\tr}{\operatorname{tr}}
136
+ \newcommand{\norm}[1]{\left\lVert#1\right\rVert}
137
+ \newcommand{\set}[1]{\left\{ {#1} \right\}}
138
+
139
+ \newcommand{\diag}[1]{\mathop{\bigtriangleup\subex{#1}}\nolimits}
140
+ \newcommand{\stack}[1]{\operatorname{stack}\subex{#1}}
141
+ \newcommand{\deriv}[2]{\frac{d #1}{ d #2 }}
142
+
143
+ \newcommand{\subex}[1]{\left(#1\right)}
144
+ %%%%
145
+
146
+ \usepackage[table]{xcolor}
147
+ %\usepackage{colortbl}
148
+
149
+ \usepackage{floatrow}
150
+ \DeclareFloatFont{tiny}{\tiny}% "scriptsize" is defined by floatrow, "tiny" not
151
+ \floatsetup[table]{font=tiny}
152
+
153
+ $if(title)$
154
+ \title{$title$}
155
+ $endif$
156
+ $if(subtitle)$
157
+ \subtitle{$subtitle$}
158
+ $endif$
159
+ $if(author)$
160
+ \author{$for(author)$$author$$sep$ \and $endfor$}
161
+ $endif$
162
+ $if(date)$
163
+ \date{$date$}
164
+ $endif$
165
+ $for(header-includes)$
166
+ $header-includes$
167
+ $endfor$
168
+
169
+ \begin{document}
170
+ $if(title)$
171
+ \maketitle
172
+ $endif$
173
+ $if(abstract)$
174
+ \begin{abstract}
175
+ $abstract$
176
+ \end{abstract}
177
+ $endif$
178
+
179
+ $for(include-before)$
180
+ $include-before$
181
+
182
+ $endfor$
183
+ $if(toc)$
184
+ {
185
+ \hypersetup{linkcolor=black}
186
+ \setcounter{tocdepth}{$toc-depth$}
187
+ \tableofcontents
188
+ }
189
+ $endif$
190
+ $body$
191
+
192
+ $if(natbib)$
193
+ $if(biblio-files)$
194
+ $if(biblio-title)$
195
+ $if(book-class)$
196
+ \renewcommand\bibname{$biblio-title$}
197
+ $else$
198
+ \renewcommand\refname{$biblio-title$}
199
+ $endif$
200
+ $endif$
201
+ \bibliography{$biblio-files$}
202
+
203
+ $endif$
204
+ $endif$
205
+ $if(biblatex)$
206
+ \printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$
207
+
208
+ $endif$
209
+ $for(include-after)$
210
+ $include-after$
211
+
212
+ $endfor$
213
+ \end{document}
@@ -0,0 +1,150 @@
1
+ require_relative 'git'
2
+ require_relative 'svn'
3
+ require_relative 'download'
4
+
5
+ require 'contextual_exceptions'
6
+
7
+ module BrickAndMortar
8
+ module Brick
9
+ class Location
10
+ using ContextualExceptions::ClassRefinement
11
+ exceptions :no_path_or_url_provided, :unrecognized_format
12
+ attr_reader :method, :path, :format
13
+
14
+ FORMATS = {:plain => 'plain', :zip => 'zip', :tar_gz => 'tar.gz'}
15
+
16
+ def self.url_to_format(url)
17
+ if url.match(/\.zip$/)
18
+ FORMATS[:zip]
19
+ elsif url.match(/\.tar.gz$/)
20
+ FORMATS[:tar_gz]
21
+ else
22
+ FORMATS[:plain]
23
+ end
24
+ end
25
+
26
+ alias_method :url, :path
27
+
28
+ def initialize(data)
29
+ @format = FORMATS[:plain]
30
+ if data.respond_to?(:keys)
31
+ if data['path'] && !data['path'].empty? && data['url'] && data['url'].empty?
32
+ fail "Path was specified as \"#{data['path']}\", but url was specified as \"#{data['url']}\". Only one can be defined at a time."
33
+ end
34
+ @path = if data['path']
35
+ @method = 'copy'
36
+ @format = self.class().url_to_format(data['path'])
37
+ data['path']
38
+ elsif data['url']
39
+ @format = self.class().url_to_format(data['url'])
40
+ data['url']
41
+ else
42
+ @path
43
+ end
44
+ @method = data['method'] if data['method']
45
+ @format = data['format'] if data['format']
46
+ else
47
+ if data.match(/^\s*svn:/)
48
+ @method = 'svn'
49
+ elsif data.match(/^\s*git:/) || data.match(/\.git\s*$/)
50
+ @method = 'git'
51
+ elsif data.match(/^\s*https?:/)
52
+ @method = 'download'
53
+ end
54
+ @path = data
55
+ @format = self.class().url_to_format(data)
56
+ end
57
+
58
+ fail NoPathOrUrlProvided.new('Must have a path or URL') unless @path
59
+ unless FORMATS.values.include?(@format)
60
+ fail UnrecognizedFormat.new("Unrecognized format: #{@format}. Recognized formats: #{FORMATS}.")
61
+ end
62
+ end
63
+ end
64
+ class Config
65
+ using ContextualExceptions::ClassRefinement
66
+ exceptions :unrecognized_retrieval_method, :unrecognized_format
67
+
68
+ attr_reader :name, :version, :location, :destination
69
+
70
+ def initialize(data, brick_store, verbose = true)
71
+ @name = data['name']
72
+ @version = data['version']
73
+ @location = Location.new(data['location'])
74
+ @destination = File.join(brick_store, name_with_version)
75
+
76
+ @creation_closure = if exists?
77
+ if verbose
78
+ -> { puts "Using #{name_with_version} in #{@destination}" }
79
+ else
80
+ -> {}
81
+ end
82
+ else
83
+ case @location.method
84
+ when 'git'
85
+ -> do
86
+ if verbose
87
+ puts "Installing #{name_with_version} to #{@destination} from #{@location.path} with git"
88
+ end
89
+ Git.clone_repo(@location.path, @destination)
90
+ end
91
+ when 'svn'
92
+ -> do
93
+ if verbose
94
+ puts "Installing #{@name_with_version} to #{@destination} from #{@location.path} with svn"
95
+ end
96
+ Svn.checkout_repo(@location.path, @destination)
97
+ end
98
+ when 'download'
99
+ -> do
100
+ if verbose
101
+ puts "Installing #{@name_with_version} to #{@destination} from #{@location.path}"
102
+ end
103
+ if @location.format == Location::FORMATS[:zip]
104
+ Download.get_and_unpack_zip(@location.path, @destination)
105
+ elsif
106
+ if @location.format == Location::FORMATS[:tar_gz]
107
+ Download.get_and_unpack_tar_gz(@location.path, @destination)
108
+ end
109
+ else
110
+ ap @location.format
111
+ raise UnrecognizedFormat.new(@location.format)
112
+ end
113
+ end
114
+ else
115
+ -> { raise UnrecognizedRetrievalMethod.new(@location.method) }
116
+ end
117
+ end
118
+ end
119
+
120
+ def name_with_version
121
+ "#{@name}-#{@version}"
122
+ end
123
+
124
+ def exists?
125
+ File.exist? @destination
126
+ end
127
+
128
+ alias_method :exist?, :exists?
129
+
130
+ def create!
131
+ @creation_closure.call
132
+ end
133
+
134
+ def laid?(project_vendor_dir)
135
+ File.exist? File.join(project_vendor_dir, name)
136
+ end
137
+
138
+ def lay!(project_vendor_dir)
139
+ create!
140
+ unless laid?(project_vendor_dir)
141
+ File.symlink @destination, File.join(project_vendor_dir, name)
142
+ end
143
+ end
144
+
145
+ def destroy!
146
+ FileUtils.rm_rf @destination, {:secure => true}
147
+ end
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,131 @@
1
+ require 'fileutils'
2
+ require 'yaml'
3
+
4
+ require 'brick_and_mortar/brick'
5
+
6
+ module BrickAndMortar
7
+ class Config
8
+ attr_accessor :store
9
+
10
+ def initialize(store_)
11
+ @store = store_
12
+ end
13
+
14
+ def store_exists?
15
+ Dir.exist? @store
16
+ end
17
+
18
+ def create_store!
19
+ unless store_exists?
20
+ FileUtils.mkpath @store
21
+ fail "Could not create store at \"#{@store}\"" unless store_exists?
22
+ end
23
+ end
24
+
25
+ def destroy_store!
26
+ FileUtils.rm_rf @store
27
+ end
28
+
29
+ alias_method :store_exist?, :store_exists?
30
+
31
+ def parse_data!(brick_data, store_ = @store)
32
+ brick_data.map do |brick|
33
+ Brick::Config.new(brick, store_)
34
+ end
35
+ end
36
+
37
+ def bricks_and_store_from_data(data)
38
+ store_ = @store
39
+ begin
40
+ brick_data = if data['store'] && !data['store'].empty?
41
+ store_ = data['store']
42
+ data['bricks']
43
+ elsif data['bricks']
44
+ data['bricks']
45
+ else
46
+ []
47
+ end
48
+ rescue TypeError
49
+ brick_data = data
50
+ end
51
+ [brick_data, store_]
52
+ end
53
+
54
+ def parse!(yaml)
55
+ brick_data, store_ = bricks_and_store_from_data YAML.load(yaml)
56
+ parse_data! brick_data, store_
57
+ end
58
+
59
+ def parse_file!(yaml_file)
60
+ brick_data, store_ = bricks_and_store_from_data YAML.load_file(yaml_file)
61
+ parse_data! brick_data, store_
62
+ end
63
+ end
64
+ end
65
+
66
+ # @todo This should be helpful
67
+ # require 'pathname'
68
+ # require 'yaml'
69
+ # require 'fileutils'
70
+ # require 'rake'
71
+ #
72
+ # def self.ensure_directory_present(dir)
73
+ # FileUtils.mkpath dir unless File.exists? dir
74
+ # raise "Results directory, \"#{dir}\" is not a directory!" unless File.directory?(dir)
75
+ # end
76
+ #
77
+ # def self.resolve_path(path, root = __FILE__)
78
+ # path = Pathname.new(path)
79
+ # if path.exist?
80
+ # path.realpath
81
+ # else
82
+ # File.expand_path(path, root)
83
+ # end
84
+ # end
85
+ #
86
+ # def self.from_yaml(yaml_file, num_reps = 1, quiet = false)
87
+ # yaml_directory = File.expand_path('../', yaml_file)
88
+ # config_data = YAML.load_file(yaml_file)
89
+ # interpolation_hash = { pwd: yaml_directory, home: Dir.home, :~ => Dir.home }
90
+ # dealer_directory = ::PokerTournament.resolve_path(
91
+ # config_data['dealer_directory'] % interpolation_hash,
92
+ # yaml_directory
93
+ # ).to_s
94
+ # interpolation_hash[:dealer_directory] = dealer_directory
95
+ #
96
+ # new(
97
+ # ::PokerTournament.resolve_path(
98
+ # config_data['match_directory'] % interpolation_hash, yaml_directory
99
+ # ).to_s,
100
+ # ::PokerTournament.resolve_path(
101
+ # config_data['game_def'] % interpolation_hash,
102
+ # yaml_directory
103
+ # ).to_s,
104
+ # config_data['participants'].map do |player|
105
+ # Participant.new(
106
+ # player['name'],
107
+ # (->() do
108
+ # argument = player['strategy'] % interpolation_hash
109
+ # strategy_argument = ::PokerTournament.resolve_path(
110
+ # argument,
111
+ # yaml_directory
112
+ # ).to_s
113
+ # unless File.exist? strategy_argument
114
+ # strategy_argument = argument
115
+ # end
116
+ # strategy_argument
117
+ # end).call(),
118
+ # ::PokerTournament.resolve_path(
119
+ # player['dealer_player_object'] % interpolation_hash,
120
+ # yaml_directory
121
+ # ).to_s
122
+ # )
123
+ # end,
124
+ # config_data['num_hands'].to_i,
125
+ # config_data['num_players'].to_i,
126
+ # dealer_directory,
127
+ # num_reps,
128
+ # config_data['random_seed'].to_i,
129
+ # quiet
130
+ # )
131
+ # end
@@ -0,0 +1,5 @@
1
+ {
2
+ "result": {
3
+ "covered_percent": 100.0
4
+ }
5
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "MiniTest": {
3
+ "coverage": {
4
+ },
5
+ "timestamp": 1440889445
6
+ }
7
+ }