qb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +146 -0
  3. data/.qb-options.yml +4 -0
  4. data/.rspec +2 -0
  5. data/.travis.yml +4 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +4 -0
  9. data/Rakefile +6 -0
  10. data/ansible.cfg +5 -0
  11. data/bin/console +14 -0
  12. data/bin/qb +287 -0
  13. data/bin/setup +9 -0
  14. data/dev/bin/.gitkeep +0 -0
  15. data/dev/bin/ungem +19 -0
  16. data/dev/setup.yml +58 -0
  17. data/lib/qb.rb +5 -0
  18. data/lib/qb/version.rb +3 -0
  19. data/library/git_mkdir.py +70 -0
  20. data/library/qb_facts.py +38 -0
  21. data/qb.gemspec +27 -0
  22. data/requirements.yml +2 -0
  23. data/roles/qb.gem/.qb-options.yml +4 -0
  24. data/roles/qb.gem/defaults/main.yml +17 -0
  25. data/roles/qb.gem/files/.gitkeep +0 -0
  26. data/roles/qb.gem/files/.rspec +2 -0
  27. data/roles/qb.gem/files/Rakefile +6 -0
  28. data/roles/qb.gem/files/setup +7 -0
  29. data/roles/qb.gem/filter_plugins/ruby_constantize.py +22 -0
  30. data/roles/qb.gem/meta/main.yml +35 -0
  31. data/roles/qb.gem/tasks/main.yml +105 -0
  32. data/roles/qb.gem/templates/.gitkeep +0 -0
  33. data/roles/qb.gem/templates/.travis.yml.j2 +4 -0
  34. data/roles/qb.gem/templates/BSD2-LICENSE.txt.j2 +23 -0
  35. data/roles/qb.gem/templates/BSD3-LICENSE.txt.j2 +27 -0
  36. data/roles/qb.gem/templates/Gemfile.j2 +4 -0
  37. data/roles/qb.gem/templates/MIT-LICENSE.txt.j2 +21 -0
  38. data/roles/qb.gem/templates/console.j2 +14 -0
  39. data/roles/qb.gem/templates/gemspec.j2 +36 -0
  40. data/roles/qb.gem/templates/module.rb.j2 +5 -0
  41. data/roles/qb.gem/templates/spec.rb.j2 +11 -0
  42. data/roles/qb.gem/templates/spec_helper.rb.j2 +2 -0
  43. data/roles/qb.gem/templates/version.rb.j2 +3 -0
  44. data/roles/qb.git_repo/defaults/main.yml +2 -0
  45. data/roles/qb.git_repo/meta/main.yml +5 -0
  46. data/roles/qb.git_repo/tasks/main.yml +9 -0
  47. data/roles/qb.gitignore/defaults/main.yml +4 -0
  48. data/roles/qb.gitignore/meta/main.yml +12 -0
  49. data/roles/qb.gitignore/tasks/main.yml +31 -0
  50. data/roles/qb.project/.qb-options.yml +3 -0
  51. data/roles/qb.project/defaults/main.yml +12 -0
  52. data/roles/qb.project/meta/main.yml +49 -0
  53. data/roles/qb.project/qb/get_dir +13 -0
  54. data/roles/qb.project/tasks/main.yml +102 -0
  55. data/roles/qb.project/templates/.gitkeep +0 -0
  56. data/roles/qb.project/templates/README.md.j2 +2 -0
  57. data/roles/qb.project/templates/setup.yml.j2 +52 -0
  58. data/roles/qb.role/.qb-options.yml +3 -0
  59. data/roles/qb.role/defaults/main.yml +9 -0
  60. data/roles/qb.role/meta/main.yml +31 -0
  61. data/roles/qb.role/tasks/main.yml +117 -0
  62. data/roles/qb.role/templates/.gitkeep +0 -0
  63. data/roles/qb.role/templates/defaults/main.yml.j2 +2 -0
  64. data/roles/qb.role/templates/handlers/main.yml.j2 +2 -0
  65. data/roles/qb.role/templates/meta/main.yml.j2 +5 -0
  66. data/roles/qb.role/templates/tasks/main.yml.j2 +2 -0
  67. data/roles/qb.role/templates/vars/main.yml.j2 +2 -0
  68. data/scratch/case.rb +38 -0
  69. data/temp.yml +19 -0
  70. metadata +169 -0
File without changes
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - {{ gem_ruby_version.stdout }}
4
+ before_install: gem install bundler -v {{ gem_bundler_version.stdout | regex_replace('.*(\d+\.\d+\.\d+)$', '\\1') }}
@@ -0,0 +1,23 @@
1
+ Copyright (c) {{ ansible_date_time.year }}, {{ gem_authors | join(',') }}
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,27 @@
1
+ Copyright (c) {{ ansible_date_time.year }}, {{ gem_authors | join(',') }}
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ * Neither the name of {{ gem_authors | join(',') }} nor the names of its
15
+ contributors may be used to endorse or promote products derived from
16
+ this software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in {{ gem_name }}.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) {{ ansible_date_time.year }} {{ gem_authors | join(',') }}
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "{{ gem_dirname }}"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require '{{ gem_dirname }}/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "{{ gem_name }}"
8
+ spec.version = {{ gem_constant }}::VERSION
9
+ spec.authors = {{ gem_authors | to_json }}
10
+ spec.email = {{ gem_emails | to_json }}
11
+
12
+ spec.summary = %q{TODO: Write a short summary, because Rubygems requires one.}
13
+ spec.description = %q{TODO: Write a longer description or delete this line.}
14
+ spec.homepage = "https://github.com/{{ git_user_name }}/{{ dir | basename }}"
15
+ {% if gem_license is defined -%}
16
+ spec.license = "{{ gem_license }}"
17
+ {%- endif %}
18
+
19
+ {% if gem_allowed_push_host is defined -%}
20
+ # Prevent pushing this gem to RubyGems.org
21
+ if spec.respond_to?(:metadata)
22
+ spec.metadata['allowed_push_host'] = "{{ gem_allowed_push_host }}"
23
+ else
24
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
25
+ end
26
+ {%- endif %}
27
+
28
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.10"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec"
36
+ end
@@ -0,0 +1,5 @@
1
+ require "{{ gem_dirname }}/version"
2
+
3
+ module {{ gem_constant }}
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe {{ gem_constant }} do
4
+ it 'has a version number' do
5
+ expect({{ gem_constant }}::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require '{{ gem_dirname }}'
@@ -0,0 +1,3 @@
1
+ module {{ gem_constant }}
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ # defaults file for qb.git_repo
@@ -0,0 +1,5 @@
1
+ ---
2
+ # meta file for qb.git_repo
3
+
4
+ dependencies: []
5
+ # - role: role-name
@@ -0,0 +1,9 @@
1
+ ---
2
+ # tasks file for qb.git_repo
3
+
4
+ - name: initialize git
5
+ command: git init
6
+ args:
7
+ chdir: "{{ dir }}"
8
+ creates: "{{ dir }}/.git"
9
+
@@ -0,0 +1,4 @@
1
+ ---
2
+ # defaults file for qb.gitignore
3
+
4
+ gitignore_update: false
@@ -0,0 +1,12 @@
1
+ ---
2
+ # meta file for qb.gitignore
3
+
4
+ dependencies:
5
+ - role: qb.git_repo
6
+
7
+ qb_info:
8
+ vars:
9
+ - name: name
10
+ desciption: name of gitignore
11
+ required: true
12
+ type: string
@@ -0,0 +1,31 @@
1
+ ---
2
+ # tasks file for qb.gitignore
3
+
4
+ - name: check out nrser/gitignore
5
+ git:
6
+ repo: git@github.com:nrser/gitignore.git
7
+ dest: ./tmp/gitignore
8
+ version: master
9
+ depth: 1
10
+ update: "{{ gitignore_update }}"
11
+
12
+ - name: create .gitignore
13
+ copy:
14
+ content: ''
15
+ dest: "{{ dir }}/.gitignore"
16
+ force: false
17
+ register: gitignore_created
18
+
19
+ - name: add the gitignore
20
+ blockinfile:
21
+ content: "{{ lookup('file', './tmp/gitignore/' + gitignore_name + '.gitignore') }}"
22
+ dest: "{{ dir }}/.gitignore"
23
+ marker: "# {mark} {{ gitignore_name }}.gitignore"
24
+ register: gitignore_added
25
+
26
+ - command: git add -f .gitignore
27
+ args:
28
+ chdir: "{{ dir }}"
29
+ when: >
30
+ gitignore_created.changed or
31
+ gitignore_added.changed
@@ -0,0 +1,3 @@
1
+ ---
2
+ qb.role:
3
+ templates: true
@@ -0,0 +1,12 @@
1
+ ---
2
+ # defaults file for qb.project
3
+ project_owner: "{{ ansible_env.GITHUB_USER }}"
4
+ project_name: "{{ dir | realpath | basename }}"
5
+ project_bin: true
6
+ project_dev: true
7
+ project_setup: true
8
+ project_scratch: true
9
+ project_tmp: true
10
+ project_readme: true
11
+ project_hub: false
12
+ project_private: true
@@ -0,0 +1,49 @@
1
+ ---
2
+ # meta file for qb.project
3
+
4
+ dependencies:
5
+ - role: qb.gitignore
6
+ gitignore_name: Global/OSX
7
+
8
+ qb_info:
9
+ vars:
10
+ - name: owner
11
+ desciption: github owner of directory
12
+ type: string
13
+
14
+ - name: name
15
+ description: github name of directory
16
+ type: string
17
+
18
+ - name: bin
19
+ description: create a /bin directory
20
+ type: boolean
21
+
22
+ - name: dev
23
+ description: create a /dev directory
24
+ type: boolean
25
+
26
+ - name: setup
27
+ description: create a /dev/setup.yml playbook
28
+ type: boolean
29
+
30
+ - name: scratch
31
+ description: create a /scratch directory
32
+ type: boolean
33
+
34
+ - name: tmp
35
+ description: create a /tmp directory
36
+ type: boolean
37
+
38
+ - name: readme
39
+ description: create a /README.md file
40
+ type: boolean
41
+
42
+ - name: hub
43
+ description: run `hub create` in the directory
44
+ type: boolean
45
+
46
+ - name: private
47
+ description: create as private when using hub
48
+ type: boolean
49
+
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'json'
4
+ require 'pp'
5
+
6
+ options = JSON.parse STDIN.read
7
+
8
+ name = options['name']
9
+ owner = options['owner'] || ENV.fetch('GITHUB_USER')
10
+
11
+ abort unless name
12
+
13
+ puts "#{ ENV.fetch('GITHUB_ROOT') }/#{ owner }/#{ name }"
@@ -0,0 +1,102 @@
1
+ ---
2
+ # tasks file for qb.project
3
+
4
+ # bin
5
+ # ===
6
+
7
+ - name: create /bin directory
8
+ git_mkdir:
9
+ path: "{{ dir }}/bin"
10
+ when: project_bin
11
+
12
+ # dev
13
+ # ===
14
+
15
+ - name: create /dev and /dev/bin directories
16
+ git_mkdir:
17
+ path: "{{ dir }}/dev/bin"
18
+ when: project_dev
19
+
20
+ # setup
21
+ # =====
22
+
23
+ - name: create /dev/setup.yml
24
+ template:
25
+ src: setup.yml.j2
26
+ dest: "{{ dir }}/dev/setup.yml"
27
+ force: false
28
+ when: project_setup
29
+ register: setup_yml
30
+
31
+ - command: git add dev/setup.yml
32
+ args:
33
+ chdir: "{{ dir }}"
34
+ when: setup_yml.changed
35
+
36
+ - name: ignore /dev/repos in git
37
+ lineinfile:
38
+ line: /dev/repos
39
+ dest: "{{ dir }}/.gitignore"
40
+ register: ignore_dev_repos
41
+
42
+ - name: ignore /dev/ref/repos in git
43
+ lineinfile:
44
+ line: /dev/ref/repos
45
+ dest: "{{ dir }}/.gitignore"
46
+ register: ignore_dev_ref_repos
47
+
48
+ # scratch
49
+ # =======
50
+
51
+ - name: create scratch directory
52
+ git_mkdir:
53
+ path: "{{ dir }}/scratch"
54
+
55
+ # tmp
56
+ # ===
57
+
58
+ - name: create tmp directory
59
+ git_mkdir:
60
+ path: "{{ dir }}/tmp"
61
+
62
+ - name: ignore tmp dir in git
63
+ lineinfile:
64
+ line: /tmp
65
+ dest: "{{ dir }}/.gitignore"
66
+ register: ignore_tmp
67
+
68
+ # readme
69
+ # ======
70
+
71
+ - name: create readme
72
+ template:
73
+ src: README.md.j2
74
+ dest: "{{ dir }}/README.md"
75
+ force: false
76
+ when: project_readme
77
+ register: readme
78
+
79
+ - command: git add README.md
80
+ args:
81
+ chdir: "{{ dir }}"
82
+ when: readme.changed
83
+
84
+ # hub
85
+ # ===
86
+
87
+ - name: run `hub create`
88
+ command: "hub create{% if project_private %} -p{% endif %}"
89
+ args:
90
+ chdir: "{{ dir }}"
91
+ when: project_hub
92
+
93
+ # postamble
94
+ # =========
95
+
96
+ - command: git add .gitignore
97
+ args:
98
+ chdir: "{{ dir }}"
99
+ when: >
100
+ ignore_dev_repos.changed or
101
+ ignore_dev_ref_repos.changed or
102
+ ignore_tmp.changed
File without changes
@@ -0,0 +1,2 @@
1
+ {{ project_name }}
2
+ {{ "=" * project_name|length }}
@@ -0,0 +1,52 @@
1
+ ---
2
+ # playbook to setup the dev env for this repo
3
+ - name: dev setup for {{ project_owner }}/{{ project_name }}
4
+ {% raw %}
5
+ hosts: localhost
6
+
7
+ vars:
8
+ # repos that are co-developed
9
+ repos: []
10
+ # example:
11
+ # - owner: nrser
12
+ # name: qb
13
+
14
+ # repos that are used for reference only
15
+ ref_repos: []
16
+ # example:
17
+ # - owner: ansible
18
+ # name: ansible
19
+ # version: v1.9.4-1
20
+ # dir_name: ansible-v1.9.4
21
+ # depth: 1
22
+
23
+ tasks:
24
+ - name: clone co-dev repos
25
+ git:
26
+ repo: git@github.com:{{ item.owner }}/{{ item.name }}.git
27
+ dest: ./repos/{{ item.dir_name | default(item.name) }}
28
+ version: "{{ item.version | default('HEAD') }}"
29
+ update: no
30
+ with_items: repos
31
+
32
+ - name: see if the repos have a Gemfile
33
+ stat:
34
+ path: "./repos/{{ item.dir_name | default(item.name) }}/Gemfile"
35
+ with_items: repos
36
+ register: gemfile_stats
37
+
38
+ - name: install bunlde for any that have a Gemfile
39
+ shell: bash -lc "bundle install --path=./.bundle"
40
+ args:
41
+ chdir: "{{ item.invocation.module_complex_args.path | dirname }}"
42
+ when: item.stat.exists
43
+ with_items: gemfile_stats.results | default([])
44
+
45
+ - name: clone ref repos
46
+ git:
47
+ repo: git@github.com:{{ item.owner }}/{{ item.name }}.git
48
+ dest: ./ref/repos/{{ item.dir_name | default(item.name) }}
49
+ version: "{{ item.version | default('HEAD') }}"
50
+ depth: "{{ item.depth | default(0) }}"
51
+ with_items: ref_repos
52
+ {% endraw %}