qb 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +146 -0
- data/.qb-options.yml +4 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +4 -0
- data/Rakefile +6 -0
- data/ansible.cfg +5 -0
- data/bin/console +14 -0
- data/bin/qb +287 -0
- data/bin/setup +9 -0
- data/dev/bin/.gitkeep +0 -0
- data/dev/bin/ungem +19 -0
- data/dev/setup.yml +58 -0
- data/lib/qb.rb +5 -0
- data/lib/qb/version.rb +3 -0
- data/library/git_mkdir.py +70 -0
- data/library/qb_facts.py +38 -0
- data/qb.gemspec +27 -0
- data/requirements.yml +2 -0
- data/roles/qb.gem/.qb-options.yml +4 -0
- data/roles/qb.gem/defaults/main.yml +17 -0
- data/roles/qb.gem/files/.gitkeep +0 -0
- data/roles/qb.gem/files/.rspec +2 -0
- data/roles/qb.gem/files/Rakefile +6 -0
- data/roles/qb.gem/files/setup +7 -0
- data/roles/qb.gem/filter_plugins/ruby_constantize.py +22 -0
- data/roles/qb.gem/meta/main.yml +35 -0
- data/roles/qb.gem/tasks/main.yml +105 -0
- data/roles/qb.gem/templates/.gitkeep +0 -0
- data/roles/qb.gem/templates/.travis.yml.j2 +4 -0
- data/roles/qb.gem/templates/BSD2-LICENSE.txt.j2 +23 -0
- data/roles/qb.gem/templates/BSD3-LICENSE.txt.j2 +27 -0
- data/roles/qb.gem/templates/Gemfile.j2 +4 -0
- data/roles/qb.gem/templates/MIT-LICENSE.txt.j2 +21 -0
- data/roles/qb.gem/templates/console.j2 +14 -0
- data/roles/qb.gem/templates/gemspec.j2 +36 -0
- data/roles/qb.gem/templates/module.rb.j2 +5 -0
- data/roles/qb.gem/templates/spec.rb.j2 +11 -0
- data/roles/qb.gem/templates/spec_helper.rb.j2 +2 -0
- data/roles/qb.gem/templates/version.rb.j2 +3 -0
- data/roles/qb.git_repo/defaults/main.yml +2 -0
- data/roles/qb.git_repo/meta/main.yml +5 -0
- data/roles/qb.git_repo/tasks/main.yml +9 -0
- data/roles/qb.gitignore/defaults/main.yml +4 -0
- data/roles/qb.gitignore/meta/main.yml +12 -0
- data/roles/qb.gitignore/tasks/main.yml +31 -0
- data/roles/qb.project/.qb-options.yml +3 -0
- data/roles/qb.project/defaults/main.yml +12 -0
- data/roles/qb.project/meta/main.yml +49 -0
- data/roles/qb.project/qb/get_dir +13 -0
- data/roles/qb.project/tasks/main.yml +102 -0
- data/roles/qb.project/templates/.gitkeep +0 -0
- data/roles/qb.project/templates/README.md.j2 +2 -0
- data/roles/qb.project/templates/setup.yml.j2 +52 -0
- data/roles/qb.role/.qb-options.yml +3 -0
- data/roles/qb.role/defaults/main.yml +9 -0
- data/roles/qb.role/meta/main.yml +31 -0
- data/roles/qb.role/tasks/main.yml +117 -0
- data/roles/qb.role/templates/.gitkeep +0 -0
- data/roles/qb.role/templates/defaults/main.yml.j2 +2 -0
- data/roles/qb.role/templates/handlers/main.yml.j2 +2 -0
- data/roles/qb.role/templates/meta/main.yml.j2 +5 -0
- data/roles/qb.role/templates/tasks/main.yml.j2 +2 -0
- data/roles/qb.role/templates/vars/main.yml.j2 +2 -0
- data/scratch/case.rb +38 -0
- data/temp.yml +19 -0
- metadata +169 -0
data/bin/setup
ADDED
data/dev/bin/.gitkeep
ADDED
File without changes
|
data/dev/bin/ungem
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
[
|
6
|
+
'bin/console',
|
7
|
+
'bin/setup',
|
8
|
+
'lib',
|
9
|
+
'spec',
|
10
|
+
'.rspec',
|
11
|
+
'.travis.yml',
|
12
|
+
'Gemfile',
|
13
|
+
'LICENSE.txt',
|
14
|
+
'qb.gemspec',
|
15
|
+
'Rakefile',
|
16
|
+
].each do |path|
|
17
|
+
`git reset HEAD #{ path }`
|
18
|
+
FileUtils.rm_rf path
|
19
|
+
end
|
data/dev/setup.yml
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
---
|
2
|
+
# playbook to setup the dev env for this repo
|
3
|
+
- name: dev setup for nrser/qb
|
4
|
+
|
5
|
+
hosts: localhost
|
6
|
+
|
7
|
+
vars:
|
8
|
+
# repos that are co-developed
|
9
|
+
repos:
|
10
|
+
- owner: nrser
|
11
|
+
name: gitignore
|
12
|
+
|
13
|
+
# repos that are used for reference only
|
14
|
+
ref_repos:
|
15
|
+
- owner: ansible
|
16
|
+
name: ansible
|
17
|
+
version: v1.9.4-1
|
18
|
+
dir_name: ansible-v1.9.4
|
19
|
+
depth: 1
|
20
|
+
|
21
|
+
- owner: nrser
|
22
|
+
name: nrser.env
|
23
|
+
|
24
|
+
- owner: beiarea
|
25
|
+
name: workstations
|
26
|
+
|
27
|
+
- owner: nrser
|
28
|
+
name: ansible-nrser.profile
|
29
|
+
|
30
|
+
tasks:
|
31
|
+
- name: clone co-dev repos
|
32
|
+
git:
|
33
|
+
repo: git@github.com:{{ item.owner }}/{{ item.name }}.git
|
34
|
+
dest: ./repos/{{ item.dir_name | default(item.name) }}
|
35
|
+
version: "{{ item.version | default('HEAD') }}"
|
36
|
+
update: no
|
37
|
+
with_items: repos
|
38
|
+
|
39
|
+
- name: see if the repos have a Gemfile
|
40
|
+
stat:
|
41
|
+
path: "./repos/{{ item.dir_name | default(item.name) }}/Gemfile"
|
42
|
+
with_items: repos
|
43
|
+
register: gemfile_stats
|
44
|
+
|
45
|
+
- name: install bunlde for any that have a Gemfile
|
46
|
+
shell: bash -lc "bundle install --path=./.bundle"
|
47
|
+
args:
|
48
|
+
chdir: "{{ item.invocation.module_complex_args.path | dirname }}"
|
49
|
+
when: item.stat.exists
|
50
|
+
with_items: gemfile_stats.results | default([])
|
51
|
+
|
52
|
+
- name: clone ref repos
|
53
|
+
git:
|
54
|
+
repo: git@github.com:{{ item.owner }}/{{ item.name }}.git
|
55
|
+
dest: ./ref/repos/{{ item.dir_name | default(item.name) }}
|
56
|
+
version: "{{ item.version | default('HEAD') }}"
|
57
|
+
depth: "{{ item.depth | default(0) }}"
|
58
|
+
with_items: ref_repos
|
data/lib/qb.rb
ADDED
data/lib/qb/version.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/python
|
2
|
+
|
3
|
+
# import some python modules that we'll use. These are all
|
4
|
+
# available in Python's core
|
5
|
+
|
6
|
+
import datetime
|
7
|
+
import sys
|
8
|
+
import json
|
9
|
+
import os
|
10
|
+
import shlex
|
11
|
+
import errno
|
12
|
+
import subprocess
|
13
|
+
import contextlib
|
14
|
+
|
15
|
+
def mkdir_p(path):
|
16
|
+
try:
|
17
|
+
os.makedirs(path)
|
18
|
+
except OSError as exc: # Python >2.5
|
19
|
+
if exc.errno == errno.EEXIST and os.path.isdir(path):
|
20
|
+
pass
|
21
|
+
else:
|
22
|
+
raise
|
23
|
+
|
24
|
+
def contians_files(path):
|
25
|
+
for dirpath, dirnames, filenames in os.walk(path):
|
26
|
+
if len(filenames) > 0:
|
27
|
+
return True
|
28
|
+
|
29
|
+
@contextlib.contextmanager
|
30
|
+
def cd(newdir):
|
31
|
+
prevdir = os.getcwd()
|
32
|
+
os.chdir(os.path.expanduser(newdir))
|
33
|
+
try:
|
34
|
+
yield
|
35
|
+
finally:
|
36
|
+
os.chdir(prevdir)
|
37
|
+
|
38
|
+
def main():
|
39
|
+
module = AnsibleModule(
|
40
|
+
argument_spec = dict(
|
41
|
+
path=dict(required=True),
|
42
|
+
),
|
43
|
+
supports_check_mode = False,
|
44
|
+
)
|
45
|
+
|
46
|
+
changed = False
|
47
|
+
path = module.params['path']
|
48
|
+
|
49
|
+
if os.path.isdir(path) is False:
|
50
|
+
mkdir_p(path)
|
51
|
+
changed = True
|
52
|
+
|
53
|
+
keep_path = os.path.join(path, '.gitkeep')
|
54
|
+
|
55
|
+
if (not os.path.exists(keep_path)) and (not contians_files(path)):
|
56
|
+
open(os.path.join(path, '.gitkeep'), 'a').close()
|
57
|
+
with cd(path):
|
58
|
+
subprocess.check_call(['git', 'add', '.gitkeep'])
|
59
|
+
changed = True
|
60
|
+
|
61
|
+
module.exit_json(
|
62
|
+
changed = changed,
|
63
|
+
)
|
64
|
+
|
65
|
+
# import module snippets
|
66
|
+
from ansible.module_utils.basic import *
|
67
|
+
from ansible.module_utils.known_hosts import *
|
68
|
+
|
69
|
+
if __name__ == '__main__':
|
70
|
+
main()
|
data/library/qb_facts.py
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/python
|
2
|
+
|
3
|
+
import subprocess
|
4
|
+
|
5
|
+
def main():
|
6
|
+
module = AnsibleModule(
|
7
|
+
argument_spec = dict(
|
8
|
+
),
|
9
|
+
supports_check_mode = False,
|
10
|
+
)
|
11
|
+
|
12
|
+
|
13
|
+
facts = {}
|
14
|
+
|
15
|
+
d = {
|
16
|
+
'git_user_name': ['git', 'config', 'user.name'],
|
17
|
+
'git_user_email': ['git', 'config', 'user.email'],
|
18
|
+
}
|
19
|
+
|
20
|
+
for key, cmd in d.iteritems():
|
21
|
+
try:
|
22
|
+
facts[key] = subprocess.check_output(cmd).rstrip()
|
23
|
+
except subprocess.CalledProcessError as e:
|
24
|
+
pass
|
25
|
+
|
26
|
+
changed = False
|
27
|
+
|
28
|
+
module.exit_json(
|
29
|
+
changed = changed,
|
30
|
+
ansible_facts = facts,
|
31
|
+
)
|
32
|
+
|
33
|
+
# import module snippets
|
34
|
+
from ansible.module_utils.basic import *
|
35
|
+
from ansible.module_utils.known_hosts import *
|
36
|
+
|
37
|
+
if __name__ == '__main__':
|
38
|
+
main()
|
data/qb.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'qb/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "qb"
|
8
|
+
spec.version = QB::VERSION
|
9
|
+
spec.authors = ["nrser"]
|
10
|
+
spec.email = ["neil@ztkae.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{qb is all about projects. named after everyone's favorite projects.}
|
13
|
+
# spec.description = %q{TODO: Write a longer description or delete this line.}
|
14
|
+
spec.homepage = "https://github.com/nrser/qb"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
|
26
|
+
spec.add_dependency "cmds", ">= 0.0.9"
|
27
|
+
end
|
data/requirements.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
# defaults file for qb.gem
|
3
|
+
|
4
|
+
# like some_gem
|
5
|
+
gem_name: "{{ dir | basename }}"
|
6
|
+
|
7
|
+
# folder in /lib as you would use in `require some_gem`
|
8
|
+
gem_dirname: "{{ gem_name }}"
|
9
|
+
|
10
|
+
# the ruby constant (class or module name), like "SomeGem"
|
11
|
+
gem_constant: "{{ gem_dirname | ruby_constantize }}"
|
12
|
+
|
13
|
+
gem_authors:
|
14
|
+
- "{{ git_user_name }}"
|
15
|
+
|
16
|
+
gem_emails:
|
17
|
+
- "{{ git_user_email }}"
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import re
|
2
|
+
import subprocess
|
3
|
+
import pipes
|
4
|
+
from ansible import errors
|
5
|
+
|
6
|
+
# from bundler's implementation
|
7
|
+
#
|
8
|
+
# name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }
|
9
|
+
#
|
10
|
+
# https://github.com/bundler/bundler/blob/7ae072865e3fc23d9844322dde6ad0f6906e3f2c/lib/bundler/cli/gem.rb#L29
|
11
|
+
#
|
12
|
+
def ruby_constantize(s):
|
13
|
+
ruby = 'puts "%s".gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }' % s
|
14
|
+
return subprocess.check_output("/usr/bin/env ruby -e %s" % pipes.quote(ruby), shell=True).rstrip()
|
15
|
+
|
16
|
+
class FilterModule(object):
|
17
|
+
'''ruby_constantize filter'''
|
18
|
+
|
19
|
+
def filters(self):
|
20
|
+
return {
|
21
|
+
'ruby_constantize': ruby_constantize,
|
22
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
---
|
2
|
+
# meta file for qb.gem
|
3
|
+
|
4
|
+
dependencies:
|
5
|
+
- role: qb.gitignore
|
6
|
+
gitignore_name: Ruby
|
7
|
+
- role: qb.gitignore
|
8
|
+
gitignore_name: Gem
|
9
|
+
|
10
|
+
qb_info:
|
11
|
+
vars:
|
12
|
+
- name: name
|
13
|
+
description: name of gem
|
14
|
+
type: string
|
15
|
+
|
16
|
+
- name: dirname
|
17
|
+
description: folder name in /lib as you would use in `require some_gem`
|
18
|
+
type: string
|
19
|
+
|
20
|
+
- name: constant
|
21
|
+
description: Ruby module or class name.
|
22
|
+
type: string
|
23
|
+
|
24
|
+
- name: license
|
25
|
+
description: license to include.
|
26
|
+
type: string
|
27
|
+
options:
|
28
|
+
- MIT
|
29
|
+
- BSD
|
30
|
+
|
31
|
+
- name: allowed_push_host
|
32
|
+
description: >
|
33
|
+
web address of server this gem is allowed to be pushed to. settings this
|
34
|
+
prohibits pushing to RubyGems.org and should be done for private gems.
|
35
|
+
type: string
|
@@ -0,0 +1,105 @@
|
|
1
|
+
---
|
2
|
+
# tasks file for qb.gem
|
3
|
+
|
4
|
+
# preamble... should move to facts?
|
5
|
+
|
6
|
+
- name: get ruby version
|
7
|
+
command: ruby -e "puts RUBY_VERSION"
|
8
|
+
register: gem_ruby_version
|
9
|
+
changed_when: false
|
10
|
+
|
11
|
+
- name: get bundler version
|
12
|
+
command: bundle --version
|
13
|
+
register: gem_bundler_version
|
14
|
+
changed_when: false
|
15
|
+
|
16
|
+
# ok, actual work....
|
17
|
+
|
18
|
+
- name: add /bin/console
|
19
|
+
template:
|
20
|
+
src: console.j2
|
21
|
+
dest: "{{ dir }}/bin/console"
|
22
|
+
force: false
|
23
|
+
mode: a+x
|
24
|
+
|
25
|
+
- name: add /bin/setup
|
26
|
+
copy:
|
27
|
+
src: setup
|
28
|
+
dest: "{{ dir }}/bin/setup"
|
29
|
+
force: false
|
30
|
+
mode: a+x
|
31
|
+
|
32
|
+
- name: create /lib
|
33
|
+
file:
|
34
|
+
path: "{{ dir }}/lib"
|
35
|
+
state: directory
|
36
|
+
|
37
|
+
- name: add /lib/<dirname>.rb
|
38
|
+
template:
|
39
|
+
src: module.rb.j2
|
40
|
+
dest: "{{ dir }}/lib/{{ gem_dirname }}.rb"
|
41
|
+
force: false
|
42
|
+
|
43
|
+
- name: create /lib/<dirname>
|
44
|
+
file:
|
45
|
+
path: "{{ dir }}/lib/{{ gem_dirname }}"
|
46
|
+
state: directory
|
47
|
+
|
48
|
+
- name: add /lib/<dirname>/version.rb
|
49
|
+
template:
|
50
|
+
src: version.rb.j2
|
51
|
+
dest: "{{ dir }}/lib/{{ gem_dirname }}/version.rb"
|
52
|
+
force: false
|
53
|
+
|
54
|
+
- name: create /spec
|
55
|
+
file:
|
56
|
+
path: "{{ dir }}/spec"
|
57
|
+
state: directory
|
58
|
+
|
59
|
+
- name: add /spec/spec_helper.rb
|
60
|
+
template:
|
61
|
+
src: spec_helper.rb.j2
|
62
|
+
dest: "{{ dir }}/spec/spec_helper.rb"
|
63
|
+
force: false
|
64
|
+
|
65
|
+
- name: add /spec/<dirname>_spec.rb
|
66
|
+
template:
|
67
|
+
src: spec.rb.j2
|
68
|
+
dest: "{{ dir }}/spec/{{ gem_dirname }}_spec.rb"
|
69
|
+
force: false
|
70
|
+
|
71
|
+
- name: add /.rspec
|
72
|
+
copy:
|
73
|
+
src: .rspec
|
74
|
+
dest: "{{ dir }}/.rspec"
|
75
|
+
force: false
|
76
|
+
|
77
|
+
- name: add /.travis.yml
|
78
|
+
template:
|
79
|
+
src: .travis.yml.j2
|
80
|
+
dest: "{{ dir }}/.travis.yml"
|
81
|
+
force: false
|
82
|
+
|
83
|
+
- name: add {{ gem_name }}.gemspec
|
84
|
+
template:
|
85
|
+
src: gemspec.j2
|
86
|
+
dest: "{{ dir }}/{{ gem_name }}.gemspec"
|
87
|
+
force: false
|
88
|
+
|
89
|
+
- name: add /Gemfile
|
90
|
+
template:
|
91
|
+
src: Gemfile.j2
|
92
|
+
dest: "{{ dir }}/Gemfile"
|
93
|
+
force: false
|
94
|
+
|
95
|
+
- name: add /LICENSE.txt
|
96
|
+
template:
|
97
|
+
src: "{{ gem_license }}-LICENSE.txt.j2"
|
98
|
+
dest: "{{ dir }}/LICENSE.txt"
|
99
|
+
force: false
|
100
|
+
when: gem_license is defined
|
101
|
+
|
102
|
+
- name: add /Rakefile
|
103
|
+
copy:
|
104
|
+
src: Rakefile
|
105
|
+
dest: "{{ dir }}/Rakefile"
|