rubysmith 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/LICENSE.adoc +162 -0
  5. data/README.adoc +207 -0
  6. data/bin/rubysmith +11 -0
  7. data/lib/rubysmith.rb +30 -0
  8. data/lib/rubysmith/builder.rb +145 -0
  9. data/lib/rubysmith/builders/bundler.rb +34 -0
  10. data/lib/rubysmith/builders/console.rb +29 -0
  11. data/lib/rubysmith/builders/core.rb +29 -0
  12. data/lib/rubysmith/builders/documentation.rb +60 -0
  13. data/lib/rubysmith/builders/git/commit.rb +45 -0
  14. data/lib/rubysmith/builders/git/setup.rb +29 -0
  15. data/lib/rubysmith/builders/guard.rb +28 -0
  16. data/lib/rubysmith/builders/pragma.rb +37 -0
  17. data/lib/rubysmith/builders/rake.rb +32 -0
  18. data/lib/rubysmith/builders/reek.rb +27 -0
  19. data/lib/rubysmith/builders/rspec/context.rb +31 -0
  20. data/lib/rubysmith/builders/rspec/helper.rb +33 -0
  21. data/lib/rubysmith/builders/rubocop.rb +43 -0
  22. data/lib/rubysmith/builders/setup.rb +27 -0
  23. data/lib/rubysmith/cli/configuration.rb +29 -0
  24. data/lib/rubysmith/cli/defaults.yml +34 -0
  25. data/lib/rubysmith/cli/parsers/assembler.rb +39 -0
  26. data/lib/rubysmith/cli/parsers/build.rb +101 -0
  27. data/lib/rubysmith/cli/parsers/core.rb +59 -0
  28. data/lib/rubysmith/cli/processors/build.rb +44 -0
  29. data/lib/rubysmith/cli/processors/config.rb +35 -0
  30. data/lib/rubysmith/cli/shell.rb +61 -0
  31. data/lib/rubysmith/identity.rb +11 -0
  32. data/lib/rubysmith/pathway.rb +37 -0
  33. data/lib/rubysmith/realm.rb +69 -0
  34. data/lib/rubysmith/renderers/erb.rb +29 -0
  35. data/lib/rubysmith/renderers/namespace.rb +47 -0
  36. data/lib/rubysmith/templates/%project_name%/.reek.yml.erb +3 -0
  37. data/lib/rubysmith/templates/%project_name%/.rubocop.yml.erb +7 -0
  38. data/lib/rubysmith/templates/%project_name%/.ruby-version.erb +1 -0
  39. data/lib/rubysmith/templates/%project_name%/CHANGES.adoc.erb +5 -0
  40. data/lib/rubysmith/templates/%project_name%/CHANGES.md.erb +5 -0
  41. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.adoc.erb +114 -0
  42. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.md.erb +115 -0
  43. data/lib/rubysmith/templates/%project_name%/CONTRIBUTING.adoc.erb +22 -0
  44. data/lib/rubysmith/templates/%project_name%/CONTRIBUTING.md.erb +22 -0
  45. data/lib/rubysmith/templates/%project_name%/Gemfile.erb +33 -0
  46. data/lib/rubysmith/templates/%project_name%/Guardfile.erb +5 -0
  47. data/lib/rubysmith/templates/%project_name%/LICENSE-apache.adoc.erb +162 -0
  48. data/lib/rubysmith/templates/%project_name%/LICENSE-apache.md.erb +162 -0
  49. data/lib/rubysmith/templates/%project_name%/LICENSE-mit.adoc.erb +20 -0
  50. data/lib/rubysmith/templates/%project_name%/LICENSE-mit.md.erb +20 -0
  51. data/lib/rubysmith/templates/%project_name%/README.adoc.erb +78 -0
  52. data/lib/rubysmith/templates/%project_name%/README.md.erb +66 -0
  53. data/lib/rubysmith/templates/%project_name%/Rakefile.erb +33 -0
  54. data/lib/rubysmith/templates/%project_name%/bin/console.erb +11 -0
  55. data/lib/rubysmith/templates/%project_name%/bin/guard.erb +6 -0
  56. data/lib/rubysmith/templates/%project_name%/bin/rubocop.erb +7 -0
  57. data/lib/rubysmith/templates/%project_name%/bin/setup.erb +8 -0
  58. data/lib/rubysmith/templates/%project_name%/lib/%project_name%.rb.erb +1 -0
  59. data/lib/rubysmith/templates/%project_name%/lib/%project_name%/identity.rb.erb +8 -0
  60. data/lib/rubysmith/templates/%project_name%/spec/spec_helper.rb.erb +34 -0
  61. data/lib/rubysmith/templates/%project_name%/spec/support/shared_contexts/temp_dir.rb.erb +9 -0
  62. data/lib/rubysmith/text/inserter.rb +31 -0
  63. metadata +367 -0
  64. metadata.gz.sig +0 -0
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/pathnames"
4
+
5
+ module Rubysmith
6
+ # Represents a pathway which has source start and destination end.
7
+ Pathway = Struct.new :start_root, :start_path, :end_root, keyword_init: true do
8
+ using Refinements::Pathnames
9
+
10
+ def initialize *arguments
11
+ super
12
+ each_pair { |key, value| self[key] = Pathname value }
13
+ self[:start_path] = start_path.absolute? ? start_path : start_root.join(start_path)
14
+ freeze
15
+ end
16
+
17
+ def with attributes
18
+ self.class.new to_h.merge(attributes)
19
+ end
20
+
21
+ def end_path
22
+ end_root.join from_parent, start_path.basename
23
+ end
24
+
25
+ def partial?
26
+ start_path.basename.fnmatch? "_*"
27
+ end
28
+
29
+ private
30
+
31
+ def from_parent
32
+ return end_root.join start_path.parent if start_path.relative?
33
+
34
+ start_path.relative_parent start_root
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,69 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ require "refinements/strings"
5
+
6
+ module Rubysmith
7
+ REALM_KEYS = %i[
8
+ config
9
+ template_root
10
+ template_path
11
+ build_root
12
+ project_name
13
+ author_name
14
+ author_email
15
+ author_url
16
+ now
17
+ documentation_format
18
+ documentation_license
19
+ build_bundler_audit
20
+ build_console
21
+ build_documentation
22
+ build_git
23
+ build_git_lint
24
+ build_guard
25
+ build_pry
26
+ build_reek
27
+ build_rspec
28
+ build_rubocop
29
+ build_setup
30
+ build_simple_cov
31
+ builders_pragmater_comments
32
+ builders_pragmater_includes
33
+ version
34
+ help
35
+ ].freeze
36
+
37
+ # Represents the common context in which all builders and templates operate in.
38
+ Realm = Struct.new(*REALM_KEYS, keyword_init: true) do
39
+ using Refinements::Strings
40
+
41
+ def initialize *arguments
42
+ super
43
+
44
+ self[:template_root] ||= Pathname(__dir__).join("templates").expand_path
45
+ self[:build_root] ||= Pathname.pwd
46
+ freeze
47
+ end
48
+
49
+ def with attributes
50
+ self.class.new to_h.merge(attributes)
51
+ end
52
+
53
+ def project_label
54
+ project_name.titleize
55
+ end
56
+
57
+ def project_class
58
+ project_name.camelcase
59
+ end
60
+
61
+ def project_root
62
+ build_root.join project_name
63
+ end
64
+
65
+ def to_pathway
66
+ Pathway[start_root: template_root, start_path: template_path, end_root: build_root]
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "erb"
4
+
5
+ module Rubysmith
6
+ module Renderers
7
+ # Renders ERB templates as fully functional files.
8
+ class ERB
9
+ def initialize realm, scope: Renderers::Namespace.new(realm.project_class), client: ::ERB
10
+ @realm = realm
11
+ @scope = scope
12
+ @client = client
13
+ end
14
+
15
+ def call content
16
+ client.new(content, trim_mode: "<>", eoutvar: "@buffer").result binding
17
+ end
18
+
19
+ private
20
+
21
+ attr_accessor :buffer
22
+ attr_reader :realm, :scope, :client
23
+
24
+ def namespace
25
+ self.buffer = scope.call yield
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "refinements/strings"
4
+
5
+ module Rubysmith
6
+ module Renderers
7
+ # Renders single or multiple modules with correct, two-space indentation for templates.
8
+ class Namespace
9
+ using Refinements::Strings
10
+
11
+ def initialize namespace
12
+ @namespace = namespace
13
+ @modules = namespace.split "::"
14
+ @depth = namespace.scan("::").length
15
+ end
16
+
17
+ def call content
18
+ "#{prefix}#{body content}#{suffix.chomp}"
19
+ end
20
+
21
+ private
22
+
23
+ attr_reader :namespace, :modules, :depth
24
+
25
+ def prefix
26
+ modules.each.with_index.reduce "" do |snippet, (module_name, index)|
27
+ %(#{snippet}#{"module".indent index} #{module_name}\n)
28
+ end
29
+ end
30
+
31
+ # :reek:FeatureEnvy
32
+ def body content
33
+ content.lstrip.split("\n").reduce "" do |snippet, line|
34
+ next "#{snippet}\n" if line.blank?
35
+
36
+ "#{snippet}#{line.gsub(/^\s{2}/, "").indent depth + 1}\n"
37
+ end
38
+ end
39
+
40
+ def suffix
41
+ modules.each.with_index.reduce "" do |snippet, (_, index)|
42
+ %(#{snippet}#{"end".indent depth - index}\n)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ exclude_paths:
2
+ - tmp
3
+ - vendor
@@ -0,0 +1,7 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/bkuhlmann/code_quality/master/configurations/rubocop/ruby.yml
3
+ - https://raw.githubusercontent.com/bkuhlmann/code_quality/master/configurations/rubocop/rake.yml
4
+ - https://raw.githubusercontent.com/bkuhlmann/code_quality/master/configurations/rubocop/performance.yml
5
+ <% if realm.build_rspec %>
6
+ - https://raw.githubusercontent.com/bkuhlmann/code_quality/master/configurations/rubocop/rspec.yml
7
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= RUBY_VERSION %>
@@ -0,0 +1,5 @@
1
+ = Changes
2
+
3
+ == 0.1.0 (<%= realm.now.strftime "%Y-%m-%d" %>)
4
+
5
+ * Added initial implementation.
@@ -0,0 +1,5 @@
1
+ # Changes
2
+
3
+ ## 0.1.0 (<%= realm.now.strftime "%Y-%m-%d" %>)
4
+
5
+ - Added initial implementation.
@@ -0,0 +1,114 @@
1
+ = Contributor Covenant Code of Conduct
2
+
3
+ == Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a
6
+ harassment-free experience for everyone, regardless of age, body size, visible or invisible
7
+ disability, ethnicity, sex characteristics, gender identity and expression, level of experience,
8
+ education, socio-economic status, nationality, personal appearance, race, religion, or sexual
9
+ identity and orientation.
10
+
11
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and
12
+ healthy community.
13
+
14
+ == Our Standards
15
+
16
+ Examples of behavior that contributes to a positive environment for our community include:
17
+
18
+ * Demonstrating empathy and kindness toward other people
19
+ * Being respectful of differing opinions, viewpoints, and experiences
20
+ * Giving and gracefully accepting constructive feedback
21
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the
22
+ experience
23
+ * Focusing on what is best not just for us as individuals, but for the overall community
24
+
25
+ Examples of unacceptable behavior include:
26
+
27
+ * The use of sexualized language or imagery, and sexual attention or advances of any kind
28
+ * Trolling, insulting or derogatory comments, and personal or political attacks
29
+ * Public or private harassment
30
+ * Publishing others' private information, such as a physical or email address, without their
31
+ explicit permission
32
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
33
+
34
+ == Enforcement Responsibilities
35
+
36
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior
37
+ and will take appropriate and fair corrective action in response to any behavior that they deem
38
+ inappropriate, threatening, offensive, or harmful.
39
+
40
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits,
41
+ code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and
42
+ will communicate reasons for moderation decisions when appropriate.
43
+
44
+ == Scope
45
+
46
+ This Code of Conduct applies within all community spaces, and also applies when an individual is
47
+ officially representing the community in public spaces. Examples of representing our community
48
+ include using an official e-mail address, posting via an official social media account, or acting as
49
+ an appointed representative at an online or offline event.
50
+
51
+ == Enforcement
52
+
53
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community
54
+ leaders responsible for enforcement at link:mailto:<%= realm.author_email %>?subject=Conduct[<%=
55
+ realm.author_name %>].
56
+
57
+ All complaints will be reviewed and investigated promptly and fairly.
58
+
59
+ All community leaders are obligated to respect the privacy and security of the reporter of any
60
+ incident.
61
+
62
+ == Enforcement Guidelines
63
+
64
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for
65
+ any action they deem in violation of this Code of Conduct:
66
+
67
+ === 1. Correction
68
+
69
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or
70
+ unwelcome in the community.
71
+
72
+ **Consequence**: A private, written warning from community leaders, providing clarity around the
73
+ nature of the violation and an explanation of why the behavior was inappropriate. A public apology
74
+ may be requested.
75
+
76
+ === 2. Warning
77
+
78
+ **Community Impact**: A violation through a single incident or series of actions.
79
+
80
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people
81
+ involved, including unsolicited interaction with those enforcing the Code of Conduct, for a
82
+ specified period of time. This includes avoiding interactions in community spaces as well as
83
+ external channels like social media. Violating these terms may lead to a temporary or permanent ban.
84
+
85
+ === 3. Temporary Ban
86
+
87
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate
88
+ behavior.
89
+
90
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the
91
+ community for a specified period of time. No public or private interaction with the people involved,
92
+ including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this
93
+ period. Violating these terms may lead to a permanent ban.
94
+
95
+ === 4. Permanent Ban
96
+
97
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including
98
+ sustained inappropriate behavior, harassment of an individual, or aggression toward or
99
+ disparagement of classes of individuals.
100
+
101
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
102
+
103
+ == Attribution
104
+
105
+ This Code of Conduct is adapted from the
106
+ link:https://www.contributor-covenant.org/version/2/0/code_of_conduct.html[Contributor Covenant,
107
+ Version 2.0].
108
+
109
+ Community Impact Guidelines were inspired by link:https://github.com/mozilla/diversity[Mozilla's
110
+ code of conduct enforcement ladder].
111
+
112
+ For answers to common questions about this code of conduct, see the
113
+ link:https://www.contributor-covenant.org/faq[FAQ]. Translations are available
114
+ link:https://www.contributor-covenant.org/translations[here].
@@ -0,0 +1,115 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a
6
+ harassment-free experience for everyone, regardless of age, body size, visible or invisible
7
+ disability, ethnicity, sex characteristics, gender identity and expression, level of experience,
8
+ education, socio-economic status, nationality, personal appearance, race, religion, or sexual
9
+ identity and orientation.
10
+
11
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and
12
+ healthy community.
13
+
14
+ ## Our Standards
15
+
16
+ Examples of behavior that contributes to a positive environment for our community include:
17
+
18
+ * Demonstrating empathy and kindness toward other people
19
+ * Being respectful of differing opinions, viewpoints, and experiences
20
+ * Giving and gracefully accepting constructive feedback
21
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the
22
+ experience
23
+ * Focusing on what is best not just for us as individuals, but for the overall community
24
+
25
+ Examples of unacceptable behavior include:
26
+
27
+ * The use of sexualized language or imagery, and sexual attention or advances of any kind
28
+ * Trolling, insulting or derogatory comments, and personal or political attacks
29
+ * Public or private harassment
30
+ * Publishing others' private information, such as a physical or email address, without their
31
+ explicit permission
32
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
33
+
34
+ ## Enforcement Responsibilities
35
+
36
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior
37
+ and will take appropriate and fair corrective action in response to any behavior that they deem
38
+ inappropriate, threatening, offensive, or harmful.
39
+
40
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits,
41
+ code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and
42
+ will communicate reasons for moderation decisions when appropriate.
43
+
44
+ ## Scope
45
+
46
+ This Code of Conduct applies within all community spaces, and also applies when an individual is
47
+ officially representing the community in public spaces. Examples of representing our community
48
+ include using an official e-mail address, posting via an official social media account, or acting as
49
+ an appointed representative at an online or offline event.
50
+
51
+ ## Enforcement
52
+
53
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community
54
+ leaders responsible for enforcement at [<%= realm.author_name %>](mailto:<%= realm.author_email
55
+ %>?subject=Conduct).
56
+ All complaints will be reviewed and investigated promptly and fairly.
57
+
58
+ All community leaders are obligated to respect the privacy and security of the reporter of any
59
+ incident.
60
+
61
+ ## Enforcement Guidelines
62
+
63
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for
64
+ any action they deem in violation of this Code of Conduct:
65
+
66
+ ### 1. Correction
67
+
68
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or
69
+ unwelcome in the community.
70
+
71
+ **Consequence**: A private, written warning from community leaders, providing clarity around the
72
+ nature of the violation and an explanation of why the behavior was inappropriate. A public apology
73
+ may be requested.
74
+
75
+ ### 2. Warning
76
+
77
+ **Community Impact**: A violation through a single incident or series of actions.
78
+
79
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people
80
+ involved, including unsolicited interaction with those enforcing the Code of Conduct, for a
81
+ specified period of time. This includes avoiding interactions in community spaces as well as
82
+ external channels like social media. Violating these terms may lead to a temporary or permanent ban.
83
+
84
+ ### 3. Temporary Ban
85
+
86
+ **Community Impact**: A serious violation of community standards, including
87
+ sustained inappropriate behavior.
88
+
89
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the
90
+ community for a specified period of time. No public or private interaction with the people involved,
91
+ including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this
92
+ period. Violating these terms may lead to a permanent ban.
93
+
94
+ ### 4. Permanent Ban
95
+
96
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including
97
+ sustained inappropriate behavior, harassment of an individual, or aggression toward or
98
+ disparagement of classes of individuals.
99
+
100
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
101
+
102
+ ## Attribution
103
+
104
+ This Code of Conduct is adapted from the [Contributor Covenant, Version
105
+ 2.0](https://www.contributor-covenant.org/version/2/0/code_of_conduct.html)
106
+
107
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement
108
+ ladder](https://github.com/mozilla/diversity).
109
+
110
+ [homepage]: https://www.contributor-covenant.org
111
+
112
+ For answers to common questions about this code of conduct, see the
113
+ [FAQ](https://www.contributor-covenant.org/faq). Translations are available
114
+ [here](https://www.contributor-covenant.org/translations).
115
+