qb 0.1.88 → 0.3.1

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 (44) hide show
  1. checksums.yaml +4 -4
  2. data/exe/qb +3 -53
  3. data/lib/qb.rb +3 -1
  4. data/lib/qb/ansible.rb +5 -0
  5. data/lib/qb/ansible/config_file.rb +147 -0
  6. data/lib/qb/ansible/env.rb +49 -0
  7. data/lib/qb/ansible/playbook.rb +4 -0
  8. data/lib/qb/cli.rb +4 -0
  9. data/lib/qb/cli/play.rb +33 -0
  10. data/lib/qb/options.rb +48 -7
  11. data/lib/qb/role.rb +228 -74
  12. data/lib/qb/util.rb +2 -2
  13. data/lib/qb/util/bundler.rb +56 -0
  14. data/lib/qb/version.rb +1 -1
  15. data/node_modules/.bin/semver +1 -1
  16. data/plugins/filter_plugins/{path.py → path_plugins.py} +35 -0
  17. data/plugins/filter_plugins/{ruby_interop.py → ruby_interop_plugins.py} +0 -0
  18. data/plugins/filter_plugins/{string.py → string_plugins.py} +19 -0
  19. data/plugins/filter_plugins/{version.py → version_plugins.py} +0 -0
  20. data/qb.gemspec +1 -0
  21. data/roles/nrser.blockinfile/tests/expected/test-follow/link2.txt +1 -1
  22. data/roles/nrser.blockinfile/tests/fixtures/test-follow/link0.txt +1 -1
  23. data/roles/nrser.blockinfile/tests/fixtures/test-follow/link1.txt +1 -1
  24. data/roles/nrser.blockinfile/tests/fixtures/test-follow/link2.txt +1 -1
  25. data/roles/nrser.blockinfile/tests/roles/yaegashi.blockinfile +1 -1
  26. data/roles/qb.gitignore/files/gitignore/Clojure.gitignore +1 -1
  27. data/roles/qb.gitignore/files/gitignore/Fortran.gitignore +1 -1
  28. data/roles/qb.qb_role/templates/qb.yml.j2 +1 -1
  29. data/roles/qb/dev/ref/repo/git/defaults/main.yml +32 -0
  30. data/roles/qb/dev/ref/repo/git/meta/main.yml +8 -0
  31. data/roles/qb/dev/ref/repo/git/meta/qb.yml +67 -0
  32. data/roles/qb/dev/ref/repo/git/tasks/main.yml +16 -0
  33. data/roles/qb/facts/defaults/main.yml +3 -0
  34. data/roles/{qb.facts → qb/facts}/meta/main.yml +1 -1
  35. data/roles/{qb.facts → qb/facts}/meta/qb.yml +1 -1
  36. data/roles/{qb.facts → qb/facts}/tasks/main.yml +1 -1
  37. data/roles/qb/osx/git/change_case/README.md +16 -0
  38. data/roles/qb/osx/git/change_case/defaults/main.yml +2 -0
  39. data/roles/qb/osx/git/change_case/meta/main.yml +8 -0
  40. data/roles/qb/osx/git/change_case/meta/qb.yml +80 -0
  41. data/roles/qb/osx/git/change_case/tasks/main.yml +6 -0
  42. data/roles/qb/osx/git/change_case/tasks/upcase.yml +26 -0
  43. metadata +42 -11
  44. data/roles/qb.facts/defaults/main.yml +0 -3
data/lib/qb/version.rb CHANGED
@@ -4,7 +4,7 @@ module QB
4
4
 
5
5
  GEM_NAME = 'qb'
6
6
 
7
- VERSION = "0.1.88"
7
+ VERSION = "0.3.1"
8
8
 
9
9
  MIN_ANSIBLE_VERSION = Gem::Version.new '2.1.2'
10
10
 
@@ -1 +1 @@
1
- node_modules/.bin/../semver/bin/semver
1
+ ../semver/bin/semver
@@ -45,7 +45,41 @@ def resolve(*path_segments):
45
45
  '''
46
46
 
47
47
  return Path(*path_segments).resolve().__str__()
48
+
49
+
50
+ def path_upcase_filename(path):
51
+ '''
52
+ Implemented pretty much just for `qb/osx/git/change_case` role...
53
+ just upcase the file (or directory) name at `path`, leaving any "normal"
54
+ file extension as is (will prob fuck up in weird file extension cases).
55
+
56
+ >>> path_upcase_filename('./a.txt')
57
+ './A.txt'
58
+
59
+ >>> path_upcase_filename('./a/b.txt')
60
+ './a/B.txt'
61
+
62
+ >>> path_upcase_filename('./a')
63
+ './A'
48
64
 
65
+ >>> path_upcase_filename('./a/b')
66
+ './a/B'
67
+
68
+ >>> path_upcase_filename('./a.b.txt')
69
+ './A.B.txt'
70
+
71
+ >>> path_upcase_filename('./products/sg-v1/')
72
+ './products/SG-V1'
73
+
74
+ >>> path_upcase_filename('./products/sg-v1')
75
+ './products/SG-V1'
76
+ '''
77
+
78
+ head, ext = os.path.splitext(path.strip('/'))
79
+ dirname = os.path.dirname(head)
80
+ filename = os.path.basename(head)
81
+ return os.path.join(dirname, filename.upper() + ext)
82
+
49
83
 
50
84
  class FilterModule(object):
51
85
  '''
@@ -56,6 +90,7 @@ class FilterModule(object):
56
90
  return {
57
91
  'path_join': os.path.join,
58
92
  'path_resolve': resolve,
93
+ 'path_upcase_filename': path_upcase_filename,
59
94
  }
60
95
 
61
96
 
@@ -1,3 +1,22 @@
1
+ # **WARNING**
2
+ #
3
+ # Naming this file `string.py` fucks something up:
4
+ #
5
+ # $ python2 plugins/filter_plugins/path.py
6
+ # Traceback (most recent call last):
7
+ # File "plugins/filter_plugins/path.py", line 17, in <module>
8
+ # from pathlib2 import Path
9
+ # File "/usr/local/lib/python2.7/site-packages/pathlib2.py", line 21, in <module>
10
+ # from urllib import quote as urlquote_from_bytes
11
+ # File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py", line 30, in <module>
12
+ # import base64
13
+ # File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/base64.py", line 98, in <module>
14
+ # _urlsafe_encode_translation = string.maketrans(b'+/', b'-_')
15
+ # AttributeError: 'module' object has no attribute 'maketrans'
16
+ #
17
+ # https://stackoverflow.com/questions/35139025/can-not-handle-attributeerror-module-object-has-no-attribute-maketrans
18
+ #
19
+
1
20
  from __future__ import (absolute_import, division, print_function)
2
21
  __metaclass__ = type
3
22
 
data/qb.gemspec CHANGED
@@ -92,6 +92,7 @@ Gem::Specification.new do |spec|
92
92
  spec.add_development_dependency "rake", "~> 10.0"
93
93
  spec.add_development_dependency "rspec"
94
94
  spec.add_development_dependency "yard"
95
+ spec.add_development_dependency "pry"
95
96
 
96
97
  spec.add_dependency "cmds",'~> 0.0', ">= 0.2.1"
97
98
  spec.add_dependency "nrser",'~> 0.0', ">= 0.0.20"
@@ -1 +1 @@
1
- roles/nrser.blockinfile/tests/expected/test-follow/real2.txt
1
+ real2.txt
@@ -1 +1 @@
1
- roles/nrser.blockinfile/tests/fixtures/test-follow/real0.txt
1
+ real0.txt
@@ -1 +1 @@
1
- roles/nrser.blockinfile/tests/fixtures/test-follow/real1.txt
1
+ real1.txt
@@ -1 +1 @@
1
- roles/nrser.blockinfile/tests/fixtures/test-follow/real2.txt
1
+ real2.txt
@@ -1 +1 @@
1
- roles/nrser.blockinfile/tests/roles/../..
1
+ ../..
@@ -1 +1 @@
1
- roles/qb.gitignore/files/gitignore/Leiningen.gitignore
1
+ Leiningen.gitignore
@@ -1 +1 @@
1
- roles/qb.gitignore/files/gitignore/C++.gitignore
1
+ C++.gitignore
@@ -11,7 +11,7 @@ description: null
11
11
  # generalize in the future.
12
12
  requirements:
13
13
  gems:
14
- qb: ~> 0.1.69
14
+ qb: ~> 0.3.0
15
15
 
16
16
  # prefix for role variables
17
17
  var_prefix: null
@@ -0,0 +1,32 @@
1
+ ---
2
+ # defaults file for qb/ref/repo/git
3
+ project_root: >-
4
+ {{ qb_dir }}
5
+
6
+ version: HEAD
7
+
8
+ host: github.com
9
+
10
+ ssh_user: git
11
+
12
+ protocol: ssh
13
+
14
+ depth: 1
15
+
16
+ update: false
17
+
18
+ owner: >-
19
+ {{ full_name.split('/')[0] }}
20
+
21
+ name: >-
22
+ {{ full_path.split('/')[1] }}
23
+
24
+ full_name: >-
25
+ {{ owner }}/{{ name }}
26
+
27
+ rel_dest: >-
28
+ {{ name }}@{{ version }}
29
+
30
+ dest: >-
31
+ {{ project_root }}/dev/ref/{{ rel_dest }}
32
+
@@ -0,0 +1,8 @@
1
+ ---
2
+ # meta file for qb/ref/repo/git
3
+
4
+ allow_duplicates: yes
5
+
6
+ dependencies: []
7
+ # - role: role-name
8
+
@@ -0,0 +1,67 @@
1
+ ---
2
+ # meta/qb.yml file for qb/ref/repo/git
3
+ #
4
+ # qb settings for this role. see README.md for more info.
5
+ #
6
+
7
+ # description of the role to show in it's help output.
8
+ description: null
9
+
10
+ # Gemspec-style requirements. Right now only `gems:qb` is used, but plan to
11
+ # generalize in the future.
12
+ requirements:
13
+ gems:
14
+ qb: ~> 0.3.0
15
+
16
+ # prefix for role variables
17
+ var_prefix: false
18
+
19
+ # how to get a default for `dir` if it's not provided as the only
20
+ # positional argument. if a positional argument is provided it will
21
+ # override the method defined here.
22
+ #
23
+ # options:
24
+ #
25
+ # - null
26
+ # - require the value on the command line.
27
+ # - false
28
+ # - don't provide qb_dir (means doesn't load or save options either).
29
+ # - git_root
30
+ # - use the git root fof the directory that the `qb` command is invoked
31
+ # from. useful for 'project-centric' commands so they can be invoked
32
+ # from anywhere in the repo.
33
+ # - cwd
34
+ # - use the directory the `qb` command is invoked form.
35
+ # - {exe: PATH}
36
+ # - invoke an execuable, passing a JSON serialization of the options
37
+ # mapping their CLI names to values. path can be relative to role
38
+ # directory.
39
+ # - {find_up: FILENAME}
40
+ # - starting at the current direcotry and climbing up to parent
41
+ # directories, use the first one that contains FILENAME. error
42
+ # if none is found.
43
+ default_dir: null
44
+
45
+ # If `true`, QB will ensure the default dir exists before starting the play.
46
+ #
47
+ # For legacy reasons, this defaults to `true` if not present, but we want to
48
+ # default declare it as `false` here so new roles can turn it on only if
49
+ # they need it.
50
+ #
51
+ mkdir: false
52
+
53
+ # default user to become for play
54
+ default_user: null
55
+
56
+ # set to false to not save options in .qb-options.yml files
57
+ save_options: true
58
+
59
+ # options to pass to ansible-playbook
60
+ ansible_options: {}
61
+
62
+ options: []
63
+ # - name: example
64
+ # description: an example of a variable.
65
+ # required: false
66
+ # type: boolean # boolean (default) | string
67
+ # short: e
@@ -0,0 +1,16 @@
1
+ ---
2
+ # tasks file for qb/ref/repo/git
3
+
4
+ - name: >-
5
+ Clone {{ full_name }}@{{ version }} Git repo for reference.
6
+ git:
7
+ repo: >-
8
+ {{ ssh_user }}@{{ host }}:{{ full_name }}.git
9
+ dest: >-
10
+ {{ dest }}
11
+ version: >-
12
+ {{ version }}
13
+ depth: >-
14
+ {{ depth }}
15
+ update: >-
16
+ {{ update }}
@@ -0,0 +1,3 @@
1
+ ---
2
+ # defaults file for qb/facts
3
+ facts_github_api: false
@@ -1,5 +1,5 @@
1
1
  ---
2
- # meta file for qb.facts
2
+ # meta file for qb/facts
3
3
 
4
4
  allow_duplicates: yes
5
5
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- # meta/qb.yml file for qb.facts
2
+ # meta/qb.yml file for qb/facts
3
3
  #
4
4
  # qb settings for this role. see README.md for more info.
5
5
  #
@@ -1,5 +1,5 @@
1
1
  ---
2
- # tasks file for qb.facts
2
+ # tasks file for qb/facts
3
3
 
4
4
  - path_facts:
5
5
  path: "{{ qb_dir }}"
@@ -0,0 +1,16 @@
1
+ qb/osx/git/change_case Role
2
+ ===========================
3
+
4
+ Changes casing of a file or directory under Git control on OSX.
5
+
6
+ Due to OSX's default file system being *case insensitive* (and changing it to case-sensitive causing all sorts of problems), it's my current understanding that this requires:
7
+
8
+ 1. Changing the name in a way that is recognized by the case-insensitive file system.
9
+
10
+ 2. Committing that change.
11
+
12
+ 3. Changing the name to the desired name.
13
+
14
+ 4. Committing that change.
15
+
16
+ So that's what this role does.
@@ -0,0 +1,2 @@
1
+ ---
2
+ # defaults file for change_case
@@ -0,0 +1,8 @@
1
+ ---
2
+ # meta file for change_case
3
+
4
+ allow_duplicates: yes
5
+
6
+ dependencies: []
7
+ # - role: role-name
8
+
@@ -0,0 +1,80 @@
1
+ ---
2
+ # meta/qb.yml file for change_case
3
+ #
4
+ # qb settings for this role. see README.md for more info.
5
+ #
6
+
7
+ # description of the role to show in it's help output.
8
+ description: >-
9
+ Change casing of a file or directory under Git control on OSX.
10
+
11
+ # Gemspec-style requirements. Right now only `gems:qb` is used, but plan to
12
+ # generalize in the future.
13
+ requirements:
14
+ gems:
15
+ qb: ~> 0.3.0
16
+
17
+ # prefix for role variables
18
+ var_prefix: null
19
+
20
+ # how to get a default for `dir` if it's not provided as the only
21
+ # positional argument. if a positional argument is provided it will
22
+ # override the method defined here.
23
+ #
24
+ # options:
25
+ #
26
+ # - null
27
+ # - require the value on the command line.
28
+ # - false
29
+ # - don't provide qb_dir (means doesn't load or save options either).
30
+ # - git_root
31
+ # - use the git root fof the directory that the `qb` command is invoked
32
+ # from. useful for 'project-centric' commands so they can be invoked
33
+ # from anywhere in the repo.
34
+ # - cwd
35
+ # - use the directory the `qb` command is invoked form.
36
+ # - {exe: PATH}
37
+ # - invoke an execuable, passing a JSON serialization of the options
38
+ # mapping their CLI names to values. path can be relative to role
39
+ # directory.
40
+ # - {find_up: FILENAME}
41
+ # - starting at the current direcotry and climbing up to parent
42
+ # directories, use the first one that contains FILENAME. error
43
+ # if none is found.
44
+ default_dir: false
45
+
46
+ # If `true`, QB will ensure the default dir exists before starting the play.
47
+ #
48
+ # For legacy reasons, this defaults to `true` if not present, but we want to
49
+ # default declare it as `false` here so new roles can turn it on only if
50
+ # they need it.
51
+ #
52
+ mkdir: false
53
+
54
+ # default user to become for play
55
+ default_user: null
56
+
57
+ # set to false to not save options in .qb-options.yml files
58
+ save_options: false
59
+
60
+ # options to pass to ansible-playbook
61
+ ansible_options: {}
62
+
63
+ options:
64
+ # - name: example
65
+ # description: an example of a variable.
66
+ # required: false
67
+ # type: boolean # boolean (default) | string
68
+ # short: e
69
+
70
+ - name: from
71
+ description: >-
72
+ Path or glob of the current files.
73
+ required: true
74
+ type: glob
75
+
76
+ - name: upcase
77
+ description: >-
78
+ Convert all file names to all upper-case.
79
+ require: false
80
+ type: boolean
@@ -0,0 +1,6 @@
1
+ ---
2
+ # tasks file for change_case
3
+
4
+ - when: change_case_upcase
5
+ include: >-
6
+ {{ role_path }}/tasks/upcase.yml
@@ -0,0 +1,26 @@
1
+ ---
2
+
3
+ - name: >-
4
+ Change file names to all upper case.
5
+ with_items: >-
6
+ {{ change_case_from }}
7
+ command: >-
8
+ git mv {{ item }} {{ (item.strip('/') + '.RENAME_TEMP') | quote }}
9
+
10
+ - name: >-
11
+ Commit temp file names in Git.
12
+ command: >-
13
+ git commit -m {{ "Temp file renames when upcasing on OSX" | quote }}
14
+
15
+ - name: >-
16
+ Change file name to desired upper case.
17
+ with_items: >-
18
+ {{ change_case_from }}
19
+ command: >-
20
+ git mv {{ (item.strip('/') + '.RENAME_TEMP') | quote }}
21
+ {{ item | path_upcase_filename }}
22
+
23
+ - name: >-
24
+ Commit final file names in Git.
25
+ command: >-
26
+ git commit -m {{ "Final file renames when upcasing on OSX" | quote }}