firespring_dev_commands 2.1.15.pre.alpha.4 → 2.1.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac7a7e99923f24533a5a3f2e08f6ac7d3c765d6b2647ee97939e65b13727752f
4
- data.tar.gz: e4dff47f1b3c2f7243ec49cdaa0dcd28c7768ea1a7db9eb005fdc328731d2c3c
3
+ metadata.gz: 49b0ba04f2d599eeb051817190f1ad693c23a7ac2ce6fd04c8e4c478dbe5ad4f
4
+ data.tar.gz: 041c2d0f8287874828f2ee3f2de13afb436a6aaa83306e258daa1604c1b62464
5
5
  SHA512:
6
- metadata.gz: 70d5ab92ec6263e7003a52fd6ce4a2bc147ae8741fd704d4443510d7fc8614d3e0a19699afa8e463fcb1c56d99911c443247e5bb085daf1558f6bc97da016b86
7
- data.tar.gz: 8e359e285075a38d3e4003654239c343a982059fb3afbc2d37ed9134743da19eec5d3f9eb5971a2f8dfa7118dbbe651aebc543ea9e2cb0ba1acc157666a18c61
6
+ metadata.gz: 61139c9e9d70768dd34ece5dc505d605909ec87c76a46ed0e5043eb8cf6a95694409a1e70db9149e90d166c0935c1f2d8ede79cc582eb38bdc4d61ab4475ee51
7
+ data.tar.gz: 313ecbc1858923afad98468989ee1c8b971cc85a353083aae06b0e0475bb69989d003bc43e62cb1c2ac3484cd66b537dedd9cf6386c4a57c65133114e23d3b74
@@ -2,7 +2,8 @@ module Dev
2
2
  class BloomGrowth
3
3
  # Class containing rock information
4
4
  class Rock
5
- attr_accessor :data, :id, :type, :name, :owner, :complete, :state, :created, :due
5
+ attr_accessor :data, :id, :type, :name, :owner, :complete, :completion_id, :created, :due
6
+ attr_reader :state
6
7
 
7
8
  def initialize(data)
8
9
  @data = data
@@ -11,13 +12,14 @@ module Dev
11
12
  @name = data['Name'].to_s.strip
12
13
  @owner = User.new(data['Owner']) if data['Owner']
13
14
  @complete = data['Complete']
14
- @state = completion_to_state(data['Completion'])
15
+ @completion_id = data['Completion']
15
16
  @created = Time.parse(data['CreateTime']) if data['CreateTime']
16
17
  @due = Time.parse(data['DueDate']) if data['DueDate']
17
18
  @archived = data['Archived']
18
19
  end
19
20
 
20
- def completion_to_state(completion_id)
21
+ # Convert the completion_id bloom growth gives us into a text version
22
+ def state
21
23
  case completion_id
22
24
  when 0
23
25
  'Off Track'
@@ -27,14 +29,6 @@ module Dev
27
29
  'Complete'
28
30
  end
29
31
  end
30
-
31
- def colorized_state
32
- return unless state
33
- return state.light_red if state.downcase.include?('off track')
34
- return state.light_green if state.downcase.include?('complete')
35
-
36
- state.light_white
37
- end
38
32
  end
39
33
  end
40
34
  end
@@ -0,0 +1,16 @@
1
+ module Dev
2
+ class BloomGrowth
3
+ # Class containing seat information
4
+ class Seat
5
+ attr_accessor :data, :id, :type, :name
6
+
7
+ def initialize(data)
8
+ @data = data
9
+ position = data.dig('Group', 'Position')
10
+ @id = position&.fetch('Id')
11
+ @type = position&.fetch('Type')
12
+ @name = position&.fetch('Name').to_s.strip
13
+ end
14
+ end
15
+ end
16
+ end
@@ -2,13 +2,16 @@ module Dev
2
2
  class BloomGrowth
3
3
  # Class containing user information
4
4
  class User
5
- attr_accessor :data, :id, :type, :name, :rocks, :direct_reports
5
+ attr_accessor :data, :id, :type, :name, :rocks, :direct_reports, :seats
6
6
 
7
7
  def initialize(data)
8
8
  @data = data
9
9
  @id = data['Id']
10
10
  @type = data['Type']
11
11
  @name = data['Name'].to_s.strip
12
+ @rocks = nil
13
+ @direct_reports = nil
14
+ @seats = nil
12
15
  end
13
16
 
14
17
  def rocks
@@ -26,6 +29,15 @@ module Dev
26
29
  end
27
30
  end
28
31
  end
32
+
33
+ def seats
34
+ @seats ||= [].tap do |ary|
35
+ Dev::BloomGrowth.new.get("/api/v1/users/#{id}/seats") do |data|
36
+ ary << Seat.new(data)
37
+ puts ary.last.inspect
38
+ end
39
+ end
40
+ end
29
41
  end
30
42
  end
31
43
  end
@@ -1,6 +1,7 @@
1
1
  require 'net/http'
2
2
 
3
3
  module Dev
4
+ # Class for interacting with the Bloom Growth api
4
5
  class BloomGrowth
5
6
  # The config file to try to load credentials from
6
7
  CONFIG_FILE = "#{Dir.home}/.env.bloom".freeze
@@ -11,6 +12,7 @@ module Dev
11
12
  # The text of the password variable key
12
13
  BLOOM_PASSWORD = 'BLOOM_PASSWORD'.freeze
13
14
 
15
+ # The text of the token variable key
14
16
  BLOOM_TOKEN = 'BLOOM_TOKEN'.freeze
15
17
 
16
18
  # The text of the url variable key
@@ -65,8 +67,12 @@ module Dev
65
67
  }
66
68
  end
67
69
 
68
- # TODO: Should we look at https://github.com/DannyBen/lightly for caching the token?
70
+ # Method for getting a bearer token for the bloom growth api. There are a couple of possible logic paths
71
+ # - If a token has already been defined, use it
72
+ # - If a token is found in the ENV, use it
73
+ # - Otherwise, use the username and passowrd that has been configured to request a new token from bloom
69
74
  def token
75
+ # TODO: Should we look at https://github.com/DannyBen/lightly for caching the token?
70
76
  @token ||= ENV.fetch(BLOOM_TOKEN, nil)
71
77
 
72
78
  unless @token
@@ -89,6 +95,7 @@ module Dev
89
95
  @token
90
96
  end
91
97
 
98
+ # Return all user objects visible to the logged in user
92
99
  def visible_users(&)
93
100
  [].tap do |ary|
94
101
  get('/api/v1/users/mineviewable') do |user_data|
@@ -112,6 +119,8 @@ module Dev
112
119
  nil
113
120
  end
114
121
 
122
+ # Perform a post request to the given path using the gien data
123
+ # Return the parsed json body
115
124
  def post(path, data, headers: default_headers)
116
125
  data = data.to_json unless data.is_a?(String)
117
126
  response = client.request_post(path, data, headers)
@@ -6,6 +6,6 @@ module Dev
6
6
  # Use 'v.v.v.pre.alpha.v' for pre-release vesions
7
7
  # Use 'v.v.v.beta.v for beta versions
8
8
  # Use semantic versioning for any releases (https://semver.org/)
9
- VERSION = '2.1.15.pre.alpha.4'.freeze
9
+ VERSION = '2.1.15'.freeze
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firespring_dev_commands
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.15.pre.alpha.4
4
+ version: 2.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Firespring
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-30 00:00:00.000000000 Z
11
+ date: 2023-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -329,6 +329,7 @@ files:
329
329
  - lib/firespring_dev_commands/aws/s3.rb
330
330
  - lib/firespring_dev_commands/bloom_growth.rb
331
331
  - lib/firespring_dev_commands/bloom_growth/rock.rb
332
+ - lib/firespring_dev_commands/bloom_growth/seat.rb
332
333
  - lib/firespring_dev_commands/bloom_growth/user.rb
333
334
  - lib/firespring_dev_commands/boolean.rb
334
335
  - lib/firespring_dev_commands/common.rb
@@ -402,9 +403,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
402
403
  version: '3.1'
403
404
  required_rubygems_version: !ruby/object:Gem::Requirement
404
405
  requirements:
405
- - - ">"
406
+ - - ">="
406
407
  - !ruby/object:Gem::Version
407
- version: 1.3.1
408
+ version: '0'
408
409
  requirements: []
409
410
  rubygems_version: 3.4.10
410
411
  signing_key: