qb 0.1.8 → 0.1.9

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 (52) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +41 -2
  3. data/ansible.cfg +2 -2
  4. data/bin/qb +11 -2
  5. data/dev/ansible.cfg +1 -0
  6. data/dev/requirements.yml +4 -4
  7. data/dev/setup.yml +12 -0
  8. data/exe/qb +66 -59
  9. data/lib/qb.rb +120 -1
  10. data/lib/qb/role.rb +39 -0
  11. data/lib/qb/version.rb +1 -1
  12. data/qb.gemspec +1 -0
  13. data/requirements.yml +5 -1
  14. data/roles/qb.build_gem/defaults/main.yml +2 -0
  15. data/roles/qb.build_gem/meta/main.yml +6 -0
  16. data/roles/qb.build_gem/tasks/main.yml +26 -0
  17. data/roles/qb.gem/meta/main.yml +0 -27
  18. data/roles/qb.gem/meta/qb.yml +26 -0
  19. data/roles/qb.git_repo/meta/qb.yml +0 -0
  20. data/roles/qb.gitignore/meta/main.yml +0 -7
  21. data/roles/qb.gitignore/meta/qb.yml +8 -0
  22. data/roles/qb.install_gem/defaults/main.yml +3 -0
  23. data/roles/qb.install_gem/meta/main.yml +12 -0
  24. data/roles/qb.install_gem/meta/qb.yml +6 -0
  25. data/roles/qb.install_gem/tasks/main.yml +2 -0
  26. data/roles/qb.meteor_react_component/defaults/main.yml +6 -0
  27. data/roles/qb.meteor_react_component/library/component_facts.py +39 -0
  28. data/roles/qb.meteor_react_component/meta/main.yml +7 -0
  29. data/roles/qb.meteor_react_component/meta/qb.yml +51 -0
  30. data/roles/qb.meteor_react_component/tasks/main.yml +41 -0
  31. data/roles/qb.meteor_react_component/templates/component.jsx.j2 +75 -0
  32. data/roles/qb.meteor_react_component/templates/style.import.less.j2 +4 -0
  33. data/roles/qb.project/files/requirements.yml +1 -1
  34. data/roles/qb.project/meta/main.yml +0 -46
  35. data/roles/qb.project/meta/qb.yml +48 -0
  36. data/roles/qb.project/tasks/main.yml +0 -6
  37. data/roles/qb.qb_role/.qb-options.yml +3 -0
  38. data/roles/qb.qb_role/defaults/main.yml +10 -0
  39. data/roles/qb.qb_role/meta/main.yml +15 -0
  40. data/roles/qb.qb_role/meta/qb.yml +47 -0
  41. data/roles/qb.qb_role/tasks/main.yml +13 -0
  42. data/roles/qb.qb_role/templates/.gitkeep +0 -0
  43. data/roles/qb.qb_role/templates/qb.yml.j2 +21 -0
  44. data/roles/qb.role/defaults/main.yml +2 -1
  45. data/roles/qb.role/meta/main.yml +0 -26
  46. data/roles/qb.role/meta/qb.yml +47 -0
  47. data/roles/qb.role/templates/defaults/main.yml.j2 +1 -1
  48. data/roles/qb.role/templates/handlers/main.yml.j2 +1 -1
  49. data/roles/qb.role/templates/meta/main.yml.j2 +3 -1
  50. data/roles/qb.role/templates/tasks/main.yml.j2 +1 -1
  51. data/roles/qb.role/templates/vars/main.yml.j2 +1 -1
  52. metadata +43 -2
@@ -0,0 +1,39 @@
1
+ module QB
2
+ class Role
3
+ attr_accessor :path, :name, :rel_path
4
+
5
+ def initialize path
6
+ @path = path
7
+
8
+ @rel_path = if path.to_s.start_with? QB::ROLES_DIR.to_s
9
+ path.sub(QB::ROLES_DIR.to_s + '/', '')
10
+ elsif path.to_s.start_with? Dir.getwd
11
+ path.sub(Dir.getwd + '/', './')
12
+ else
13
+ path
14
+ end
15
+
16
+ @name = path.to_s.split(File::SEPARATOR).last
17
+ end
18
+
19
+ def to_s
20
+ @rel_path.to_s
21
+ end
22
+
23
+ def namespace
24
+ if @name.include? '.'
25
+ @name.split('.').first
26
+ else
27
+ nil
28
+ end
29
+ end
30
+
31
+ def namespaceless
32
+ @name.split('.', 2).last
33
+ end
34
+
35
+ def options_key
36
+ @rel_path.to_s
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,3 @@
1
1
  module QB
2
- VERSION = "0.1.8"
2
+ VERSION = "0.1.9"
3
3
  end
data/qb.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "rspec"
25
25
 
26
26
  spec.add_dependency "cmds", ">= 0.0.9"
27
+ spec.add_dependency "nrser-extras", ">= 0.0.3"
27
28
  end
@@ -1,3 +1,7 @@
1
1
  - src: https://github.com/nrser/ansible-role-blockinfile.git
2
2
  name: nrser.blockinfile
3
- version: v0.6.nrser.1
3
+ version: v0.6.nrser.1
4
+ - src: https://github.com/nrser/ansible-nrser.rbenv_gem.git
5
+ name: nrser.rbenv_gem
6
+ version: v0.1.2
7
+
@@ -0,0 +1,2 @@
1
+ ---
2
+ # defaults file for qb.role
@@ -0,0 +1,6 @@
1
+ ---
2
+ # meta file for qb.role
3
+ allow_duplicates: yes
4
+
5
+ dependencies: []
6
+ # - role: role-name
@@ -0,0 +1,26 @@
1
+ ---
2
+ # tasks file for qb.role
3
+ - name: get the gem name from the .gemspec
4
+ command: ruby -e "puts Gem::Specification::load(Dir.glob('./*.gemspec')[0]).name"
5
+ args:
6
+ chdir: "{{ dir }}"
7
+ register: build_gem_name_result
8
+ changed_when: false
9
+
10
+ - name: get the gem version from the .gemspec
11
+ command: ruby -e "puts Gem::Specification::load(Dir.glob('./*.gemspec')[0]).version.to_s"
12
+ args:
13
+ chdir: "{{ dir }}"
14
+ register: build_gem_version_result
15
+ changed_when: false
16
+
17
+ - set_fact:
18
+ build_gem_name: "{{ build_gem_name_result.stdout }}"
19
+ build_gem_version: "{{ build_gem_version_result.stdout }}"
20
+
21
+ - command: "gem build {{ build_gem_name }}.gemspec"
22
+ args:
23
+ chdir: "{{ dir }}"
24
+
25
+ - set_fact:
26
+ build_gem_path: "{{ dir }}/{{ build_gem_name }}-{{ build_gem_version }}.gem"
@@ -6,30 +6,3 @@ dependencies:
6
6
  gitignore_name: Ruby
7
7
  - role: qb.gitignore
8
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,26 @@
1
+ ---
2
+ vars:
3
+ - name: name
4
+ description: name of gem
5
+ type: string
6
+
7
+ - name: dirname
8
+ description: folder name in /lib as you would use in `require some_gem`
9
+ type: string
10
+
11
+ - name: constant
12
+ description: Ruby module or class name.
13
+ type: string
14
+
15
+ - name: license
16
+ description: license to include.
17
+ type: string
18
+ options:
19
+ - MIT
20
+ - BSD
21
+
22
+ - name: allowed_push_host
23
+ description: >
24
+ web address of server this gem is allowed to be pushed to. settings this
25
+ prohibits pushing to RubyGems.org and should be done for private gems.
26
+ type: string
File without changes
@@ -5,10 +5,3 @@ allow_duplicates: yes
5
5
 
6
6
  dependencies:
7
7
  - role: qb.git_repo
8
-
9
- qb_info:
10
- vars:
11
- - name: name
12
- desciption: name of gitignore
13
- required: true
14
- type: string
@@ -0,0 +1,8 @@
1
+ ---
2
+ save_options: false
3
+
4
+ vars:
5
+ - name: name
6
+ desciption: name of gitignore
7
+ required: true
8
+ type: string
@@ -0,0 +1,3 @@
1
+ ---
2
+ # defaults file for qb.install_gem
3
+ install_gem_rubies: all
@@ -0,0 +1,12 @@
1
+ ---
2
+ # meta file for qb.install_gem
3
+ allow_duplicates: yes
4
+
5
+ dependencies:
6
+ - role: qb.build_gem
7
+
8
+ - role: nrser.rbenv_gem
9
+ rbenv_gem_rubies: "{{ install_gem_rubies }}"
10
+ rbenv_gem_name: "{{ build_gem_name }}"
11
+ rbenv_gem_source: "{{ build_gem_path }}"
12
+ rbenv_gem_state: present
@@ -0,0 +1,6 @@
1
+ ---
2
+ vars:
3
+ - name: rubies
4
+ description: rubies to install for
5
+ required: false
6
+ type: string
@@ -0,0 +1,2 @@
1
+ ---
2
+ # tasks file for qb.install_gem
@@ -0,0 +1,6 @@
1
+ ---
2
+ # defaults file for qb.meteor_react_component
3
+ component_data: false
4
+ component_root: div
5
+ component_blaze: false
6
+ component_force: false
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/python
2
+
3
+ import os
4
+
5
+ def main():
6
+ module = AnsibleModule(
7
+ argument_spec = dict(
8
+ path = dict(required=True, type='str'),
9
+ ),
10
+ supports_check_mode = False,
11
+ )
12
+
13
+
14
+ facts = {}
15
+ changed = False
16
+
17
+ path = module.params.get('path')
18
+ path_parts = path.split('/')
19
+
20
+ dir = os.path.join(*path_parts[:-1])
21
+ dashed = "-".join(path_parts)
22
+ class_name = "".join([s.capitalize() for s in path_parts])
23
+
24
+ facts['component_dir'] = dir
25
+ facts['component_dashed'] = dashed
26
+ facts['component_class_name'] = class_name
27
+ facts['component_logger_name'] = ":".join(['imports', 'ui'] + path_parts)
28
+
29
+ module.exit_json(
30
+ changed = changed,
31
+ ansible_facts = facts,
32
+ )
33
+
34
+ # import module snippets
35
+ from ansible.module_utils.basic import *
36
+ from ansible.module_utils.known_hosts import *
37
+
38
+ if __name__ == '__main__':
39
+ main()
@@ -0,0 +1,7 @@
1
+ ---
2
+ # meta file for qb.meteor_react_component
3
+
4
+ allow_duplicates: yes
5
+
6
+ dependencies: []
7
+ # - role: role-name
@@ -0,0 +1,51 @@
1
+ ---
2
+ # meta/qb.yml file for qb.meteor_react_component
3
+ #
4
+ # qb settings for this role. see README.md for more info.
5
+ #
6
+
7
+ # prefix for role variables
8
+ # use a shorter name
9
+ var_prefix: 'component'
10
+
11
+ # how to get a default for `dir` if it's not provided as the
12
+ default_dir: false
13
+ # exe: qb/get_dir
14
+
15
+ save_options: false
16
+
17
+ vars:
18
+ # - name: example
19
+ # description: an example of a variable.
20
+ # required: false
21
+ # type: boolean # boolean (default) | string
22
+ # short: e
23
+ - name: path
24
+ description: "symbolic path to the view component (ex: 'posts/tiles')"
25
+ required: true
26
+ type: string
27
+ short: p
28
+
29
+ - name: data
30
+ description: add ReactDataMixin
31
+ required: false
32
+ type: boolean
33
+ short: m
34
+
35
+ - name: root
36
+ description: root element name
37
+ required: false
38
+ type: string
39
+ short: r
40
+
41
+ - name: blaze
42
+ description: register class name as a global Blaze template helper
43
+ required: false
44
+ type: boolean
45
+ short: b
46
+
47
+ - name: force
48
+ description: overwrite existing file
49
+ required: false
50
+ type: boolean
51
+ short: f
@@ -0,0 +1,41 @@
1
+ ---
2
+ # tasks file for qb.meteor_react_component
3
+ - component_facts:
4
+ path: "{{ component_path }}"
5
+
6
+ - name: create component directory
7
+ file:
8
+ path: "{{ qb_dir }}/imports/ui/{{ component_dir }}"
9
+ state: directory
10
+ recurse: true
11
+
12
+ - name: "create {{ component_class_name }} component"
13
+ template:
14
+ src: component.jsx.j2
15
+ dest: "{{ qb_dir }}/imports/ui/{{ component_dir }}/{{ component_dashed }}.jsx"
16
+ force: "{{ component_force }}"
17
+
18
+ - name: add import line to imports/ui/index.js
19
+ lineinfile:
20
+ dest: "{{ qb_dir }}/imports/ui/index.js"
21
+ line: "export * from './{{ component_dir }}/{{ component_dashed }}.jsx';"
22
+ when: component_blaze
23
+
24
+ - name: create styles directory
25
+ file:
26
+ path: "{{ qb_dir }}/client/styles/{{ component_dir }}"
27
+ state: directory
28
+ recurse: true
29
+
30
+ - name: create a stylesheet for it
31
+ template:
32
+ src: style.import.less.j2
33
+ dest: "{{ qb_dir }}/client/styles/{{ component_dir }}/{{ component_dashed }}.import.less"
34
+ force: "{{ component_force }}"
35
+
36
+ - name: add import line to client/styles/index.less
37
+ lineinfile:
38
+ dest: "{{ qb_dir }}/client/styles/index.less"
39
+ line: '@import "{{ component_dir }}/{{ component_dashed }}.import.less";'
40
+ create: true
41
+
@@ -0,0 +1,75 @@
1
+ // standard imports
2
+ import { Meteor } from 'meteor/meteor';
3
+ import { _ } from 'meteor/underscore';
4
+ import { check } from 'meteor/check';
5
+
6
+ // react imports
7
+ import React, { Component, PropTypes } from 'react';
8
+ import ReactDOM from 'react-dom';
9
+ {% if component_data -%}
10
+ import { createContainer, ReactMeteorData } from 'meteor/react-meteor-data';
11
+ {% endif %}
12
+
13
+ // other package imports
14
+ {% if component_blaze -%}
15
+ import { Template } from 'meteor/templating';
16
+ {% endif %}
17
+
18
+ // project imports
19
+ import * as Util from '/imports/util';
20
+
21
+ const log = Util.logger('{{ component_logger_name }}');
22
+
23
+ export default class {{ component_class_name }} extends Component {
24
+ constructor() {
25
+ super();
26
+ } // constructor()
27
+
28
+ {% if component_data -%}
29
+ getMeteorData() {
30
+ return {
31
+ };
32
+ } // getMeteorData()
33
+ {% endif %}
34
+
35
+ // helper methods
36
+ // ==============
37
+
38
+ // action methods
39
+ // ==============
40
+
41
+ // render methods
42
+ // ==============
43
+
44
+ renderContent() {
45
+
46
+ } // renderContent()
47
+
48
+ render() {
49
+ return (
50
+ <{{ component_root }} className="{{ component_class_name }}">
51
+ { this.renderContent() }
52
+ </{{ component_root }}>
53
+ );
54
+ } // render()
55
+
56
+ // hook methods
57
+ // ===========
58
+
59
+ } // {{ component_class_name }}
60
+
61
+ {{ component_class_name }}.propTypes = {
62
+
63
+ } // propTypes
64
+
65
+ {% if component_data -%}
66
+ // mixin that calls `component.getMeteorData()`
67
+ reactMixin({{ component_class_name }}.prototype, ReactDataMixin);
68
+ {% endif %}
69
+
70
+ {% if component_blaze -%}
71
+ // register component globally to be used by Blaze
72
+ Template.registerHelper('{{ component_class_name }}', () => {
73
+ return {{ component_class_name }};
74
+ });
75
+ {% endif %}
@@ -0,0 +1,4 @@
1
+ // styles for {{ component_class_name }} component
2
+ .{{ component_class_name }} {
3
+
4
+ }