rdv 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f99ec689d6fad21107ce3b252787078d8075058f
4
- data.tar.gz: c800d18457a91002a60a270d21960f619d5ee1bc
3
+ metadata.gz: ae30eb908dd0bf34431fdf388f33ea7395520a96
4
+ data.tar.gz: 97ea4cb0bdb73c0ac1ce0607e754628679c38546
5
5
  SHA512:
6
- metadata.gz: 57abc88789c223c13fa25dc6c9f83ca3826df2159af19c683907f2089c9fe7352bd5328d3cc43a952a88ff9e921de9077069a8c2c9dbacb15a133ec93a2b4e1a
7
- data.tar.gz: c16155fa70434704f23dd084dcf569b539abaa982af679e4839d546ea875aa676f42013a3a4ae7c817e434d73291536dfb7b17e4f1880d626f55f92299635383
6
+ metadata.gz: 98513f600a3cf184f7ed083d3eeba2f65b57b09630bd03fd5e550e155a510de392204fb8fba234b6b0eada82f45f2c93eeb38020b2c0b642984293bd3a384d1f
7
+ data.tar.gz: 6c086e5beda3b7a7654ef9bc0765bc1473b987339652b48fb8df1c9aa169bdaacb3230a2a550ada01452f66cc58caff2c9ff3a17592e1c9b0552e773f9fe1704
data/README.md CHANGED
@@ -29,19 +29,20 @@ Newsletter :
29
29
  * etc.
30
30
  - Other issue with labels
31
31
  Do something not being in a list ...
32
+
32
33
  blah...
33
- tags | at | the | end
34
+ | tags | at | the | end
34
35
 
35
36
  Other Theme :
36
37
  -> Issue with a preceding arrow
37
38
  Issue content, can be anything ...
38
- tag it | here
39
+ | tag it | here
39
40
  ```
40
41
 
41
42
  What matters :
42
43
  * Structure depends on indentation, so Theme / Issue / Content should be respected
43
44
  * Collaborator assignment should be at the end of the issue title
44
- * Labels should be at the end of the issue content, separated by pipes (|)
45
+ * Labels list should be at the end of the issue content, beginning with a pipe (|) and each label separated by a pipe too
45
46
 
46
47
  What is optional :
47
48
  * Collaborator assignment is optional
data/bin/rdv CHANGED
@@ -4,5 +4,10 @@ $:.push File.expand_path("../../lib", __FILE__)
4
4
 
5
5
  require "rdv"
6
6
 
7
- Rdv::CLI.start(ARGV)
7
+ begin
8
+ Rdv::CLI.start(ARGV)
9
+ rescue Interrupt => e
10
+ puts "\nAborted !".red
11
+ exit 1
12
+ end
8
13
 
data/lib/rdv.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module Rdv
2
2
  end
3
3
 
4
+ require "rdv/core_ext/string"
4
5
  require "rdv/parser"
5
6
  require "rdv/issues"
6
7
  require "rdv/cli"
@@ -1,6 +1,5 @@
1
1
  require "thor"
2
2
  require "io/console"
3
- require "rdv/core_ext/string"
4
3
  require "octokit"
5
4
 
6
5
  module Rdv
@@ -11,28 +10,40 @@ module Rdv
11
10
  repo = repo
12
11
  # Parse themes and issues from input file
13
12
  themes = Parser.parse File.read(file)
13
+
14
+ puts "Please enter your Github credentials.".green
15
+ # Next actions need to be retriable, so we wrap them to be able to
16
+ # call it back if authorization fails
17
+ remote_actions = lambda do
18
+ client = build_github_client
19
+ # Convert themes to issues and count them
20
+ issues = Issues.create_from(client, repo, themes)
21
+ puts "Created #{ issues.length } issues".yellow
22
+ end
14
23
  # Request user's Github credentials to connect to API and build client
15
- client = build_github_client
16
- # Convert themes to issues and count them
17
- issues = Issues.create_from(client, repo, themes)
18
- puts "Created #{ issues.length } issues".yellow
24
+ remote_actions.call
25
+ rescue Octokit::Unauthorized, Octokit::Forbidden => e
26
+ case e.class.name
27
+ # When user fails to log in, let him try again
28
+ when "Octokit::Unauthorized"
29
+ puts "Bad credentials ... please try again.".red
30
+ remote_actions.call
31
+ # When user fails too many times, exit
32
+ when "Octokit::Forbidden"
33
+ puts "Too many attempts ... please try again later.".red
34
+ exit 1
35
+ end
19
36
  end
20
37
 
21
38
  protected
22
39
 
23
40
  def build_github_client
24
- puts "Please enter your Github credentials.".green
25
41
  print "Username : ".green
26
42
  username = STDIN.gets.chop
27
43
  print "Password : ".green
28
44
  password = STDIN.noecho(&:gets).chop
29
45
  puts ""
30
-
31
46
  Octokit::Client.new(login: username, password: password)
32
47
  end
33
-
34
- def create_issues themes
35
-
36
- end
37
48
  end
38
49
  end
@@ -19,17 +19,17 @@ module Rdv
19
19
  # Fetch contents
20
20
  contents = @raw_content.reduce([]) do |list, line|
21
21
  line = trim_indentation(line)
22
- list << line unless line.match(/^\s+$/)
22
+ list << line
23
23
  list
24
- end.compact
24
+ end.join("").strip.lines
25
25
 
26
- if contents.last.scan(/\|/).length > 0
27
- @tags = contents.pop.split("|").map do |tag|
26
+ if contents.last.match(/^\|/)
27
+ @tags = contents.pop.split("|")[1..-1].map do |tag|
28
28
  capitalize(tag)
29
- end
29
+ end.compact
30
30
  end
31
31
 
32
- @content = contents.join("")
32
+ @content = contents.join
33
33
 
34
34
  # If a @user tag is found in the issue name, strip it and store it as
35
35
  # the assignee user login
@@ -1,3 +1,3 @@
1
1
  module Rdv
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valentin Ballestrino