sparrowhawk 0.9.3 → 0.9.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## 0.9.4 (31 December 2010)
2
+
3
+ * Features
4
+
5
+ * Include a bundler config in the war to make sure only the correct gems are loaded by bundler (https://www.pivotaltracker.com/story/show/8048525)
6
+
7
+ * Bugs
8
+
9
+ * Make sure the correct version of Bundler is available (https://www.pivotaltracker.com/story/show/8034021)
10
+
1
11
  ## 0.9.3 (29 December 2010)
2
12
 
3
13
  * Bugs
@@ -0,0 +1,58 @@
1
+ module Sparrowhawk
2
+
3
+ class BundlerArtifactMapper
4
+ include Enumerable
5
+
6
+ attr_reader :definition
7
+
8
+ def initialize
9
+ @definition = BundlerDefinition.new gemfile, lockfile
10
+ end
11
+
12
+ def each
13
+ entries.each { |entry| yield entry }
14
+ end
15
+
16
+ private
17
+
18
+ def entries
19
+ entries = []
20
+ entries << GemfileEntry.new
21
+ entries << LockfileEntry.new
22
+ entries << gems
23
+ unless groups.empty?
24
+ entries << bundler_configuration
25
+ end
26
+ entries.flatten
27
+ end
28
+
29
+ def gems
30
+ unless @gems
31
+ gem_finder = BundlerGemFinder.new definition
32
+ @gems = GemMapper.new(gem_finder).to_a.flatten
33
+ end
34
+ @gems
35
+ end
36
+
37
+ def groups
38
+ @groups ||= definition.groups or []
39
+ end
40
+
41
+ def bundler_configuration
42
+ @bundler_configuration ||= BundlerConfigurationEntry.new :without => excluded_groups
43
+ end
44
+
45
+ def excluded_groups
46
+ definition.excluded_groups
47
+ end
48
+
49
+ def gemfile
50
+ 'Gemfile'
51
+ end
52
+
53
+ def lockfile
54
+ 'Gemfile.lock'
55
+ end
56
+ end
57
+
58
+ end
@@ -0,0 +1,23 @@
1
+ module Sparrowhawk
2
+
3
+ class BundlerConfigurationEntry
4
+ attr_reader :name
5
+ attr_reader :content
6
+
7
+ def initialize options = {}
8
+ @name = 'WEB-INF/.bundle/config'
9
+ @content = config_yaml options
10
+ end
11
+
12
+ private
13
+
14
+ def config_yaml options
15
+ config = {}
16
+ if options[:without]
17
+ config['BUNDLE_WITHOUT'] = options[:without].join(':')
18
+ end
19
+ config.to_yaml
20
+ end
21
+ end
22
+
23
+ end
@@ -3,8 +3,9 @@ require 'delegate'
3
3
  module Sparrowhawk
4
4
 
5
5
  class BundlerDefinition < DelegateClass(::Bundler::Definition)
6
- def initialize
7
- super ::Bundler::Definition.build('Gemfile', 'Gemfile.lock', nil)
6
+
7
+ def initialize gemfile, lockfile
8
+ super ::Bundler::Definition.build(gemfile, lockfile, nil)
8
9
  end
9
10
 
10
11
  # Filters dependencies based on what should be in the war at runtime
@@ -12,9 +13,17 @@ module Sparrowhawk
12
13
  dependencies.select do |dep|
13
14
  dep.type.to_sym == :runtime and
14
15
  (dep.platforms.empty? or dep.platforms.include?(:jruby)) and
15
- !(dep.groups & [:default, :production]).empty?
16
+ !(dep.groups & production_groups).empty?
16
17
  end
17
18
  end
19
+
20
+ def excluded_groups
21
+ @excluded_groups ||= groups - production_groups
22
+ end
23
+
24
+ def production_groups
25
+ [:default, :production]
26
+ end
18
27
  end
19
28
 
20
29
  end
@@ -5,8 +5,8 @@ module Sparrowhawk
5
5
 
6
6
  attr_reader :definition
7
7
 
8
- def initialize
9
- @definition = BundlerDefinition.new
8
+ def initialize definition
9
+ @definition = definition
10
10
  end
11
11
 
12
12
  def each
@@ -29,11 +29,7 @@ module Sparrowhawk
29
29
  war.entries << ApplicationFilesMapper.new(application_dirs).to_a
30
30
  war.entries << JRubyCoreJarEntry.new
31
31
  war.entries << JRubyStdLibJarEntry.new
32
- war.entries << JRubyRackJarEntry.new
33
- gem_finder = BundlerGemFinder.new
34
- war.entries << GemMapper.new(gem_finder).to_a
35
- war.entries << GemfileEntry.new
36
- war.entries << LockfileEntry.new
32
+ war.entries << BundlerArtifactMapper.new.to_a
37
33
  other_files.each do |file|
38
34
  war.entries << FileEntry.new("WEB-INF/#{file}", file)
39
35
  end if other_files
data/lib/sparrowhawk.rb CHANGED
@@ -1,28 +1,30 @@
1
1
  require 'bundler'
2
2
 
3
3
  module Sparrowhawk
4
- VERSION = "0.9.3"
4
+ VERSION = "0.9.4"
5
5
 
6
- autoload :War ,'sparrowhawk/war'
7
- autoload :Configuration ,'sparrowhawk/configuration'
6
+ autoload :War ,'sparrowhawk/war'
7
+ autoload :Configuration ,'sparrowhawk/configuration'
8
8
 
9
- autoload :Entry ,'sparrowhawk/entry'
10
- autoload :FileEntry ,'sparrowhawk/file_entry'
11
- autoload :WebXmlEntry ,'sparrowhawk/web_xml_entry'
12
- autoload :ManifestEntry ,'sparrowhawk/manifest_entry'
13
- autoload :JarEntry ,'sparrowhawk/jar_entry'
14
- autoload :JRubyCoreJarEntry ,'sparrowhawk/jruby_core_jar_entry'
15
- autoload :JRubyStdLibJarEntry ,'sparrowhawk/jruby_stdlib_jar_entry'
16
- autoload :JRubyRackJarEntry ,'sparrowhawk/jruby_rack_jar_entry'
17
- autoload :GemfileEntry ,'sparrowhawk/gemfile_entry'
18
- autoload :LockfileEntry ,'sparrowhawk/lockfile_entry'
9
+ autoload :Entry ,'sparrowhawk/entry'
10
+ autoload :FileEntry ,'sparrowhawk/file_entry'
11
+ autoload :WebXmlEntry ,'sparrowhawk/web_xml_entry'
12
+ autoload :ManifestEntry ,'sparrowhawk/manifest_entry'
13
+ autoload :JarEntry ,'sparrowhawk/jar_entry'
14
+ autoload :JRubyCoreJarEntry ,'sparrowhawk/jruby_core_jar_entry'
15
+ autoload :JRubyStdLibJarEntry ,'sparrowhawk/jruby_stdlib_jar_entry'
16
+ autoload :JRubyRackJarEntry ,'sparrowhawk/jruby_rack_jar_entry'
17
+ autoload :GemfileEntry ,'sparrowhawk/gemfile_entry'
18
+ autoload :LockfileEntry ,'sparrowhawk/lockfile_entry'
19
+ autoload :BundlerConfigurationEntry ,'sparrowhawk/bundler_configuration_entry'
19
20
 
20
- autoload :FileEntryMapper ,'sparrowhawk/file_entry_mapper'
21
- autoload :PublicDirMapper ,'sparrowhawk/public_dir_mapper'
22
- autoload :ApplicationFilesMapper ,'sparrowhawk/application_files_mapper'
23
- autoload :GemMapper ,'sparrowhawk/gem_mapper'
21
+ autoload :FileEntryMapper ,'sparrowhawk/file_entry_mapper'
22
+ autoload :PublicDirMapper ,'sparrowhawk/public_dir_mapper'
23
+ autoload :ApplicationFilesMapper ,'sparrowhawk/application_files_mapper'
24
+ autoload :GemMapper ,'sparrowhawk/gem_mapper'
25
+ autoload :BundlerArtifactMapper ,'sparrowhawk/bundler_artifact_mapper'
24
26
 
25
- autoload :BundlerGemFinder ,'sparrowhawk/bundler_gem_finder'
26
- autoload :BundlerDefinition ,'sparrowhawk/bundler_definition'
27
- autoload :Index ,'sparrowhawk/index'
27
+ autoload :BundlerGemFinder ,'sparrowhawk/bundler_gem_finder'
28
+ autoload :BundlerDefinition ,'sparrowhawk/bundler_definition'
29
+ autoload :Index ,'sparrowhawk/index'
28
30
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sparrowhawk
3
3
  version: !ruby/object:Gem::Version
4
- hash: 61
4
+ hash: 51
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 3
10
- version: 0.9.3
9
+ - 4
10
+ version: 0.9.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan L. Bell
@@ -15,12 +15,29 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-29 00:00:00 -05:00
18
+ date: 2010-12-31 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
23
+ type: :runtime
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 27
30
+ segments:
31
+ - 1
32
+ - 0
33
+ - 6
34
+ version: 1.0.6
35
+ requirement: *id001
36
+ name: bundler
37
+ - !ruby/object:Gem::Dependency
38
+ prerelease: false
39
+ type: :runtime
40
+ version_requirements: &id002 !ruby/object:Gem::Requirement
24
41
  none: false
25
42
  requirements:
26
43
  - - ">="
@@ -29,12 +46,12 @@ dependencies:
29
46
  segments:
30
47
  - 0
31
48
  version: "0"
32
- type: :runtime
33
- version_requirements: *id001
49
+ requirement: *id002
34
50
  name: rubyzip
35
51
  - !ruby/object:Gem::Dependency
36
52
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
53
+ type: :runtime
54
+ version_requirements: &id003 !ruby/object:Gem::Requirement
38
55
  none: false
39
56
  requirements:
40
57
  - - ">="
@@ -43,12 +60,12 @@ dependencies:
43
60
  segments:
44
61
  - 0
45
62
  version: "0"
46
- type: :runtime
47
- version_requirements: *id002
63
+ requirement: *id003
48
64
  name: jruby-jars
49
65
  - !ruby/object:Gem::Dependency
50
66
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
67
+ type: :runtime
68
+ version_requirements: &id004 !ruby/object:Gem::Requirement
52
69
  none: false
53
70
  requirements:
54
71
  - - ">="
@@ -57,12 +74,12 @@ dependencies:
57
74
  segments:
58
75
  - 0
59
76
  version: "0"
60
- type: :runtime
61
- version_requirements: *id003
77
+ requirement: *id004
62
78
  name: jruby-rack
63
79
  - !ruby/object:Gem::Dependency
64
80
  prerelease: false
65
- requirement: &id004 !ruby/object:Gem::Requirement
81
+ type: :development
82
+ version_requirements: &id005 !ruby/object:Gem::Requirement
66
83
  none: false
67
84
  requirements:
68
85
  - - ">="
@@ -71,12 +88,12 @@ dependencies:
71
88
  segments:
72
89
  - 0
73
90
  version: "0"
74
- type: :development
75
- version_requirements: *id004
91
+ requirement: *id005
76
92
  name: rake
77
93
  - !ruby/object:Gem::Dependency
78
94
  prerelease: false
79
- requirement: &id005 !ruby/object:Gem::Requirement
95
+ type: :development
96
+ version_requirements: &id006 !ruby/object:Gem::Requirement
80
97
  none: false
81
98
  requirements:
82
99
  - - ">="
@@ -85,12 +102,12 @@ dependencies:
85
102
  segments:
86
103
  - 0
87
104
  version: "0"
88
- type: :development
89
- version_requirements: *id005
105
+ requirement: *id006
90
106
  name: rspec
91
107
  - !ruby/object:Gem::Dependency
92
108
  prerelease: false
93
- requirement: &id006 !ruby/object:Gem::Requirement
109
+ type: :development
110
+ version_requirements: &id007 !ruby/object:Gem::Requirement
94
111
  none: false
95
112
  requirements:
96
113
  - - ">="
@@ -99,12 +116,12 @@ dependencies:
99
116
  segments:
100
117
  - 0
101
118
  version: "0"
102
- type: :development
103
- version_requirements: *id006
119
+ requirement: *id007
104
120
  name: cucumber
105
121
  - !ruby/object:Gem::Dependency
106
122
  prerelease: false
107
- requirement: &id007 !ruby/object:Gem::Requirement
123
+ type: :development
124
+ version_requirements: &id008 !ruby/object:Gem::Requirement
108
125
  none: false
109
126
  requirements:
110
127
  - - ">="
@@ -113,12 +130,12 @@ dependencies:
113
130
  segments:
114
131
  - 0
115
132
  version: "0"
116
- type: :development
117
- version_requirements: *id007
133
+ requirement: *id008
118
134
  name: aruba
119
135
  - !ruby/object:Gem::Dependency
120
136
  prerelease: false
121
- requirement: &id008 !ruby/object:Gem::Requirement
137
+ type: :development
138
+ version_requirements: &id009 !ruby/object:Gem::Requirement
122
139
  none: false
123
140
  requirements:
124
141
  - - ">="
@@ -127,8 +144,7 @@ dependencies:
127
144
  segments:
128
145
  - 0
129
146
  version: "0"
130
- type: :development
131
- version_requirements: *id008
147
+ requirement: *id009
132
148
  name: nokogiri
133
149
  description: Sparrowhawk uses bundler and vendor/cache to package rails applications into a war file, without executing Java or JRuby
134
150
  email:
@@ -140,7 +156,9 @@ extensions: []
140
156
  extra_rdoc_files: []
141
157
 
142
158
  files:
159
+ - lib/sparrowhawk/bundler_configuration_entry.rb
143
160
  - lib/sparrowhawk/public_dir_mapper.rb
161
+ - lib/sparrowhawk/bundler_artifact_mapper.rb
144
162
  - lib/sparrowhawk/war.rb
145
163
  - lib/sparrowhawk/jruby_stdlib_jar_entry.rb
146
164
  - lib/sparrowhawk/rake_task.rb