flight_plan_cli 0.3.4 → 0.3.5

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: 8c6ff4e9c6395e03790bb5865270d88c4880d3ec
4
- data.tar.gz: d47443d71c83c7ae068942b128ab457d2661cb08
3
+ metadata.gz: 333ada2e946b4a88e03817a17f8af707311533fb
4
+ data.tar.gz: ed3606ebc99f0ea80b8937860964251ae7f439d0
5
5
  SHA512:
6
- metadata.gz: f6554aaf832eabdcd397d04027257b5b1fc23cfa57b1173ea7a171515278e50aea266ba711d7d7aa463433ab0afe071038283dc9c0a4b46c27601329715d5b4a
7
- data.tar.gz: cfdb6032a1ab59fe06c2b3aa5b53eb049c0d13db16247cc02c77711838d10fa112e18328db1952d26b45a41a98e1e80ae1c9eebebe0f35e5dc85647e360c258b
6
+ metadata.gz: e89c55f15768ea01d9a0788b858b58787c5ee0ea2efdd239f718ae40397c4d2958aee1573dabb9b35b2b93739ce43da6b84707d0d1280f3711726fc632512e63
7
+ data.tar.gz: 13cbb1a2bd9ea7701c11a4945e6073774d662efd9cde4e90356dbbbc098abf659d4bf95ed7c4fee0c6b9fef9a892a8ecff3ab03f929ab13086a3ecf691500032
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.5
@@ -2,7 +2,6 @@ require 'httparty'
2
2
 
3
3
  module FlightPlanCli
4
4
  class Api
5
-
6
5
  def initialize(url:, key:, secret:, board_id: nil, repo_id: nil)
7
6
  @url = url
8
7
  @key = key
@@ -0,0 +1,15 @@
1
+ module FlightPlanCli
2
+ module Clients
3
+ module FlightPlan
4
+ def flight_plan
5
+ @flight_plan ||= FlightPlanCli::Api.new(
6
+ url: FlightPlanCli::Settings.api_url,
7
+ key: FlightPlanCli::Settings.api_key,
8
+ secret: FlightPlanCli::Settings.api_secret,
9
+ board_id: FlightPlanCli::Settings.board_id,
10
+ repo_id: FlightPlanCli::Settings.repo_id
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ module FlightPlanCli
2
+ module Clients
3
+ module Git
4
+ def git
5
+ @git ||= ::Git.open(Dir.pwd)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -1,12 +1,12 @@
1
1
  module FlightPlanCli
2
2
  module Commands
3
3
  class Checkout
4
- include FlightPlanCli::Config
4
+ include FlightPlanCli::Clients::Git
5
+ include FlightPlanCli::Clients::FlightPlan
5
6
 
6
7
  def initialize(issue_no)
7
8
  @issue_no = issue_no
8
9
  @fetched = false
9
- read_config
10
10
  end
11
11
 
12
12
  def process
@@ -43,14 +43,14 @@ module FlightPlanCli
43
43
  end
44
44
 
45
45
  def new_branch_for_issue
46
- git.checkout('master')
47
- git.pull
48
- branches = client.board_tickets(remote_number: issue_no)
46
+ branches = flight_plan.board_tickets(remote_number: issue_no)
49
47
  # TODO: update flight_plan to only return one issue when remote_numer is provided
50
48
  branches = branches.select { |b| b['ticket']['remote_number'] == issue_no }
51
49
  return false unless branches.count == 1
52
50
 
53
51
  branch_name = branch_name(branches.first)
52
+ git.checkout('master')
53
+ git.pull
54
54
  puts "Creating new branch #{branch_name} from master".green
55
55
  git.branch(branch_name).checkout
56
56
  end
@@ -1,6 +1,9 @@
1
1
  module FlightPlanCli
2
2
  module Commands
3
3
  class List
4
+ include FlightPlanCli::Clients::Git
5
+ include FlightPlanCli::Clients::FlightPlan
6
+
4
7
  module Color
5
8
  SWIMLANE = :cyan
6
9
  ISSUE = :yellow
@@ -8,15 +11,9 @@ module FlightPlanCli
8
11
  CHECKED_OUT_BACKGROUND = :light_black
9
12
  end
10
13
 
11
- include FlightPlanCli::Config
12
-
13
- def initialize
14
- read_config
15
- end
16
-
17
14
  def process
18
15
  swimlanes = tickets_by_swimlane
19
- default_swimlane_ids.each do |swimlane_id|
16
+ Settings.default_swimlane_ids.each do |swimlane_id|
20
17
  next unless swimlanes.key?(swimlane_id)
21
18
 
22
19
  print_swimlane(swimlanes[swimlane_id])
@@ -31,14 +28,14 @@ module FlightPlanCli
31
28
  private
32
29
 
33
30
  def tickets_by_swimlane
34
- response = client.board_tickets
31
+ response = flight_plan.board_tickets
35
32
  raise ApiUnauthorized if response.code == 401
36
33
  raise ApiNotFound if response.code == 404
37
34
 
38
35
  swimlanes = {}
39
36
  response.each do |board_ticket|
40
37
  swimlane = board_ticket['swimlane']
41
- next unless default_swimlane_ids.include? swimlane['id']
38
+ next unless Settings.default_swimlane_ids.include? swimlane['id']
42
39
 
43
40
  swimlanes[swimlane['id']] ||= swimlane
44
41
  swimlanes[swimlane['id']]['tickets'] ||= []
@@ -1,16 +1,8 @@
1
-
2
1
  module FlightPlanCli
3
2
  class ApiUnauthorized < StandardError; end
4
3
  class ApiNotFound < StandardError; end
5
4
 
6
5
  class Initializer < Thor
7
- include FlightPlanCli::Config
8
-
9
- def initialize(*args)
10
- read_config
11
- super
12
- end
13
-
14
6
  desc 'ls', 'List open issues'
15
7
  def ls
16
8
  Commands::List.new.process
@@ -0,0 +1,46 @@
1
+ module FlightPlanCli
2
+ module Settings
3
+ CONFIG_YAML_PATH = '.flight_plan_cli/config.yml'.freeze
4
+ USER_YAML_PATH = '.flight_plan_cli/user.yml'.freeze
5
+
6
+ def self.board_id
7
+ config['board_id']
8
+ end
9
+
10
+ def self.repo_id
11
+ config['repo_id']
12
+ end
13
+
14
+ def self.default_swimlane_ids
15
+ config['ls']['default_swimlane_ids']
16
+ end
17
+
18
+ def self.api_url
19
+ config['api_url']
20
+ end
21
+
22
+ def self.api_key
23
+ config['flight_plan_api_key']
24
+ end
25
+
26
+ def self.api_secret
27
+ config['flight_plan_api_secret']
28
+ end
29
+
30
+ def self.config
31
+ @config ||=
32
+ begin
33
+ check_config_exists
34
+ YAML.load_file(CONFIG_YAML_PATH).merge(
35
+ FileTest.exist?(USER_YAML_PATH) ? YAML.load_file(USER_YAML_PATH) : {}
36
+ )
37
+ end
38
+ end
39
+
40
+ def self.check_config_exists
41
+ return if FileTest.exist?(CONFIG_YAML_PATH)
42
+ puts "#{CONFIG_YAML_PATH} not found"
43
+ exit 1
44
+ end
45
+ end
46
+ end
@@ -1,7 +1,9 @@
1
1
  require 'thor'
2
2
  require 'colorize'
3
3
  require 'git'
4
- require 'flight_plan_cli/config'
4
+ require 'flight_plan_cli/settings'
5
+ require 'flight_plan_cli/clients/git'
6
+ require 'flight_plan_cli/clients/flight_plan'
5
7
  require 'flight_plan_cli/commands/list'
6
8
  require 'flight_plan_cli/commands/checkout'
7
9
  require 'flight_plan_cli/initializer'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flight_plan_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Cleary
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-19 00:00:00.000000000 Z
11
+ date: 2018-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -176,10 +176,12 @@ files:
176
176
  - bin/flight
177
177
  - lib/flight_plan_cli.rb
178
178
  - lib/flight_plan_cli/api.rb
179
+ - lib/flight_plan_cli/clients/flight_plan.rb
180
+ - lib/flight_plan_cli/clients/git.rb
179
181
  - lib/flight_plan_cli/commands/checkout.rb
180
182
  - lib/flight_plan_cli/commands/list.rb
181
- - lib/flight_plan_cli/config.rb
182
183
  - lib/flight_plan_cli/initializer.rb
184
+ - lib/flight_plan_cli/settings.rb
183
185
  - lib/flight_plan_cli/version.rb
184
186
  homepage: https://github.com/jcleary/flight_plan_cli
185
187
  licenses:
@@ -1,51 +0,0 @@
1
- module FlightPlanCli
2
- module Config
3
- private
4
-
5
- CONFIG_YAML_PATH = '.flight_plan_cli/config.yml'.freeze
6
- USER_YAML_PATH = '.flight_plan_cli/user.yml'.freeze
7
-
8
- attr_reader :board_id, :repo_id, :default_swimlane_ids
9
- attr_reader :api_url, :api_key, :api_secret
10
-
11
- def read_config
12
- @board_id = config['board_id']
13
- @repo_id = config['repo_id']
14
- @default_swimlane_ids = config['ls']['default_swimlane_ids']
15
-
16
- @api_url = config['api_url']
17
- @api_key = config['flight_plan_api_key']
18
- @api_secret = config['flight_plan_api_secret']
19
- end
20
-
21
- def client
22
- @client ||= FlightPlanCli::Api.new(
23
- url: api_url,
24
- key: api_key,
25
- secret: api_secret,
26
- board_id: board_id,
27
- repo_id: repo_id
28
- )
29
- end
30
-
31
- def git
32
- @git ||= Git.open(Dir.pwd)
33
- end
34
-
35
- def config
36
- @config ||=
37
- begin
38
- check_config_exists
39
- YAML.load_file(CONFIG_YAML_PATH).merge(
40
- FileTest.exist?(USER_YAML_PATH) ? YAML.load_file(USER_YAML_PATH) : {}
41
- )
42
- end
43
- end
44
-
45
- def check_config_exists
46
- return if FileTest.exist?(CONFIG_YAML_PATH)
47
- puts "#{CONFIG_YAML_PATH} not found"
48
- exit 1
49
- end
50
- end
51
- end