doubleshot 0.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/Doubleshot +33 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.textile +208 -0
  4. data/bin/doubleshot +7 -0
  5. data/ext/java/Empty.java +0 -0
  6. data/lib/doubleshot.rb +37 -0
  7. data/lib/doubleshot/cli.rb +84 -0
  8. data/lib/doubleshot/cli/options.rb +34 -0
  9. data/lib/doubleshot/commands/build.rb +34 -0
  10. data/lib/doubleshot/commands/gem.rb +39 -0
  11. data/lib/doubleshot/commands/init.rb +129 -0
  12. data/lib/doubleshot/commands/install.rb +35 -0
  13. data/lib/doubleshot/commands/jar.rb +7 -0
  14. data/lib/doubleshot/commands/test.rb +119 -0
  15. data/lib/doubleshot/compiler.rb +47 -0
  16. data/lib/doubleshot/configuration.rb +361 -0
  17. data/lib/doubleshot/configuration/source_locations.rb +59 -0
  18. data/lib/doubleshot/dependencies.rb +31 -0
  19. data/lib/doubleshot/dependencies/dependency.rb +38 -0
  20. data/lib/doubleshot/dependencies/dependency_list.rb +60 -0
  21. data/lib/doubleshot/dependencies/gem_dependency.rb +8 -0
  22. data/lib/doubleshot/dependencies/gem_dependency_list.rb +10 -0
  23. data/lib/doubleshot/dependencies/jar_dependency.rb +8 -0
  24. data/lib/doubleshot/dependencies/jar_dependency_list.rb +10 -0
  25. data/lib/doubleshot/jar.rb +51 -0
  26. data/lib/doubleshot/readonly_collection.rb +32 -0
  27. data/lib/doubleshot/setup.rb +49 -0
  28. data/lib/ruby/blank.rb +132 -0
  29. data/lib/ruby/gem/requirement.rb +5 -0
  30. data/lib/ruby/kernel.rb +8 -0
  31. data/lib/ruby/pathname.rb +11 -0
  32. data/lib/ruby/string.rb +42 -0
  33. data/lib/ruby/time.rb +8 -0
  34. data/test/compiler_spec.rb +44 -0
  35. data/test/configuration/source_locations_spec.rb +98 -0
  36. data/test/configuration_spec.rb +295 -0
  37. data/test/dependencies/dependency_list_spec.rb +73 -0
  38. data/test/dependencies/dependency_spec.rb +49 -0
  39. data/test/dependencies/gem_dependency_list_spec.rb +7 -0
  40. data/test/dependencies/gem_dependency_spec.rb +7 -0
  41. data/test/dependencies/jar_dependency_list_spec.rb +7 -0
  42. data/test/dependencies/jar_dependency_spec.rb +7 -0
  43. data/test/dependencies_spec.rb +42 -0
  44. data/test/doubleshot_spec.rb +51 -0
  45. data/test/helper.rb +18 -0
  46. data/test/readonly_collection_spec.rb +45 -0
  47. metadata +300 -0
@@ -0,0 +1,39 @@
1
+ class Doubleshot::CLI::Commands::Gem < Doubleshot::CLI
2
+
3
+ def self.summary
4
+ <<-EOS.margin
5
+ Package your project as a Rubygem, bundling any
6
+ JAR dependencies and Java classes in with the distribution.
7
+ EOS
8
+ end
9
+
10
+ def self.options
11
+ Options.new do |options|
12
+ options.banner = "Usage: doubleshot gem"
13
+ options.separator ""
14
+ options.separator "Options"
15
+
16
+ options.test = true
17
+ options.on "--no-test", "Disable testing as a build prerequisite." do
18
+ options.test = false
19
+ end
20
+
21
+ options.separator ""
22
+ options.separator "Summary: #{summary}"
23
+ end
24
+ end
25
+
26
+ def self.start(args)
27
+ options = self.options.parse!(args)
28
+
29
+ # TODO:
30
+ # compile Java
31
+ # download Jars and add them to the gemspec require_paths (I THINK).
32
+ config = Doubleshot::current.config
33
+
34
+ # TODO: This is version specific since in HEAD they've changed this to Gem::Package::build.
35
+ ::Gem::Builder.new(config.gemspec).build
36
+
37
+ return true
38
+ end
39
+ end
@@ -0,0 +1,129 @@
1
+ class Doubleshot::CLI::Commands::Init < Doubleshot::CLI
2
+
3
+ def self.summary
4
+ <<-EOS.margin
5
+ Generate a Doubleshot file for your project.
6
+ EOS
7
+ end
8
+
9
+ def self.options
10
+ Options.new do |options|
11
+ options.banner = "Usage: doubleshot init [PATH]"
12
+ options.separator ""
13
+ options.separator " [PATH] The path to your project directory."
14
+ options.separator " DEFAULT: Current working directory."
15
+ options.separator ""
16
+ options.separator "Summary: #{summary}"
17
+ end
18
+ end
19
+
20
+ def self.start(args)
21
+ session = new(args)
22
+ if session.doubleshot_file.exist?
23
+ return puts <<-EOS.margin
24
+ ERROR: A Doubleshot file already exists.
25
+ Rename or delete it to initialize a new one.
26
+ EOS
27
+ end
28
+ session.import_gemspec!
29
+ session.mark_gemspec_for_deletion!
30
+ session.generate_doubleshot_file!
31
+
32
+ puts <<-EOS.margin
33
+ We have created a Doubleshot file for your project.
34
+
35
+ Please review it and make changes as you see fit. It will
36
+ be used for all the things.
37
+ EOS
38
+ return true
39
+ end
40
+
41
+ def initialize(args)
42
+ @path = Pathname(args.empty? ? "." : args.first)
43
+ @config = Doubleshot::Configuration.new
44
+ end
45
+
46
+ def doubleshot_file
47
+ Pathname(@path + "Doubleshot")
48
+ end
49
+
50
+ def gemspec
51
+ @gemspec ||= Pathname::glob(@path + "*.gemspec").first
52
+ end
53
+
54
+ def import_gemspec!
55
+ original = gemspec ? eval_gemspec(gemspec.read) : ::Gem::Specification.new
56
+
57
+ @config.gemspec do |spec|
58
+ spec.name = default original.name, "THE PROJECT NAME"
59
+ spec.summary = default original.summary, "SUMMARIZE ME"
60
+ spec.description = default original.description, "A VERY DETAILED DESCRIPTION"
61
+ spec.author = default original.author, "WHOAMI"
62
+ spec.homepage = default original.homepage, "I AM FROM THE INTERNET"
63
+ spec.email = default original.email, "ME@EXAMPLE.COM"
64
+ spec.version = default original.version, "9000.1"
65
+ spec.license = default original.license, "MIT-LICENSE"
66
+ spec.executables = original.executables
67
+ end
68
+
69
+ original.runtime_dependencies.each do |dependency|
70
+ @config.gem dependency.name, *dependency.requirements_list
71
+ end
72
+
73
+ @config.development do
74
+ original.development_dependencies.each do |dependency|
75
+ @config.gem dependency.name, *dependency.requirements_list
76
+ end
77
+ end
78
+ end
79
+
80
+ def eval_gemspec(contents)
81
+ puts "Importing Gemspec..."
82
+ begin
83
+ ::Gem::Specification.from_yaml(contents)
84
+ # Raises ArgumentError if the file is not valid YAML
85
+ rescue ArgumentError, SyntaxError, ::Gem::EndOfYAMLException, ::Gem::Exception
86
+ begin
87
+ eval(contents, Doubleshot::CLI::binding)
88
+ rescue LoadError, SyntaxError => e
89
+ original_line = e.backtrace.find { |line| line.include?(path.to_s) }
90
+ msg = "There was a #{e.class} while evaluating #{gemspec_pathname.basename}: \n#{e.message}"
91
+ msg << " from\n #{original_line}" if original_line
92
+ msg << "\n"
93
+ raise GemspecError, msg
94
+ end
95
+ end
96
+ end
97
+
98
+ def mark_gemspec_for_deletion!
99
+ if gemspec
100
+ delete_me = gemspec.basename.to_s + ".DELETE_ME"
101
+ gemspec.rename(delete_me)
102
+ puts <<-EOS.margin, "", ""
103
+
104
+ IMPORTANT: We have renamed your gemspec to:
105
+
106
+ #{delete_me}
107
+
108
+ Please delete this file after you have reviewed your Doubleshot file.
109
+ It cannot be used to distribute your project. A valid gemspec will be
110
+ generated for you during the build process so that JAR, Gem, and compiled
111
+ sources are included in your distribution.
112
+
113
+ DELETE YOUR GEMSPEC!
114
+ EOS
115
+ end
116
+ end
117
+
118
+ def generate_doubleshot_file!
119
+ doubleshot_file.open("w+") do |file|
120
+ file << @config.to_ruby
121
+ end
122
+ end
123
+
124
+ private
125
+ def default(value, default_value)
126
+ value.blank? ? default_value : value
127
+ end
128
+
129
+ end
@@ -0,0 +1,35 @@
1
+ class Doubleshot::CLI::Commands::Install < Doubleshot::CLI
2
+
3
+ def self.summary
4
+ <<-EOS.margin
5
+ Install your project as a Rubygem.
6
+ EOS
7
+ end
8
+
9
+ def self.options
10
+ Options.new do |options|
11
+ options.banner = "Usage: doubleshot install"
12
+ options.separator ""
13
+ options.separator "Options"
14
+
15
+ options.test = true
16
+ options.on "--no-test", "Disable testing as a build prerequisite." do
17
+ options.test = false
18
+ end
19
+
20
+ options.separator ""
21
+ options.separator "Summary: #{summary}"
22
+ end
23
+ end
24
+
25
+ def self.start(args)
26
+ Doubleshot::CLI::Commands::Gem.start(args)
27
+
28
+ require "rubygems/dependency_installer"
29
+
30
+ installer = ::Gem::DependencyInstaller.new
31
+ installer.install Doubleshot::current.config.gemspec.file_name
32
+
33
+ return true
34
+ end
35
+ end
@@ -0,0 +1,7 @@
1
+ class Doubleshot::CLI::Commands::Jar < Doubleshot::CLI
2
+ def self.summary
3
+ <<-EOS.margin
4
+ TODO
5
+ EOS
6
+ end
7
+ end
@@ -0,0 +1,119 @@
1
+ class Doubleshot::CLI::Commands::Test < Doubleshot::CLI
2
+ def self.summary
3
+ <<-EOS.margin
4
+ A test harness that watches files, builds your
5
+ source, and executes tests based on filename
6
+ conventions. The location of your tests is
7
+ determined by the 'config.source.tests'
8
+ attribute of your Doubleshot configuration.
9
+ EOS
10
+ end
11
+
12
+ def self.options
13
+ Options.new do |options|
14
+ options.banner = "Usage: doubleshot test"
15
+
16
+ options.separator ""
17
+ options.separator "Summary: #{summary}"
18
+ end
19
+ end
20
+
21
+ def self.start(args)
22
+ require "listen"
23
+ watcher = new(Doubleshot::current.config)
24
+ watcher.run
25
+ end
26
+
27
+ def initialize(config)
28
+ @config = config
29
+ @interrupted = false
30
+
31
+ # Hit Ctrl-C once to re-run all specs; twice to exit the program.
32
+ Signal.trap("INT") do
33
+ if @interrupted
34
+ puts "\nShutting down..."
35
+ exit 0
36
+ else
37
+ @interrupted = true
38
+ run_all_specs
39
+ @interrupted = false
40
+ end
41
+ end
42
+ end
43
+
44
+ def run
45
+ # Output here just so you know when changes will be
46
+ # picked up after you start the program.
47
+ puts "Listening for changes..."
48
+ listener.start
49
+ end
50
+
51
+ private
52
+ def listener
53
+ # This creates a MultiListener
54
+ Listen.to(@config.source.tests.to_s, @config.source.ruby.to_s).change do |modified, added, removed|
55
+ modified.each do |location|
56
+ path = Pathname(location)
57
+ next unless path.extname == ".rb"
58
+
59
+ test = if path.child_of? @config.source.tests
60
+ path
61
+ else
62
+ relative_path = path.relative_path_from(@config.source.ruby.expand_path)
63
+ matcher = relative_path.sub(/(\w+)\.rb/, "\\1_{spec,test}.rb")
64
+ matchers = [ matcher, Pathname(matcher.to_s.split("/")[1..-1].join("/")) ]
65
+
66
+ match = matchers.detect do |matcher|
67
+ if match = Pathname::glob(@config.source.tests + matcher).first
68
+ break match
69
+ end
70
+ end
71
+ end
72
+
73
+ if test && test.exist?
74
+ duration = Time::measure do
75
+ puts "\n --- Running test for #{test.to_s} ---\n\n"
76
+
77
+ org.jruby.Ruby.newInstance.executeScript <<-RUBY, test.to_s
78
+ begin
79
+ require #{test.to_s.inspect}
80
+ MiniTest::Unit.new._run
81
+ rescue java.lang.Throwable, Exception => e
82
+ puts e.to_s, e.backtrace.join("\n")
83
+ end
84
+ RUBY
85
+ end
86
+
87
+ puts "Completed in #{duration}s"
88
+ else
89
+ puts "\nNo matching test for #{path.relative_path_from(@config.source.ruby.expand_path).to_s}"
90
+ end
91
+ end
92
+ end
93
+ end
94
+
95
+ def run_all_specs
96
+ duration = Time::measure do
97
+
98
+ puts "\n --- Running all tests ---\n\n"
99
+
100
+ script = <<-RUBY
101
+ begin
102
+ #{
103
+ Pathname::glob(@config.source.tests + "**/*_{spec,test}.rb").map do |path|
104
+ "require #{path.to_s.inspect}"
105
+ end.join("\n")
106
+ }
107
+ MiniTest::Unit.new._run
108
+ rescue java.lang.Throwable, Exception => e
109
+ puts e.to_s, e.backtrace.join("\n")
110
+ end
111
+ RUBY
112
+ # puts "SCRIPT:", script
113
+ org.jruby.Ruby.newInstance.executeScript script, "all-specs"
114
+ end
115
+
116
+ puts "Completed in #{duration}s"
117
+ end
118
+
119
+ end # class Doubleshot::CLI::Commands::Test < Doubleshot::CLI
@@ -0,0 +1,47 @@
1
+ require "java"
2
+ require "ant"
3
+
4
+ class Doubleshot
5
+ class Compiler
6
+
7
+ def initialize(source, target)
8
+ @source = Pathname(source.to_s)
9
+ @target = Pathname(target.to_s)
10
+ end
11
+
12
+ attr_reader :source, :target
13
+
14
+ def build!
15
+ @target.mkdir unless @target.exist?
16
+
17
+ # The JRuby ant integration throws JRuby Persistence
18
+ # warnings that you can't supress, so we run it
19
+ # inside of a Kernel#silence block.
20
+ silence do
21
+ ant.path id: "classpath" do
22
+ fileset dir: @target.to_s
23
+
24
+ $CLASSPATH.map do |path|
25
+ Pathname path.to_s.gsub(/file\:/, "")
26
+ end.select do |path|
27
+ path.exist?
28
+ end.map do |path|
29
+ (path.directory? ? path : path.dirname).to_s.ensure_ends_with("/")
30
+ end.uniq.each do |path|
31
+ fileset dir: path
32
+ end
33
+ end
34
+
35
+ ant.javac srcdir: @source.to_s,
36
+ destdir: @target.to_s,
37
+ debug: "yes",
38
+ includeantruntime: "no",
39
+ classpathref: "classpath"
40
+ end
41
+
42
+ p $CLASSPATH
43
+ $CLASSPATH << @target.to_s unless $CLASSPATH.include?(@target.to_s)
44
+ end
45
+
46
+ end # class Compiler
47
+ end # class Doubleshot
@@ -0,0 +1,361 @@
1
+ require "doubleshot/dependencies"
2
+ require "doubleshot/configuration/source_locations"
3
+
4
+ class Doubleshot
5
+ class Configuration
6
+
7
+ DEFAULT_PATHS = [ "Doubleshot", "*LICENSE*", "README*" ]
8
+ DEFAULT_WHITELIST = %w[
9
+ .rb .java .js
10
+ .yaml .yml .json .xml .properties
11
+ .css .less .sass .scss
12
+ .erb .haml .rxml .builder .html
13
+ ]
14
+
15
+ SOURCE_RUBY_MESSAGE = <<-EOS.margin
16
+ # Relative path to the folder containing your
17
+ # Ruby source code (.rb files).
18
+ # The default is "lib".
19
+ EOS
20
+
21
+ SOURCE_JAVA_MESSAGE = <<-EOS.margin
22
+ # Relative path to the folder containing your
23
+ # Java source code (.java files).
24
+ # The default is "ext/java".
25
+ EOS
26
+
27
+ SOURCE_TESTS_MESSAGE = <<-EOS.margin
28
+ # Relative path to the folder containing your
29
+ # tests. This feature is used when running
30
+ # doubleshot test
31
+ # Tests are assumed to be written in Ruby
32
+ # exclusively. Java test frameworks are not
33
+ # supported.
34
+ # This value is optional. The default is "test".
35
+ EOS
36
+
37
+ TARGET_MESSAGE = <<-EOS.margin
38
+ # Relative path to the folder containing the
39
+ # compiled Java files (.class files).
40
+ # The default is "target".
41
+ EOS
42
+
43
+ WHITELIST_MESSAGE = <<-EOS.margin
44
+ # List of file extensions within source folders
45
+ # that will be included during packaging.
46
+ # Does NOT override defaults, but adds to them.
47
+ # The default list can be found in
48
+ # Doubleshot::Configuration::DEFAULT_WHITELIST.
49
+ EOS
50
+
51
+
52
+ GEMSPEC_MESSAGE = <<-EOS.margin
53
+ # A subset of Gem::Specification compatible
54
+ # with Doubleshot. Since Doubleshot manages
55
+ # your Rubygems dependencies, and what files
56
+ # are included in your build, those options
57
+ # are not applicable (and will be discarded if
58
+ # provided).
59
+ EOS
60
+
61
+ GEM_DEPENDENCY_MESSAGE = <<-EOS.margin
62
+ # Add your Gem dependencies here using similar
63
+ # syntax to a gemspec, except your method is
64
+ # "gem" instead of "add_runtime_dependency".
65
+ EOS
66
+
67
+ JAR_DEPENDENCY_MESSAGE = <<-EOS.margin
68
+ # Add your JAR dependencies using Buildr
69
+ # dependency formatting (available as a
70
+ # copy-and-paste option on most Maven search
71
+ # repositories).
72
+ EOS
73
+
74
+ DEVELOPMENT_MESSAGE = <<-EOS.margin
75
+ # Add your Gem and JAR development dependencies
76
+ # similar to above. By default "doubleshot" is
77
+ # added as a development dependency to your gemspec.
78
+ # That's the equivalent of:
79
+ #
80
+ # config.development do
81
+ # config.gem "doubleshot"
82
+ # end
83
+ #
84
+ # NOTE: The above won't appear in your Doubleshot
85
+ # file as it's added during the build process for you.
86
+ EOS
87
+
88
+ def initialize
89
+ @defaults = {}
90
+ @gemspec = Gem::Specification.new
91
+ @gemspec.platform = Gem::Platform.new("java")
92
+ @source = SourceLocations.new
93
+ @target = default :target, Pathname("target")
94
+
95
+ @runtime_dependencies = Dependencies.new
96
+ @development_dependencies = Dependencies.new
97
+ @development_environment = false
98
+
99
+ @paths = default :paths, DEFAULT_PATHS.dup
100
+ @whitelist = default :whitelist, DEFAULT_WHITELIST.dup
101
+ end
102
+
103
+ def source
104
+ @source
105
+ end
106
+
107
+ def target
108
+ @target
109
+ end
110
+
111
+ def target=(path)
112
+ @target = Pathname(path.to_s)
113
+ end
114
+
115
+ def whitelist(extname)
116
+ @whitelist << extname.ensure_starts_with(".")
117
+ self
118
+ end
119
+
120
+ def development
121
+ if block_given?
122
+ @development_environment = true
123
+ yield
124
+ @development_environment = false
125
+ end
126
+ @development_dependencies
127
+ end
128
+
129
+ def gem(name, *requirements)
130
+ dependencies = @development_environment ?
131
+ @development_dependencies :
132
+ @runtime_dependencies
133
+
134
+ dependency = dependencies.gems.fetch(name)
135
+ dependencies.gems.add(dependency)
136
+
137
+ requirements.each do |requirement|
138
+ dependency.add_requirement(requirement)
139
+ end
140
+
141
+ dependency
142
+ end
143
+
144
+ def runtime
145
+ @runtime_dependencies
146
+ end
147
+
148
+ def paths
149
+ ReadonlyCollection.new @paths
150
+ end
151
+
152
+ def add_path(path)
153
+ @paths << path
154
+ self
155
+ end
156
+
157
+ def eql?(other)
158
+ other.is_a?(self.class) &&
159
+ other.target == target &&
160
+ other.source == source &&
161
+ other.runtime == runtime &&
162
+ other.development == development &&
163
+ other.paths == paths &&
164
+ other.gemspec == gemspec
165
+ end
166
+ alias :== :eql?
167
+
168
+ def gemspec(&b)
169
+ if b
170
+ yield @gemspec
171
+ else
172
+ @gemspec.rdoc_options = rdoc_options
173
+ @gemspec.require_paths = [ @source.ruby.to_s ]
174
+
175
+ test_files = []
176
+ @source.tests.find do |path|
177
+ test_files << path.to_s if path.file?
178
+ end
179
+ @gemspec.test_files = test_files
180
+
181
+ files = []
182
+
183
+ @paths.each do |path|
184
+ Pathname::glob(path).each do |match|
185
+ files << match.to_s if match.file?
186
+ end
187
+ end
188
+
189
+ @source.ruby.find do |path|
190
+ files << path.to_s if path.file? && @whitelist.include?(path.extname)
191
+ end
192
+
193
+ @source.java.find do |path|
194
+ files << path.to_s if path.file? && @whitelist.include?(path.extname)
195
+ end
196
+
197
+ if @target.exist?
198
+ @target.find do |path|
199
+ files << path.to_s if path.file?
200
+ end
201
+ end
202
+
203
+ @gemspec.files.concat(files)
204
+
205
+ @runtime_dependencies.gems.each do |dependency|
206
+ @gemspec.add_runtime_dependency dependency.name, *dependency.requirements
207
+ end
208
+
209
+ @development_dependencies.gems.each do |dependency|
210
+ @gemspec.add_development_dependency dependency.name, *dependency.requirements
211
+ end
212
+
213
+ @gemspec.add_development_dependency "doubleshot"
214
+
215
+ @gemspec
216
+ end
217
+ end
218
+
219
+ def to_ruby
220
+ <<-EOS.margin
221
+ # encoding: UTF-8
222
+
223
+ Doubleshot.new do |config|
224
+ #{
225
+ inner_heredoc = false
226
+ to_ruby_body.split("\n").map do |line|
227
+ output = if inner_heredoc
228
+ " #{line}"
229
+ else
230
+ " #{line}"
231
+ end
232
+
233
+ if line =~ /\<\<\-DESCRIPTION/
234
+ inner_heredoc = true
235
+ elsif line =~ /^\s*DESCRIPTION/
236
+ inner_heredoc = false
237
+ end
238
+ output
239
+ end.join("\n")}
240
+ end
241
+ EOS
242
+ end
243
+
244
+ def to_ruby_body
245
+ spec = gemspec
246
+
247
+ config_changes = __changes__
248
+ source_changes = @source.__changes__
249
+
250
+ <<-EOS.margin
251
+ #{Doubleshot::Configuration::SOURCE_RUBY_MESSAGE}
252
+ #{"# " unless source_changes.include? :ruby}config.source.ruby = #{@source.ruby.to_s.inspect}
253
+
254
+ #{Doubleshot::Configuration::SOURCE_JAVA_MESSAGE}
255
+ #{"# " unless source_changes.include? :java}config.source.java = #{@source.java.to_s.inspect}
256
+
257
+ #{Doubleshot::Configuration::SOURCE_TESTS_MESSAGE}
258
+ #{"# " unless source_changes.include? :tests}config.source.tests = #{@source.tests.to_s.inspect}
259
+
260
+
261
+ #{Doubleshot::Configuration::TARGET_MESSAGE}
262
+ #{"# " unless config_changes.include? :target}config.target = #{@target.to_s.inspect}
263
+
264
+
265
+ #{Doubleshot::Configuration::WHITELIST_MESSAGE}
266
+ #{
267
+ if config_changes.include? :whitelist
268
+ (@whitelist - DEFAULT_WHITELIST).map do |ext|
269
+ "config.whitelist #{ext.inspect}"
270
+ end.join("\n ")
271
+ else
272
+ "# config.whitelist \".ext\""
273
+ end
274
+ }
275
+
276
+
277
+ #{Doubleshot::Configuration::GEM_DEPENDENCY_MESSAGE}
278
+ #{
279
+ if @runtime_dependencies.gems.empty?
280
+ "# config.gem \"bcrypt-ruby\", \"~> 3.0\""
281
+ else
282
+ @runtime_dependencies.gems.map do |dependency|
283
+ if dependency.requirements.empty?
284
+ "config.gem \"#{dependency}\""
285
+ else
286
+ "config.gem \"#{dependency}\", \"#{dependency.requirements.map(&:to_s).join("\", \"")}\""
287
+ end
288
+ end.join("\n ")
289
+ end
290
+ }
291
+
292
+ #{Doubleshot::Configuration::JAR_DEPENDENCY_MESSAGE}
293
+ #{
294
+ if @runtime_dependencies.jars.empty?
295
+ "# config.jar \"ch.qos.logback:logback:jar:0.5\""
296
+ else
297
+ @runtime_dependencies.jars.map do |dependency|
298
+ "config.jar \"#{dependency}\""
299
+ end.join("\n ")
300
+ end
301
+ }
302
+
303
+ #{Doubleshot::Configuration::DEVELOPMENT_MESSAGE}
304
+ #{
305
+ unless @development_dependencies.empty?
306
+ "config.development do\n " +
307
+ (
308
+ @development_dependencies.gems.map do |dependency|
309
+ if dependency.requirements.empty?
310
+ " config.gem \"#{dependency}\""
311
+ else
312
+ " config.gem \"#{dependency}\", \"#{dependency.requirements.map(&:to_s).join("\", \"")}\""
313
+ end
314
+ end +
315
+ @development_dependencies.jars.map do |dependency|
316
+ " config.jar \"#{dependency}\""
317
+ end
318
+ ).join("\n ") + "\n end"
319
+ end
320
+ }
321
+
322
+ #{Doubleshot::Configuration::GEMSPEC_MESSAGE}
323
+ config.gemspec do |spec|
324
+ spec.name = #{spec.name.inspect}
325
+ spec.version = #{spec.version.to_s.inspect}
326
+ spec.summary = #{spec.summary.inspect}
327
+ spec.description = <<-DESCRIPTION
328
+ #{spec.description.strip}
329
+ DESCRIPTION
330
+ spec.homepage = #{spec.homepage.inspect}
331
+ spec.author = #{spec.author.inspect}
332
+ spec.email = #{spec.email.inspect}
333
+ spec.license = #{spec.license.inspect}
334
+ spec.executables = #{spec.executables.inspect}
335
+ end
336
+ EOS
337
+ end
338
+
339
+ def __changes__
340
+ changes = []
341
+ @defaults.each_pair do |key,value|
342
+ changes << key unless instance_variable_get("@#{key}") == value
343
+ end
344
+ changes
345
+ end
346
+
347
+ private
348
+ def rdoc_options
349
+ [
350
+ "--line-numbers",
351
+ "--main", "README.textile",
352
+ "--title", "#{@gemspec.name} Documentation",
353
+ @source.ruby.to_s, "README.textile"
354
+ ]
355
+ end
356
+
357
+ def default(key, value)
358
+ @defaults[key] = value
359
+ end
360
+ end
361
+ end