trello_flow 2.0.1 → 2.1.0

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
  SHA1:
3
- metadata.gz: ed3adf035887ea1b0ced5801b46da8e9479f9f42
4
- data.tar.gz: 807ee2ec7032e537309309acf47475dbf5d1a4ff
3
+ metadata.gz: 3618ad36b3d55822f45748524afd2cd3e7586ee6
4
+ data.tar.gz: dc9b1e38ba649fe530c0a216cbda31e04c23a88a
5
5
  SHA512:
6
- metadata.gz: 7575207b7441e554e6c03805a1a578e6ddfaf24ff33b01fcabcc96029669c0cc4dcced0430762323363649d1c5b54504e586b4e789154f2dc5ed081eb27fcf8b
7
- data.tar.gz: 045407f54a511bfeae697b87f68d139a437c34c1a1c530af3a5fa39a7a011ea6f091a7d431f68c3e10b973f021f9b23cf694b525517e29be1f8facf8c27bba12
6
+ metadata.gz: 52a3872c775e9253203ead4c1f01ff704d30cc525526a20c9530a8b7fb2c44c9e0ff5df40973a931aacf1ee1b9c3d6b9f04a17503ddc633124c24e33e8eefc48
7
+ data.tar.gz: ee35f9e9a3a50296e965cd259ef01daefaf7c854fd5303644574ea5253c7f827dff14997c1d53863885e97ece84de0243f7b759a66ea98b5211cfe29e1150c51
data/lib/trello_flow.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require "trello_flow/version"
2
2
  require "trello_flow/cli"
3
3
  require "trello_flow/table"
4
- require "trello_flow/config"
5
4
  require "trello_flow/branch"
6
5
  require "trello_flow/cleanup"
7
6
  require "trello_flow/main"
@@ -0,0 +1,32 @@
1
+ module TrelloFlow
2
+ class ConfigStore
3
+ def initialize(path)
4
+ @path = path
5
+ end
6
+
7
+ def [](key)
8
+ data[key]
9
+ end
10
+
11
+ def save(key, value)
12
+ data[key] = value
13
+ File.new(path, "w") unless File.exists?(path)
14
+ File.open(path, "w") { |f| f.write(data.to_yaml) }
15
+ value
16
+ end
17
+
18
+ private
19
+
20
+ attr_reader :path
21
+
22
+ def data
23
+ @_data ||= load_data
24
+ end
25
+
26
+ def load_data
27
+ YAML.load File.read(path)
28
+ rescue
29
+ {}
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,39 @@
1
+ require "trello_flow/config_store"
2
+ require "trello_flow/api/base"
3
+
4
+ module TrelloFlow
5
+ class GlobalConfig
6
+ PATH = ENV["HOME"] + "/.trello_flow"
7
+
8
+ def initialize(store = nil)
9
+ @store = store || ConfigStore.new(PATH)
10
+ end
11
+
12
+ def key
13
+ @_key ||= store[:key] || configure_key
14
+ end
15
+
16
+ def token
17
+ @_token ||= store[:token] || configure_token
18
+ end
19
+
20
+ private
21
+
22
+ attr_reader :store
23
+
24
+ def configure_key
25
+ Cli.ask "Press enter to setup Trello for this project (will open public key url)"
26
+ Cli.open_url "https://trello.com/app-key"
27
+ store.save :key, Cli.ask("Input Developer API key")
28
+ end
29
+
30
+ def configure_token
31
+ Cli.open_url authorize_url(key)
32
+ store.save :token, Cli.ask("Input member token")
33
+ end
34
+
35
+ def authorize_url(key)
36
+ "https://trello.com/1/authorize?key=#{key}&name=Trello-Flow&scope=read,write,account&expiration=never&response_type=token"
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,29 @@
1
+ module TrelloFlow
2
+ class LocalConfig
3
+ PATH = ".trello_flow"
4
+
5
+ def initialize(store = nil)
6
+ @store = store || ConfigStore.new(PATH)
7
+ end
8
+
9
+ def board
10
+ @_board ||= Api::Board.find(board_id)
11
+ end
12
+
13
+ private
14
+
15
+ attr_reader :store
16
+
17
+ def board_id
18
+ @_board_id ||= store[:board_id] || configure_board_id
19
+ end
20
+
21
+ def configure_board_id
22
+ store.save :board_id, Table.pick(current_user.boards.active).id
23
+ end
24
+
25
+ def current_user
26
+ Api::Member.current
27
+ end
28
+ end
29
+ end
@@ -1,7 +1,11 @@
1
+ require "trello_flow/local_config"
2
+ require "trello_flow/global_config"
3
+
1
4
  module TrelloFlow
2
5
  class Main
3
- def initialize(config = Config.new)
4
- @config = config
6
+ def initialize(global_config = GlobalConfig.new, local_config = LocalConfig.new)
7
+ Api::Base.configure(key: global_config.key, token: global_config.token)
8
+ @local_config = local_config
5
9
  end
6
10
 
7
11
  def start(name)
@@ -28,6 +32,12 @@ module TrelloFlow
28
32
 
29
33
  private
30
34
 
35
+ attr_reader :local_config
36
+
37
+ def board
38
+ @_board ||= local_config.board
39
+ end
40
+
31
41
  def create_or_pick_card(name)
32
42
  if name.to_s.start_with?("http")
33
43
  Api::Card.find_by_url(name)
@@ -39,12 +49,10 @@ module TrelloFlow
39
49
  end
40
50
 
41
51
  def create_new_card(name)
42
- board = Table.pick(current_user.boards.active)
43
52
  board.lists.backlog.cards.create name: name
44
53
  end
45
54
 
46
55
  def pick_existing_card
47
- board = Table.pick(current_user.boards.active)
48
56
  Table.pick board.lists.backlog.cards
49
57
  end
50
58
 
@@ -1,3 +1,3 @@
1
1
  module TrelloFlow
2
- VERSION = "2.0.1"
2
+ VERSION = "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trello_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Balvig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-22 00:00:00.000000000 Z
11
+ date: 2017-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -238,7 +238,9 @@ files:
238
238
  - lib/trello_flow/branch.rb
239
239
  - lib/trello_flow/cleanup.rb
240
240
  - lib/trello_flow/cli.rb
241
- - lib/trello_flow/config.rb
241
+ - lib/trello_flow/config_store.rb
242
+ - lib/trello_flow/global_config.rb
243
+ - lib/trello_flow/local_config.rb
242
244
  - lib/trello_flow/main.rb
243
245
  - lib/trello_flow/pull_request.rb
244
246
  - lib/trello_flow/repo.rb
@@ -266,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
266
268
  version: '0'
267
269
  requirements: []
268
270
  rubyforge_project:
269
- rubygems_version: 2.5.1
271
+ rubygems_version: 2.5.2
270
272
  signing_key:
271
273
  specification_version: 4
272
274
  summary: GitHub/Trello flow gemified.
@@ -1,52 +0,0 @@
1
- require "trello_flow/api/base"
2
-
3
- module TrelloFlow
4
- class Config
5
- PATH = ENV["HOME"] + "/.trello_flow"
6
-
7
- def initialize(data = load_data || {})
8
- @data = data
9
- Api::Base.configure(key: key, token: token)
10
- end
11
-
12
- private
13
-
14
- attr_reader :data
15
-
16
- def load_data
17
- YAML.load(File.read(PATH))
18
- rescue
19
- false
20
- end
21
-
22
- def key
23
- @_key ||= data[:key] || configure_key
24
- end
25
-
26
- def token
27
- @_token ||= data[:token] || configure_token
28
- end
29
-
30
- def configure_key
31
- Cli.ask "Press enter to setup Trello for this project (will open public key url)"
32
- Cli.open_url "https://trello.com/app-key"
33
- save :key, Cli.ask("Input Developer API key")
34
- end
35
-
36
- def configure_token
37
- Cli.open_url authorize_url(key)
38
- save :token, Cli.ask("Input member token")
39
- end
40
-
41
- def save(key, value)
42
- data[key] = value
43
- File.new(PATH, "w") unless File.exists?(PATH)
44
- File.open(PATH, "w") { |f| f.write(data.to_yaml) }
45
- value
46
- end
47
-
48
- def authorize_url(key)
49
- "https://trello.com/1/authorize?key=#{key}&name=Trello-Flow&scope=read,write,account&expiration=never&response_type=token"
50
- end
51
- end
52
- end