ehpt 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ehpt.rb +8 -7
- data/lib/ehpt/create_stories.rb +11 -12
- data/lib/ehpt/create_story.rb +3 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 278b527d924ee5cef6328be96682e18250fa30d449cec2a8f9aa3abe4ec35603
|
4
|
+
data.tar.gz: 65736a6878779bda11a0d3a33d979855058a2035666b810cfa262ebbb13f8c4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2849d58b9de11b409b8b0e4adc251f8d6894c5fb3472f9db448234a5922c77bf9cad5f1ba4e42136c45cc423b8ea308033a55f1367e9e5ba58e7d2fac3ff0c9e
|
7
|
+
data.tar.gz: fbb28dd01aa013215d0fdd3defa1ae7313395725ab7455dca5f02285dd93856ec9a78b1bdca5abe0c47f381a3f0847c9b33ee4778232f92b0d565c9a9fed2664
|
data/lib/ehpt.rb
CHANGED
@@ -3,24 +3,25 @@ require 'ehpt/get_project'
|
|
3
3
|
require 'ehpt/create_stories'
|
4
4
|
|
5
5
|
class Ehpt
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :csv_file, :project
|
7
7
|
|
8
8
|
def initialize(csv_file, token, project_id)
|
9
|
-
@
|
10
|
-
@project =
|
9
|
+
@csv_file = csv_file
|
10
|
+
@project = get_project_by(token, project_id)
|
11
11
|
end
|
12
12
|
|
13
13
|
def call
|
14
|
-
stories_creator = Ehpt::CreateStories.new(
|
14
|
+
stories_creator = Ehpt::CreateStories.new(csv_file, project)
|
15
15
|
stories_creator.call
|
16
|
+
puts "Done"
|
16
17
|
if stories_creator.error?
|
17
|
-
|
18
|
+
puts "Errors: #{stories_creator.errors}"
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
22
|
private
|
22
23
|
|
23
|
-
def
|
24
|
+
def get_project_by(token, project_id)
|
24
25
|
project_getter = Ehpt::GetProject.new(token, project_id)
|
25
26
|
project_getter.call
|
26
27
|
|
@@ -28,7 +29,7 @@ class Ehpt
|
|
28
29
|
raise StandardError, project_getter.errors
|
29
30
|
end
|
30
31
|
|
31
|
-
puts "Found project #{project_getter.data.name}"
|
32
|
+
puts "Found project: #{project_getter.data.name}"
|
32
33
|
project_getter.data
|
33
34
|
end
|
34
35
|
end
|
data/lib/ehpt/create_stories.rb
CHANGED
@@ -4,7 +4,7 @@ require 'ehpt/create_story'
|
|
4
4
|
|
5
5
|
class Ehpt
|
6
6
|
class CreateStories < Base
|
7
|
-
attr_reader :
|
7
|
+
attr_reader :csv_file, :project
|
8
8
|
|
9
9
|
ARRAY_TYPE_ATTRIBUTES = %w[ labels tasks pull_requests branches blockers comments reviews ]
|
10
10
|
|
@@ -14,35 +14,34 @@ class Ehpt
|
|
14
14
|
|
15
15
|
FLOAT_TYPE_ATTRIBUES = %w[ estimate ]
|
16
16
|
|
17
|
-
def initialize(
|
18
|
-
@
|
17
|
+
def initialize(csv_file, project)
|
18
|
+
@csv_file = csv_file
|
19
19
|
@project = project
|
20
20
|
super
|
21
21
|
end
|
22
22
|
|
23
23
|
def call
|
24
|
-
|
24
|
+
validate_csv_file!
|
25
25
|
create_stories unless error?
|
26
|
-
puts "Done"
|
27
26
|
rescue StandardError => e
|
28
27
|
errors << e.message
|
29
28
|
end
|
30
29
|
|
31
30
|
private
|
32
31
|
|
33
|
-
def
|
34
|
-
if
|
35
|
-
|
36
|
-
end
|
37
|
-
puts "Read CSV done"
|
32
|
+
def validate_csv_file!
|
33
|
+
@errors << 'Input file must be a csv file' if File.extname(csv_file) != '.csv'
|
34
|
+
@errors << 'CSV content is empty' if File.zero?(csv_file)
|
38
35
|
end
|
39
36
|
|
40
37
|
def create_stories
|
41
|
-
CSV.
|
38
|
+
CSV.foreach(csv_file, headers: true) do |row|
|
42
39
|
story_attrs = create_story_attributes(row)
|
43
40
|
story_creator = Ehpt::CreateStory.new(project, story_attrs)
|
44
41
|
story_creator.call
|
45
|
-
if story_creator.
|
42
|
+
if story_creator.success?
|
43
|
+
puts "Created story: #{story_creator.data.name}"
|
44
|
+
else
|
46
45
|
@errors = @errors.concat(story_creator.errors)
|
47
46
|
end
|
48
47
|
end
|
data/lib/ehpt/create_story.rb
CHANGED
@@ -13,7 +13,6 @@ class Ehpt
|
|
13
13
|
def call
|
14
14
|
create_story
|
15
15
|
prefix_story_name_with_id
|
16
|
-
puts "Created story: #{@story.name}"
|
17
16
|
rescue StandardError => e
|
18
17
|
errors << e.message
|
19
18
|
end
|
@@ -21,12 +20,12 @@ class Ehpt
|
|
21
20
|
private
|
22
21
|
|
23
22
|
def create_story
|
24
|
-
@
|
23
|
+
@data = project.create_story(story_attrs)
|
25
24
|
end
|
26
25
|
|
27
26
|
def prefix_story_name_with_id
|
28
|
-
@
|
29
|
-
@
|
27
|
+
@data.name = [@data.id.to_s.split(//).last(3).join, @data.name].join(' - ')
|
28
|
+
@data.save
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|