busser 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +12 -0
- data/features/deserialize_command.feature +19 -0
- data/features/files/base64.txt +1 -0
- data/features/step_definitions/busser_root_steps.rb +8 -0
- data/lib/busser/cli.rb +8 -0
- data/lib/busser/command/deserialize.rb +54 -0
- data/lib/busser/command/plugin_install.rb +2 -1
- data/lib/busser/version.rb +1 -1
- metadata +7 -2
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
|
+
## 0.1.1 / 2013-03-29
|
2
|
+
|
3
|
+
### New features
|
4
|
+
|
5
|
+
* Add `busser deserialize` command to accept streamed files. ([@fnichol][])
|
6
|
+
|
7
|
+
### Improvements
|
8
|
+
|
9
|
+
* Support installing plugins from local .gem files. ([@fnichol][])
|
10
|
+
|
1
11
|
## 0.1.0 / 2013-03-28
|
2
12
|
|
3
13
|
* Initial release
|
4
14
|
|
5
15
|
[@fnichol]: https://github.com/fnichol
|
16
|
+
<!--- The following link definition list is generated by PimpMyChangelog --->
|
17
|
+
[@fnichol]: https://github.com/fnichol
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Feature: Deserialize command
|
2
|
+
In order to stream individual files over a text-based SSH session
|
3
|
+
As a user of Busser
|
4
|
+
I want a command that can accept a stream, decode, and install the file
|
5
|
+
|
6
|
+
Scenario: Streaming a file
|
7
|
+
When I run `bash -c "cat ../../features/files/base64.txt | busser deserialize --destination=decoded.txt --md5sum=c9f888ea2bf1c7409ece4ffe81111e4e --perms=0755"`
|
8
|
+
Then the file "decoded.txt" should contain exactly:
|
9
|
+
"""
|
10
|
+
Hello there.
|
11
|
+
|
12
|
+
"""
|
13
|
+
And the file "decoded.txt" should have permissions "0755"
|
14
|
+
And the exit status should be 0
|
15
|
+
|
16
|
+
Scenario: Mismatching MD5 sum fails command
|
17
|
+
When I run `bash -c "cat ../../features/files/base64.txt | busser deserialize --destination=decoded.txt --md5sum=nope --perms=0755"`
|
18
|
+
Then the output should contain "does not match source file"
|
19
|
+
Then the exit status should not be 0
|
@@ -0,0 +1 @@
|
|
1
|
+
SGVsbG8gdGhlcmUuCg==
|
@@ -60,6 +60,14 @@ Then(/^a busser binstub file should contain:$/) do |partial_content|
|
|
60
60
|
check_file_content(file, partial_content, true)
|
61
61
|
end
|
62
62
|
|
63
|
+
Then(/^the file "(.*?)" should have permissions "(.*?)"$/) do |file, perms|
|
64
|
+
in_current_dir do
|
65
|
+
file_perms = sprintf("%o", File.stat(file).mode)
|
66
|
+
file_perms = file_perms[2, 4]
|
67
|
+
file_perms.should eq(perms)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
63
71
|
Then(/^pry me$/) do
|
64
72
|
require 'pry' ; binding.pry
|
65
73
|
end
|
data/lib/busser/cli.rb
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
|
19
19
|
require 'busser/thor'
|
20
|
+
require 'busser/command/deserialize'
|
20
21
|
require 'busser/command/plugin'
|
21
22
|
require 'busser/command/setup'
|
22
23
|
require 'busser/command/suite'
|
@@ -30,12 +31,19 @@ module Busser
|
|
30
31
|
#
|
31
32
|
class CLI < Thor::Base
|
32
33
|
|
34
|
+
register Busser::Command::Deserialize, "deserialize",
|
35
|
+
"deserialize", "Takes a Base64 file stream and creates a local file"
|
36
|
+
tasks["deserialize"].options = Busser::Command::Deserialize.class_options
|
37
|
+
|
33
38
|
register Busser::Command::Setup, "setup",
|
34
39
|
"setup", "Creates a Busser home"
|
40
|
+
|
35
41
|
register Busser::Command::Plugin, "plugin",
|
36
42
|
"plugin SUBCOMMAND", "Plugin subcommands"
|
43
|
+
|
37
44
|
register Busser::Command::Suite, "suite",
|
38
45
|
"suite SUBCOMMAND", "Suite subcommands"
|
46
|
+
|
39
47
|
register Busser::Command::Test, "test",
|
40
48
|
"test [PLUGIN ...]", "Runs test suites"
|
41
49
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# Author:: Fletcher Nichol (<fnichol@nichol.ca>)
|
4
|
+
#
|
5
|
+
# Copyright (C) 2013, Fletcher Nichol
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
|
19
|
+
require 'base64'
|
20
|
+
require 'digest'
|
21
|
+
|
22
|
+
require 'busser/thor'
|
23
|
+
|
24
|
+
module Busser
|
25
|
+
|
26
|
+
module Command
|
27
|
+
|
28
|
+
# Deserialize command.
|
29
|
+
#
|
30
|
+
# @author Fletcher Nichol <fnichol@nichol.ca>
|
31
|
+
#
|
32
|
+
class Deserialize < Busser::Thor::BaseGroup
|
33
|
+
|
34
|
+
class_option :destination, :desc => "Destination file path"
|
35
|
+
|
36
|
+
class_option :md5sum, :desc => "MD5 digest of original file"
|
37
|
+
|
38
|
+
class_option :perms, :desc => "Unix permissions on destination file"
|
39
|
+
|
40
|
+
def perform
|
41
|
+
file = File.expand_path(options[:destination])
|
42
|
+
contents = Base64.decode64(STDIN.read)
|
43
|
+
|
44
|
+
FileUtils.mkdir_p(File.dirname(file))
|
45
|
+
File.open(file, "wb") { |f| f.write(contents) }
|
46
|
+
FileUtils.chmod(Integer(options[:perms]), file)
|
47
|
+
|
48
|
+
if Digest::MD5.hexdigest(contents) != options[:md5sum]
|
49
|
+
abort "Streamed file #{file} does not match source file md5"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -44,11 +44,12 @@ module Busser
|
|
44
44
|
|
45
45
|
def install_gem(plugin)
|
46
46
|
name, version = plugin.split("@")
|
47
|
+
install_arg = name =~ /\.gem$/ ? name : new_dep(name, version)
|
47
48
|
|
48
49
|
if gem_installed?(name, version)
|
49
50
|
info "#{plugin} plugin already installed"
|
50
51
|
else
|
51
|
-
spec = dep_installer.install(
|
52
|
+
spec = dep_installer.install(install_arg).first
|
52
53
|
info "Plugin #{plugin} installed (version #{spec.version})"
|
53
54
|
end
|
54
55
|
end
|
data/lib/busser/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: busser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -256,6 +256,8 @@ files:
|
|
256
256
|
- Rakefile
|
257
257
|
- bin/busser
|
258
258
|
- busser.gemspec
|
259
|
+
- features/deserialize_command.feature
|
260
|
+
- features/files/base64.txt
|
259
261
|
- features/plugin_install_command.feature
|
260
262
|
- features/setup_command.feature
|
261
263
|
- features/step_definitions/busser_root_steps.rb
|
@@ -264,6 +266,7 @@ files:
|
|
264
266
|
- features/support/env.rb
|
265
267
|
- lib/busser.rb
|
266
268
|
- lib/busser/cli.rb
|
269
|
+
- lib/busser/command/deserialize.rb
|
267
270
|
- lib/busser/command/plugin.rb
|
268
271
|
- lib/busser/command/plugin_install.rb
|
269
272
|
- lib/busser/command/plugin_list.rb
|
@@ -301,7 +304,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
301
304
|
version: '0'
|
302
305
|
segments:
|
303
306
|
- 0
|
304
|
-
hash:
|
307
|
+
hash: -1680018210627822446
|
305
308
|
requirements: []
|
306
309
|
rubyforge_project:
|
307
310
|
rubygems_version: 1.8.24
|
@@ -309,6 +312,8 @@ signing_key:
|
|
309
312
|
specification_version: 3
|
310
313
|
summary: Kitchen Busser - Runs tests for projects in test-kitchen
|
311
314
|
test_files:
|
315
|
+
- features/deserialize_command.feature
|
316
|
+
- features/files/base64.txt
|
312
317
|
- features/plugin_install_command.feature
|
313
318
|
- features/setup_command.feature
|
314
319
|
- features/step_definitions/busser_root_steps.rb
|