confetti 0.2.4 → 0.2.5
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.
- data/Gemfile.lock +1 -1
- data/lib/confetti/template_helper.rb +8 -2
- data/lib/confetti/templates/java_checks.rb +3 -1
- data/lib/confetti/version.rb +1 -1
- data/spec/spec_helper.rb +12 -2
- data/spec/templates/java_checks_spec.rb +4 -0
- metadata +6 -6
data/Gemfile.lock
CHANGED
@@ -18,9 +18,15 @@ module Confetti
|
|
18
18
|
filepath = args.first
|
19
19
|
|
20
20
|
template = send generate_method
|
21
|
-
filepath ||= File.join(Dir.pwd, template.output_filename)
|
22
21
|
|
23
|
-
|
22
|
+
begin
|
23
|
+
output = template.render
|
24
|
+
filepath ||= File.join(Dir.pwd, template.output_filename)
|
25
|
+
|
26
|
+
open(filepath, 'w') { |f| f.puts output }
|
27
|
+
rescue
|
28
|
+
raise IOError, "unable to write template file"
|
29
|
+
end
|
24
30
|
end
|
25
31
|
end
|
26
32
|
end
|
@@ -10,8 +10,10 @@ module Confetti
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def is_java_package_id(str)
|
13
|
+
components = str.split('.', -1)
|
14
|
+
|
13
15
|
# second param to #split ensures can't be dot-terminated
|
14
|
-
|
16
|
+
components.length > 1 and components.all? { |s| is_java_identifier(s) }
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
data/lib/confetti/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -57,21 +57,31 @@ module ConfigHelpers
|
|
57
57
|
@output = mock(IO)
|
58
58
|
|
59
59
|
@config.should_receive(generate_method).and_return(@template)
|
60
|
-
@template.should_receive(:render).and_return(@contents)
|
61
|
-
@output.should_receive(:puts).with(@contents)
|
62
60
|
end
|
63
61
|
|
64
62
|
it "should write the rendered #{ default_filename } to the fs" do
|
65
63
|
filepath = "my_directory/#{ default_filename }"
|
66
64
|
@config.should_receive(:open).with(filepath, 'w').and_yield(@output)
|
65
|
+
@template.should_receive(:render).and_return(@contents)
|
66
|
+
@output.should_receive(:puts).with(@contents)
|
67
67
|
|
68
68
|
@config.send(write_method, filepath)
|
69
69
|
end
|
70
70
|
|
71
|
+
it "should not write to the fs if the render call fails" do
|
72
|
+
filepath = "my_directory/#{ default_filename }"
|
73
|
+
@template.should_receive(:render).and_raise(IOError)
|
74
|
+
@config.should_not_receive(:open).with(filepath, 'w')
|
75
|
+
|
76
|
+
lambda { @config.send(write_method, filepath) }.should raise_error
|
77
|
+
end
|
78
|
+
|
71
79
|
describe "when no filepath is passed" do
|
72
80
|
it "should write the rendered #{ default_filename } to the default location" do
|
73
81
|
default_path = File.join(Dir.pwd, default_filename)
|
74
82
|
@config.should_receive(:open).with(default_path, 'w').and_yield(@output)
|
83
|
+
@template.should_receive(:render).and_return(@contents)
|
84
|
+
@output.should_receive(:puts).with(@contents)
|
75
85
|
|
76
86
|
@config.send(write_method)
|
77
87
|
end
|
@@ -55,5 +55,9 @@ describe Confetti::Template::JavaChecks do
|
|
55
55
|
it "should not accept a dot-first string" do
|
56
56
|
is_java_package_id(".com.alunny.foo").should be_false
|
57
57
|
end
|
58
|
+
|
59
|
+
it "should not accept a single java identifier" do
|
60
|
+
is_java_package_id("a27a4").should be_false
|
61
|
+
end
|
58
62
|
end
|
59
63
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confetti
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 5
|
10
|
+
version: 0.2.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andrew Lunny
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-20 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -213,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
213
213
|
requirements: []
|
214
214
|
|
215
215
|
rubyforge_project: confetti
|
216
|
-
rubygems_version: 1.
|
216
|
+
rubygems_version: 1.3.7
|
217
217
|
signing_key:
|
218
218
|
specification_version: 3
|
219
219
|
summary: Generate mobile app config files
|