Module: Tagfu

Defined in:
lib/tagfu.rb,
lib/tagfu/tagger.rb,
lib/tagfu/version.rb

Defined Under Namespace

Classes: Tagger

Constant Summary collapse

VERSION =
"1.0.2"

Class Method Summary collapse

Class Method Details

.op_tags_absent?(options) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
49
# File 'lib/tagfu.rb', line 46

def self.op_tags_absent?(options)		
	tags = [:update_tags, :delete_tags, :add_tags, :delete_all]
	(tags & options.keys).empty?
end

.path_absent?(path) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/tagfu.rb', line 51

def self.path_absent?(path)
	path.nil?
end

.run(*args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/tagfu.rb', line 5

def self.run(*args)
	options = {}

	option_parser = OptionParser.new do |opts|
		opts.banner = 'Usage: tagfu [PATH] [OPTIONS]'

		opts.on('-d', '--delete TAG1,TAG2', Array, 'Delete comma seperated list of tags from scenario(s), e.g. smoke, regression, wip') do |tags|
			options[:delete_tags] = tags
		end

		opts.on('--delete-all', 'Delete all tags from specified feature files') do |t|
			options[:delete_all] = true
		end

		opts.on('-u', '--update FROM_TAG,TO_TAG', Array, 'Update tag names in scenario(s) e.g. "wip" to "smoke"') do |tags|
			options[:update_tags] = tags
		end

		opts.on('-a', '--add TAG1,TAG2', Array, 'Add comma seperated list of tags at the feature level, e.g. smoke, regression, wip') do |tags|
			options[:add_tags] = tags
		end

		opts.on('-p PATH', '--path PATH', 'Path to the cucumber feature file(s)') do |path|
			options[:path] = path
		end
	end

	begin 
		option_parser.parse!
		raise OptionParser::MissingArgument, "Atleast one of the options '--update', '--delete', '--add' or '--delete-all' should be specified" if op_tags_absent?(options)
		raise OptionParser::MissingArgument, "Path '--path' should be specified" if path_absent?(options[:path])
	rescue OptionParser::ParseError => e
		puts e.message
		puts
		puts option_parser
		exit -1
	end

	Tagger.new(options).get_files
end