qb 0.3.15 → 0.3.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/lib/qb/ansible/module.rb +80 -10
  3. data/lib/qb/package.rb +4 -14
  4. data/lib/qb/path.rb +21 -18
  5. data/lib/qb/repo.rb +5 -15
  6. data/lib/qb/repo/git.rb +69 -53
  7. data/lib/qb/repo/git/github.rb +12 -4
  8. data/lib/qb/repo/git/user.rb +33 -0
  9. data/lib/qb/role.rb +22 -22
  10. data/lib/qb/version.rb +1 -1
  11. data/library/path_facts +0 -90
  12. data/qb.gemspec +2 -2
  13. data/roles/qb/git/check/clean/defaults/main.yml +7 -0
  14. data/roles/qb/git/check/clean/meta/qb.yml +48 -0
  15. data/roles/qb/git/check/clean/tasks/main.yml +26 -10
  16. data/roles/qb/role/meta/qb.yml +3 -3
  17. data/roles/qb/role/qb/templates/qb.yml.j2 +1 -1
  18. data/roles/qb/ruby/dependency/.qb-options.yml +4 -0
  19. data/roles/qb/ruby/dependency/defaults/main.yml +23 -0
  20. data/roles/qb/ruby/dependency/filter_plugins/dependency_filters.py +207 -0
  21. data/roles/qb/ruby/dependency/meta/main.yml +10 -0
  22. data/roles/qb/ruby/dependency/meta/qb.yml +49 -0
  23. data/roles/qb/ruby/dependency/tasks/detect_type.yml +18 -0
  24. data/roles/qb/ruby/dependency/tasks/main.yml +16 -0
  25. data/roles/qb/ruby/dependency/tasks/types/gemfile.yml +6 -0
  26. data/roles/qb/ruby/dependency/tasks/types/gemspec.yml +71 -0
  27. data/roles/qb/{gem → ruby/gem}/bin_stubs/defaults/main.yml +1 -1
  28. data/roles/qb/{gem → ruby/gem}/bin_stubs/meta/main.yml +1 -1
  29. data/roles/qb/{gem → ruby/gem}/bin_stubs/meta/qb.yml +1 -1
  30. data/roles/qb/{gem → ruby/gem}/bin_stubs/tasks/main.yml +1 -1
  31. data/roles/qb/ruby/gem/bin_stubs/templates/console +33 -0
  32. data/roles/qb/{gem → ruby/gem}/bin_stubs/templates/rake +0 -0
  33. data/roles/qb/{gem → ruby/gem}/bin_stubs/templates/rspec +0 -0
  34. data/roles/qb/{gem → ruby/gem}/build/defaults/main.yml +1 -1
  35. data/roles/qb/{gem → ruby/gem}/build/meta/main.yml +0 -0
  36. data/roles/qb/{gem → ruby/gem}/build/meta/qb.yml +1 -1
  37. data/roles/qb/{gem → ruby/gem}/build/tasks/main.yml +1 -1
  38. data/roles/qb/{gem → ruby/gem}/install/defaults/main.yml +0 -0
  39. data/roles/qb/{gem → ruby/gem}/install/meta/main.yml +1 -1
  40. data/roles/qb/{gem → ruby/gem}/install/meta/qb.yml +0 -0
  41. data/roles/qb/{gem → ruby/gem}/install/tasks/main.yml +0 -0
  42. data/roles/qb/{gem → ruby/gem}/new/defaults/main.yml +1 -1
  43. data/roles/qb/{gem → ruby/gem}/new/meta/main.yml +1 -1
  44. data/roles/qb/{gem → ruby/gem}/new/meta/qb.yml +1 -1
  45. data/roles/qb/{gem → ruby/gem}/new/tasks/bundle_gem.yml +0 -0
  46. data/roles/qb/{gem → ruby/gem}/new/tasks/main.yml +1 -1
  47. data/roles/qb/ruby/gem/release/defaults/main.yml +5 -0
  48. data/roles/qb/{gem → ruby/gem}/release/meta/main.yml +1 -1
  49. data/roles/qb/ruby/gem/release/meta/qb.yml +27 -0
  50. data/roles/qb/{gem → ruby/gem}/release/tasks/main.yml +4 -6
  51. data/roles/qb/ruby/gem/release/tasks/release.yml +42 -0
  52. data/roles/qb/ruby/rspec/setup/defaults/main.yml +7 -0
  53. data/roles/qb/ruby/rspec/setup/meta/main.yml +9 -0
  54. data/roles/qb/ruby/rspec/setup/meta/qb.yml +47 -0
  55. data/roles/qb/ruby/rspec/setup/tasks/main.yml +4 -0
  56. data/roles/qb/ruby/rspec/setup/tasks/persistence.yml +0 -0
  57. data/roles/qb/ruby/yard/clean/defaults/main.yml +7 -0
  58. data/roles/qb/ruby/yard/clean/meta/main.yml +9 -0
  59. data/roles/qb/ruby/yard/clean/meta/qb.yml +48 -0
  60. data/roles/qb/ruby/yard/clean/tasks/main.yml +27 -0
  61. data/roles/qb/ruby/yard/config/.qb-options.yml +4 -0
  62. data/roles/qb/ruby/yard/config/defaults/main.yml +15 -0
  63. data/roles/qb/ruby/yard/config/library/yard.get_output_dir +59 -0
  64. data/roles/qb/ruby/yard/config/meta/main.yml +10 -0
  65. data/roles/qb/ruby/yard/config/meta/qb.yml +49 -0
  66. data/roles/qb/ruby/yard/config/tasks/get_yard_output_dir.yml +10 -0
  67. data/roles/qb/ruby/yard/config/tasks/main.yml +4 -0
  68. data/roles/qb/ruby/yard/setup/defaults/main.yml +6 -0
  69. data/roles/qb/ruby/yard/{meta → setup/meta}/main.yml +2 -1
  70. data/roles/qb/ruby/yard/{meta → setup/meta}/qb.yml +5 -5
  71. data/roles/qb/ruby/yard/setup/tasks/main.yml +35 -0
  72. data/roles/qb/ruby/yard/setup/tasks/versions/v0.9.yml +32 -0
  73. data/roles/qb/ruby/yard/setup/tasks/yardopts.yml +59 -0
  74. metadata +65 -35
  75. data/roles/qb/gem/bin_stubs/templates/console +0 -25
  76. data/roles/qb/gem/release/defaults/main.yml +0 -5
  77. data/roles/qb/gem/release/meta/qb.yml +0 -21
  78. data/roles/qb/ruby/yard/defaults/args.yml +0 -2
  79. data/roles/qb/ruby/yard/defaults/main.yml +0 -9
  80. data/roles/qb/ruby/yard/tasks/main.yml +0 -28
@@ -25,7 +25,7 @@ using NRSER::Types
25
25
  # Definitions
26
26
  # =======================================================================
27
27
 
28
- # Git repo where the `origin` remote points to GitHub, which is used to
28
+ # Git repo where the `origin` remote points to GitHub, which is used to
29
29
  # determine it's owner and name.
30
30
  #
31
31
  class QB::Repo::Git::GitHub < QB::Repo::Git
@@ -55,12 +55,12 @@ class QB::Repo::Git::GitHub < QB::Repo::Git
55
55
  # ---------------------------------------------------------------------
56
56
 
57
57
  def self.ssh_url? string
58
- SSH_URL_RE =~ string
58
+ !!(SSH_URL_RE =~ string)
59
59
  end
60
60
 
61
61
 
62
62
  def self.https_url? string
63
- HTTPS_URL_RE =~ string
63
+ !!(HTTPS_URL_RE =~ string)
64
64
  end
65
65
 
66
66
 
@@ -122,6 +122,15 @@ class QB::Repo::Git::GitHub < QB::Repo::Git
122
122
  # Instance Methods
123
123
  # ======================================================================
124
124
 
125
+ # Part of the {QB::Repo::Git} API, always `true` for GitHub instances.
126
+ #
127
+ # @return [true]
128
+ #
129
+ def github?
130
+ true
131
+ end
132
+
133
+
125
134
  def api
126
135
  QB::GitHub::API.client.repo repo_id.path
127
136
  end
@@ -134,4 +143,3 @@ class QB::Repo::Git::GitHub < QB::Repo::Git
134
143
 
135
144
 
136
145
  end # class QB::Repo::Git::GitHub
137
-
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Requirements
4
+ # =======================================================================
5
+
6
+ # Stdlib
7
+ # -----------------------------------------------------------------------
8
+
9
+ # Deps
10
+ # -----------------------------------------------------------------------
11
+ require 'nrser'
12
+
13
+ # Project / Package
14
+ # -----------------------------------------------------------------------
15
+ require 'qb/util/resource'
16
+
17
+ # Refinements
18
+ # =======================================================================
19
+
20
+ using NRSER
21
+ using NRSER::Types
22
+
23
+
24
+ # Definitions
25
+ # =======================================================================
26
+
27
+ class QB::Repo::Git::User < QB::Util::Resource
28
+ prop :name, type: t.maybe(t.str), default: nil
29
+ prop :email, type: t.maybe(t.str), default: nil
30
+ end
31
+
32
+ # Post-Processing
33
+ # =======================================================================
@@ -47,7 +47,7 @@ class QB::Role
47
47
  # Constants
48
48
  # =====================================================================
49
49
 
50
- # Array of string paths to directories to search for roles or paths to
50
+ # Array of string paths to directories to search for roles or paths to
51
51
  # `ansible.cfg` files to look for an extract role paths from.
52
52
  #
53
53
  # For the moment at least you can just mutate this value like you would
@@ -60,8 +60,8 @@ class QB::Role
60
60
  #
61
61
  # **WARNING**
62
62
  #
63
- # Search is **deep** - don't point this at large directory trees and
64
- # expect any sort of reasonable performance (any directory that
63
+ # Search is **deep** - don't point this at large directory trees and
64
+ # expect any sort of reasonable performance (any directory that
65
65
  # contains `node_modules` is usually a terrible idea for instance).
66
66
  #
67
67
  BUILTIN_PATH = [
@@ -131,7 +131,7 @@ class QB::Role
131
131
  ].freeze
132
132
 
133
133
 
134
- # Array of string paths to directories to search for roles or paths to
134
+ # Array of string paths to directories to search for roles or paths to
135
135
  # `ansible.cfg` files to look for an extract role paths from.
136
136
  #
137
137
  # Value is a duplicate of the frozen {QB::Role::BUILTIN_PATH}. You can
@@ -147,8 +147,8 @@ class QB::Role
147
147
  #
148
148
  # **WARNING**
149
149
  #
150
- # Search is **deep** - don't point this at large directory trees and
151
- # expect any sort of reasonable performance (any directory that
150
+ # Search is **deep** - don't point this at large directory trees and
151
+ # expect any sort of reasonable performance (any directory that
152
152
  # contains `node_modules` is usually a terrible idea for instance).
153
153
  #
154
154
  PATH = BUILTIN_PATH.dup
@@ -157,7 +157,7 @@ class QB::Role
157
157
  # Class Methods
158
158
  # =======================================================================
159
159
 
160
- # Reset {QB::Role::PATH} to the original built-in values in
160
+ # Reset {QB::Role::PATH} to the original built-in values in
161
161
  # {QB::Role::BUILTIN_PATH}.
162
162
  #
163
163
  # Created for testing but might be useful elsewhere as well.
@@ -206,7 +206,7 @@ class QB::Role
206
206
  # i. ./dev/roles/tmp
207
207
  # - used for roles that are downloaded but shouldn't be included
208
208
  # in source control.
209
- # 3.
209
+ # 3.
210
210
  #
211
211
  # @return [Array<Pathname>]
212
212
  # places to look for role dirs.
@@ -237,7 +237,7 @@ class QB::Role
237
237
  ['', '.yml', '.yaml'].flat_map { |ext|
238
238
  Pathname.glob(search_dir.join '**', 'meta', "qb#{ ext }").
239
239
  map {|meta_path|
240
- [meta_path.dirname.dirname, search_dir: search_dir]
240
+ [meta_path.dirname.dirname, search_dir: search_dir]
241
241
  }
242
242
  }
243
243
  }.
@@ -261,19 +261,19 @@ class QB::Role
261
261
  return [role] if role.display_path.to_s == input
262
262
  }
263
263
 
264
- # create an array of "separator" variations to try *exact* matching
264
+ # create an array of "separator" variations to try *exact* matching
265
265
  # against. in order of preference:
266
266
  #
267
267
  # 1. exact input
268
268
  # - this means if you ended up with roles that actually *are*
269
- # differnetiated by '_/-' differences (which, IMHO, is a
269
+ # differnetiated by '_/-' differences (which, IMHO, is a
270
270
  # horrible fucking idea), you can get exactly what you ask for
271
271
  # as a first priority
272
272
  # 2. input with '-' changed to '_'
273
273
  # - prioritized because convetion is to underscore-separate
274
274
  # role names.
275
275
  # 3. input with '_' changed to '-'
276
- # - really just for convience's sake so you don't really have to
276
+ # - really just for convience's sake so you don't really have to
277
277
  # remember what separator is used.
278
278
  #
279
279
  separator_variations = [
@@ -289,7 +289,7 @@ class QB::Role
289
289
  }.each { |role|
290
290
  # exact match without the namespace prefix ('qb.' or similar)
291
291
  return [role] if role.namespaceless == variation
292
- }
292
+ }
293
293
  }
294
294
 
295
295
  # see if we prefix match any full names
@@ -306,7 +306,7 @@ class QB::Role
306
306
  role.namespaceless.start_with? variation
307
307
  }
308
308
  unless namespaceless_prefix_matches.empty?
309
- return namespaceless_prefix_matches
309
+ return namespaceless_prefix_matches
310
310
  end
311
311
  }
312
312
 
@@ -370,7 +370,7 @@ class QB::Role
370
370
  end # .require
371
371
 
372
372
 
373
- # Get the include path for an included role based on the
373
+ # Get the include path for an included role based on the
374
374
  # option metadata that defines the include and the current
375
375
  # include path.
376
376
  #
@@ -385,7 +385,7 @@ class QB::Role
385
385
  # @return [Array<string>]
386
386
  # include path for the included role.
387
387
  #
388
- def self.get_include_path role, option_meta, current_include_path
388
+ def self.get_include_path role, option_meta, current_include_path
389
389
  new_include_path = if option_meta.key? 'as'
390
390
  case option_meta['as']
391
391
  when nil, false
@@ -549,7 +549,7 @@ class QB::Role
549
549
  # in meta.
550
550
  def var_prefix
551
551
  # ugh, i was generating meta/qb.yml files that set 'var_prefix' to
552
- # `null`, but it would be nice to
552
+ # `null`, but it would be nice to
553
553
  #
554
554
  meta_or 'var_prefix', namespaceless
555
555
  end
@@ -744,7 +744,7 @@ class QB::Role
744
744
  end
745
745
 
746
746
 
747
- # Parsed tree structure of version requirements of the role from the
747
+ # Parsed tree structure of version requirements of the role from the
748
748
  # `requirements` value in the QB meta data.
749
749
  #
750
750
  # @return [Hash]
@@ -767,7 +767,7 @@ class QB::Role
767
767
  # If the version of Ansible found does not satisfy the role's requirements.
768
768
  #
769
769
  # @raise [QB::QBVersionError]
770
- # If the the version of QB we're running does not satisfy the role's
770
+ # If the the version of QB we're running does not satisfy the role's
771
771
  # requirements.
772
772
  #
773
773
  def check_requirements
@@ -825,7 +825,7 @@ class QB::Role
825
825
  # all. you need to use `false` if you want to tell QB not to do something.
826
826
  #
827
827
  # @param [String | Symbol | Array<String | Symbol>] keys
828
- # Single
828
+ # Single
829
829
  #
830
830
  # @return [Object]
831
831
  #
@@ -858,7 +858,7 @@ class QB::Role
858
858
  end
859
859
 
860
860
  raise QB::Role::MetadataError.squished <<-END
861
- Expected metadata for role #{ self } to define (non-null) value for
861
+ Expected metadata for role #{ self } to define (non-null) value for
862
862
  one of keys #{ keys.inspect }.
863
863
  END
864
864
  end # need_meta
@@ -866,4 +866,4 @@ class QB::Role
866
866
 
867
867
  # end private
868
868
 
869
- end # class QB::Role
869
+ end # class QB::Role
@@ -4,7 +4,7 @@ module QB
4
4
 
5
5
  GEM_NAME = 'qb'
6
6
 
7
- VERSION = "0.3.15"
7
+ VERSION = "0.3.16"
8
8
 
9
9
  MIN_ANSIBLE_VERSION = Gem::Version.new '2.1.2'
10
10
 
@@ -26,9 +26,6 @@ class Result < OpenStruct
26
26
  end
27
27
  end
28
28
 
29
- GITHUB_SSH_URL_RE = /^git@github\.com\:(?<owner>.*)\/(?<name>.*)\.git$/
30
- GITHUB_HTTPS_URL_RE = /^https:\/\/github\.com\/(?<owner>.*)\/(?<name>.*)\.git$/
31
-
32
29
 
33
30
  class PathFacts < QB::Ansible::Module
34
31
  # Add a bunch of useful things to know about the path
@@ -65,93 +62,6 @@ class PathFacts < QB::Ansible::Module
65
62
  end
66
63
 
67
64
 
68
- # If the path is part of a Git repo, as well as useful general
69
- # Git environment facts.
70
- def add_git_facts_old
71
- # see if we're in a git repo. first, we need a directory that exists
72
- dir = @path.expand_path.ascend.find {|p| p.directory? }
73
-
74
- Dir.chdir(dir) do
75
- root_result = Cmds.capture "git rev-parse --show-toplevel"
76
-
77
- unless root_result.ok?
78
- @result.in_git_repo = false
79
- @result.is_git_root = false
80
- return
81
- end
82
-
83
- @result.in_git_repo = true
84
-
85
- git = @result.git = Result.new
86
- git.root = Pathname.new root_result.out.chomp
87
- @result.is_git_root = @path == git.root
88
-
89
- user = git.user = Result.new
90
-
91
- ['name', 'email'].each {|key|
92
- user[key] = begin
93
- Cmds.chomp! "git config user.#{ key }"
94
- rescue
95
- end
96
- }
97
-
98
- git.is_clean = Cmds.chomp!('git status --porcelain 2>/dev/null').empty?
99
-
100
- rev_parse = Cmds.capture 'git rev-parse HEAD'
101
-
102
- if rev_parse.ok?
103
- git.head = rev_parse.out.chomp
104
- git.head_short = git.head[0...7]
105
- else
106
- git.head = git.head_short = nil
107
- end
108
-
109
- branch = Cmds.capture 'git branch --no-color 2> /dev/null'
110
-
111
- git.branch = if branch.ok?
112
- if line = branch.out.lines.find {|line| line.start_with? '*'}
113
- if m = line.match(/\*\s+(\S+)/)
114
- m[1]
115
- end
116
- end
117
- end
118
-
119
- git.origin = begin
120
- Cmds.chomp! "git remote get-url origin"
121
- rescue
122
- end
123
-
124
- match = GITHUB_SSH_URL_RE.match(git.origin) ||
125
- GITHUB_HTTPS_URL_RE.match(git.origin)
126
-
127
- git.is_github = !! match
128
-
129
- return unless match
130
-
131
- git.owner = match['owner']
132
- git.name = match['name']
133
- git.full_name = "#{ git.owner }/#{ git.name }"
134
-
135
- if true == @args['github_api']
136
- github = git.github = Result.new
137
- github.api_url = "https://api.github.com/repos/#{ git.owner }/#{ git.name }"
138
-
139
- response = Net::HTTP.get_response URI(github.api_url)
140
-
141
- if response.is_a? Net::HTTPSuccess
142
- # parse response body and add everything to github result
143
- parsed = JSON.parse response.body
144
- parsed.each {|k, v| github[k] = v}
145
- else
146
- # assume it's private if we failed to find it
147
- github.private = true
148
- end
149
-
150
- end
151
- end
152
- end
153
-
154
-
155
65
  # Find the only *.gemspec path in the `@path` directory. Warns and returns
156
66
  # `nil` if there is more than one match.
157
67
  def gemspec_path
data/qb.gemspec CHANGED
@@ -194,8 +194,8 @@ Gem::Specification.new do |spec|
194
194
  # Runtime Dependencies
195
195
  # ----------------------------------------------------------------------------
196
196
 
197
- spec.add_dependency "cmds", '~> 0.0', ">= 0.2.5"
198
- spec.add_dependency "nrser", '~> 0.1', ">= 0.1.1"
197
+ spec.add_dependency "cmds", '~> 0.0', ">= 0.2.7"
198
+ spec.add_dependency "nrser", '~> 0.1', ">= 0.1.2"
199
199
  spec.add_dependency "nrser-extras", '~> 0.0', ">= 0.0.3"
200
200
  spec.add_dependency "state_mate", '~> 0.0', ">= 0.1.0"
201
201
 
@@ -0,0 +1,7 @@
1
+
2
+ # When true allow submodules to be dirty
3
+ git_root: >-
4
+ {{ qb_dir }}
5
+
6
+ git_check_clean_ignore_submodules: false
7
+ git_check_clean_ignore: []
@@ -0,0 +1,48 @@
1
+ ---
2
+ ##############################################################################
3
+ # QB metadata for `qb/git/check/clean` role.
4
+ #
5
+ # QB settings for this role.
6
+ #
7
+ # @see http://www.rubydoc.info/gems/qb/file/doc/qb_roles/metadata.md
8
+ #
9
+ ##############################################################################
10
+
11
+ # Shown in help output, etc.
12
+ description: >-
13
+ TODO describe qb/git/check/clean role
14
+
15
+ # Gemspec-style requirements. Right now only `.gems.qb` is used.
16
+ requirements:
17
+ gems:
18
+ qb: ~> 0.3.0
19
+
20
+ # Prefix for role variables
21
+ var_prefix: git_check_clean
22
+
23
+ # How to get a default for `DIRECTORY` arg if not provided by user.
24
+ #
25
+ # @see http://www.rubydoc.info/gems/qb/file/doc/qb_roles/metadata/default_dir.md
26
+ #
27
+ default_dir: null # means use *must* provide `DIRECTORY` arg
28
+
29
+ # If `true`, QB will ensure `DIRECTORY` exists before starting the play.
30
+ mkdir: false
31
+
32
+ # Default user to become for play
33
+ default_user: null
34
+
35
+ # Save options in `.qb-options.yml` files
36
+ save_options: false
37
+
38
+ # Options to pass to `ansible-playbook`
39
+ ansible_options: {}
40
+
41
+ # Role CLI options that become Ansible vars
42
+ options:
43
+ - name: ignore
44
+ description: >-
45
+ File glob patterns to ignore (allow to be dirty)
46
+ required: false
47
+ type: list
48
+ short: i
@@ -1,19 +1,35 @@
1
1
  ---
2
2
  # tasks file for qb/git/check/clean
3
3
 
4
- - name: >
5
- Get git status for repo {{ git_root }}
6
- shell: git status --porcelain 2>/dev/null
7
- args:
8
- chdir: "{{ git_root }}"
9
- register: git_check_clean_status
10
- changed_when: false
4
+ - path_facts:
5
+ path: >-
6
+ {{ git_root }}
7
+ register: git_root_facts
11
8
 
12
- - name: >
9
+ - set_fact:
10
+ git_check_is_clean: >-
11
+ {{
12
+ git_root_facts.git
13
+ | qb_send( 'clean?', ignore=git_check_clean_ignore )
14
+ }}
15
+
16
+ # - name: >
17
+ # Get git status for repo {{ git_root }}
18
+ # shell: >-
19
+ # git status
20
+ # {% if git_check_clean_ignore_submodules %}
21
+ # --ignore-submodules
22
+ # {% endif %}
23
+ # --porcelain 2>/dev/null
24
+ # args:
25
+ # chdir: "{{ git_root }}"
26
+ # register: git_check_clean_status
27
+ # changed_when: false
28
+
29
+ - when: not git_check_is_clean
30
+ name: >
13
31
  Fail if the repo at {{ git_root }} has any untracked or modified files.
14
32
  fail:
15
33
  msg: >
16
34
  Repo at {{ git_root }} can not have any untracked or
17
35
  modified files, please commit or stash and retry.
18
- when: (git_check_clean_status.stdout_lines | length) != 0
19
-