qb 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,67 @@
1
+ # Requirements
2
+ # =====================================================================
3
+
4
+ # stdlib
1
5
  require 'thread'
2
6
  require 'socket'
3
7
  require 'securerandom'
4
8
  require 'fileutils'
5
9
  require 'nrser'
6
10
 
11
+ # Refinements
12
+ # =====================================================================
13
+
14
+ require 'nrser/refinements'
7
15
  using NRSER
8
16
 
17
+
18
+ # Declarations
19
+ # =====================================================================
20
+
9
21
  module QB; end
10
22
  module QB::Util; end
11
23
 
24
+
25
+ # Definitions
26
+ # =====================================================================
27
+
28
+ # Utilities for QB's standard-IO (`stdio`) handling feature.
29
+ #
30
+ # Normally, Ansible modules can't really do much with `stdio` - they return
31
+ # results by writing JSON to `stdout`, can't do anything useful with `stdin`,
32
+ # and I think things written to `stderr` don't go anywhere useful.
33
+ #
34
+ # This makes dealing with logging, error reporting and wrapping executables
35
+ # that report useful progress info to `stdout` or `stderr` pretty shitty.
36
+ #
37
+ # So, what we do is create streaming sockets for `stdout`, `stderr` and
38
+ # `stdin` in the QB process and write their paths to environment variables,
39
+ # which will be available to modules.
40
+ #
41
+ # {QB::Ansible::Module} automatically detects these variables and sets up
42
+ # `$stdout`, `$stderr` and `$stdin` to point to the sockets, which proxy
43
+ # back to the QB process' `stdio`.
44
+ #
45
+ # Of course other modules written in any language can also connect to these
46
+ # file sockets in the same manner.
47
+ #
48
+ # @note
49
+ # This feature only works for `localhost`. I have no idea what it will do
50
+ # in other cases. It doesn't seem like it should break anything, but remotely
51
+ # executing modules definitely won't be able to connect to the sockets on
52
+ # the host.
53
+ #
54
+ # @todo
55
+ # `stdin` support is pretty experimental / broken at this point. That would
56
+ # be nice to fix in the future so that programs that make use of user
57
+ # interaction work seamlessly through QB. This will probably require
58
+ # using pseudo-TTY streams or whatever.
59
+ #
12
60
  module QB::Util::STDIO
61
+
62
+ # Constants
63
+ # =====================================================================
64
+
13
65
  SOCKET_DIR = Pathname.new('/').join 'tmp', 'qb-stdio'
14
66
 
15
67
  # STDIO as a service exposed on a UNIX socket so that modules can stream
@@ -4,7 +4,7 @@ module QB
4
4
 
5
5
  GEM_NAME = 'qb'
6
6
 
7
- VERSION = "0.3.3"
7
+ VERSION = "0.3.4"
8
8
 
9
9
  MIN_ANSIBLE_VERSION = Gem::Version.new '2.1.2'
10
10
 
@@ -30,7 +30,7 @@ GITHUB_SSH_URL_RE = /^git@github\.com\:(?<owner>.*)\/(?<name>.*)\.git$/
30
30
  GITHUB_HTTPS_URL_RE = /^https:\/\/github\.com\/(?<owner>.*)\/(?<name>.*)\.git$/
31
31
 
32
32
 
33
- class PathFacts < QB::AnsibleModule
33
+ class PathFacts < QB::Ansible::Module
34
34
  # Add a bunch of useful things to know about the path
35
35
  def add_path_facts
36
36
  @result.expanded = @path.expand_path
@@ -14,7 +14,7 @@ end
14
14
  require 'qb'
15
15
  require 'cmds'
16
16
 
17
- class Stream < QB::AnsibleModule
17
+ class Stream < QB::Ansible::Module
18
18
  def main
19
19
  template = @args['template'] || @args['cmd']
20
20
 
@@ -1 +1 @@
1
- ../semver/bin/semver
1
+ node_modules/.bin/../semver/bin/semver
data/qb.gemspec CHANGED
@@ -94,8 +94,8 @@ Gem::Specification.new do |spec|
94
94
  spec.add_development_dependency "yard"
95
95
  spec.add_development_dependency "pry"
96
96
 
97
- spec.add_dependency "cmds",'~> 0.0', ">= 0.2.1"
98
- spec.add_dependency "nrser",'~> 0.0', ">= 0.0.21"
97
+ spec.add_dependency "cmds",'~> 0.0', ">= 0.2.2"
98
+ spec.add_dependency "nrser",'~> 0.0', ">= 0.0.22"
99
99
  spec.add_dependency "nrser-extras", '~> 0.0', ">= 0.0.3"
100
100
  spec.add_dependency "state_mate", '~> 0.0', ">= 0.0.9"
101
101
  spec.add_dependency 'parseconfig', '~> 1.0', '>= 1.0.8'
@@ -1 +1 @@
1
- real2.txt
1
+ roles/nrser.blockinfile/tests/expected/test-follow/real2.txt
@@ -1 +1 @@
1
- real0.txt
1
+ roles/nrser.blockinfile/tests/fixtures/test-follow/real0.txt
@@ -1 +1 @@
1
- real1.txt
1
+ roles/nrser.blockinfile/tests/fixtures/test-follow/real1.txt
@@ -1 +1 @@
1
- real2.txt
1
+ roles/nrser.blockinfile/tests/fixtures/test-follow/real2.txt
@@ -1 +1 @@
1
- ../..
1
+ roles/nrser.blockinfile/tests/roles/../..
@@ -86,7 +86,7 @@ class Version
86
86
  # ------------------------------------------------------------------------
87
87
 
88
88
  def to_json options
89
- QB::AnsibleModule.stringify_keys(to_hash).to_json options
89
+ QB::Ansible::Module.stringify_keys(to_hash).to_json options
90
90
  end # #to_json
91
91
  end # Version
92
92
 
@@ -179,7 +179,7 @@ class NodeBumper < Bumper
179
179
  end # NodeBumper
180
180
 
181
181
 
182
- class Bump < QB::AnsibleModule
182
+ class Bump < QB::Ansible::Module
183
183
 
184
184
  def check_repo_clean!
185
185
  unless Cmds.chomp!('git status --porcelain 2>/dev/null') == ''
@@ -19,7 +19,7 @@ require 'nrser'
19
19
 
20
20
  using NRSER
21
21
 
22
- class GitSubmoduleUpdate < QB::AnsibleModule
22
+ class GitSubmoduleUpdate < QB::Ansible::Module
23
23
  def main_dir
24
24
  File.realpath @args['dir']
25
25
  end
@@ -1 +1 @@
1
- Leiningen.gitignore
1
+ roles/qb.gitignore/files/gitignore/Leiningen.gitignore
@@ -1 +1 @@
1
- C++.gitignore
1
+ roles/qb.gitignore/files/gitignore/C++.gitignore
@@ -79,7 +79,7 @@ vars:
79
79
 
80
80
  - name: modules
81
81
  description: >-
82
- create ruby module boilerplate(s) in library using QB::AnsibleModule.
82
+ create ruby module boilerplate(s) in library using QB::Ansible::Module.
83
83
  type: array
84
84
  required: false
85
85
  # TODO not yet implemented
@@ -14,7 +14,7 @@ end
14
14
  require 'qb'
15
15
  require 'nrser'
16
16
 
17
- class {{ role_module_class }} < QB::AnsibleModule
17
+ class {{ role_module_class }} < QB::Ansible::Module
18
18
  # define arg names to NRSER::Types::Type instances here and they
19
19
  # will be type checked and set as @<name>
20
20
  #
@@ -18,6 +18,33 @@
18
18
  {{ gem_root }}
19
19
 
20
20
 
21
+ - name: >-
22
+ See if a pre-release script exists at `//dev/hooks/pre-release`.
23
+ stat:
24
+ path: >-
25
+ {{ gem_root | path_join( 'dev', 'hooks', 'pre-release' ) }}
26
+ register: gem_pre_release_script_stat
27
+
28
+ - debug: var=gem_pre_release_script_stat
29
+
30
+
31
+ # NOTE Contrary to how it might seems in the [docs][1],
32
+ # the `stat` object seems to *only* have the `exists` property if the
33
+ # path does not exist (set to `false`), necessitating we
34
+ #
35
+ # [1]: http://docs.ansible.com/ansible/latest/stat_module.html
36
+ #
37
+ - when: >-
38
+ gem_pre_release_script_stat.stat.exists and
39
+ gem_pre_release_script_stat.stat.executable
40
+ name: >-
41
+ Execute `//dev/hooks/pre-release` script.
42
+ stream:
43
+ cmd: ./dev/hooks/pre-release
44
+ chdir: >-
45
+ {{ gem_root }}
46
+
47
+
21
48
  - name: >-
22
49
  Get gem and version info
23
50
  vars.rb:
@@ -32,8 +59,6 @@
32
59
  raise "No gemspec found for pattern #{ spec_pattern }"
33
60
  end
34
61
 
35
- spec = Gem::Specification.load spec_path
36
-
37
62
  # The gem *may already be loaded*, which would break the standard gemspec
38
63
  # approach because the `require` will be a no-op, resulting in the
39
64
  # already loaded version number being used instead of the one in the
@@ -71,68 +96,102 @@
71
96
  'version_path' => "#{ gem_root }/lib/#{ name }/version.rb",
72
97
  'spec_path' => spec_path,
73
98
  }
74
-
99
+
100
+
75
101
  - debug:
76
102
  msg:
77
- # - spec_path: >-
78
- # {{ gem_spec_path }}
79
- # - version_path: >-
80
- # {{ gem_version_path }}
81
103
  - current: >-
82
104
  {{ gem_current_version }}
83
105
  - release: >-
84
106
  {{ gem_release_version }}
85
107
  - next: >-
86
108
  {{ gem_next_version }}
109
+ # - spec_path: >-
110
+ # {{ gem_spec_path }}
111
+ # - version_path: >-
112
+ # {{ gem_version_path }}
87
113
 
88
- - name: "change version to release version {{ gem_release_version }}"
89
- replace:
90
- dest: "{{ gem_version_path }}"
91
- regexp: "VERSION\\s*=\\s*\"{{ gem_current_version }}\""
92
- replace: "VERSION = \"{{ gem_release_version }}\""
93
- when: gem_current_version != gem_release_version
94
114
 
115
+ - when: gem_current_version != gem_release_version
116
+ name: >-
117
+ Change version in `{{ gem_version_path }}` from current
118
+ `{{ gem_current_version }}` to `{{ gem_release_version }}`.
119
+ block:
120
+ - name: >-
121
+ Change version to release version `{{ gem_release_version }}`.
122
+ replace:
123
+ dest: >-
124
+ {{ gem_version_path }}
125
+ regexp: >-
126
+ VERSION\s*=\s*["']{{ gem_current_version }}["']
127
+ replace: >-
128
+ VERSION = "{{ gem_release_version }}"
129
+
130
+
131
+ - name: >-
132
+ Add version file `{{ gem_version_path }}` to Git.
133
+ command: >-
134
+ git add {{ gem_version_path }}
135
+ args:
136
+ chdir: >-
137
+ {{ gem_root }}
138
+ when: gem_current_version != gem_release_version
95
139
 
96
- - name: >-
97
- Add version file {{ gem_version_path }} to Git.
98
- command: "git add {{ gem_version_path }}"
99
- args:
100
- chdir: "{{ gem_root }}"
101
- when: gem_current_version != gem_release_version
140
+
141
+ - name: >-
142
+ Commit version file `{{ gem_version_path }}` in Git.
143
+ command: git commit -m "bump to v{{ gem_release_version }}"
144
+ args:
145
+ chdir: >-
146
+ {{ gem_root }}
147
+ when: gem_current_version != gem_release_version
148
+ # /block
102
149
 
103
150
 
104
151
  - name: >-
105
- Commit version file {{ gem_version_path }} in Git.
106
- command: git commit -m "bump to v{{ gem_release_version }}"
107
- args:
108
- chdir: "{{ gem_root }}"
109
- when: gem_current_version != gem_release_version
110
-
111
- - name: release with bundler
152
+ Release with Bundler via `bundle exec rake release`.
112
153
  shell: bundle exec rake release
113
154
  args:
114
- chdir: "{{ gem_root }}"
155
+ chdir: >-
156
+ {{ gem_root }}
115
157
 
116
- - name: "change version to next version {{ gem_next_version }}"
158
+
159
+ - name: >-
160
+ Change version to next version `{{ gem_next_version }}`.
117
161
  replace:
118
- dest: "{{ gem_version_path }}"
119
- regexp: "VERSION\\s*=\\s*\"{{ gem_release_version }}\""
120
- replace: "VERSION = \"{{ gem_next_version }}\""
162
+ dest: >-
163
+ {{ gem_version_path }}
164
+ regexp: >-
165
+ VERSION\s*=\s*["']{{ gem_release_version }}["']
166
+ replace: >-
167
+ VERSION = "{{ gem_next_version }}"
168
+
121
169
 
122
- - name: add next dev version to git
123
- command: "git add {{ gem_version_path }}"
170
+ - name: >-
171
+ Add next dev version to git.
172
+ command: >-
173
+ git add {{ gem_version_path }}
124
174
  args:
125
- chdir: "{{ gem_root }}"
175
+ chdir: >-
176
+ {{ gem_root }}
177
+
126
178
 
127
- - name: commit next dev version
128
- command: git commit -m "start {{ gem_next_version }}"
179
+ - name: >-
180
+ Commit next dev version.
181
+ command: >-
182
+ git commit -m "start {{ gem_next_version }}"
129
183
  args:
130
- chdir: "{{ gem_root }}"
184
+ chdir: >-
185
+ {{ gem_root }}
131
186
 
132
- - name: push next dev version
187
+
188
+ - name: >-
189
+ Push next dev version.
133
190
  command: git push
134
191
  args:
135
- chdir: "{{ gem_root }}"
192
+ chdir: >-
193
+ {{ gem_root }}
194
+
136
195
 
137
196
  - debug:
138
197
  msg: >
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - nrser
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-11 00:00:00.000000000 Z
11
+ date: 2017-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,7 +89,7 @@ dependencies:
89
89
  version: '0.0'
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: 0.2.1
92
+ version: 0.2.2
93
93
  type: :runtime
94
94
  prerelease: false
95
95
  version_requirements: !ruby/object:Gem::Requirement
@@ -99,7 +99,7 @@ dependencies:
99
99
  version: '0.0'
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
- version: 0.2.1
102
+ version: 0.2.2
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: nrser
105
105
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0.0'
110
110
  - - ">="
111
111
  - !ruby/object:Gem::Version
112
- version: 0.0.21
112
+ version: 0.0.22
113
113
  type: :runtime
114
114
  prerelease: false
115
115
  version_requirements: !ruby/object:Gem::Requirement
@@ -119,7 +119,7 @@ dependencies:
119
119
  version: '0.0'
120
120
  - - ">="
121
121
  - !ruby/object:Gem::Version
122
- version: 0.0.21
122
+ version: 0.0.22
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: nrser-extras
125
125
  requirement: !ruby/object:Gem::Requirement
@@ -195,12 +195,14 @@ files:
195
195
  - exe/qb
196
196
  - lib/qb.rb
197
197
  - lib/qb/ansible.rb
198
+ - lib/qb/ansible/cmds/playbook.rb
198
199
  - lib/qb/ansible/config_file.rb
199
200
  - lib/qb/ansible/env.rb
200
- - lib/qb/ansible/playbook.rb
201
+ - lib/qb/ansible/module.rb
201
202
  - lib/qb/ansible_module.rb
202
203
  - lib/qb/cli.rb
203
204
  - lib/qb/cli/play.rb
205
+ - lib/qb/cli/run.rb
204
206
  - lib/qb/errors.rb
205
207
  - lib/qb/options.rb
206
208
  - lib/qb/options/option.rb
@@ -693,7 +695,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
693
695
  version: '0'
694
696
  requirements: []
695
697
  rubyforge_project:
696
- rubygems_version: 2.5.2
698
+ rubygems_version: 2.6.11
697
699
  signing_key:
698
700
  specification_version: 4
699
701
  summary: qb is all about projects. named after everyone's favorite projects.
@@ -1,4 +0,0 @@
1
- module QB; end
2
- module QB::Ansible; end
3
-
4
-