qb 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/exe/qb +39 -1
  3. data/lib/qb/cli.rb +104 -1
  4. data/lib/qb/errors.rb +25 -2
  5. data/lib/qb/options.rb +33 -2
  6. data/lib/qb/options/option.rb +1 -0
  7. data/lib/qb/role.rb +53 -21
  8. data/lib/qb/role/errors.rb +3 -3
  9. data/lib/qb/version.rb +1 -1
  10. data/qb.gemspec +1 -1
  11. data/roles/qb.project/tasks/main.yml +1 -0
  12. data/roles/qb.role/defaults/main.yml +3 -1
  13. data/roles/qb/gem/new/defaults/main.yml +12 -0
  14. data/roles/{qb.git_check_clean → qb/gem/new}/meta/main.yml +1 -1
  15. data/roles/qb/gem/new/meta/qb.yml +90 -0
  16. data/roles/qb/gem/new/tasks/bundle_gem.yml +97 -0
  17. data/roles/qb/gem/new/tasks/main.yml +22 -0
  18. data/roles/qb/gem/release/defaults/main.yml +5 -0
  19. data/roles/{qb.release_gem → qb/gem/release}/meta/main.yml +1 -1
  20. data/roles/{qb.release_gem → qb/gem/release}/meta/qb.yml +2 -2
  21. data/roles/{qb.release_gem → qb/gem/release}/tasks/main.yml +57 -35
  22. data/roles/qb/git/check/clean/README.md +4 -0
  23. data/roles/qb/git/check/clean/meta/main.yml +8 -0
  24. data/roles/{qb.git_check_clean → qb/git/check/clean}/tasks/main.yml +5 -5
  25. data/roles/qb/osx/notif/defaults/main.yml +4 -0
  26. data/roles/qb/osx/notif/meta/main.yml +8 -0
  27. data/roles/qb/osx/notif/meta/qb.yml +81 -0
  28. data/roles/qb/osx/notif/tasks/main.yml +14 -0
  29. metadata +20 -32
  30. data/roles/qb.gem/.qb-options.yml +0 -4
  31. data/roles/qb.gem/defaults/main.yml +0 -17
  32. data/roles/qb.gem/files/.gitkeep +0 -0
  33. data/roles/qb.gem/files/.rspec +0 -2
  34. data/roles/qb.gem/files/Rakefile +0 -6
  35. data/roles/qb.gem/files/setup +0 -7
  36. data/roles/qb.gem/filter_plugins/ruby_constantize.py +0 -22
  37. data/roles/qb.gem/meta/main.yml +0 -8
  38. data/roles/qb.gem/meta/qb.yml +0 -26
  39. data/roles/qb.gem/tasks/main.yml +0 -105
  40. data/roles/qb.gem/templates/.gitkeep +0 -0
  41. data/roles/qb.gem/templates/.travis.yml.j2 +0 -4
  42. data/roles/qb.gem/templates/BSD2-LICENSE.txt.j2 +0 -23
  43. data/roles/qb.gem/templates/BSD3-LICENSE.txt.j2 +0 -27
  44. data/roles/qb.gem/templates/Gemfile.j2 +0 -4
  45. data/roles/qb.gem/templates/MIT-LICENSE.txt.j2 +0 -21
  46. data/roles/qb.gem/templates/console.j2 +0 -14
  47. data/roles/qb.gem/templates/gemspec.j2 +0 -36
  48. data/roles/qb.gem/templates/module.rb.j2 +0 -5
  49. data/roles/qb.gem/templates/spec.rb.j2 +0 -11
  50. data/roles/qb.gem/templates/spec_helper.rb.j2 +0 -2
  51. data/roles/qb.gem/templates/version.rb.j2 +0 -3
  52. data/roles/qb.release_gem/defaults/main.yml +0 -2
@@ -4,7 +4,7 @@ module QB
4
4
 
5
5
  GEM_NAME = 'qb'
6
6
 
7
- VERSION = "0.3.1"
7
+ VERSION = "0.3.2"
8
8
 
9
9
  MIN_ANSIBLE_VERSION = Gem::Version.new '2.1.2'
10
10
 
data/qb.gemspec CHANGED
@@ -95,7 +95,7 @@ Gem::Specification.new do |spec|
95
95
  spec.add_development_dependency "pry"
96
96
 
97
97
  spec.add_dependency "cmds",'~> 0.0', ">= 0.2.1"
98
- spec.add_dependency "nrser",'~> 0.0', ">= 0.0.20"
98
+ spec.add_dependency "nrser",'~> 0.0', ">= 0.0.21"
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'
@@ -29,6 +29,7 @@
29
29
  lineinfile:
30
30
  line: /tmp
31
31
  dest: "{{ project_dest }}/.gitignore"
32
+ create: true
32
33
  when: project_tmp
33
34
 
34
35
  # readme
@@ -1,8 +1,10 @@
1
1
  ---
2
2
  role_dest: "{{ qb_dir }}"
3
3
  role_force: false
4
- # can't be named `role_name` 'cause ansible sets that?
4
+
5
+ # can't be named `role_name` 'cause Ansible sets that?
5
6
  role_role_name: "{{ role_dest | basename }}"
7
+
6
8
  role_defaults: true
7
9
  role_files: false
8
10
  role_handlers: false
@@ -0,0 +1,12 @@
1
+ ---
2
+ # defaults file for qb/gem/new
3
+
4
+ gem_is_project: false
5
+
6
+ gem_root: >-
7
+ {{ qb_dir }}
8
+
9
+ gem_name: >-
10
+ {{ gem_root | basename }}
11
+
12
+ force: false
@@ -1,5 +1,5 @@
1
1
  ---
2
- # meta file for qb.git_check_clean
2
+ # meta file for qb/gem/new
3
3
 
4
4
  allow_duplicates: yes
5
5
 
@@ -0,0 +1,90 @@
1
+ ---
2
+ # meta/qb.yml file for qb/gem/new
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
+ Create a new Ruby gem, optionally as it's own project.
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: gem
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: null
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: true
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: name
71
+ description: >-
72
+ Name of the new gem.
73
+ type: string
74
+ short: n
75
+
76
+ - name: is_project
77
+ description: >-
78
+ Structure the gem as a project.
79
+ type: boolean
80
+ short: p
81
+
82
+ - include: qb.project
83
+ as: false
84
+
85
+ - name: force
86
+ var_name: force
87
+ description: >-
88
+ Override existing files with newly generated ones.
89
+ type: boolean
90
+ short: f
@@ -0,0 +1,97 @@
1
+ ---
2
+ # Run `bundle gem <gem_name>` targeting a temp directory, then merge the
3
+ # results into `gem_root`.
4
+
5
+ - name: >-
6
+ Create a tempdir to run `bundle gem {{ gem_name }}` in.
7
+ tempfile:
8
+ state: directory
9
+ suffix: gem
10
+ register: tempdir
11
+ changed_when: false
12
+
13
+
14
+ - name: >-
15
+ Run `bundle gem {{ gem_name }}` in tempdir `{{ tempdir.path }}`.
16
+ stream:
17
+ cmd: >-
18
+ bundle gem %{gem_name}
19
+ kwds:
20
+ gem_name: >-
21
+ {{ gem_name }}
22
+ chdir: >-
23
+ {{ tempdir.path }}
24
+ changed_when: false
25
+
26
+
27
+ - name: >-
28
+ Get rid of the `.git` directory and `.gitignore` file since we don't want
29
+ to merge them.
30
+ with_items:
31
+ - .git
32
+ - .gitignore
33
+ file:
34
+ path: >-
35
+ {{ tempdir.path | path_join(gem_name, item) }}
36
+ state: absent
37
+ changed_when: false
38
+
39
+
40
+ - name: >-
41
+ Create destination directories in gem root `{{ gem_root }}`.
42
+ with_filetree: >-
43
+ {{ tempdir.path | path_join(gem_name) }}
44
+ when: item.state == 'directory'
45
+ file:
46
+ dest: >-
47
+ {{ gem_root | path_join(item.path) }}
48
+ state: directory
49
+ changed_when: false
50
+
51
+
52
+ - name: >-
53
+ Copy files from tempdir to gem root `{{ gem_root }}`.
54
+ with_filetree: >-
55
+ {{ tempdir.path | path_join(gem_name) }}
56
+ when: item.state == 'file'
57
+ copy:
58
+ src: >-
59
+ {{ item.src }}
60
+ dest: >-
61
+ {{ gem_root | path_join(item.path) }}
62
+ force: >-
63
+ {{ force }}
64
+
65
+
66
+ # Prob don't need this, but what the hell...
67
+ #
68
+ # From
69
+ #
70
+ # http://docs.ansible.com/ansible/latest/playbooks_loops.html#looping-over-filetrees
71
+ #
72
+ # along with the rest of it. Seem to work for relative symlinks.
73
+ #
74
+ - name: >-
75
+ Recreate symlinks from tempdir to gem root `{{ gem_root }}`.
76
+ with_filetree: >-
77
+ {{ tempdir.path | path_join(gem_name) }}
78
+ when: item.state == 'link'
79
+ file:
80
+ src: >-
81
+ {{ item.src }}
82
+ dest: >-
83
+ {{ gem_root | path_join(item.path) }}
84
+ state: link
85
+ force: >-
86
+ {{ force }}
87
+ mode: >-
88
+ {{ item.mode }}
89
+
90
+
91
+ - name: >-
92
+ Remove the temp dir at `{{ tempdir.path }}`.
93
+ file:
94
+ path: >-
95
+ {{ tempdir.path }}
96
+ state: absent
97
+ changed_when: false
@@ -0,0 +1,22 @@
1
+ ---
2
+ # tasks file for qb/gem/new
3
+
4
+ - include: >-
5
+ {{ role_path }}/tasks/bundle_gem.yml
6
+
7
+ - name: >-
8
+ Add gitignore blocks.
9
+ with_items:
10
+ - Ruby
11
+ - Gem
12
+ include_role:
13
+ name: qb.gitignore
14
+ vars:
15
+ gitignore_name: >-
16
+ {{ item }}
17
+
18
+ - when: gem_is_project
19
+ name: >-
20
+ Include `qb.project` role.
21
+ include_role:
22
+ name: qb.project
@@ -0,0 +1,5 @@
1
+ ---
2
+ # defaults file for qb/gem/release
3
+
4
+ gem_root: >-
5
+ {{ qb_dir }}
@@ -1,5 +1,5 @@
1
1
  ---
2
- # meta file for qb.release_gem
2
+ # meta file for qb/gem/release
3
3
 
4
4
  allow_duplicates: yes
5
5
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- # meta/qb.yml file for qb.release_gem
2
+ # meta/qb.yml file for qb/gem/release
3
3
  #
4
4
  # qb settings for this role. see README.md for more info.
5
5
  #
@@ -10,7 +10,7 @@ var_prefix: null
10
10
  # how to get a default for `dir` if it's not provided as the
11
11
  default_dir: null
12
12
 
13
- # set to false to not save options in /Users/nrser/dev/gh/nrser/qb/roles/qb.release_gem/.qb-options.yml
13
+ # set to false to not save options in /Users/nrser/dev/gh/nrser/qb/roles/qb/gem/release/.qb-options.yml
14
14
  save_options: true
15
15
 
16
16
  vars: []
@@ -1,13 +1,31 @@
1
1
  ---
2
- # tasks file for qb.release_gem
2
+ # tasks file for qb/gem/release
3
3
 
4
- - name: get gem and version info
4
+ - name: >-
5
+ Check that the git repo at {{ gem_root }} is clean.
6
+ include_role:
7
+ name: qb/git/check/clean
8
+ vars:
9
+ git_root: >-
10
+ {{ gem_root }}
11
+
12
+
13
+ - name: >-
14
+ Do a `bundle install`.
15
+ bundler:
16
+ state: present
17
+ chdir: >-
18
+ {{ gem_root }}
19
+
20
+
21
+ - name: >-
22
+ Get gem and version info
5
23
  vars.rb:
6
- namespace: release_gem
24
+ namespace: gem
7
25
  bind:
8
- qb_dir: "{{ qb_dir }}"
26
+ gem_root: "{{ gem_root }}"
9
27
  src: |
10
- spec_pattern = "#{ qb_dir }/*.gemspec"
28
+ spec_pattern = "#{ gem_root }/*.gemspec"
11
29
  spec_path = Dir.glob(spec_pattern)[0]
12
30
 
13
31
  if spec_path.nil?
@@ -50,68 +68,72 @@
50
68
  'current_version' => version.version,
51
69
  'release_version' => version.release,
52
70
  'next_version' => next_version,
53
- 'version_path' => "#{ qb_dir }/lib/#{ name }/version.rb",
71
+ 'version_path' => "#{ gem_root }/lib/#{ name }/version.rb",
54
72
  'spec_path' => spec_path,
55
73
  }
56
74
 
57
75
  - debug:
58
76
  msg:
59
77
  # - spec_path: >-
60
- # {{ release_gem_spec_path }}
78
+ # {{ gem_spec_path }}
61
79
  # - version_path: >-
62
- # {{ release_gem_version_path }}
80
+ # {{ gem_version_path }}
63
81
  - current: >-
64
- {{ release_gem_current_version }}
82
+ {{ gem_current_version }}
65
83
  - release: >-
66
- {{ release_gem_release_version }}
84
+ {{ gem_release_version }}
67
85
  - next: >-
68
- {{ release_gem_next_version }}
86
+ {{ gem_next_version }}
69
87
 
70
- - name: "change version to release version {{ release_gem_release_version }}"
88
+ - name: "change version to release version {{ gem_release_version }}"
71
89
  replace:
72
- dest: "{{ release_gem_version_path }}"
73
- regexp: "VERSION\\s*=\\s*\"{{ release_gem_current_version }}\""
74
- replace: "VERSION = \"{{ release_gem_release_version }}\""
75
- when: release_gem_current_version != release_gem_release_version
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
+
76
95
 
77
- - name: add release version to git
78
- command: "git add {{ release_gem_version_path }}"
96
+ - name: >-
97
+ Add version file {{ gem_version_path }} to Git.
98
+ command: "git add {{ gem_version_path }}"
79
99
  args:
80
- chdir: "{{ qb_dir }}"
81
- when: release_gem_current_version != release_gem_release_version
100
+ chdir: "{{ gem_root }}"
101
+ when: gem_current_version != gem_release_version
102
+
82
103
 
83
- - name: commit release version
84
- command: git commit -m "bump to v{{ release_gem_release_version }}"
104
+ - name: >-
105
+ Commit version file {{ gem_version_path }} in Git.
106
+ command: git commit -m "bump to v{{ gem_release_version }}"
85
107
  args:
86
- chdir: "{{ qb_dir }}"
87
- when: release_gem_current_version != release_gem_release_version
108
+ chdir: "{{ gem_root }}"
109
+ when: gem_current_version != gem_release_version
88
110
 
89
111
  - name: release with bundler
90
112
  shell: bundle exec rake release
91
113
  args:
92
- chdir: "{{ qb_dir }}"
114
+ chdir: "{{ gem_root }}"
93
115
 
94
- - name: "change version to next version {{ release_gem_next_version }}"
116
+ - name: "change version to next version {{ gem_next_version }}"
95
117
  replace:
96
- dest: "{{ release_gem_version_path }}"
97
- regexp: "VERSION\\s*=\\s*\"{{ release_gem_release_version }}\""
98
- replace: "VERSION = \"{{ release_gem_next_version }}\""
118
+ dest: "{{ gem_version_path }}"
119
+ regexp: "VERSION\\s*=\\s*\"{{ gem_release_version }}\""
120
+ replace: "VERSION = \"{{ gem_next_version }}\""
99
121
 
100
122
  - name: add next dev version to git
101
- command: "git add {{ release_gem_version_path }}"
123
+ command: "git add {{ gem_version_path }}"
102
124
  args:
103
- chdir: "{{ qb_dir }}"
125
+ chdir: "{{ gem_root }}"
104
126
 
105
127
  - name: commit next dev version
106
- command: git commit -m "start {{ release_gem_next_version }}"
128
+ command: git commit -m "start {{ gem_next_version }}"
107
129
  args:
108
- chdir: "{{ qb_dir }}"
130
+ chdir: "{{ gem_root }}"
109
131
 
110
132
  - name: push next dev version
111
133
  command: git push
112
134
  args:
113
- chdir: "{{ qb_dir }}"
135
+ chdir: "{{ gem_root }}"
114
136
 
115
137
  - debug:
116
138
  msg: >
117
- v{{ release_gem_release_version }} released.
139
+ v{{ gem_release_version }} released.
@@ -0,0 +1,4 @@
1
+ qb/git/check/clean Role
2
+ ========================================================================
3
+
4
+ Fails if `git_root` is not clean of modified and uncommitted files.