expansions 0.4.33 → 0.4.35

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4cded197400bbf924399c1f9fa721ef57da0e88b
4
- data.tar.gz: 91a2f79e7fd6369b696249d1e6968eb83b7f9d70
2
+ SHA256:
3
+ metadata.gz: b1eb812bc08443b3690124ff06b7c3160bf53f1b5119a4729133fe0b0c7fadc3
4
+ data.tar.gz: 4dd15f72d8ea0889e1d3e3527cba52f951b7a56a27bd787de5772a660e9743a7
5
5
  SHA512:
6
- metadata.gz: 6d0dcdda88d70c6f5915cc317126a4d77bc686c350f43929056b114e7a958bbf7d1269f8e642941c037f47152f844cf4aa4ad4153a06f2889d73bd2859e51f00
7
- data.tar.gz: 243cb9f686dded797f0d90bad37a21fe149b2553ce21bdf83d51500507634c219d3295b6c32147a145f1898b697bda6adc38aa35b1d27ee1c2e92327740dd38b
6
+ metadata.gz: 9faf85ebb12b2f665cda089e6de19ba745bd82a392d260e68753db1c6726edc829c6f10e590b406c04be787bad00ec46373f3d9aa23844db916a51cb88490eb1
7
+ data.tar.gz: 921a5edaeb87e6e6406ca9c1c3c2c55eabc08c0886144097e4959b8cca35cab52a62db9652da70b21c9f766a1b1571955d26815d0230a5e655f929eefdc580b6
@@ -59,7 +59,7 @@ module Expansions
59
59
 
60
60
  def add_merge_file(items,file)
61
61
  return if items.include?(file)
62
- items << file if File.exists?(file)
62
+ items << file if File.exist?(file)
63
63
  end
64
64
  end
65
65
  end
@@ -11,28 +11,34 @@ module Expansions
11
11
 
12
12
  def run_using(file_name)
13
13
  processor = processors.get_processor_for(file_name)
14
-
15
- generated_name = File.basename(file_name,File.extname(file_name))
16
-
17
- load_settings_file(File.dirname(file_name), generated_name)
18
-
19
- generated_name = generated_name.gsub(DOT_FILE_PATTERN, "")
20
-
21
- generated_name = ".#{generated_name}" if (DOT_FILE_PATTERN =~ file_name)
22
-
23
- output = File.join(File.dirname(file_name),generated_name)
24
-
14
+ names = get_file_names(file_name)
15
+ load_settings_file(names[:settings_file])
16
+ output = names[:output_file_name]
25
17
  file.delete(output) if file.exists?(output)
26
18
 
27
- processor.process(:input => file_name,:output => output)
19
+ begin
20
+ processor.process(:input => file_name,:output => output)
21
+ rescue Exception => e
22
+ raise "Error processing template file: #{file_name}"
23
+ end
28
24
  end
29
25
 
30
- def load_settings_file(folder, file_name)
31
- settings_file = File.join(folder, "#{file_name}.settings")
26
+ def get_file_names(file_name)
27
+ base_name = File.basename(file_name, File.extname(file_name))
28
+ dir_name = File.dirname(file_name)
29
+ generated_name = base_name.gsub(DOT_FILE_PATTERN, "")
30
+ generated_name = ".#{generated_name}" if (DOT_FILE_PATTERN =~ file_name)
31
+ output_file_name = File.join(dir_name, generated_name)
32
+ settings_file = File.join(dir_name, "#{base_name}.settings")
33
+
34
+ {
35
+ settings_file: settings_file,
36
+ output_file_name: output_file_name
37
+ }
38
+ end
32
39
 
33
- if File.exist?(settings_file)
34
- load settings_file
35
- end
40
+ def load_settings_file(settings_file)
41
+ load settings_file if File.exist?(settings_file)
36
42
  end
37
43
  end
38
44
  end
@@ -1,3 +1,3 @@
1
1
  module Expansions
2
- VERSION = "0.4.33"
2
+ VERSION = "0.4.35"
3
3
  end
@@ -7,7 +7,7 @@ module Expansions
7
7
  let(:output_file){"out_file.rb"}
8
8
  let(:sut){FileMerge.new(output_file)}
9
9
  before (:each) do
10
- File.stub(:exists?).with(file).and_return(true)
10
+ File.stub(:exist?).with(file).and_return(true)
11
11
  end
12
12
  context "and it is not already in the list" do
13
13
  before (:each) do
@@ -36,7 +36,7 @@ module Expansions
36
36
  let(:output_file){"out_file.rb"}
37
37
  let(:sut){FileMerge.new(output_file)}
38
38
  before (:each) do
39
- File.stub(:exists?).with(file).and_return(true)
39
+ File.stub(:exist?).with(file).and_return(true)
40
40
  end
41
41
 
42
42
  before (:each) do
@@ -27,7 +27,7 @@ describe Expansions do
27
27
 
28
28
  context "and no block is given" do
29
29
  before (:each) do
30
- @result = glob(File.join(RelativeFileSystem.base_path,"**/*.*"))
30
+ @result = glob(File.join(RelativeFileSystem.base_path,"**/**"))
31
31
  end
32
32
 
33
33
  it "should return all files in path" do
@@ -41,7 +41,7 @@ describe Expansions do
41
41
  end
42
42
 
43
43
  before (:each) do
44
- @result = glob(File.join(RelativeFileSystem.base_path,"**/*.*")) do |file|
44
+ @result = glob(File.join(RelativeFileSystem.base_path,"**/*")) do |file|
45
45
  @items_visited += 1
46
46
  end
47
47
  end
@@ -20,7 +20,6 @@ module Expansions
20
20
  context "and the generated file already exists" do
21
21
  let(:file_name){"some.file"}
22
22
  before (:each) do
23
- the_processor.stub(:remove_template_extension_from).and_return(file_name)
24
23
  file.stub(:exists?).with("./some.file").and_return(true)
25
24
  end
26
25
 
@@ -34,7 +33,6 @@ module Expansions
34
33
  context "and the generated file does not already exists" do
35
34
  let(:file_name){"some.file"}
36
35
  before (:each) do
37
- the_processor.stub(:remove_template_extension_from).and_return(file_name)
38
36
  file.stub(:exists?).with("./some.file").and_return(false)
39
37
  end
40
38
 
@@ -53,7 +51,6 @@ module Expansions
53
51
 
54
52
  before (:each) do
55
53
  registry.stub(:get_processor_for).and_return(the_processor)
56
- the_processor.stub(:remove_template_extension_from).ignore_arg.and_return("bashrc.dotfile")
57
54
  end
58
55
  before (:each) do
59
56
  sut.run_using(file_name)
@@ -69,7 +66,6 @@ module Expansions
69
66
 
70
67
  before (:each) do
71
68
  registry.stub(:get_processor_for).and_return(the_processor)
72
- the_processor.stub(:remove_template_extension_from).ignore_arg.and_return("bashrc")
73
69
  end
74
70
  before (:each) do
75
71
  sut.run_using(file_name)
@@ -79,6 +75,29 @@ module Expansions
79
75
  the_processor.should have_received_message(:process,:input => file_name,:output => "blah/bashrc")
80
76
  end
81
77
  end
78
+
79
+ context "and the template processor throw an exception" do
80
+ let(:file_name){"blah/bashrc.erb"}
81
+ let(:options){{}}
82
+ let(:inner) { Exception.new("This is an error") }
83
+
84
+ before (:each) do
85
+ registry.stub(:get_processor_for).and_return(the_processor)
86
+ the_processor.stub(:process).throws(inner)
87
+ end
88
+
89
+ before (:each) do
90
+ begin
91
+ sut.run_using(file_name)
92
+ rescue Exception => e
93
+ @error = e
94
+ end
95
+ end
96
+
97
+ it "should rethrow the exception with details of the file that could not be transformed" do
98
+ expect(@error.message).to match(/Error processing/)
99
+ end
100
+ end
82
101
  end
83
102
  end
84
103
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expansions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.33
4
+ version: 0.4.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Develop With Passion®
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-01 00:00:00.000000000 Z
11
+ date: 2023-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: configatron
@@ -112,7 +112,7 @@ homepage: http://www.developwithpassion.com
112
112
  licenses:
113
113
  - MIT
114
114
  metadata: {}
115
- post_install_message:
115
+ post_install_message:
116
116
  rdoc_options: []
117
117
  require_paths:
118
118
  - lib
@@ -127,26 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
129
  requirements: []
130
- rubyforge_project: expansions
131
- rubygems_version: 2.2.2
132
- signing_key:
130
+ rubygems_version: 3.3.7
131
+ signing_key:
133
132
  specification_version: 4
134
133
  summary: Simple Expansion Automation Utility
135
- test_files:
136
- - spec/spec_helper.rb
137
- - spec/specs/array_spec.rb
138
- - spec/specs/configuration_spec.rb
139
- - spec/specs/copy_spec.rb
140
- - spec/specs/copy_to_target_spec.rb
141
- - spec/specs/enumerable_extensions_spec.rb
142
- - spec/specs/erb_template_file_spec.rb
143
- - spec/specs/expansion_spec.rb
144
- - spec/specs/file_merge_spec.rb
145
- - spec/specs/file_spec.rb
146
- - spec/specs/kernel_spec.rb
147
- - spec/specs/mustache_template_file_spec.rb
148
- - spec/specs/shell_action_against_file_spec.rb
149
- - spec/specs/string_spec.rb
150
- - spec/specs/template_processors_spec.rb
151
- - spec/specs/template_visitor_spec.rb
152
- has_rdoc:
134
+ test_files: []