texas 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,9 +3,11 @@ module Texas
3
3
  module Task
4
4
  class RewriteMarkedTemplates < Base
5
5
  def run
6
- build.ran_templates.select { |t| t.marked_for_rewrite? }.each do |t|
7
- t.write
8
- end
6
+ templates.each { |t| t.write }
7
+ end
8
+
9
+ def templates
10
+ build.ran_templates.uniq.select { |t| t.marked_for_rewrite? }
9
11
  end
10
12
  end
11
13
  end
@@ -66,7 +66,7 @@ module Texas
66
66
  end
67
67
  end
68
68
 
69
- def find_contents_file(file)
69
+ def find_contents_template(file)
70
70
  file = file.gsub("#{Texas.contents_subdir_name}/", "")
71
71
  glob = File.join(Texas.contents_subdir_name, "#{file}*")
72
72
  if Dir[glob].empty?
@@ -192,7 +192,7 @@ module Texas
192
192
  options.check_mandatory_arguments = true
193
193
  options.load_local_libs = true
194
194
  options.contents_dir = Texas.contents_subdir_name
195
- options.contents_template = find_contents_file("contents")
195
+ options.contents_template = find_contents_template("contents")
196
196
  options.backtrace = false
197
197
  options.colors = true
198
198
  options.merge_config = nil
@@ -203,7 +203,7 @@ module Texas
203
203
 
204
204
  def set_contents_template_from_args
205
205
  f = args.shift
206
- options.contents_template = find_contents_file(f)
206
+ options.contents_template = find_contents_template(f)
207
207
  options.contents_dir = find_contents_dir(f)
208
208
  end
209
209
 
@@ -10,7 +10,11 @@ module Texas
10
10
  end
11
11
 
12
12
  def build(klass = Build::Dry)
13
- @build ||= klass.new(options).run
13
+ @build ||= begin
14
+ b = klass.new(options)
15
+ b.run
16
+ b
17
+ end
14
18
  end
15
19
 
16
20
  def run
@@ -83,3 +83,4 @@ Texas::Template.known_extensions = []
83
83
  require_relative 'template/helper'
84
84
  require_relative 'template/runner'
85
85
  require_relative 'template/template_error'
86
+ require_relative 'template/template_not_found'
@@ -72,7 +72,7 @@ module Texas
72
72
  if filename = find_template_file(parts, possible_exts, possible_paths)
73
73
  filename
74
74
  else
75
- raise TemplateError.new(self, "File doesn't exists anywhere: #{parts.size > 1 ? parts : parts.first}")
75
+ raise TemplateNotFound.new(self, "File doesn't exists anywhere: #{parts.size > 1 ? parts : parts.first}")
76
76
  end
77
77
  end
78
78
 
@@ -0,0 +1,2 @@
1
+ class TemplateNotFound < TemplateError
2
+ end
@@ -2,7 +2,7 @@ module Texas
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- BUILD = 7
5
+ BUILD = 8
6
6
 
7
7
  STRING = [MAJOR, MINOR, BUILD].join('.').freeze
8
8
  end
@@ -0,0 +1,3 @@
1
+
2
+
3
+ <%= render :this_template_wont_be_found %>
@@ -30,6 +30,29 @@ describe Texas::Template::Runner::Base do
30
30
  found_location.should == image_file_location
31
31
  end
32
32
  end
33
+
34
+ it "should return nil if file can't be found" do
35
+ run_scenario "basic" do |runner|
36
+ build = runner.task_instance
37
+ work_dir = build.root
38
+ template = test_template(runner)
39
+
40
+ found_location = template.find_template_file([:something])
41
+ found_location.should be_nil
42
+ end
43
+ end
44
+
45
+ it "should raise TemplateNotFound if file can't be found" do
46
+ run_scenario "basic" do |runner|
47
+ build = runner.task_instance
48
+ work_dir = build.root
49
+ template = test_template(runner)
50
+
51
+ lambda {
52
+ template.find_template_file!([:something])
53
+ }.should raise_error(TemplateNotFound)
54
+ end
55
+ end
33
56
  end
34
57
 
35
58
  end
@@ -63,9 +63,15 @@ describe Texas::Runner do
63
63
  }.should raise_error
64
64
  end
65
65
 
66
- it "run scenario for pdflatex-error and fail" do
66
+ it "run scenario for error-pdflatex and fail" do
67
67
  lambda {
68
- run_scenario "pdflatex-error"
68
+ run_scenario "error-pdflatex"
69
+ }.should raise_error
70
+ end
71
+
72
+ it "run scenario for error-template-not-found and fail" do
73
+ lambda {
74
+ run_scenario "error-template-not-found"
69
75
  }.should raise_error
70
76
  end
71
77
 
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: texas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - René Föhring
@@ -13,6 +14,7 @@ dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: term-ansicolor
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ! '>='
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ! '>='
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: listen
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ! '>='
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: rb-inotify
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ~>
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
@@ -60,114 +67,117 @@ executables:
60
67
  extensions: []
61
68
  extra_rdoc_files: []
62
69
  files:
63
- - lib/texas/version.rb
64
- - lib/texas/runner.rb
65
- - lib/texas/build.rb
66
- - lib/texas/task/base.rb
67
- - lib/texas/task/watch.rb
68
- - lib/texas/task/new_project.rb
69
- - lib/texas/template/helper.rb
70
- - lib/texas/template/runner.rb
71
- - lib/texas/template/runner/base.rb
72
- - lib/texas/template/runner/md.rb
73
- - lib/texas/template/runner/tex.rb
74
- - lib/texas/template/template_error.rb
75
- - lib/texas/template/helper/base.rb
70
+ - lib/texas/output_helper.rb
76
71
  - lib/texas/template/helper/md.rb
77
72
  - lib/texas/template/helper/tex.rb
78
73
  - lib/texas/template/helper/info.rb
79
- - lib/texas/core_ext.rb
80
- - lib/texas/output_helper.rb
74
+ - lib/texas/template/helper/base.rb
75
+ - lib/texas/template/template_not_found.rb
76
+ - lib/texas/template/runner.rb
77
+ - lib/texas/template/template_error.rb
78
+ - lib/texas/template/runner/md.rb
79
+ - lib/texas/template/runner/tex.rb
80
+ - lib/texas/template/runner/base.rb
81
+ - lib/texas/template/helper.rb
82
+ - lib/texas/build.rb
83
+ - lib/texas/task/watch.rb
84
+ - lib/texas/task/new_project.rb
85
+ - lib/texas/task/base.rb
81
86
  - lib/texas/option_parser.rb
82
87
  - lib/texas/task.rb
83
- - lib/texas/template.rb
84
- - lib/texas/build/base.rb
85
- - lib/texas/build/final.rb
86
- - lib/texas/build/dry.rb
87
- - lib/texas/build/task/rewrite_marked_templates.rb
88
- - lib/texas/build/task/base.rb
89
- - lib/texas/build/task/execute_before_scripts.rb
90
- - lib/texas/build/task/script.rb
91
- - lib/texas/build/task/execute_after_scripts.rb
88
+ - lib/texas/version.rb
89
+ - lib/texas/runner.rb
90
+ - lib/texas/core_ext/string.rb
91
+ - lib/texas/core_ext/hash.rb
92
92
  - lib/texas/build/task/copy_contents_to_build_path.rb
93
- - lib/texas/build/task/run_master_template.rb
94
93
  - lib/texas/build/task/open_pdf.rb
94
+ - lib/texas/build/task/execute_after_scripts.rb
95
95
  - lib/texas/build/task/publish_pdf.rb
96
+ - lib/texas/build/task/rewrite_marked_templates.rb
96
97
  - lib/texas/build/task/add_default_templates_to_build_path.rb
97
- - lib/texas/build/config.rb
98
+ - lib/texas/build/task/execute_before_scripts.rb
99
+ - lib/texas/build/task/run_master_template.rb
100
+ - lib/texas/build/task/script.rb
101
+ - lib/texas/build/task/base.rb
98
102
  - lib/texas/build/config_loader.rb
99
- - lib/texas/core_ext/hash.rb
100
- - lib/texas/core_ext/string.rb
103
+ - lib/texas/build/config.rb
104
+ - lib/texas/build/base.rb
105
+ - lib/texas/build/final.rb
106
+ - lib/texas/build/dry.rb
107
+ - lib/texas/core_ext.rb
108
+ - lib/texas/template.rb
101
109
  - lib/texas.rb
110
+ - spec/texas/template/runner_spec.rb
111
+ - spec/texas/template/helper/info_spec.rb
112
+ - spec/texas/task/base_spec.rb
113
+ - spec/texas/template_spec.rb
114
+ - spec/texas/option_parser_spec.rb
115
+ - spec/texas/build/task/publish_pdf_spec.rb
116
+ - spec/texas/build/task/base_spec.rb
117
+ - spec/texas/build/config_spec.rb
118
+ - spec/texas/build/base_spec.rb
119
+ - spec/texas_spec.rb
120
+ - spec/fixtures/different-master-tex/contents/contents.tex.erb
121
+ - spec/fixtures/different-master-tex/contents/contents.tex.should
122
+ - spec/fixtures/different-master-tex/contents/master.tex.should
123
+ - spec/fixtures/different-master-tex/contents/master.tex.erb
124
+ - spec/fixtures/basic-tex/contents/sub_dir/unused_template.tex.erb
125
+ - spec/fixtures/basic-tex/contents/input_template.tex.should
126
+ - spec/fixtures/basic-tex/contents/input_template.tex.erb
127
+ - spec/fixtures/basic-tex/contents/contents.tex.erb
128
+ - spec/fixtures/basic-tex/contents/contents.tex.should
102
129
  - spec/fixtures/basic/figures/test_figure.png
103
130
  - spec/fixtures/basic/contents/contents.tex.erb
104
- - spec/fixtures/new-project/lib/helpers/document_helper.rb
131
+ - spec/fixtures/error-template-not-found/contents/contents.tex.erb
132
+ - spec/fixtures/lib-helpers/lib/init.rb
133
+ - spec/fixtures/lib-helpers/lib/helpers/document_helper.rb
134
+ - spec/fixtures/lib-helpers/contents/contents.tex.erb
135
+ - spec/fixtures/lib-helpers/contents/contents.tex.should
105
136
  - spec/fixtures/new-project/lib/init.rb
137
+ - spec/fixtures/new-project/lib/helpers/document_helper.rb
106
138
  - spec/fixtures/new-project/contents/contents.tex.erb
107
- - spec/fixtures/pdflatex-error/contents/contents.tex.erb
108
- - spec/fixtures/basic-tex/contents/contents.tex.should
109
- - spec/fixtures/basic-tex/contents/sub_dir/unused_template.tex.erb
110
- - spec/fixtures/basic-tex/contents/input_template.tex.should
111
- - spec/fixtures/basic-tex/contents/contents.tex.erb
112
- - spec/fixtures/basic-tex/contents/input_template.tex.erb
139
+ - spec/fixtures/rerun/contents/contents.tex.erb
140
+ - spec/fixtures/rerun/contents/contents.tex.should
141
+ - spec/fixtures/basic-md/contents/input_template.md.erb
142
+ - spec/fixtures/basic-md/contents/contents.tex.should
143
+ - spec/fixtures/basic-md/contents/contents.md.erb
144
+ - spec/fixtures/error-pdflatex/contents/contents.tex.erb
145
+ - spec/fixtures/texasrc/contents/contents.tex.erb
146
+ - spec/fixtures/texasrc/contents/contents.tex.should
113
147
  - spec/fixtures/helper-methods-tex/figures/test_figure.png
114
- - spec/fixtures/helper-methods-tex/contents/contents.tex.should
115
- - spec/fixtures/helper-methods-tex/contents/some_chapter/test_include.tex.erb
116
- - spec/fixtures/helper-methods-tex/contents/some_chapter/another_include.tex
117
- - spec/fixtures/helper-methods-tex/contents/some_chapter/test_include.tex.should
118
- - spec/fixtures/helper-methods-tex/contents/template/helper/_some_partial.md.erb
148
+ - spec/fixtures/helper-methods-tex/contents/template/helper/base.tex.erb
119
149
  - spec/fixtures/helper-methods-tex/contents/template/helper/info.tex.should
150
+ - spec/fixtures/helper-methods-tex/contents/template/helper/_some_partial.md.erb
120
151
  - spec/fixtures/helper-methods-tex/contents/template/helper/base.tex.should
121
152
  - spec/fixtures/helper-methods-tex/contents/template/helper/info.md.erb
122
- - spec/fixtures/helper-methods-tex/contents/template/helper/base.tex.erb
123
- - spec/fixtures/helper-methods-tex/contents/test_figure.tex.erb
153
+ - spec/fixtures/helper-methods-tex/contents/some_chapter.tex.erb
124
154
  - spec/fixtures/helper-methods-tex/contents/input_template.tex.should
125
155
  - spec/fixtures/helper-methods-tex/contents/some_chapter.tex.should
126
- - spec/fixtures/helper-methods-tex/contents/some_chapter.tex.erb
127
- - spec/fixtures/helper-methods-tex/contents/contents.tex.erb
128
156
  - spec/fixtures/helper-methods-tex/contents/input_template.tex.erb
129
- - spec/fixtures/lib-helpers/lib/helpers/document_helper.rb
130
- - spec/fixtures/lib-helpers/lib/init.rb
131
- - spec/fixtures/lib-helpers/contents/contents.tex.should
132
- - spec/fixtures/lib-helpers/contents/contents.tex.erb
133
- - spec/fixtures/rerun/contents/contents.tex.should
134
- - spec/fixtures/rerun/contents/contents.tex.erb
135
- - spec/fixtures/different-master-tex/contents/contents.tex.should
136
- - spec/fixtures/different-master-tex/contents/master.tex.erb
137
- - spec/fixtures/different-master-tex/contents/master.tex.should
138
- - spec/fixtures/different-master-tex/contents/contents.tex.erb
139
- - spec/fixtures/texasrc/contents/contents.tex.should
140
- - spec/fixtures/texasrc/contents/contents.tex.erb
141
- - spec/fixtures/basic-md/contents/contents.tex.should
142
- - spec/fixtures/basic-md/contents/input_template.md.erb
143
- - spec/fixtures/basic-md/contents/contents.md.erb
144
- - spec/texas_spec.rb
157
+ - spec/fixtures/helper-methods-tex/contents/contents.tex.erb
158
+ - spec/fixtures/helper-methods-tex/contents/contents.tex.should
159
+ - spec/fixtures/helper-methods-tex/contents/test_figure.tex.erb
160
+ - spec/fixtures/helper-methods-tex/contents/some_chapter/test_include.tex.erb
161
+ - spec/fixtures/helper-methods-tex/contents/some_chapter/test_include.tex.should
162
+ - spec/fixtures/helper-methods-tex/contents/some_chapter/another_include.tex
145
163
  - spec/spec_helper.rb
146
- - spec/texas/template_spec.rb
147
- - spec/texas/task/base_spec.rb
148
- - spec/texas/template/runner_spec.rb
149
- - spec/texas/template/helper/info_spec.rb
150
- - spec/texas/build/base_spec.rb
151
- - spec/texas/build/config_spec.rb
152
- - spec/texas/build/task/base_spec.rb
153
- - spec/texas/build/task/publish_pdf_spec.rb
154
- - spec/texas/option_parser_spec.rb
155
164
  - bin/texas
156
- - contents/master.tex.erb
157
165
  - contents/_preambel.tex.erb
166
+ - contents/master.tex.erb
158
167
  homepage: http://github.com/rrrene/texas
159
168
  licenses: []
160
- metadata: {}
161
169
  post_install_message:
162
170
  rdoc_options: []
163
171
  require_paths:
164
172
  - lib
165
173
  required_ruby_version: !ruby/object:Gem::Requirement
174
+ none: false
166
175
  requirements:
167
176
  - - ! '>='
168
177
  - !ruby/object:Gem::Version
169
178
  version: '0'
170
179
  required_rubygems_version: !ruby/object:Gem::Requirement
180
+ none: false
171
181
  requirements:
172
182
  - - ! '>='
173
183
  - !ruby/object:Gem::Version
@@ -175,8 +185,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
185
  requirements:
176
186
  - none
177
187
  rubyforge_project:
178
- rubygems_version: 2.0.3
188
+ rubygems_version: 1.8.24
179
189
  signing_key:
180
- specification_version: 4
190
+ specification_version: 3
181
191
  summary: A tool for creating LaTex files from ERb templates.
182
192
  test_files: []
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZTExNmYwNjAzZGVhYmE0ZTMwMzkzNTc3NDY5ODQzMWM1ZjUyNWU4NQ==
5
- data.tar.gz: !binary |-
6
- YWVlNmFkNDhkNTI0YWQ5Yzg0ZTk2YTc3YTU4NWQ2ZmQ3NDFmYjkzYg==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- ZjQxNGM0N2ExZTQxOTU2MTI2OWFlZjQxZmZiYmQ0NmJlYzA1NWUwMGY3ODc1
10
- ZmU3YTg5ODk5NzA1NWI2MWZiNTM3NTIxMTQ1NjYxMjM5NzdhNmJhMDJiMGYz
11
- MmJiODQ3ZTczN2UyZjcyMDYyZDk0YTAwZGMwOWQ1NTZmNjIzNjU=
12
- data.tar.gz: !binary |-
13
- NGJmYzJiY2ZlYzE3ZWYxYWY3ZTEyNDAxNzY3NWIwMzc5Y2MzNTdmNzMyNjc3
14
- NjZhM2ViZjdiODJmOWFmOGIzM2VkNDc4M2FjOWYwNDU2YmQ1YjhiODYyOTJh
15
- ODE1MTM5MWE2OTAxNTU0Yjc4YmM0ZTcxNzgwODQ0Yzc4YWQ1NjI=