checkoff 0.6.0 → 0.7.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
  SHA256:
3
- metadata.gz: 5ed54aed7a0c5a533627bc50c187c1a0d0a289a0132d63549914b9e024dde68e
4
- data.tar.gz: 531ed220ec4d4fcbfc20413d1571ada5074fe745ba81df81dd66cea81e1da5ed
3
+ metadata.gz: 4602a0a2276fa337153e3394f009fa99a8a22603003baf9e99fb9da65c9b9107
4
+ data.tar.gz: e1a006d0debc96dbf11fd5e63d4930446bf35a3ae7f261bbbfca79a9d9bbad02
5
5
  SHA512:
6
- metadata.gz: e2a700a5ca4b8ea76977b0d8fdcd1e1b72dd50dbcfc8020d5a8d6193cf809c6c0d7be1011f21d15389163aec348f85d8c73b01295c01fd91b3e12a75e40183f6
7
- data.tar.gz: 7c263678ca6533ed555cd69655f66eac149124b932c63c10320ab87b4546c57de0cf9728f5b8d166eedea3d36cfab6e3d0f85f408626c768b304afa9ca0da7ac
6
+ metadata.gz: 9c998ad14b388dd17a118536b1abacd2e2dc0195fd42f847090c142cb17636f9bd8fe17e2ee4202d2784d7d907ea6aad59381639a5fa71af32babd70bd229229
7
+ data.tar.gz: b47bb6ce0899ad62c683fefb67596cc5ca371dc0b67d1cacec881060c19d2cb796175b781530231d2cb320b7662dd4929b5a6eac21b8ae9accfd1c138d344d10
data/.overcommit.yml ADDED
@@ -0,0 +1,33 @@
1
+ # Use this file to configure the Overcommit hooks you wish to use. This will
2
+ # extend the default configuration defined in:
3
+ # https://github.com/sds/overcommit/blob/master/config/default.yml
4
+ #
5
+ # At the topmost level of this YAML file is a key representing type of hook
6
+ # being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
7
+ # customize each hook, such as whether to only run it on certain files (via
8
+ # `include`), whether to only display output if it fails (via `quiet`), etc.
9
+ #
10
+ # For a complete list of hooks, see:
11
+ # https://github.com/sds/overcommit/tree/master/lib/overcommit/hook
12
+ #
13
+ # For a complete list of options that you can use to customize hooks, see:
14
+ # https://github.com/sds/overcommit#configuration
15
+ #
16
+ # Uncomment the following lines to make the configuration take effect.
17
+
18
+ PreCommit:
19
+ RuboCop:
20
+ enabled: true
21
+ on_warn: fail # Treat all warnings as failures
22
+ #
23
+ # TrailingWhitespace:
24
+ # enabled: true
25
+ # exclude:
26
+ # - '**/db/structure.sql' # Ignore trailing whitespace in generated files
27
+ #
28
+ #PostCheckout:
29
+ # ALL: # Special hook name that customizes all hooks of this type
30
+ # quiet: true # Change all post-checkout hooks to only display output on failure
31
+ #
32
+ # IndexTags:
33
+ # enabled: true # Generate a tags file with `ctags` each time HEAD changes
data/README.md CHANGED
@@ -126,6 +126,8 @@ my_tasks:
126
126
  personal_access_token: 'some_big_long_string_from_asana.com_here'
127
127
  ```
128
128
 
129
+ Alternately you can set environment variables to match - e.g., `ASANA__PERSONAL_ACCESS_TOKEN`
130
+
129
131
  ## Developing
130
132
 
131
133
  ```bash
data/checkoff.gemspec CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency 'bundler'
31
31
  spec.add_development_dependency 'minitest-profile'
32
32
  spec.add_development_dependency 'mocha'
33
+ spec.add_development_dependency 'overcommit'
33
34
  spec.add_development_dependency 'quality', '~> 38'
34
35
  spec.add_development_dependency 'rake', '~> 13.0'
35
36
  spec.add_development_dependency 'rspec', '>=3.4'
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "result": {
3
- "covered_percent": 83.74
3
+ "covered_percent": 85.38
4
4
  }
5
5
  }
@@ -4,12 +4,52 @@ require 'yaml'
4
4
  require 'active_support/core_ext/hash'
5
5
 
6
6
  module Checkoff
7
+ # Use the provided config from a YAML file, and fall back to env
8
+ # variable if it's not populated for a key'
9
+ class EnvFallbackConfigLoader
10
+ def initialize(config, sym, yaml_filename)
11
+ @config = config
12
+ @envvar_prefix = sym.upcase
13
+ @yaml_filename = yaml_filename
14
+ end
15
+
16
+ def envvar_name(key)
17
+ "#{@envvar_prefix}__#{key.upcase}"
18
+ end
19
+
20
+ def [](key)
21
+ config_value = @config[key]
22
+ return config_value unless config_value.nil?
23
+
24
+ ENV[envvar_name(key)]
25
+ end
26
+
27
+ def fetch(key)
28
+ out = self[key]
29
+ return out unless out.nil?
30
+
31
+ raise KeyError,
32
+ "Please configure either the #{key} key in #{@yaml_filename} or set #{envvar_name(key)}"
33
+ end
34
+ end
35
+
7
36
  # Load configuration file
8
37
  class ConfigLoader
9
- def self.load(sym)
38
+ def self.yaml_filename(sym)
10
39
  file = "#{sym}.yml"
11
- YAML.load_file(File.expand_path("~/.#{file}"))
12
- .with_indifferent_access
40
+ File.expand_path("~/.#{file}")
41
+ end
42
+
43
+ def self.load_yaml_file(sym)
44
+ filename = yaml_filename(sym)
45
+ return {} unless File.exist?(filename)
46
+
47
+ YAML.load_file(filename).with_indifferent_access
48
+ end
49
+
50
+ def self.load(sym)
51
+ yaml_result = load_yaml_file(sym)
52
+ EnvFallbackConfigLoader.new(yaml_result, sym, yaml_filename(sym))
13
53
  end
14
54
  end
15
55
  end
@@ -49,8 +49,8 @@ module Checkoff
49
49
  end
50
50
 
51
51
  def my_tasks(workspace_name)
52
- my_tasks = @config[:my_tasks]
53
- gid = @config[:my_tasks][workspace_name] unless my_tasks.nil?
52
+ my_tasks = @config.fetch(:my_tasks)
53
+ gid = my_tasks[workspace_name] unless my_tasks.nil?
54
54
  raise "Please define [:my_tasks][#{workspace_name}] in config file" if my_tasks.nil? || gid.nil?
55
55
 
56
56
  projects.find_by_id(gid)
@@ -50,7 +50,7 @@ module Checkoff
50
50
  end
51
51
 
52
52
  def default_assignee_gid
53
- @config[:default_assignee_gid]
53
+ @config.fetch(:default_assignee_gid)
54
54
  end
55
55
  end
56
56
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Checkoff
4
- VERSION = '0.6.0'
4
+ VERSION = '0.7.0'
5
5
  end
@@ -11,13 +11,13 @@ module Checkoff
11
11
 
12
12
  def client
13
13
  @client ||= @asana_client.new do |c|
14
- c.authentication :access_token, @config[:personal_access_token]
14
+ c.authentication :access_token, @config.fetch(:personal_access_token)
15
15
  c.default_headers 'asana-enable' => 'string_ids,new_sections'
16
16
  end
17
17
  end
18
18
 
19
19
  def default_workspace_gid
20
- @config[:default_workspace_gid]
20
+ @config.fetch(:default_workspace_gid)
21
21
  end
22
22
 
23
23
  def workspace_by_name(workspace_name)
@@ -1 +1 @@
1
- 414
1
+ 416
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checkoff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-22 00:00:00.000000000 Z
11
+ date: 2021-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: overcommit
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: quality
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -174,6 +188,7 @@ extra_rdoc_files: []
174
188
  files:
175
189
  - ".circleci/config.yml"
176
190
  - ".gitignore"
191
+ - ".overcommit.yml"
177
192
  - ".rubocop.yml"
178
193
  - ".ruby-version"
179
194
  - ".travis.yml"