qa_at_migration 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ec11e2160ea631a1f2ff20a5b6dad4b7cd5ef0a9208e038561b113bc222a2d29
4
+ data.tar.gz: a826c0007000fefc1f4c102ead9094dc5ea5459318bbf538e2f5161704fab68c
5
+ SHA512:
6
+ metadata.gz: 7c22b97e71d6d26b9049a9e4c3fa364f4d32c257fbce9f651d935d2356c87f0af5114a456074698774098acaa92584aca20de609fe77809d33bb67019798c182
7
+ data.tar.gz: e37ac87fe73d46d70954decc1d014ec56c794b8afcf05c2640ccf9f385e2d8ec133384b2385d37ab54b381cc07ca77e4409cc1416b97420ab374295d2e6711a3
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'qa_at_migration'
4
+
5
+ QaAtMigration::ThorCommands.start
@@ -0,0 +1,43 @@
1
+ require 'thor'
2
+ require 'yaml'
3
+ require 'csv'
4
+
5
+ require 'qa_at_migration/translator'
6
+ require 'qa_at_migration/test_file'
7
+ require 'qa_at_migration/generator'
8
+
9
+ module QaAtMigration
10
+ class ThorCommands < Thor
11
+ option :sourcepath, :aliases => "-s", :required => true, :banner => '</path/to/project>'
12
+ option :targetpath, :aliases => "-t", :required => false, :banner => '</path/to/generate>, current path if no targetpath is provided'
13
+ desc "generate_csv [<OUTPUT_FILENAME>.csv]",
14
+ "The default value will be 'master.csv' if no OUTPUT_FILENAME is provided"
15
+ long_desc <<-LONGDESC
16
+ The default value will be 'master.csv' if no OUTPUT_FILENAME is provided.\n
17
+ This tool will look for all the *.md files that are inside </path/to/project> and convert each of them
18
+ into its csv representation and then stored into a single file called <OUTPUT_FILENAME>.csv inside
19
+ the </path/to/generate/> provided.
20
+ LONGDESC
21
+ def generate_csv *output_filename
22
+ output_filename = output_filename.length > 0 ? "#{output_filename[0]}.csv" : nil
23
+ if output_filename
24
+ Generator.new.generate options[:sourcepath], options[:targetpath], output_filename
25
+ else
26
+ Generator.new.generate options[:sourcepath], options[:targetpath]
27
+ end
28
+ end
29
+ desc "hello LANGUAGE", "say hello in LANGUAGE, default 'english'"
30
+ def hello(language = "english")
31
+ translator = Translator.new(language)
32
+ puts translator.hi
33
+ end
34
+ desc "say_hello NAME", "say hello to NAME"
35
+ def say_hello(name = nil)
36
+ if name
37
+ puts "hola #{name}"
38
+ else
39
+ puts "aún no sé cual es tu nombre"
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,28 @@
1
+ module QaAtMigration
2
+ class Generator
3
+ CONFIG_FILE = 'config.yml'.freeze
4
+ CONFIG_IGNORE_KEY = 'ignore'.freeze
5
+ TEST_FILE_PATTERN = '**/*.md'.freeze
6
+ CSV_HEADERS = %w(Title Description Preconditions Steps Status).freeze
7
+
8
+ def generate sourcepath, targetpath, output_filename = 'master.csv'
9
+ @sourcepath = sourcepath
10
+ output_path_filename = targetpath ? File.join(targetpath, output_filename) : output_filename
11
+ CSV.open(output_path_filename, 'w', headers: CSV_HEADERS, write_headers: true) do |csv|
12
+ paths.each { |path| csv << TestFile.new(path).content }
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def paths
19
+ Dir.glob(File.join(@sourcepath, TEST_FILE_PATTERN), File::FNM_CASEFOLD).reject do |filename|
20
+ File.directory?(filename) || File.basename(filename).start_with?(*ignored_files)
21
+ end
22
+ end
23
+
24
+ def ignored_files
25
+ YAML.load_file(File.join(@sourcepath, CONFIG_FILE))[CONFIG_IGNORE_KEY]
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,62 @@
1
+ module QaAtMigration
2
+ class TestFile
3
+ DEFAULT_STATUS = 'Draft'.freeze
4
+
5
+ def initialize(path)
6
+ @path = path
7
+ end
8
+
9
+ def content
10
+ [
11
+ title,
12
+ description,
13
+ preconditions,
14
+ steps,
15
+ status
16
+ ]
17
+ end
18
+
19
+ private
20
+
21
+ def info
22
+ parts.first
23
+ end
24
+
25
+ def title
26
+ info[0].chomp.tap { |t| t[0..1] = '' }
27
+ end
28
+
29
+ def description
30
+ info[1].chomp
31
+ end
32
+
33
+ def preconditions
34
+ extract_steps(parts[1]) unless parts.length != 3
35
+ end
36
+
37
+ def steps
38
+ extract_steps(parts.last)
39
+ end
40
+
41
+ def status
42
+ DEFAULT_STATUS
43
+ end
44
+
45
+ def text
46
+ File.read(@path)
47
+ end
48
+
49
+ def parts
50
+ @parts ||= lines.slice_before(/^##? /).to_a
51
+ end
52
+
53
+ def lines
54
+ text.lines.reject { |line| line == "\n" || line.start_with?('<!---') }
55
+ end
56
+
57
+ def extract_steps(part)
58
+ part.shift
59
+ part.join('')
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,16 @@
1
+ module QaAtMigration
2
+ class Translator
3
+ def initialize(language)
4
+ @language = language
5
+ end
6
+
7
+ def hi
8
+ case @language
9
+ when "spanish"
10
+ "hola mundo"
11
+ else
12
+ "hello world"
13
+ end
14
+ end
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: qa_at_migration
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Dennis Huillca
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-01-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: this tool is used to make an easy migration of AT files (*.md) from the
28
+ github repository of AT
29
+ email: dhuillca@able.co
30
+ executables:
31
+ - qa_at_migration
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - bin/qa_at_migration
36
+ - lib/qa_at_migration.rb
37
+ - lib/qa_at_migration/generator.rb
38
+ - lib/qa_at_migration/test_file.rb
39
+ - lib/qa_at_migration/translator.rb
40
+ homepage: http://rubygems.org/gems/qa_at_migration
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.7.4
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: tool to make migration of AT files (*.md) easy
64
+ test_files: []