repo_manager 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemfiles +115 -0
- data/.gitattributes +1 -0
- data/.gitignore +7 -0
- data/.rspec +3 -0
- data/.yardopts +11 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +99 -0
- data/Guardfile +63 -0
- data/HISTORY.markdown +12 -0
- data/LICENSE +20 -0
- data/README.markdown +192 -0
- data/Rakefile +94 -0
- data/TODO.markdown +15 -0
- data/VERSION +1 -0
- data/bin/repo +151 -0
- data/cucumber.yml +28 -0
- data/examples/pc_saved_game_backup/.gitignore +2 -0
- data/examples/pc_saved_game_backup/INSTALL.markdown +420 -0
- data/examples/pc_saved_game_backup/README.markdown +108 -0
- data/examples/pc_saved_game_backup/remote/.gitignore +2 -0
- data/examples/pc_saved_game_backup/repo_manager/Gemfile +12 -0
- data/examples/pc_saved_game_backup/repo_manager/Gemfile.lock +66 -0
- data/examples/pc_saved_game_backup/repo_manager/assets/.gitignore +2 -0
- data/examples/pc_saved_game_backup/repo_manager/features/support/aruba.rb +15 -0
- data/examples/pc_saved_game_backup/repo_manager/features/support/env.rb +11 -0
- data/examples/pc_saved_game_backup/repo_manager/features/support/steps.rb +3 -0
- data/examples/pc_saved_game_backup/repo_manager/features/tasks/update.feature +144 -0
- data/examples/pc_saved_game_backup/repo_manager/global/default/asset.conf +2 -0
- data/examples/pc_saved_game_backup/repo_manager/repo.conf +64 -0
- data/examples/pc_saved_game_backup/repo_manager/tasks/.gitignore +0 -0
- data/examples/pc_saved_game_backup/repo_manager/tasks/remote.rb +57 -0
- data/examples/pc_saved_game_backup/repo_manager/tasks/update.rb +65 -0
- data/examples/pc_saved_game_backup/saved_games/hearts/save1 +1 -0
- data/examples/pc_saved_game_backup/saved_games/hearts/save2 +1 -0
- data/examples/pc_saved_game_backup/saved_games/mines/my_profile.ini +1 -0
- data/examples/pc_saved_game_backup/saved_games/mines/saves/save1 +1 -0
- data/examples/pc_saved_game_backup/saved_games/mines/saves/save2 +1 -0
- data/features/actions/git.feature +296 -0
- data/features/actions/help.feature +53 -0
- data/features/actions/list.feature +624 -0
- data/features/actions/path.feature +195 -0
- data/features/actions/status.feature +261 -0
- data/features/actions/task.feature +127 -0
- data/features/assets/configuration.feature +204 -0
- data/features/assets/rendering.feature +42 -0
- data/features/assets/user_attributes.feature +98 -0
- data/features/bin.feature +42 -0
- data/features/logger.feature +218 -0
- data/features/settings.feature +240 -0
- data/features/support/aruba.rb +15 -0
- data/features/support/env.rb +11 -0
- data/features/support/steps.rb +3 -0
- data/features/tasks/add/asset.feature +178 -0
- data/features/tasks/generate/init.feature +56 -0
- data/lib/repo_manager.rb +36 -0
- data/lib/repo_manager/actions.rb +8 -0
- data/lib/repo_manager/actions/action_helper.rb +39 -0
- data/lib/repo_manager/actions/app_action.rb +30 -0
- data/lib/repo_manager/actions/base_action.rb +296 -0
- data/lib/repo_manager/actions/git_action.rb +113 -0
- data/lib/repo_manager/actions/help_action.rb +52 -0
- data/lib/repo_manager/actions/list_action.rb +123 -0
- data/lib/repo_manager/actions/path_action.rb +22 -0
- data/lib/repo_manager/actions/status_action.rb +192 -0
- data/lib/repo_manager/actions/task_action.rb +71 -0
- data/lib/repo_manager/app.rb +116 -0
- data/lib/repo_manager/assets.rb +3 -0
- data/lib/repo_manager/assets/app_asset.rb +15 -0
- data/lib/repo_manager/assets/asset_accessors.rb +67 -0
- data/lib/repo_manager/assets/asset_configuration.rb +137 -0
- data/lib/repo_manager/assets/asset_manager.rb +72 -0
- data/lib/repo_manager/assets/base_asset.rb +199 -0
- data/lib/repo_manager/assets/repo_asset.rb +30 -0
- data/lib/repo_manager/core.rb +2 -0
- data/lib/repo_manager/core/array.rb +21 -0
- data/lib/repo_manager/core/hash.rb +83 -0
- data/lib/repo_manager/errors.rb +10 -0
- data/lib/repo_manager/extensions/hash.rb +86 -0
- data/lib/repo_manager/git.rb +2 -0
- data/lib/repo_manager/git/lib.rb +69 -0
- data/lib/repo_manager/git/status.rb +196 -0
- data/lib/repo_manager/logger.rb +39 -0
- data/lib/repo_manager/settings.rb +98 -0
- data/lib/repo_manager/tasks.rb +3 -0
- data/lib/repo_manager/tasks/add/asset.rb +213 -0
- data/lib/repo_manager/tasks/generate/init.rb +42 -0
- data/lib/repo_manager/tasks/generate/templates/config/repo.conf.tt +61 -0
- data/lib/repo_manager/tasks/generate/templates/init/assets/.gitignore +0 -0
- data/lib/repo_manager/tasks/generate/templates/init/global/default/asset.conf +2 -0
- data/lib/repo_manager/tasks/generate/templates/init/tasks/.gitignore +0 -0
- data/lib/repo_manager/tasks/task_manager.rb +166 -0
- data/lib/repo_manager/tasks/thor_helper.rb +29 -0
- data/lib/repo_manager/test/asset_steps.rb +19 -0
- data/lib/repo_manager/test/base_steps.rb +152 -0
- data/lib/repo_manager/test/repo_api.rb +41 -0
- data/lib/repo_manager/test/repo_steps.rb +83 -0
- data/lib/repo_manager/test/test_api.rb +88 -0
- data/lib/repo_manager/views.rb +2 -0
- data/lib/repo_manager/views/app_view.rb +15 -0
- data/lib/repo_manager/views/base_view.rb +137 -0
- data/lib/repo_manager/views/templates/css/basic.css +26 -0
- data/lib/repo_manager/views/templates/default.erb +40 -0
- data/lib/repo_manager/views/templates/default.slim +37 -0
- data/lib/repo_manager/views/view_helper.rb +55 -0
- data/repo_manager.gemspec +75 -0
- data/spec/basic_app/actions/action_helper_spec.rb +54 -0
- data/spec/basic_app/assets/base_asset_spec.rb +210 -0
- data/spec/basic_app/core_spec.rb +78 -0
- data/spec/basic_app/settings_spec.rb +64 -0
- data/spec/basic_app/views/view_helper_spec.rb +28 -0
- data/spec/basic_gem/aruba_helper_spec.rb +33 -0
- data/spec/basic_gem/basic_gem_spec.rb +84 -0
- data/spec/basic_gem/gemspec_spec.rb +68 -0
- data/spec/repo_manager/git_spec.rb +31 -0
- data/spec/spec_helper.rb +25 -0
- metadata +472 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'repo_manager/views/view_helper'
|
3
|
+
|
4
|
+
module RepoManager
|
5
|
+
class Generate < Thor
|
6
|
+
namespace :generate
|
7
|
+
include Thor::Actions
|
8
|
+
include RepoManager::ThorHelper
|
9
|
+
include ::RepoManager::ViewHelper
|
10
|
+
|
11
|
+
desc "init PATH", "create the initial configuration file and folder structure"
|
12
|
+
def init(path)
|
13
|
+
logger.debug "init task initial configuration: #{configuration.inspect}"
|
14
|
+
|
15
|
+
# create instance var so that it can be referenced in templates
|
16
|
+
@path = path ? File.expand_path(path) : FileUtils.pwd
|
17
|
+
|
18
|
+
source = path_to(:repo_manager, File.join('lib', 'repo_manager', 'tasks', 'generate', 'templates', 'config', 'repo.conf.tt'))
|
19
|
+
destination = File.join(@path, 'repo.conf')
|
20
|
+
|
21
|
+
say_status :init, "creating initial config file at '#{destination}'"
|
22
|
+
template(source, destination)
|
23
|
+
|
24
|
+
source = path_to(:repo_manager, File.join('lib', 'repo_manager', 'tasks', 'generate', 'templates', 'init', '.'))
|
25
|
+
destination = @path
|
26
|
+
|
27
|
+
say_status :init, "creating initial file structure in '#{destination}'"
|
28
|
+
directory(source, destination)
|
29
|
+
|
30
|
+
return 0
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
# where to start looking, required by the template method
|
36
|
+
def self.source_root
|
37
|
+
File.dirname(__FILE__)
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
# default CLI options
|
3
|
+
options:
|
4
|
+
color : AUTO
|
5
|
+
verbose : false
|
6
|
+
short : false
|
7
|
+
unmodified : HIDE
|
8
|
+
match : ALL
|
9
|
+
list : ALL
|
10
|
+
|
11
|
+
folders:
|
12
|
+
|
13
|
+
# main repo configuration files
|
14
|
+
assets : <%= "#{@path}/assets" %>
|
15
|
+
|
16
|
+
#
|
17
|
+
# repo user tasks, file extentions can be '.rb' or '.thor'
|
18
|
+
#
|
19
|
+
# @examples:
|
20
|
+
#
|
21
|
+
# linux:
|
22
|
+
#
|
23
|
+
# ~/.repo_manager/tasks
|
24
|
+
#
|
25
|
+
# win32
|
26
|
+
#
|
27
|
+
# c:/dat/condenser/tasks
|
28
|
+
#
|
29
|
+
tasks : <%= "#{@path}/tasks" %>
|
30
|
+
|
31
|
+
# git commands must be whitelisted
|
32
|
+
commands:
|
33
|
+
- diff
|
34
|
+
- grep
|
35
|
+
- log
|
36
|
+
- ls-files
|
37
|
+
- show
|
38
|
+
- status
|
39
|
+
|
40
|
+
logging:
|
41
|
+
loggers:
|
42
|
+
- name : root
|
43
|
+
appenders:
|
44
|
+
- logfile
|
45
|
+
- stdout
|
46
|
+
appenders:
|
47
|
+
- type : Stdout
|
48
|
+
name : stdout
|
49
|
+
level : info
|
50
|
+
layout:
|
51
|
+
type : Pattern
|
52
|
+
pattern : '%l %c : %m\n'
|
53
|
+
color_scheme: default
|
54
|
+
- type : File
|
55
|
+
name : logfile
|
56
|
+
level : info
|
57
|
+
truncate : true
|
58
|
+
filename : '<%= "#{@path}/repo.log" %>'
|
59
|
+
layout:
|
60
|
+
type : Pattern
|
61
|
+
pattern : '[%d] %l %c : %m\n'
|
File without changes
|
File without changes
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'thor/core_ext/file_binary_read'
|
3
|
+
require 'thor/util'
|
4
|
+
|
5
|
+
# embed Thor engine to allow extendable tasks
|
6
|
+
module RepoManager
|
7
|
+
class TaskManager
|
8
|
+
|
9
|
+
attr_accessor :configuration
|
10
|
+
|
11
|
+
def initialize(configuration=nil)
|
12
|
+
@configuration = configuration.dup
|
13
|
+
options = @configuration[:options]
|
14
|
+
self.color = options ? options[:color] : true
|
15
|
+
end
|
16
|
+
|
17
|
+
# @examples:
|
18
|
+
#
|
19
|
+
# find_by_namespace(sweep:screenshots)
|
20
|
+
# find_by_namespace(repo_manager:sweep:screenshots)
|
21
|
+
#
|
22
|
+
# returns:
|
23
|
+
#
|
24
|
+
# RepoManager::Sweep, screenshots
|
25
|
+
#
|
26
|
+
# @return [Class, String] the Thor class and the task
|
27
|
+
def find_by_namespace(name)
|
28
|
+
names = name.to_s.split(':')
|
29
|
+
raise "invalid task namespace" unless names.any?
|
30
|
+
|
31
|
+
namespace = names.join(":")
|
32
|
+
|
33
|
+
#puts "searching for task #{namespace}"
|
34
|
+
klass, task = ::Thor::Util.find_class_and_task_by_namespace(namespace, fallback = false)
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# @examples:
|
39
|
+
#
|
40
|
+
# invoke(sweep:screenshots)
|
41
|
+
# invoke(update:models)
|
42
|
+
# invoke(generate:init, ["."], nil)
|
43
|
+
#
|
44
|
+
def invoke(name, args=ARGV)
|
45
|
+
logger.debug "invoke name: #{name}, args #{args.inspect}, configuration defined: #{configuration ? 'yes' : 'no'}"
|
46
|
+
args = args.dup
|
47
|
+
load_tasks
|
48
|
+
|
49
|
+
logger.debug "find_by_namespace: #{name}"
|
50
|
+
klass, task = find_by_namespace(name)
|
51
|
+
|
52
|
+
if klass
|
53
|
+
config = {}
|
54
|
+
config[:shell] ||= shell
|
55
|
+
klass.send(:dispatch, task, args, nil, config) do |instance|
|
56
|
+
if defined?(instance.configuration)
|
57
|
+
instance.configuration = configuration.dup
|
58
|
+
end
|
59
|
+
end
|
60
|
+
logger.debug "after invoke"
|
61
|
+
result = 0
|
62
|
+
else
|
63
|
+
puts "Could not find task #{name}"
|
64
|
+
result = 1
|
65
|
+
end
|
66
|
+
result
|
67
|
+
end
|
68
|
+
|
69
|
+
# load all the tasks in this gem plus the user's own repo_manager task folder
|
70
|
+
#
|
71
|
+
# NOTE: doesn't load any default tasks or non-RepoManager tasks
|
72
|
+
def load_tasks
|
73
|
+
return if @loaded
|
74
|
+
|
75
|
+
# By convention, the '*_helper.rb' files are helpers and need to be loaded first. Load
|
76
|
+
# them into the Thor::Sandbox namespace
|
77
|
+
Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb') ).each do |task|
|
78
|
+
if task.match(/_helper\.rb$/)
|
79
|
+
#logger.debug "load_thorfile helper: #{task}"
|
80
|
+
::Thor::Util.load_thorfile task
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# Now load the thor files
|
85
|
+
Dir.glob( File.join(File.dirname(__FILE__), '**', '*.rb') ).each do |task|
|
86
|
+
unless task.match(/_helper\.rb$/)
|
87
|
+
#logger.debug "load_thorfile: #{task}"
|
88
|
+
::Thor::Util.load_thorfile task
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# load user tasks
|
93
|
+
if user_tasks_folder
|
94
|
+
Dir.glob( File.join([user_tasks_folder, '**', '*.{rb,thor}']) ).each { |task| ::Thor::Util.load_thorfile task if task.match(/_helper\.rb$/) }
|
95
|
+
Dir.glob( File.join([user_tasks_folder, '**', '*.{rb,thor}']) ).each { |task| ::Thor::Util.load_thorfile task unless task.match(/_helper\.rb$/) }
|
96
|
+
end
|
97
|
+
|
98
|
+
@loaded = true
|
99
|
+
end
|
100
|
+
|
101
|
+
def user_tasks_folder
|
102
|
+
return unless configuration
|
103
|
+
|
104
|
+
folder = configuration[:folders] ? configuration[:folders][:tasks] : nil
|
105
|
+
return unless folder
|
106
|
+
return folder if Pathname.new(folder).absolute?
|
107
|
+
|
108
|
+
if configuration[:configuration_filename]
|
109
|
+
base_folder = File.dirname(configuration[:configuration_filename])
|
110
|
+
folder = File.join(base_folder, folder)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def color
|
115
|
+
@color
|
116
|
+
end
|
117
|
+
|
118
|
+
def color=(value)
|
119
|
+
@color = value
|
120
|
+
if value
|
121
|
+
::Thor::Base.shell = Thor::Shell::Color
|
122
|
+
else
|
123
|
+
::Thor::Base.shell = Thor::Shell::Basic
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def shell
|
128
|
+
return @shell if @shell
|
129
|
+
|
130
|
+
@shell = @color ? ::Thor::Shell::Color.new : ::Thor::Shell::Basic.new
|
131
|
+
end
|
132
|
+
|
133
|
+
# display help for the given task
|
134
|
+
#
|
135
|
+
def task_help(name)
|
136
|
+
load_tasks
|
137
|
+
|
138
|
+
klass, task = find_by_namespace(name)
|
139
|
+
|
140
|
+
# set '$thor_runner' to true to display full namespace
|
141
|
+
$thor_runner = true
|
142
|
+
|
143
|
+
klass.task_help(shell , task)
|
144
|
+
end
|
145
|
+
|
146
|
+
# display a list of tasks
|
147
|
+
def list_tasks
|
148
|
+
load_tasks
|
149
|
+
|
150
|
+
# set '$thor_runner' to true to display full namespace
|
151
|
+
$thor_runner = true
|
152
|
+
|
153
|
+
list = [] #Thor.printable_tasks(all = true, subcommand = true)
|
154
|
+
Thor::Base.subclasses.each do |klass|
|
155
|
+
list += klass.printable_tasks(false) unless klass == Thor
|
156
|
+
end
|
157
|
+
list.sort!{ |a,b| a[0] <=> b[0] }
|
158
|
+
|
159
|
+
title = "repo_manager tasks"
|
160
|
+
shell.say shell.set_color(title, :blue, bold=true)
|
161
|
+
shell.say "-" * title.size
|
162
|
+
shell.print_table(list, :ident => 2, :truncate => true)
|
163
|
+
end
|
164
|
+
|
165
|
+
end
|
166
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'rbconfig'
|
3
|
+
require 'repo_manager'
|
4
|
+
require 'repo_manager/actions/action_helper'
|
5
|
+
|
6
|
+
module RepoManager
|
7
|
+
module ThorHelper
|
8
|
+
include ::RepoManager::ActionHelper
|
9
|
+
|
10
|
+
# main repo_manager configuration setttings file
|
11
|
+
def configuration(configuration_file=nil)
|
12
|
+
return @configuration if @configuration
|
13
|
+
logger.debug "getting repo_manager configuration"
|
14
|
+
app_options = {}
|
15
|
+
app_options[:config] = configuration_file || options[:config]
|
16
|
+
@configuration = ::RepoManager::Settings.new(nil, app_options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def configuration=(value={})
|
20
|
+
logger.debug "setting repo_manager configuration"
|
21
|
+
@configuration = value.dup
|
22
|
+
end
|
23
|
+
|
24
|
+
def ruby_binary
|
25
|
+
File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Given /^the folder "([^"]*)" with the following asset configurations:$/ do |folder, table|
|
2
|
+
create_dir(folder) unless File.exists?(File.join(current_dir, folder))
|
3
|
+
|
4
|
+
table.hashes.each do |hash|
|
5
|
+
config = {}
|
6
|
+
config.merge!('path' => hash[:path]) if hash[:path]
|
7
|
+
config.merge!('parent' => hash[:parent]) if hash[:parent]
|
8
|
+
config.merge!('binary' => hash[:binary]) if hash[:binary]
|
9
|
+
config.merge!('icon' => hash[:icon]) if hash[:icon]
|
10
|
+
|
11
|
+
asset_name = hash[:name]
|
12
|
+
create_dir(File.join(folder, asset_name))
|
13
|
+
|
14
|
+
filename = File.join(folder, asset_name, 'asset.conf')
|
15
|
+
write_file(filename, config.to_conf)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'chronic'
|
3
|
+
require 'repo_manager/test/test_api'
|
4
|
+
|
5
|
+
World(RepoManager::TestApi)
|
6
|
+
|
7
|
+
# Given PENDING: some reason
|
8
|
+
Given /^PENDING/ do
|
9
|
+
pending
|
10
|
+
end
|
11
|
+
|
12
|
+
Then /^its output should contain "([^"]*)"$/ do |expected|
|
13
|
+
assert_partial_output(expected, output_from(@commands.last))
|
14
|
+
end
|
15
|
+
|
16
|
+
Then /^its output should not contain "([^"]*)"$/ do |expected|
|
17
|
+
assert_no_partial_output(expected, output_from(@commands.last))
|
18
|
+
end
|
19
|
+
|
20
|
+
Then /^its output should contain:$/ do |expected|
|
21
|
+
assert_partial_output(expected, output_from(@commands.last))
|
22
|
+
end
|
23
|
+
|
24
|
+
Then /^its output should not contain:$/ do |expected|
|
25
|
+
assert_no_partial_output(expected, output_from(@commands.last))
|
26
|
+
end
|
27
|
+
|
28
|
+
# "the output should match" allows regex in the partial_output, if
|
29
|
+
# you don't need regex, use "the output should contain" instead since
|
30
|
+
# that way, you don't have to escape regex characters that
|
31
|
+
# appear naturally in the output
|
32
|
+
Then /^its output should match \/([^\/]*)\/$/ do |expected|
|
33
|
+
assert_matching_output(expected, output_from(@commands.last))
|
34
|
+
end
|
35
|
+
|
36
|
+
Then /^its output should not match \/([^\/]*)\/$/ do |expected|
|
37
|
+
output_from(@commands.last).should_not =~ /#{expected}/
|
38
|
+
end
|
39
|
+
|
40
|
+
Then /^its output should match:$/ do |expected|
|
41
|
+
assert_matching_output(expected, output_from(@commands.last))
|
42
|
+
end
|
43
|
+
|
44
|
+
Then /^its output should not match:$/ do |expected|
|
45
|
+
output_from(@commands.last).should_not =~ /#{expected}/
|
46
|
+
end
|
47
|
+
|
48
|
+
Then /^the normalized output should contain:$/ do |partial_output|
|
49
|
+
str = process_regex_tokens(Regexp.escape(normalize(partial_output)))
|
50
|
+
normalize(all_output).should =~ Regexp.compile(str)
|
51
|
+
end
|
52
|
+
|
53
|
+
Then /^the normalized output should not contain:$/ do |partial_output|
|
54
|
+
str = process_regex_tokens(Regexp.escape(normalize(partial_output)))
|
55
|
+
normalize(all_output).should_not =~ Regexp.compile(str)
|
56
|
+
end
|
57
|
+
|
58
|
+
Then /^the normalized output should contain exactly:$/ do |partial_output|
|
59
|
+
normalize(all_output).should == normalize(partial_output)
|
60
|
+
end
|
61
|
+
|
62
|
+
Then /^the normalized output should match \/([^\/]*)\/$/ do |partial_output|
|
63
|
+
normalize(all_output).should =~ /#{normalize(partial_output)}/
|
64
|
+
end
|
65
|
+
|
66
|
+
Then /^the normalized output should not match \/([^\/]*)\/$/ do |partial_output|
|
67
|
+
normalize(all_output).should_not =~ /#{normalize(partial_output)}/
|
68
|
+
end
|
69
|
+
|
70
|
+
Then /^the normalized output should match:$/ do |partial_output|
|
71
|
+
normalize(all_output).should =~ /#{normalize(partial_output)}/m
|
72
|
+
end
|
73
|
+
|
74
|
+
Then /^the normalized output should not match:$/ do |partial_output|
|
75
|
+
normalize(all_output).should_not =~ /#{normalize(partial_output)}/m
|
76
|
+
end
|
77
|
+
|
78
|
+
Then /^the file "([^"]*)" should contain:$/ do |file, partial_content|
|
79
|
+
process_and_check_file_content(fullpath(file), partial_content, true)
|
80
|
+
end
|
81
|
+
|
82
|
+
Then /^the file "([^"]*)" should not contain:$/ do |file, partial_content|
|
83
|
+
process_and_check_file_content(fullpath(file), partial_content, false)
|
84
|
+
end
|
85
|
+
|
86
|
+
Then /^the file "([^"]*)" should match:$/ do |file, partial_content|
|
87
|
+
check_file_content(fullpath(file),/#{partial_content}/, true)
|
88
|
+
end
|
89
|
+
|
90
|
+
Then /^the file "([^"]*)" should not match:$/ do |file, partial_content|
|
91
|
+
check_file_content(fullpath(file),/#{partial_content}/, false)
|
92
|
+
end
|
93
|
+
|
94
|
+
Then /^the file "([^"]*)", within (\d+) seconds, should contain:$/ do |file, seconds, partial_content|
|
95
|
+
seconds = seconds.to_i
|
96
|
+
|
97
|
+
lambda {
|
98
|
+
|
99
|
+
timeout(seconds) do
|
100
|
+
begin
|
101
|
+
sleep 0.2 unless (seconds == 0)
|
102
|
+
end until (seconds == 0 || File.exists?(fullpath(file)))
|
103
|
+
end
|
104
|
+
|
105
|
+
}.should_not raise_exception
|
106
|
+
|
107
|
+
process_and_check_file_content(fullpath(file), partial_content, true)
|
108
|
+
end
|
109
|
+
|
110
|
+
Given /^the fixture "([^"]*)" is copied to "([^"]*)"$/ do |source, destination|
|
111
|
+
in_current_dir do
|
112
|
+
source = File.join("../../spec/fixtures/", source)
|
113
|
+
_mkdir(File.dirname(destination))
|
114
|
+
FileUtils.cp(source, destination)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# | filename | mtime | content |
|
119
|
+
Given /^the folder "([^"]*)" with the following files:$/ do |folder, table|
|
120
|
+
create_dir(folder) unless File.exists?(File.join(current_dir, folder))
|
121
|
+
table.hashes.each do |hash|
|
122
|
+
filename = hash[:filename]
|
123
|
+
content = hash[:content]
|
124
|
+
filename = File.join(folder,filename)
|
125
|
+
mtime = hash[:mtime] ? Chronic.parse(hash[:mtime]) : Time.now
|
126
|
+
write_file(filename, content)
|
127
|
+
File.utime(mtime, mtime, fullpath(filename))
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# | filename | mtime | content |
|
132
|
+
Given /^the folder "([^"]*)" with the following binary files:$/ do |folder, table|
|
133
|
+
create_dir(folder) unless File.exists?(File.join(current_dir, folder))
|
134
|
+
table.hashes.each do |hash|
|
135
|
+
filename = hash[:filename]
|
136
|
+
filename = File.join(folder,filename)
|
137
|
+
mtime = hash[:mtime] ? Chronic.parse(hash[:mtime]) : Time.now
|
138
|
+
filesize = hash[:size] || 10
|
139
|
+
write_fixed_size_file(filename, filesize.to_i)
|
140
|
+
File.utime(mtime, mtime, fullpath(filename))
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
Given /^the following empty files:$/ do |files|
|
145
|
+
files.raw.map do |file_row|
|
146
|
+
write_file(file_row[0], '')
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
Given /^a (\d+) byte file named "([^"]*)"$/ do |file_size, file_name|
|
151
|
+
write_fixed_size_file(file_name, file_size.to_i)
|
152
|
+
end
|