appbundler 0.4.0 → 0.5.0

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
2
  SHA1:
3
- metadata.gz: dd0a654c110cf3a6b807f33d19689b79efd7a262
4
- data.tar.gz: 16c4a093480e83d996a0c5dfc57445a734f80897
3
+ metadata.gz: a3f810a4157e852584ec425ed6eb051c607c4038
4
+ data.tar.gz: 5dfe2fbde8fad33d18e81a7957307853bace76cd
5
5
  SHA512:
6
- metadata.gz: acf6f4adf3b2c5b276c67f5c052b43b71d6bf1edec7bb81eed0c77e7df50742f7ed2250a106d3e3beea53c4b86dba01e2a2f15518ad7c5d576c86da64bf48c1b
7
- data.tar.gz: a655313efa7c602cb1f700fdcdf0ce876627a61b8149d808c7e4ea792116ab19cce9b16ae4eb860fac490f51645b8b97cd1de90afb8d720cfd5580a5245a18a8
6
+ metadata.gz: 7fe06ba8ebe2ee5938206d4f755d1ebc4a14fb8e540c230bb85eca0fbc151dd7c843097581f4491a5c697820ef4ae0558945a88f4f4221bd53a23911bada2075
7
+ data.tar.gz: 0f7afde6c93689b42d62e28c61bf96523b83ad092a14cea4ae873ea3cbc3caa2d8a96d514d9fc67573c044a6cb37264ede3d3a529a8e21aa854bffbaf4d4f8a7
data/.rspec CHANGED
@@ -1 +1,2 @@
1
- -cfs
1
+ -c
2
+ -f doc
@@ -1,7 +1,7 @@
1
1
  rvm:
2
- - 1.9.3
3
2
  - 2.0.0
4
3
  - 2.1.1
4
+ - 2.2
5
5
 
6
6
  branches:
7
7
  only:
@@ -19,7 +19,9 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "rake"
22
- spec.add_development_dependency "rspec", "~> 2.13"
22
+ spec.add_development_dependency "rspec", "~> 3.0"
23
23
  spec.add_development_dependency "pry"
24
24
  spec.add_development_dependency "mixlib-shellout", "~> 1.0"
25
+
26
+ spec.add_dependency "mixlib-cli", "~> 1.4"
25
27
  end
@@ -116,14 +116,15 @@ E
116
116
  end
117
117
 
118
118
  def load_statement_for(bin_file)
119
+ name, version = app_spec.name, app_spec.version
120
+ bin_basename = File.basename(bin_file)
119
121
  <<-E
120
- bin_dir = File.dirname(__FILE__)
121
- if File.symlink?(__FILE__)
122
- bin_dir = File.dirname(File.readlink(__FILE__))
123
- end
122
+ gem "#{name}", "= #{version}"
123
+
124
+ spec = Gem::Specification.find_by_name("#{name}", "= #{version}")
125
+ bin_file = spec.bin_file("#{bin_basename}")
124
126
 
125
- $:.unshift(File.expand_path("#{relative_app_lib_dir}", bin_dir))
126
- Kernel.load(File.expand_path('#{relative_bin_file(bin_file)}', bin_dir))
127
+ Kernel.load(bin_file)
127
128
  E
128
129
  end
129
130
 
@@ -1,11 +1,38 @@
1
1
  require 'appbundler/version'
2
2
  require 'appbundler/app'
3
+ require 'mixlib/cli'
3
4
 
4
5
  module Appbundler
5
6
  class CLI
7
+ include Mixlib::CLI
8
+
9
+ banner(<<-BANNER)
10
+ Usage: appbundler APPLICATION_DIR BINSTUB_DIR
11
+
12
+ APPLICATION_DIR is the root directory of your app
13
+ BINSTUB_DIR is the directory where you want generated executables to be written
14
+ BANNER
15
+
16
+ option :version,
17
+ :short => '-v',
18
+ :long => '--version',
19
+ :description => 'Show appbundler version',
20
+ :boolean => true,
21
+ :proc => lambda {|v| $stdout.puts("Appbundler Version: #{::Appbundler::VERSION}")},
22
+ :exit => 0
23
+
24
+ option :help,
25
+ :short => "-h",
26
+ :long => "--help",
27
+ :description => "Show this message",
28
+ :on => :tail,
29
+ :boolean => true,
30
+ :show_options => true,
31
+ :exit => 0
6
32
 
7
33
  def self.run(argv)
8
34
  cli = new(argv)
35
+ cli.handle_options
9
36
  cli.validate!
10
37
  cli.run
11
38
  end
@@ -17,17 +44,19 @@ module Appbundler
17
44
 
18
45
  def initialize(argv)
19
46
  @argv = argv
47
+ super()
48
+ end
49
+
50
+ def handle_options
51
+ parse_options(@argv)
20
52
  end
21
53
 
22
54
  def validate!
23
- if argv.any? {|arg| %w{-h --help help -v --version}.include?(arg) }
24
- $stdout.print(usage)
25
- exit 0
26
- elsif argv.size != 2
55
+ if cli_arguments.size != 2
27
56
  usage_and_exit!
28
57
  else
29
- @app_path = File.expand_path(argv[0])
30
- @bin_path = File.expand_path(argv[1])
58
+ @app_path = File.expand_path(cli_arguments[0])
59
+ @bin_path = File.expand_path(cli_arguments[1])
31
60
  verify_app_path
32
61
  verify_bin_path
33
62
  end
@@ -62,18 +91,8 @@ module Appbundler
62
91
  end
63
92
 
64
93
  def usage_and_exit!
65
- err(usage)
94
+ err(banner)
66
95
  exit 1
67
96
  end
68
-
69
- def usage
70
- <<-E
71
- Usage: appbundler APPLICATION_DIR BINSTUB_DIR
72
-
73
- APPLICATION_DIR is the root directory of your app
74
- BINSTUB_DIR is the directory where you want generated executables to be written
75
- E
76
- end
77
-
78
97
  end
79
98
  end
@@ -1,3 +1,3 @@
1
1
  module Appbundler
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -24,7 +24,9 @@ describe Appbundler do
24
24
  s
25
25
  end
26
26
 
27
- let(:target_bindir) { File.expand_path("../../test-tmp/bin", __FILE__) }
27
+ def target_bindir
28
+ File.expand_path("../../test-tmp/bin", __FILE__)
29
+ end
28
30
 
29
31
  context "given an app with multiple levels of dependencies" do
30
32
 
@@ -61,7 +63,7 @@ describe Appbundler do
61
63
  end
62
64
 
63
65
  before do
64
- app.stub(:gemfile_lock_specs).and_return(all_specs)
66
+ allow(app).to receive(:gemfile_lock_specs).and_return(all_specs)
65
67
  end
66
68
 
67
69
  it "finds the running ruby interpreter" do
@@ -80,7 +82,7 @@ describe Appbundler do
80
82
  expect(app.runtime_dep_specs).to include(second_level_dep_a_a)
81
83
  expect(app.runtime_dep_specs).to include(second_level_dep_b_a)
82
84
  expect(app.runtime_dep_specs).to include(second_level_dep_shared)
83
- expect(app.runtime_dep_specs.select {|s| s == second_level_dep_shared}).to have(1).item
85
+ expect(app.runtime_dep_specs.select {|s| s == second_level_dep_shared}.size).to eq(1)
84
86
  end
85
87
 
86
88
  it "generates gem activation code for the app" do
@@ -95,28 +97,16 @@ describe Appbundler do
95
97
  expect(app.runtime_activate).to_not include(%q{gem "app"})
96
98
  end
97
99
 
98
- it "adds symlink resolution to the code that activates the app" do
99
- symlink_code = <<-E
100
- bin_dir = File.dirname(__FILE__)
101
- if File.symlink?(__FILE__)
102
- bin_dir = File.dirname(File.readlink(__FILE__))
103
- end
104
- E
100
+ it "locks the main app's gem via rubygems, and loads the proper binary" do
101
+ expected_loading_code = <<-CODE
102
+ gem "app", "= 1.0.0"
105
103
 
106
- expect(app.load_statement_for(bin_path)).to include(symlink_code)
107
- end
104
+ spec = Gem::Specification.find_by_name("app", "= 1.0.0")
105
+ bin_file = spec.bin_file("foo")
108
106
 
109
- it "adds the app code to the load path" do
110
- # Our test setup makes an executable that needs to load a path in the
111
- # fictitious /opt/app/embedded/apps/app/lib path, so the relative path
112
- # will traverse all the way to the root and then back up. Therefore, the
113
- # expected output is dependent on how many directories deep this source
114
- # clone is from the root:
115
- relpath_to_root = Pathname.new("/").relative_path_from(Pathname.new(File.dirname(__FILE__))).to_s
116
-
117
- expected_code_path =
118
- %Q[$:.unshift(File.expand_path("#{relpath_to_root}/../opt/app/embedded/apps/app/lib", bin_dir))]
119
- expect(app.load_statement_for(bin_path)).to include(expected_code_path)
107
+ Kernel.load(bin_file)
108
+ CODE
109
+ expect(app.load_statement_for(bin_path)).to eq(expected_loading_code)
120
110
  end
121
111
 
122
112
  it "generates code to override GEM_HOME and GEM_PATH (e.g., rvm)" do
@@ -130,7 +120,7 @@ E
130
120
  let(:target_bindir) { "C:/opscode/chef/bin" }
131
121
 
132
122
  before do
133
- app.stub(:ruby).and_return("C:/opscode/chef/embedded/bin/ruby.exe")
123
+ allow(app).to receive(:ruby).and_return("C:/opscode/chef/embedded/bin/ruby.exe")
134
124
  end
135
125
 
136
126
  it "computes the relative path to ruby" do
@@ -152,7 +142,7 @@ E
152
142
  context "when created with the example application" do
153
143
  FIXTURES_PATH = File.expand_path("../../fixtures/", __FILE__).freeze
154
144
 
155
- APP_ROOT = File.join(FIXTURES_PATH, "example-app").freeze
145
+ APP_ROOT = File.join(FIXTURES_PATH, "appbundler-example-app").freeze
156
146
 
157
147
  let(:app_root) { APP_ROOT }
158
148
 
@@ -163,6 +153,8 @@ E
163
153
  before(:all) do
164
154
  Dir.chdir(APP_ROOT) do
165
155
  shellout!("bundle install")
156
+ shellout!("gem build appbundler-example-app.gemspec")
157
+ shellout!("gem install appbundler-example-app-1.0.0.gem")
166
158
  end
167
159
  end
168
160
 
@@ -172,6 +164,7 @@ E
172
164
  end
173
165
 
174
166
  after(:all) do
167
+ shellout!("gem uninstall appbundler-example-app -a -q -x")
175
168
  FileUtils.rm_rf(target_bindir) if File.exist?(target_bindir)
176
169
  end
177
170
 
@@ -180,7 +173,7 @@ E
180
173
  end
181
174
 
182
175
  it "names the app using the directory basename" do
183
- app.name.should == "example-app"
176
+ expect(app.name).to eq("appbundler-example-app")
184
177
  end
185
178
 
186
179
  it "lists the app's dependencies" do
@@ -191,34 +184,52 @@ E
191
184
  it "generates runtime activation code for the app" do
192
185
  expected_gem_activates=<<-E
193
186
  ENV["GEM_HOME"] = ENV["GEM_PATH"] = nil unless ENV["APPBUNDLER_ALLOW_RVM"] == "true"
194
- gem "chef", "= 11.10.4"
195
- gem "chef-zero", "= 1.7.3"
196
- gem "hashie", "= 2.0.5"
197
- gem "json", "= 1.8.1"
187
+ gem "chef", "= 12.4.1"
188
+ gem "chef-config", "= 12.4.1"
189
+ gem "mixlib-config", "= 2.2.1"
190
+ gem "mixlib-shellout", "= 2.2.0"
191
+ gem "chef-zero", "= 4.3.0"
192
+ gem "ffi-yajl", "= 2.2.2"
193
+ gem "libyajl2", "= 1.2.0"
194
+ gem "hashie", "= 2.1.2"
198
195
  gem "mixlib-log", "= 1.6.0"
199
- gem "moneta", "= 0.6.0"
200
- gem "rack", "= 1.5.2"
196
+ gem "rack", "= 1.6.4"
197
+ gem "uuidtools", "= 2.1.5"
201
198
  gem "diff-lcs", "= 1.2.5"
202
199
  gem "erubis", "= 2.7.0"
203
- gem "highline", "= 1.6.20"
204
- gem "mime-types", "= 1.25.1"
200
+ gem "highline", "= 1.7.3"
205
201
  gem "mixlib-authentication", "= 1.3.0"
206
- gem "mixlib-cli", "= 1.4.0"
207
- gem "mixlib-config", "= 2.1.0"
208
- gem "mixlib-shellout", "= 1.3.0"
209
- gem "net-ssh", "= 2.8.0"
210
- gem "net-ssh-multi", "= 1.2.0"
202
+ gem "mixlib-cli", "= 1.5.0"
203
+ gem "net-ssh", "= 2.9.2"
204
+ gem "net-ssh-multi", "= 1.2.1"
211
205
  gem "net-ssh-gateway", "= 1.2.0"
212
- gem "ohai", "= 6.20.0"
206
+ gem "ohai", "= 8.5.1"
207
+ gem "ffi", "= 1.9.10"
213
208
  gem "ipaddress", "= 0.8.0"
214
- gem "systemu", "= 2.5.2"
215
- gem "yajl-ruby", "= 1.2.0"
209
+ gem "mime-types", "= 2.6.1"
210
+ gem "rake", "= 10.1.1"
211
+ gem "systemu", "= 2.6.5"
212
+ gem "wmi-lite", "= 1.0.0"
213
+ gem "plist", "= 3.1.0"
216
214
  gem "pry", "= 0.9.12.6"
217
215
  gem "coderay", "= 1.1.0"
218
216
  gem "method_source", "= 0.8.2"
219
217
  gem "slop", "= 3.4.7"
220
- gem "puma", "= 1.6.3"
221
- gem "rest-client", "= 1.6.7"
218
+ gem "rspec-core", "= 3.3.2"
219
+ gem "rspec-support", "= 3.3.0"
220
+ gem "rspec-expectations", "= 3.3.1"
221
+ gem "rspec-mocks", "= 3.3.2"
222
+ gem "rspec_junit_formatter", "= 0.2.3"
223
+ gem "builder", "= 3.2.2"
224
+ gem "serverspec", "= 2.23.1"
225
+ gem "multi_json", "= 1.11.2"
226
+ gem "rspec", "= 3.3.0"
227
+ gem "rspec-its", "= 1.2.0"
228
+ gem "specinfra", "= 2.43.3"
229
+ gem "net-scp", "= 1.2.1"
230
+ gem "net-telnet", "= 0.1.1"
231
+ gem "sfl", "= 2.2"
232
+ gem "syslog-logger", "= 1.6.8"
222
233
  E
223
234
  expect(app.runtime_activate).to include(expected_gem_activates)
224
235
  end
@@ -242,7 +253,7 @@ E
242
253
 
243
254
  load_binary = executable_content.lines.to_a.last
244
255
 
245
- expected_load_path = %Q[Kernel.load(File.expand_path('../../fixtures/example-app/bin/app-binary-1', bin_dir))\n]
256
+ expected_load_path = %Q[Kernel.load(bin_file)\n]
246
257
 
247
258
  expect(load_binary).to eq(expected_load_path)
248
259
  end
@@ -251,10 +262,10 @@ E
251
262
  app.write_executable_stubs
252
263
  binary_1 = File.join(target_bindir, "app-binary-1")
253
264
  binary_2 = File.join(target_bindir, "app-binary-2")
254
- expect(File.exist?(binary_1)).to be_true
255
- expect(File.exist?(binary_2)).to be_true
256
- expect(File.executable?(binary_1)).to be_true
257
- expect(File.executable?(binary_1)).to be_true
265
+ expect(File.exist?(binary_1)).to be(true)
266
+ expect(File.exist?(binary_2)).to be(true)
267
+ expect(File.executable?(binary_1)).to be(true)
268
+ expect(File.executable?(binary_1)).to be(true)
258
269
  expect(shellout!(binary_1).stdout).to eq("binary 1 ran\n")
259
270
  expect(shellout!(binary_2).stdout).to eq("binary 2 ran\n")
260
271
  end
@@ -311,8 +322,8 @@ E
311
322
  app.write_executable_stubs
312
323
  binary_1 = File.join(target_bindir, "app-binary-1.bat")
313
324
  binary_2 = File.join(target_bindir, "app-binary-2.bat")
314
- expect(File.exist?(binary_1)).to be_true
315
- expect(File.exist?(binary_2)).to be_true
325
+ expect(File.exist?(binary_1)).to be(true)
326
+ expect(File.exist?(binary_2)).to be(true)
316
327
  expect(IO.read(binary_1)).to eq(expected_batch_code)
317
328
  expect(IO.read(binary_2)).to eq(expected_batch_code)
318
329
  end
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
 
3
3
  Gem::Specification.new do |spec|
4
- spec.name = "example-app"
4
+ spec.name = "appbundler-example-app"
5
5
  spec.version = "1.0.0"
6
6
  spec.authors = ["danielsdeleo"]
7
7
  spec.email = ["dan@opscode.com"]
@@ -1,5 +1,4 @@
1
1
  RSpec.configure do |c|
2
- c.treat_symbols_as_metadata_keys_with_true_values = true
3
2
  c.filter_run :focus => true
4
3
  c.run_all_when_everything_filtered = true
5
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appbundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - danielsdeleo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-24 00:00:00.000000000 Z
11
+ date: 2015-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.13'
33
+ version: '3.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.13'
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: mixlib-cli
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.4'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.4'
69
83
  description: Extracts a dependency solution from bundler's Gemfile.lock to speed gem
70
84
  activation
71
85
  email:
@@ -89,13 +103,13 @@ files:
89
103
  - lib/appbundler/cli.rb
90
104
  - lib/appbundler/version.rb
91
105
  - spec/appbundler/app_spec.rb
92
- - spec/fixtures/example-app/Gemfile
93
- - spec/fixtures/example-app/Gemfile.lock
94
- - spec/fixtures/example-app/README.md
95
- - spec/fixtures/example-app/bin/app-binary-1
96
- - spec/fixtures/example-app/bin/app-binary-2
97
- - spec/fixtures/example-app/example-app.gemspec
98
- - spec/fixtures/example-app/lib/example_app.rb
106
+ - spec/fixtures/appbundler-example-app/Gemfile
107
+ - spec/fixtures/appbundler-example-app/Gemfile.lock
108
+ - spec/fixtures/appbundler-example-app/README.md
109
+ - spec/fixtures/appbundler-example-app/appbundler-example-app.gemspec
110
+ - spec/fixtures/appbundler-example-app/bin/app-binary-1
111
+ - spec/fixtures/appbundler-example-app/bin/app-binary-2
112
+ - spec/fixtures/appbundler-example-app/lib/example_app.rb
99
113
  - spec/spec_helper.rb
100
114
  homepage: ''
101
115
  licenses:
@@ -117,18 +131,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
131
  version: '0'
118
132
  requirements: []
119
133
  rubyforge_project:
120
- rubygems_version: 2.2.2
134
+ rubygems_version: 2.4.6
121
135
  signing_key:
122
136
  specification_version: 4
123
137
  summary: Extracts a dependency solution from bundler's Gemfile.lock to speed gem activation
124
138
  test_files:
125
139
  - spec/appbundler/app_spec.rb
126
- - spec/fixtures/example-app/Gemfile
127
- - spec/fixtures/example-app/Gemfile.lock
128
- - spec/fixtures/example-app/README.md
129
- - spec/fixtures/example-app/bin/app-binary-1
130
- - spec/fixtures/example-app/bin/app-binary-2
131
- - spec/fixtures/example-app/example-app.gemspec
132
- - spec/fixtures/example-app/lib/example_app.rb
140
+ - spec/fixtures/appbundler-example-app/Gemfile
141
+ - spec/fixtures/appbundler-example-app/Gemfile.lock
142
+ - spec/fixtures/appbundler-example-app/README.md
143
+ - spec/fixtures/appbundler-example-app/appbundler-example-app.gemspec
144
+ - spec/fixtures/appbundler-example-app/bin/app-binary-1
145
+ - spec/fixtures/appbundler-example-app/bin/app-binary-2
146
+ - spec/fixtures/appbundler-example-app/lib/example_app.rb
133
147
  - spec/spec_helper.rb
134
148
  has_rdoc: