qb 0.3.15 → 0.3.16

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.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 003b446aa520075c83fc445695b0babad54437b3
4
- data.tar.gz: c994400156228766aeec6ea26103e7ee6217ad3c
3
+ metadata.gz: 2c65f9c354ec520a8f1ac149b0cd94584b17f597
4
+ data.tar.gz: 7627ef3fee17449eeed1421aa99c31fda9c8c4b5
5
5
  SHA512:
6
- metadata.gz: 2e379e64f336af6be769dc44e14654e598c01aa21b03e2148f5e82c51c23f8ece9808c0943459eb39158515b5b6e3c0f4c8ce6e27785ee2b30846543c8f6ba58
7
- data.tar.gz: '0813dfb291517540ac560d6dabf4aafb4bb328b1abf54cd61dab3b858aea28833e3060be8c6ac057a505f78371a970ebcbe1b7656abe5e678191147d6da346e2'
6
+ metadata.gz: 1f61779f264ece1c9d6bc5f6dbfce675b0d8603d9dca96ea5b8653cd169a4c041cb5a1eafa108f0356c8b2482e41c8edcde8394324367b7742ff15d763d7270b
7
+ data.tar.gz: 0b5caaf19c3ce3ccba500b16289aac12e09ceae5f9eabf1d1a93371ea4ea79646f337af00adaa8e6c8f008289b2f80b8baaddbaf2f63d9edd0449fe21b265234
@@ -2,6 +2,13 @@ require 'json'
2
2
  require 'pp'
3
3
 
4
4
 
5
+ # Refinements
6
+ # =======================================================================
7
+
8
+ using NRSER
9
+ using NRSER::Types
10
+
11
+
5
12
  # Declarations
6
13
  # =====================================================================
7
14
 
@@ -33,14 +40,16 @@ class QB::Ansible::Module
33
40
  end
34
41
 
35
42
 
36
- # Constructor
43
+ # Construction
37
44
  # =====================================================================
38
45
 
39
46
  def initialize
40
47
  @changed = false
41
- @input_file = ARGV[0]
42
- @input = File.read @input_file
43
- @args = JSON.load @input
48
+ # @input_file = ARGV[0]
49
+ # @input = File.read @input_file
50
+ # @args = JSON.load @input
51
+ init_set_args!
52
+
44
53
  @facts = {}
45
54
  @warnings = []
46
55
 
@@ -82,12 +91,73 @@ class QB::Ansible::Module
82
91
  END
83
92
  end
84
93
 
85
- instance_variable_set var_name,
86
- type.check(@args.fetch(key.to_s))
94
+ value = type.check( @args[key.to_s] ) do |type:, value:|
95
+ all_args = @args
96
+
97
+ binding.erb <<-END
98
+ Value
99
+
100
+ <%= value.pretty_inspect %>
101
+
102
+ for argument <%= key.inspect %> is not valid for type
103
+
104
+ <%= type %>
105
+
106
+ Arguments:
107
+
108
+ <%= all_args.pretty_inspect %>
109
+
110
+ END
111
+ end
112
+
113
+ instance_variable_set var_name, value
87
114
  }
88
115
  end
89
116
 
90
117
 
118
+ protected
119
+ # ========================================================================
120
+
121
+ def init_set_args!
122
+ if ARGV.length == 1 && File.file?( ARGV[0] )
123
+ # "Standard" Ansible-invoked mode, where the args written in JSON format
124
+ # to a file and the path is provided as the only CLI argument
125
+ #
126
+ @input_file = ARGV[0]
127
+ @input = File.read @input_file
128
+ @args = JSON.load @input
129
+
130
+ else
131
+ # QB-specific "fiddle-mode": if we don't have a single valid file path
132
+ # as CLI arguments, parse the CLI options we have in the common
133
+ #
134
+ # `--name=value`
135
+ #
136
+ # format into the `@args` hash.
137
+ #
138
+ # This lets us run the module file **directly** from the terminal, which
139
+ # is just a quick and dirty way of flushing things out.
140
+ #
141
+ @fiddle_mode = true
142
+ @args = {}
143
+
144
+ ARGV.each do |arg|
145
+ if arg.start_with? '--'
146
+ key, value = arg[2..-1].split( '=', 2 )
147
+
148
+ @args[key] = begin
149
+ JSON.load value
150
+ rescue
151
+ value
152
+ end
153
+ end
154
+ end
155
+ end
156
+ end # #init_set_args!
157
+
158
+ # end protected
159
+ public
160
+
91
161
 
92
162
  # Instance Methods
93
163
  # =====================================================================
@@ -102,10 +172,10 @@ class QB::Ansible::Module
102
172
  #
103
173
  # When run inside of QB (targeting localhost only at the moment, sadly)
104
174
  # we expose additional IO channels for STDIN, STDOUT and STDERR through
105
- # opening unix socket files that the main QB process spawns threads to
175
+ # opening unix socket files that the main QB process spawns threads to
106
176
  # listen to, and we provide those file paths via environment variables
107
177
  # so modules can pick those up and interact with those streams, allowing
108
- # them to act like regular scripts inside Ansible-world (see
178
+ # them to act like regular scripts inside Ansible-world (see
109
179
  # QB::Util::STDIO for details and implementation).
110
180
  #
111
181
  # We use those channels if present to provide logging mechanisms.
@@ -170,7 +240,7 @@ class QB::Ansible::Module
170
240
  def exit_json hash
171
241
  # print JSON response to process' actual STDOUT (instead of $stdout,
172
242
  # which may be pointing to the qb parent process)
173
- STDOUT.print JSON.dump(self.class.stringify_keys(hash))
243
+ STDOUT.print JSON.pretty_generate(self.class.stringify_keys(hash))
174
244
 
175
245
  [
176
246
  [:stdin, @qb_stdio_in],
@@ -191,4 +261,4 @@ class QB::Ansible::Module
191
261
  def fail msg
192
262
  exit_json failed: true, msg: msg, warnings: @warnings
193
263
  end
194
- end # class QB::Ansible::Module
264
+ end # class QB::Ansible::Module
@@ -18,19 +18,10 @@ require_relative './package/version'
18
18
  # Refinements
19
19
  # =======================================================================
20
20
 
21
- require 'nrser/refinements'
22
21
  using NRSER
23
-
24
- require 'nrser/refinements/types'
25
22
  using NRSER::Types
26
23
 
27
24
 
28
- # Declarations
29
- # =======================================================================
30
-
31
- module QB; end
32
-
33
-
34
25
  # Definitions
35
26
  # =======================================================================
36
27
 
@@ -54,14 +45,14 @@ class QB::Package < QB::Util::Resource
54
45
  # User-provided path value used to construct the resource instance, if any.
55
46
  #
56
47
  # This may not be the same as a root path for the resource, such as with
57
- # resource classes that can be constructed from any path *inside* the
48
+ # resource classes that can be constructed from any path *inside* the
58
49
  # directory, like a {QB::Repo::Git}.
59
50
  #
60
51
  # @return [String | Pathname]
61
52
  # If the resource instance was constructed based on a path argument.
62
53
  #
63
54
  # @return [nil]
64
- # If the resource instance was *not* constructed based on a path
55
+ # If the resource instance was *not* constructed based on a path
65
56
  # argument.
66
57
  #
67
58
  prop :ref_path, type: t.maybe( t.dir_path )
@@ -144,7 +135,7 @@ class QB::Package < QB::Util::Resource
144
135
 
145
136
  # Relative path from the {#repo} root to the {#root_path}.
146
137
  #
147
- # Used as the version tag prefix (unless it's `.` - when the repo root is
138
+ # Used as the version tag prefix (unless it's `.` - when the repo root is
148
139
  # the root path).
149
140
  #
150
141
  # @return [Pathname]
@@ -159,7 +150,7 @@ class QB::Package < QB::Util::Resource
159
150
  # Only makes any sense if the package is in a recognized repo, and will error
160
151
  # out if that's not the case.
161
152
  #
162
- # The most basic prefix is "v" for packages located at the root of the
153
+ # The most basic prefix is "v" for packages located at the root of the
163
154
  # repository.
164
155
  #
165
156
  # @example
@@ -230,4 +221,3 @@ end # class QB::Package
230
221
  # =======================================================================
231
222
 
232
223
  require_relative './package/gem'
233
-
@@ -3,38 +3,24 @@
3
3
 
4
4
  # Stdlib
5
5
  # -----------------------------------------------------------------------
6
-
7
6
  require 'pathname'
8
7
 
9
-
10
8
  # Deps
11
9
  # -----------------------------------------------------------------------
12
-
13
10
  require 'nrser'
14
11
 
15
-
16
12
  # Package
17
13
  # -----------------------------------------------------------------------
18
-
19
14
  require 'qb/repo/git'
20
15
 
21
16
 
22
17
  # Refinements
23
18
  # =======================================================================
24
19
 
25
- require 'nrser/refinements'
26
20
  using NRSER
27
-
28
- require 'nrser/refinements/types'
29
21
  using NRSER::Types
30
22
 
31
23
 
32
- # Declarations
33
- # =======================================================================
34
-
35
- module QB; end
36
-
37
-
38
24
  # Definitions
39
25
  # =======================================================================
40
26
 
@@ -62,7 +48,7 @@ class QB::Path < Pathname
62
48
  # and where the instance was created, which may be on a totally different
63
49
  # system if the instance was loaded from data.
64
50
  #
65
- # TODO Not totally flushed out yet, could imagine a lot of problems and
51
+ # TODO Not totally flushed out yet, could imagine a lot of problems and
66
52
  # weirdness, but it seems like we need something like this to make
67
53
  # instances transportable. Issues with relative paths come to mind...
68
54
  #
@@ -73,7 +59,7 @@ class QB::Path < Pathname
73
59
  # The raw path argument used to instantiate the path object.
74
60
  #
75
61
  # NOTE Because we reduce {Pathname} instances to {String} when converting
76
- # to data, there is some lossy-ness. I guess it's similar to how
62
+ # to data, there is some lossy-ness. I guess it's similar to how
77
63
  # symbols and strings all become strings when run through {JSON}
78
64
  # dump and load.
79
65
  #
@@ -120,6 +106,10 @@ class QB::Path < Pathname
120
106
  type: t.bool,
121
107
  source: :cwd?
122
108
 
109
+ prop :is_symlink,
110
+ type: t.bool,
111
+ source: :symlink?
112
+
123
113
  prop :relative,
124
114
  type: t.maybe( t.path ),
125
115
  source: :relative,
@@ -146,6 +136,18 @@ class QB::Path < Pathname
146
136
  source: :git
147
137
 
148
138
 
139
+ # # Value would be *loadable* via init
140
+ # prop :packages,
141
+ # type: t.map( keys: t.sym, values: QB::Package ),
142
+ # default: ->() { QB::Package.all_from_path self }
143
+ #
144
+ #
145
+ # # Value would be ignored by init and re-computed
146
+ # prop :packages,
147
+ # type: t.map( keys: t.sym, values: QB::Package ),
148
+ # source: ->() { QB::Package.all_from_path self },
149
+ # cache: true
150
+
149
151
  # Constructor
150
152
  # ======================================================================
151
153
 
@@ -163,7 +165,7 @@ class QB::Path < Pathname
163
165
  # The {#raw} value is passed up to {Pathname#initialize}.
164
166
  #
165
167
  # {#cwd} is accepted in `values`, allowing a re-instantiated object to
166
- # "make sense" when the process' current directory may no longer be the
168
+ # "make sense" when the process' current directory may no longer be the
167
169
  # one that data was constructed against.
168
170
  #
169
171
  # {#cwd} defaults to the current directory (via {Pathname.getwd}) if not
@@ -254,6 +256,8 @@ class QB::Path < Pathname
254
256
  Pathname.new self
255
257
  end
256
258
 
259
+ alias_method :pathname, :path
260
+
257
261
 
258
262
  # Composed Sub-Instances
259
263
  # ---------------------------------------------------------------------
@@ -285,4 +289,3 @@ class QB::Path < Pathname
285
289
  end
286
290
 
287
291
  end # class QB::Path
288
-
@@ -6,30 +6,26 @@
6
6
 
7
7
  # Deps
8
8
  # -----------------------------------------------------------------------
9
+ require 'nrser'
9
10
 
10
11
  # Project / Package
11
12
  # -----------------------------------------------------------------------
13
+ require 'qb/util/resource'
12
14
 
13
15
 
14
16
  # Refinements
15
17
  # =======================================================================
16
18
 
17
- require 'nrser/refinements'
18
19
  using NRSER
19
-
20
- require 'nrser/refinements/types'
21
20
  using NRSER::Types
22
21
 
23
22
 
24
- # Declarations
25
- # =======================================================================
26
-
27
-
28
23
  # Definitions
29
24
  # =======================================================================
30
25
 
31
26
  # @todo document QB::Repo class.
32
27
  class QB::Repo < QB::Util::Resource
28
+ autoload :Git, 'qb/repo/git'
33
29
 
34
30
  # Constants
35
31
  # ======================================================================
@@ -83,14 +79,14 @@ class QB::Repo < QB::Util::Resource
83
79
  # User-provided path value used to construct the resource instance, if any.
84
80
  #
85
81
  # This may not be the same as a root path for the resource, such as with
86
- # resource classes that can be constructed from any path *inside* the
82
+ # resource classes that can be constructed from any path *inside* the
87
83
  # directory, like a {QB::Repo::Git}.
88
84
  #
89
85
  # @return [String | Pathname]
90
86
  # If the resource instance was constructed based on a path argument.
91
87
  #
92
88
  # @return [nil]
93
- # If the resource instance was *not* constructed based on a path
89
+ # If the resource instance was *not* constructed based on a path
94
90
  # argument.
95
91
  #
96
92
  prop :ref_path, type: t.maybe( t.path )
@@ -129,9 +125,3 @@ class QB::Repo < QB::Util::Resource
129
125
 
130
126
 
131
127
  end # class QB::Repo
132
-
133
-
134
- # Post-Processing
135
- # =======================================================================
136
-
137
- require 'qb/repo/git'
@@ -17,10 +17,7 @@ require 'qb/util/resource'
17
17
  # Refinements
18
18
  # =======================================================================
19
19
 
20
- require 'nrser/refinements'
21
20
  using NRSER
22
-
23
- require 'nrser/refinements/types'
24
21
  using NRSER::Types
25
22
 
26
23
 
@@ -37,16 +34,33 @@ class QB::Repo < QB::Util::Resource; end
37
34
  # Encapsulate information about a Git repository and expose useful operations as
38
35
  # instance methods.
39
36
  #
40
- # The main entry point is {QB::Repo::Git.from_path}, which creates a
37
+ # The main entry point is {QB::Repo::Git.from_path}, which creates a
41
38
  #
42
39
  class QB::Repo::Git < QB::Repo
43
- GITHUB_SSH_URL_RE = /^git@github\.com\:(?<owner>.*)\/(?<name>.*)\.git$/
44
- GITHUB_HTTPS_URL_RE = /^https:\/\/github\.com\/(?<owner>.*)\/(?<name>.*)\.git$/
40
+ autoload :User, 'qb/repo/git/user'
41
+ autoload :GitHub, 'qb/repo/git/github'
45
42
 
46
- class User < QB::Util::Resource
47
- prop :name, type: t.maybe(t.str), default: nil
48
- prop :email, type: t.maybe(t.str), default: nil
49
- end
43
+ # Props
44
+ # =====================================================================
45
+
46
+ prop :user, type: User
47
+ prop :head, type: t.maybe(t.str)
48
+ prop :branch, type: t.maybe(t.str)
49
+ prop :origin, type: t.maybe(t.str)
50
+ prop :owner, type: t.maybe(t.str)
51
+ prop :github, type: t.maybe(t.hash_)
52
+
53
+
54
+ # Derived Properties
55
+ # ---------------------------------------------------------------------
56
+
57
+ prop :head_short, type: t.maybe(t.str), source: :head_short
58
+ prop :full_name, type: t.maybe(t.str), source: :full_name
59
+ prop :is_github, type: t.bool, source: :github?
60
+ prop :is_clean, type: t.bool, source: :clean?
61
+
62
+
63
+
50
64
 
51
65
 
52
66
  # class GitHubRemote < NRSER::Meta::Props::Base
@@ -64,11 +78,11 @@ class QB::Repo::Git < QB::Repo
64
78
  # # =====================================================================
65
79
  #
66
80
  # # Test if a Git SSH or HTTPS remote url points to GitHub.
67
- # #
81
+ # #
68
82
  # # @param [String] url
69
- # #
83
+ # #
70
84
  # # @return [Boolean]
71
- # #
85
+ # #
72
86
  # def self.url? url
73
87
  # SSH_URL_RE.match(url) || HTTPS_URL_RE.match(url)
74
88
  # end # .url?
@@ -76,13 +90,13 @@ class QB::Repo::Git < QB::Repo
76
90
  #
77
91
  # # Instantiate an instance from a Git SSH or HTTPS remote url that points
78
92
  # # to GitHub.
79
- # #
93
+ # #
80
94
  # # @param [type] arg_name
81
95
  # # @todo Add name param description.
82
- # #
96
+ # #
83
97
  # # @return [QB::Repo::Git::GitHubRemote]
84
98
  # # @todo Document return value.
85
- # #
99
+ # #
86
100
  # def self.from_url url, use_api: false
87
101
  # match = SSH_URL_RE.match(git.origin) ||
88
102
  # HTTPS_URL_RE.match(git.origin)
@@ -104,13 +118,13 @@ class QB::Repo::Git < QB::Repo
104
118
  #
105
119
  #
106
120
  # # @todo Document full_name method.
107
- # #
121
+ # #
108
122
  # # @param [type] arg_name
109
123
  # # @todo Add name param description.
110
- # #
124
+ # #
111
125
  # # @return [return_type]
112
126
  # # @todo Document return value.
113
- # #
127
+ # #
114
128
  # def full_name arg_name
115
129
  # "#{ owner }/#{ name }"
116
130
  # end # #full_name
@@ -139,8 +153,8 @@ class QB::Repo::Git < QB::Repo
139
153
  # the {QB::Repo::Git#github} property for repos that have a GitHub origin
140
154
  # URL.
141
155
  #
142
- # Otherwise we will just assume GitHub repos are private since it's the
143
- # safe guess, resulting in a {QB::Repo::Git#github} value of
156
+ # Otherwise we will just assume GitHub repos are private since it's the
157
+ # safe guess, resulting in a {QB::Repo::Git#github} value of
144
158
  # `{private: true}`.
145
159
  #
146
160
  # @return [QB::Repo::Git]
@@ -150,7 +164,7 @@ class QB::Repo::Git < QB::Repo
150
164
  # If `path` is not in a Git repo.
151
165
  #
152
166
  # @raise [QB::FSStateError]
153
- # - If we can't find any existing directory to look in based on
167
+ # - If we can't find any existing directory to look in based on
154
168
  # `input_path`.
155
169
  #
156
170
  def self.from_path path, use_github_api: false
@@ -283,7 +297,7 @@ class QB::Repo::Git < QB::Repo
283
297
  # @return [QB::Repo::Git]
284
298
  #
285
299
  # @raise [QB::FSStateError]
286
- # - If we can't find any existing directory to look in based on
300
+ # - If we can't find any existing directory to look in based on
287
301
  # `input_path`.
288
302
  #
289
303
  # - If the directory we do find to look in does not seems to be part of
@@ -300,26 +314,6 @@ class QB::Repo::Git < QB::Repo
300
314
  end # #from_path!
301
315
 
302
316
 
303
- # Props
304
- # =====================================================================
305
-
306
- prop :user, type: User
307
- prop :is_clean, type: t.bool
308
- prop :head, type: t.maybe(t.str)
309
- prop :branch, type: t.maybe(t.str)
310
- prop :origin, type: t.maybe(t.str)
311
- prop :owner, type: t.maybe(t.str)
312
- prop :github, type: t.maybe(t.hash_)
313
-
314
-
315
- # Derived Properties
316
- # ---------------------------------------------------------------------
317
-
318
- prop :head_short, type: t.maybe(t.str), source: :head_short
319
- prop :full_name, type: t.maybe(t.str), source: :full_name
320
- prop :is_github, type: t.bool, source: :github?
321
-
322
-
323
317
  # Instance Methods
324
318
  # =====================================================================
325
319
 
@@ -331,11 +325,22 @@ class QB::Repo::Git < QB::Repo
331
325
  head[0...7] if head
332
326
  end
333
327
 
328
+
329
+ # Always returns `false`, where {QB::Repo::Git::GitHub#github?} always
330
+ # returns `true`.
331
+ #
332
+ # Use {.from_path} to construct instances so you end up with the right
333
+ # class.
334
+ #
335
+ # @return [false]
336
+ #
334
337
  def github?
335
- !github.nil?
338
+ # origin && QB::Repo::Git::GitHub.url?( origin )
339
+ false
336
340
  end
337
341
 
338
- def api
342
+
343
+ def api
339
344
  @api ||= ::Git.open root_path
340
345
  end
341
346
 
@@ -343,11 +348,28 @@ class QB::Repo::Git < QB::Repo
343
348
  # Reading Repo State
344
349
  # ---------------------------------------------------------------------
345
350
 
351
+ def status
352
+ Cmds.new( 'git status --porcelain', chdir: root_path ).
353
+ out!.lines.map( &:chomp ).map { |line|
354
+ m = /\A\s*(?<mode>\S+)\s*(?<path>.*)\z/.match line
355
+
356
+ [m['path'], m['mode']]
357
+ }.to_h
358
+ end
359
+
360
+
346
361
  # @return [Boolean]
347
362
  # `false` if the repo has any uncommitted changes or untracked files.
348
363
  #
349
- def clean?
350
- is_clean
364
+ def clean? ignore: nil
365
+ if ignore
366
+ ignore = [*ignore]
367
+ status.reject { |path, mode|
368
+ ignore.any? { |pattern| File.fnmatch? pattern, path }
369
+ }.empty?
370
+ else
371
+ status.empty?
372
+ end
351
373
  end
352
374
 
353
375
 
@@ -356,9 +378,3 @@ class QB::Repo::Git < QB::Repo
356
378
  end
357
379
 
358
380
  end # class QB::Repo::Git
359
-
360
-
361
- # Post-Processing
362
- # =======================================================================
363
-
364
- require 'qb/repo/git/github'