hexx-dependencies 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 06edafd9f55a776138c9c14cef0000d8bcfc4470
4
+ data.tar.gz: f8b989bf59c2fb9eb08b21353ab0267b6aef4511
5
+ SHA512:
6
+ metadata.gz: a51db0341740592db0db53de842a070eff891a36ffdb01d7d664a951b799d9422f63d4c82024ad2cc43ee15e012225f41d55e79d9ce15aef0f23ce6eabfc58f0
7
+ data.tar.gz: f401c4e82c644fb82675976214dd031f120c006102c89fb776c8fcc87ba87cc6751bb5ea3fbcbc62c2e628fbda14fd2a1b457f4e303f3854f04bd177db330782
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ *.lock
3
+ .bundle/
4
+ .yardoc/
5
+ coverage/
6
+ doc/
7
+ log/
8
+ pkg/
9
+ tmp/
data/.metrics ADDED
@@ -0,0 +1,8 @@
1
+ # Settings for metric_fu and its packages are collected in the `config/metrics`
2
+ # and loaded by the Hexx::Suit::Metrics::MetricFu.
3
+
4
+ begin
5
+ require "hexx-suit"
6
+ Hexx::Suit::Metrics::MetricFu.load
7
+ rescue LoadError
8
+ end
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --require spec_helper
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ inherit_from: "./config/metrics/rubocop.yml"
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ ---
2
+ language: ruby
3
+ bundler_args: --without metrics
4
+ script: rake test:coverage:run
5
+ rvm:
6
+ - '2.0'
7
+ - ruby-head
8
+ - rbx-2 --2.0
9
+ - jruby-head-20mode
10
+ - jruby-head-21mode
data/.yardopts ADDED
@@ -0,0 +1,3 @@
1
+ --asset LICENSE
2
+ --exclude lib/hexx/dependencies/version.rb
3
+ --output doc/api
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "hexx-suit", "~> 2.0", group: :metrics if RUBY_ENGINE == "ruby"
data/Guardfile ADDED
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+
3
+ guard :rspec, cmd: "bundle exec rspec" do
4
+
5
+ watch(%r{^lib/hexx/dependencies/(\w+)\.rb$}) do |m|
6
+ "spec/tests/#{ m[1] }_spec.rb"
7
+ end
8
+
9
+ watch(%r{^lib/hexx/dependencies/cli/.+}) { "spec/tests/cli_spec.rb" }
10
+
11
+ watch(%r{^spec/tests/.+_spec\.rb$})
12
+
13
+ watch("lib/hexx.rb") { "spec" }
14
+ watch("lib/hexx/dependencies.rb") { "spec" }
15
+ watch("spec/spec_helper.rb") { "spec" }
16
+
17
+ end # guard :rspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2015 Andrew Kozin, andrew.kozin@gmail.com
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.
data/README.md ADDED
@@ -0,0 +1,162 @@
1
+ Hexx::Dependencies
2
+ ==================
3
+
4
+ [![Gem Version](https://img.shields.io/gem/v/hexx-dependencies.svg?style=flat)][gem]
5
+ [![Build Status](https://img.shields.io/travis/nepalez/hexx-dependencies/master.svg?style=flat)][travis]
6
+ [![Dependency Status](https://img.shields.io/gemnasium/nepalez/hexx-dependencies.svg?style=flat)][gemnasium]
7
+ [![Code Climate](https://img.shields.io/codeclimate/github/nepalez/hexx-dependencies.svg?style=flat)][codeclimate]
8
+ [![Coverage](https://img.shields.io/coveralls/nepalez/hexx-dependencies.svg?style=flat)][coveralls]
9
+
10
+ [codeclimate]: https://codeclimate.com/github/nepalez/hexx-dependencies
11
+ [coveralls]: https://coveralls.io/r/nepalez/hexx-dependencies
12
+ [gem]: https://rubygems.org/gems/hexx-dependencies
13
+ [gemnasium]: https://gemnasium.com/nepalez/hexx-dependencies
14
+ [travis]: https://travis-ci.org/nepalez/hexx-dependencies
15
+
16
+ Scaffolds the current project's dependency from a variable, defined outside.
17
+
18
+ The module is used inside the [hexx] collection of scaffolders.
19
+
20
+ [hexx]: https://github.com/nepalez/hexx
21
+
22
+ Usage
23
+ -----
24
+
25
+ Suppose we need the `user_class` dependency that should be initialized by dummy application as `User` taken from the external `users` module.
26
+
27
+ The dependency should be called as a core module getter:
28
+
29
+ ```ruby
30
+ MyModule.user_class # => User from 'users' gem (in the test environment)
31
+ ```
32
+
33
+ To do it start the scaffolder:
34
+
35
+ ```ruby
36
+ Hexx::Dependencies::CLI.start %w(user_class -i User -g users)
37
+ ```
38
+
39
+ Results
40
+ -------
41
+
42
+ At first the scaffolder provides base loader mechanism (if it is absent):
43
+
44
+ * dummy app `spec/dummy`.
45
+ * dummy loader `spec/spec_helper.rb`.
46
+ * the module configurator `lib/my_module/configurator.rb`.
47
+ * the module initializer `spec/dummy/config/initializers/my_module.rb`.
48
+ * the configurator loaders from `lib/my_module.rb`.
49
+
50
+ See the *Loading Order* part below for details how it works.
51
+
52
+ Then the scaffolder adds required settings:
53
+
54
+ * `user_class` attribute in `lib/my_module/configurator.rb`.
55
+ * `users` development dependency in the Gemfile.
56
+ * `users` loader in the `spec/dummy/initializers.rb`.
57
+ * `user_class = User` injection in the `spec/dummy/initializers.rb`.
58
+
59
+ ### Loading Order
60
+
61
+ The module is loaded in the following order:
62
+
63
+ * The dummy application takes the control:
64
+
65
+ ```ruby
66
+ # spec/spec_helper.rb
67
+ require_relative "dummy/lib/dummy"
68
+ ```
69
+
70
+ The dummy app:
71
+ * sets the pointer to initializers folder `ENV['PATH_TO_INITIALIZERS']`.
72
+ * gives control to the module.
73
+
74
+ ```ruby
75
+ # spec/dummy/lib/dummy.rb
76
+ ENV['PATH_TO_INITIALIZERS'] = File.expand_path(
77
+ "../../config/initializers", __FILE__
78
+ )
79
+ require "my_module"
80
+ ```
81
+
82
+ `lib/my_module.rb`:
83
+ * declares its `Configurator`.
84
+ * takes its own initializers from dummy `config/initializers` folder.
85
+ * loads the rest of the code.
86
+
87
+ ```ruby
88
+ # lib/my_module.rb
89
+ require_relative "my_module/configurator"
90
+ load File.join(ENV['PATH_TO_INITIALIZERS'], "my_module.rb")
91
+ # ...loads the rest of application
92
+
93
+ # lib/my_module/configurator.rb
94
+ module MyModule
95
+ class << self
96
+ def configure
97
+ instance_eval(yield) if block_given?
98
+ end
99
+
100
+ attr_accessor :user_class
101
+ end
102
+ end
103
+
104
+ # spec/dummy/config/initializers/my_module.rb
105
+ require "users"
106
+
107
+ MyModule.configure do |config|
108
+ user_class = User
109
+ end
110
+ ```
111
+
112
+ Installation
113
+ ------------
114
+
115
+ Add this line to your application's Gemfile:
116
+
117
+ ```ruby
118
+ # Gemfile
119
+ gem "hexx-dependencies"
120
+ ```
121
+
122
+ Then execute:
123
+
124
+ ```
125
+ bundle
126
+ ```
127
+
128
+ Or add it manually:
129
+
130
+ ```
131
+ gem install hexx-dependencies
132
+ ```
133
+
134
+ Compatibility
135
+ -------------
136
+
137
+ Tested under rubies compatible to MRI 2.0 API:
138
+ * MRI 2.0+
139
+ * Rubinius 2+ (2.0+ modes)
140
+ * JRuby-head (9000) (2.0+ modes)
141
+
142
+ Uses [RSpec] 3.0+ for testing and [hexx-suit] for dev/test tools collection.
143
+
144
+ [hexx-suit]: https://github.com/nepalez/hexx-suit
145
+
146
+ Contributing
147
+ ------------
148
+
149
+ * Fork the project.
150
+ * Read the [STYLEGUIDE](config/metrics/STYLEGUIDE).
151
+ * Make your feature addition or bug fix.
152
+ * Add tests for it. This is important so I don't break it in a
153
+ future version unintentionally.
154
+ * Commit, do not mess with Rakefile or version
155
+ (if you want to have your own version, that is fine but bump version
156
+ in a commit by itself I can ignore when I pull)
157
+ * Send me a pull request. Bonus points for topic branches.
158
+
159
+ License
160
+ -------
161
+
162
+ See the [MIT LICENSE](LICENSE).
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ begin
3
+ require "bundler/setup"
4
+ rescue LoadError
5
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
6
+ exit
7
+ end
8
+
9
+ # Loads bundler tasks
10
+ Bundler::GemHelper.install_tasks
11
+
12
+ # Loads the Hexx::RSpec and its tasks
13
+ begin
14
+ require "hexx-suit"
15
+ Hexx::Suit.install_tasks
16
+ rescue LoadError
17
+ require "hexx-rspec"
18
+ Hexx::RSpec.install_tasks
19
+ end
20
+
21
+ # Sets the Hexx::RSpec :test task to default
22
+ task default: "test:coverage:run"
@@ -0,0 +1,230 @@
1
+ = Ruby Style Guide
2
+
3
+ Adapted from Dan Kubb's Ruby Style Guide
4
+ https://github.com/dkubb/styleguide/blob/master/RUBY-STYLE
5
+
6
+ == Commiting:
7
+
8
+ * Write descriptive commit messages, following the pattern:
9
+
10
+ [TYPE] name
11
+
12
+ The message, describing the changes being made
13
+
14
+ * Use the types below to mark commits:
15
+
16
+ - FEATURE - for adding new features, or backward-compatible changes;
17
+ - CHANGE - for backward-incompatible changes;
18
+ - BUG FIX - for fixing bugs;
19
+ - REFACTORING - for other changes of the code not affecting the API;
20
+ - OTHER - for changes in documentaton, metrics etc, not touching the code;
21
+ - VERSION - for version changes.
22
+
23
+ * Always separate commits of different types (such as FEATURE and CHANGE).
24
+
25
+ * Try to separate various features from each other.
26
+
27
+ * Include specification to the same commit as the code.
28
+
29
+ * Run all tests before making a commit.
30
+ Never commit the code that break unit tests.
31
+
32
+ * Use metric (run `rake check`) before making a commit.
33
+
34
+ * Do refactoring before making a commit. Best writing is rewriting.
35
+
36
+ * Follow semantic versioning.
37
+
38
+ http://semver.org/
39
+
40
+ * For versions name the commit after a version number, following the pattern:
41
+
42
+ VERSION 1.0.0-rc2
43
+
44
+
45
+ == Formatting:
46
+
47
+ * Use UTF-8. Declare encoding in the first line of every file.
48
+
49
+ # encoding: utf-8
50
+
51
+ * Use 2 space indent, no tabs.
52
+
53
+ * Use Unix-style line endings.
54
+
55
+ * Use spaces around operators, after commas, colons and semicolons,
56
+ around { and before }.
57
+
58
+ * No spaces after (, [ and before ], ).
59
+
60
+ * Align `when` and `else` with `case`.
61
+
62
+ * Use an empty line before the return value of a method (unless it
63
+ only has one line), and an empty line between defs.
64
+
65
+ * Use empty lines to break up a long method into logical paragraphs.
66
+
67
+ * Keep lines fewer than 80 characters.
68
+
69
+ * Strip trailing whitespace.
70
+
71
+
72
+ == Syntax:
73
+
74
+ * Write for 2.0.
75
+
76
+ * Use double quotes
77
+
78
+ http://viget.com/extend/just-use-double-quoted-ruby-strings
79
+
80
+ * Use def with parentheses when there are arguments.
81
+
82
+ * Never use for, unless you exactly know why.
83
+
84
+ * Never use then, except in case statements.
85
+
86
+ * Use when x then ... for one-line cases.
87
+
88
+ * Use &&/|| for boolean expressions, and/or for control flow. (Rule
89
+ of thumb: If you have to use outer parentheses, you are using the
90
+ wrong operators.)
91
+
92
+ * Avoid double negation (!!), unless Null Objects are expected.
93
+
94
+ http://devblog.avdi.org/2011/05/30/null-objects-and-falsiness
95
+
96
+ * Avoid multiline ?:, use if.
97
+
98
+ * Use {...} when defining blocks on one line. Use do...end for multiline
99
+ blocks.
100
+
101
+ * Avoid return where not required.
102
+
103
+ * Use ||= freely.
104
+
105
+ * Use OO regexps, and avoid =~ $0-9, $~, $` and $' when possible.
106
+
107
+ * Do not use Enumerable#inject when the "memo" object does not change between
108
+ iterations, use Enumerable#each_with_object instead (in ruby 1.9,
109
+ active_support and backports).
110
+
111
+ * Prefer ENV.fetch to ENV[] syntax.
112
+ Prefer block syntax for ENV.fetch to usage of the second argument.
113
+
114
+
115
+ == Naming:
116
+
117
+ * Use snake_case for methods.
118
+
119
+ * Use CamelCase for classes and modules. (Keep acronyms like HTTP,
120
+ RFC, XML uppercase.)
121
+
122
+ * Use SCREAMING_SNAKE_CASE for other constants.
123
+
124
+ * Do not use single letter variable names. Avoid uncommunicative names.
125
+
126
+ * Use consistent variable names. Try to keep the variable names close
127
+ to the object class name.
128
+
129
+ * Use names prefixed with _ for unused variables.
130
+
131
+ * When defining a predicate method that compares against another object of
132
+ a similar type, name the argument "other".
133
+
134
+ * Prefer map over collect, detect over find, select over find_all.
135
+
136
+ * Use def self.method to define singleton methods.
137
+
138
+ * Avoid alias when alias_method will do.
139
+
140
+
141
+ == Comments:
142
+
143
+ * Use YARD and its conventions for API documentation. Don't put an
144
+ empty line between the comment block and the def.
145
+
146
+ * Comments longer than a word are capitalized and use punctuation.
147
+ Use one space after periods.
148
+
149
+ * Avoid superfluous comments.
150
+
151
+
152
+ == Code structuring:
153
+
154
+ * Break code into packages, decoupled from the environment.
155
+
156
+ * Wrap packages into gems.
157
+
158
+ * Inject dependencies explicitly.
159
+ Leave all outer references on the border of any package. Inside
160
+ the package use internal references only.
161
+
162
+ * Follow SOLID principles.
163
+
164
+ http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)
165
+
166
+ * Only give a method one purpose for existing. If you pass in a boolean
167
+ to a method, what you're saying is that this method has two different
168
+ behaviours. Just split it into two single purpose methods. If you have
169
+ to use the words "AND" or "OR" to describe what the method does it
170
+ probably does too much.
171
+
172
+ * Avoid long methods.
173
+ Try to keep them at no more than 6 lines long, and preferably 4 or less.
174
+
175
+ If sections of a method are logically separate by blank lines, then
176
+ that's probably a sign that those sections should be split into separate
177
+ methods.
178
+
179
+ * Avoid hashes-as-optional-parameters. Does the method do too much?
180
+
181
+ * Avoid long parameter lists.
182
+
183
+ * Add "global" methods to Kernel (if you have to) and make them private.
184
+
185
+ * Use OptionParser for parsing complex command line options and
186
+ ruby -s for trivial command line options.
187
+
188
+ * Avoid needless metaprogramming.
189
+
190
+ * Always freeze objects assigned to constants.
191
+
192
+
193
+ == General:
194
+
195
+ * Code in a functional way, avoid mutation when it makes sense.
196
+
197
+ * Try to have methods either return the state of the object and have
198
+ no side effects, or return self and have side effects. This is
199
+ otherwise known as Command-query separation (CQS):
200
+
201
+ http://en.wikipedia.org/wiki/Command-query_separation
202
+
203
+ * Do not mutate arguments unless that is the purpose of the method.
204
+
205
+ * Try following TRUE heuristics by Sandi Metz
206
+
207
+ http://designisrefactoring.com/2015/02/08/introducing-sandi-metz-true/
208
+
209
+ * Do not mess around in core classes when writing libraries.
210
+ Namespace your code inside the modules, or wrap core classes to
211
+ decorators of your own.
212
+
213
+ * Do not program defensively.
214
+
215
+ http://www.erlang.se/doc/programming_rules.shtml#HDR11
216
+
217
+ * Keep the code simple.
218
+
219
+ * Don't overdesign.
220
+
221
+ * Don't underdesign.
222
+
223
+ * Avoid bugs.
224
+
225
+ * Read other style guides and apply the parts that don't dissent with
226
+ this list.
227
+
228
+ * Be consistent.
229
+
230
+ * Use common sense.
@@ -0,0 +1,5 @@
1
+ ---
2
+ abc_max: "10"
3
+ line_length: "80"
4
+ no_doc: "y"
5
+ no_readme: "y"
@@ -0,0 +1,6 @@
1
+ ---
2
+ ignore_files:
3
+ - spec
4
+ - config
5
+ minimum_churn_count: 0
6
+ start_date: "1 year ago"
@@ -0,0 +1,2 @@
1
+ ---
2
+ minimum_score: 5
@@ -0,0 +1,15 @@
1
+ ---
2
+ folders: # The list of folders to be used by any metric.
3
+ - lib
4
+ - app
5
+ metrics: # The list of allowed metrics. The other metrics are disabled.
6
+ - cane
7
+ - churn
8
+ - flay
9
+ - flog
10
+ - reek
11
+ - roodi
12
+ - saikuro
13
+ format: html
14
+ output: tmp/metric_fu
15
+ verbose: false
@@ -0,0 +1 @@
1
+ ---
@@ -0,0 +1,24 @@
1
+ ---
2
+ AssignmentInConditionalCheck:
3
+ CaseMissingElseCheck:
4
+ ClassLineCountCheck:
5
+ line_count: 300
6
+ ClassNameCheck:
7
+ pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
8
+ ClassVariableCheck:
9
+ CyclomaticComplexityBlockCheck:
10
+ complexity: 4
11
+ CyclomaticComplexityMethodCheck:
12
+ complexity: 8
13
+ EmptyRescueBodyCheck:
14
+ ForLoopCheck:
15
+ MethodLineCountCheck:
16
+ line_count: 20
17
+ MethodNameCheck:
18
+ pattern: !ruby/regexp /^[\||\^|\&|\!]$|^[_a-z<>=\[|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/
19
+ ModuleLineCountCheck:
20
+ line_count: 300
21
+ ModuleNameCheck:
22
+ pattern: !ruby/regexp /^[A-Z][a-zA-Z0-9]*$/
23
+ ParameterNumberCheck:
24
+ parameter_count: 5
@@ -0,0 +1,73 @@
1
+ ---
2
+ # settings added by the 'hexx-suit' module
3
+ # output: "tmp/rubocop"
4
+ # format: "html"
5
+
6
+ AllCops:
7
+ Exclude:
8
+ - '**/db/schema.rb'
9
+
10
+ Lint/HandleExceptions:
11
+ Exclude:
12
+ - '**/*_spec.rb'
13
+
14
+ Lint/RescueException:
15
+ Exclude:
16
+ - '**/*_spec.rb'
17
+
18
+ Style/AccessorMethodName:
19
+ Exclude:
20
+ - '**/*_spec.rb'
21
+
22
+ Style/AsciiComments:
23
+ Enabled: false
24
+
25
+ Style/ClassAndModuleChildren:
26
+ Exclude:
27
+ - '**/*_spec.rb'
28
+
29
+ Style/Documentation:
30
+ Enabled: false
31
+
32
+ Style/EmptyLinesAroundBlockBody:
33
+ Enabled: false
34
+
35
+ Style/EmptyLinesAroundClassBody:
36
+ Enabled: false
37
+
38
+ Style/EmptyLinesAroundMethodBody:
39
+ Enabled: false
40
+
41
+ Style/EmptyLinesAroundModuleBody:
42
+ Enabled: false
43
+
44
+ Style/EmptyLineBetweenDefs:
45
+ Enabled: false
46
+
47
+ Style/FileName:
48
+ Enabled: false
49
+
50
+ Style/RaiseArgs:
51
+ EnforcedStyle: compact
52
+
53
+ Style/SingleLineMethods:
54
+ Exclude:
55
+ - '**/*_spec.rb'
56
+
57
+ Style/SingleSpaceBeforeFirstArg:
58
+ Enabled: false
59
+
60
+ Style/SpecialGlobalVars:
61
+ Exclude:
62
+ - '**/Gemfile'
63
+ - '**/*.gemspec'
64
+
65
+ Style/StringLiterals:
66
+ EnforcedStyle: double_quotes
67
+
68
+ Style/StringLiteralsInInterpolation:
69
+ EnforcedStyle: double_quotes
70
+
71
+ Style/TrivialAccessors:
72
+ Exclude:
73
+ - '**/*_spec.rb'
@@ -0,0 +1,3 @@
1
+ ---
2
+ warn_cyclo: 4
3
+ error_cyclo: 6
@@ -0,0 +1,8 @@
1
+ ---
2
+ output: tmp/coverage
3
+ filters: # The list of paths to be excluded from coverage checkup
4
+ - "spec/"
5
+ - "config/"
6
+ groups: # The list of groups to be shown in the coverage report
7
+ Libraries: "lib/"
8
+ Application: "app/"
@@ -0,0 +1,37 @@
1
+ ---
2
+ # Settings added by the 'hexx-suit' gem
3
+ output: "tmp/yardstick/output.log"
4
+ path: "lib/**/*.rb"
5
+ rules:
6
+ ApiTag::Presence:
7
+ enabled: true
8
+ exclude: []
9
+ ApiTag::Inclusion:
10
+ enabled: true
11
+ exclude: []
12
+ ApiTag::ProtectedMethod:
13
+ enabled: true
14
+ exclude: []
15
+ ApiTag::PrivateMethod:
16
+ enabled: false
17
+ exclude: []
18
+ ExampleTag:
19
+ enabled: true
20
+ exclude: []
21
+ ReturnTag:
22
+ enabled: true
23
+ exclude: []
24
+ Summary::Presence:
25
+ enabled: true
26
+ exclude: []
27
+ Summary::Length:
28
+ enabled: true
29
+ exclude: []
30
+ Summary::Delimiter:
31
+ enabled: true
32
+ exclude: []
33
+ Summary::SingleLine:
34
+ enabled: true
35
+ exclude: []
36
+ threshold: 100
37
+ verbose: false
@@ -0,0 +1,25 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "hexx/dependencies/version"
3
+
4
+ Gem::Specification.new do |gem|
5
+
6
+ gem.name = "hexx-dependencies"
7
+ gem.version = Hexx::Dependencies::VERSION.dup
8
+ gem.author = "Andrew Kozin"
9
+ gem.email = "andrew.kozin@gmail.com"
10
+ gem.homepage = "https://github.com/nepalez/hexx-dependencies"
11
+ gem.description = "Gem dependency scaffolder."
12
+ gem.summary = "Creates the loader mechanism and defines an external" \
13
+ " dependency for the host module."
14
+ gem.license = "MIT"
15
+
16
+ gem.require_paths = ["lib"]
17
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
+ gem.test_files = Dir["spec/**/*.rb"]
19
+ gem.extra_rdoc_files = Dir["README.md", "LICENSE"]
20
+
21
+ gem.required_ruby_version = "~> 2.0"
22
+ gem.add_runtime_dependency "hexx-cli", "~> 0.0", ">= 0.0.3"
23
+ gem.add_development_dependency "hexx-rspec", "~> 0.3"
24
+
25
+ end
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ <% tabs = 0 -%>
3
+ <% project.namespaces.each do |item| -%>
4
+
5
+ <%= " " * tabs %>module <%= item %>
6
+ <% tabs += 1 -%>
7
+ <% end -%>
8
+
9
+ <%= " " * tabs %>module <%= project.const %>
10
+
11
+ <%= " " * tabs %> # The module's eigenclass containing its settings
12
+ <%= " " * tabs %> class << self
13
+
14
+ <%= " " * tabs %> # Configures the module settings
15
+ <%= " " * tabs %> #
16
+ <%= " " * tabs %> # @example
17
+ <%= " " * tabs %> # <%= project.type %>.configure do
18
+ <%= " " * tabs %> # setting = Injection
19
+ <%= " " * tabs %> # end
20
+ <%= " " * tabs %> #
21
+ <%= " " * tabs %> # @yield the block in the module eigenclass' scope
22
+ <%= " " * tabs %> #
23
+ <%= " " * tabs %> # @return [undefined]
24
+ <%= " " * tabs %> def configure
25
+ <%= " " * tabs %> instance_eval { yield } if block_given?
26
+ <%= " " * tabs %> end
27
+
28
+ <%= " " * tabs %> end # eigenclass
29
+
30
+ <%= " " * tabs %>end # module <%= project.const %>
31
+ <% project.namespaces.reverse.each do |item| -%>
32
+
33
+ <% tabs -= 1 -%>
34
+ <%= " " * tabs %>end # module <%= item %>
35
+ <% end -%>
@@ -0,0 +1,6 @@
1
+ <% tabs = project.namespaces.count + 2 %>
2
+ <%= " " * tabs %># @!attribute <%= dependency %>
3
+ <%= " " * tabs %># @todo Describe the dependency
4
+ <%= " " * tabs %>#
5
+ <%= " " * tabs %># @return [Module]
6
+ <%= " " * tabs %>attr_accessor :<%= dependency %>
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+
3
+ # Dummy application
4
+ module Dummy
5
+
6
+ ENV["PATH_TO_INITIALIZERS"] =
7
+ ::File.expand_path("../../config/initializers", __FILE__)
8
+ require "<%= project.item %>"
9
+
10
+ end
@@ -0,0 +1,4 @@
1
+ # encoding: utf-8
2
+
3
+ <%= project.type %>.configure do
4
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+ <% tabs = 0 -%>
3
+ <% project.namespaces.each do |item| -%>
4
+
5
+ <%= " " * tabs %>module <%= item %>
6
+ <% tabs += 1 -%>
7
+ <% end -%>
8
+
9
+ <%= " " * tabs %># @todo Describe the module
10
+ <%= " " * tabs %>module <%= project.const %>
11
+
12
+ <%= " " * tabs %>end # module <%= project.const %>
13
+ <% project.namespaces.reverse.each do |item| -%>
14
+
15
+ <% tabs -= 1 -%>
16
+ <%= " " * tabs %>end # module <%= item %>
17
+ <% end -%>
@@ -0,0 +1,3 @@
1
+ <% tabs = project.namespaces.count + 1 %>
2
+ <% " " * tabs %> require_relative "<%= project.item %>/configurator"
3
+ <% " " * tabs %> load ::File.join(ENV["PATH_TO_INITIALIZERS"], "<%= project.file %>.rb")
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ require "hexx-rspec"
3
+
4
+ # Loads the runtime metrics
5
+ Hexx::RSpec.loads_metrics_for(self)
6
+
7
+ # Loads the dummy app
8
+ require_relative "dummy/lib/dummy"
@@ -0,0 +1,154 @@
1
+ # encoding: utf-8
2
+
3
+ module Hexx
4
+
5
+ module Dependencies
6
+
7
+ class CLI < Hexx::CLI::Base
8
+
9
+ def self.source_root
10
+ ::File.expand_path "../cli", __FILE__
11
+ end
12
+
13
+ desc "Scaffolds the dependency from a variable defined outside of the gem"
14
+ namespace :dependency
15
+
16
+ argument(
17
+ :name,
18
+ banner: "NAME",
19
+ desc: "The name of the dependency",
20
+ required: false,
21
+ type: :string
22
+ )
23
+
24
+ class_option(
25
+ :injection,
26
+ aliases: "-i",
27
+ banner: "Injection",
28
+ desc: "The name of the dependency implementation injected by the dummy",
29
+ required: false,
30
+ type: :string
31
+ )
32
+
33
+ class_option(
34
+ :gemname,
35
+ aliases: "-g",
36
+ banner: "gemname",
37
+ desc: "The name of the gem for dummy to inject the dependency from",
38
+ required: false,
39
+ type: :string
40
+ )
41
+
42
+ # @private
43
+ def add_dummy_loader
44
+ template "spec_helper.erb", "spec/spec_helper.rb", skip: true
45
+ gsub_file(
46
+ "spec/spec_helper.rb",
47
+ /require\s+"#{ project.item }"/,
48
+ "require_relative \"dummy/lib/dummy\""
49
+ )
50
+ end
51
+
52
+ # @private
53
+ def add_dummy_lib
54
+ template "dummy.erb", "spec/dummy/lib/dummy.rb", skip: true
55
+ end
56
+
57
+ # @private
58
+ def add_initializer
59
+ template(
60
+ "initializer.erb",
61
+ "spec/dummy/config/initializers/#{ project.file }.rb",
62
+ skip: true
63
+ )
64
+ end
65
+
66
+ # @private
67
+ def add_configurator
68
+ template(
69
+ "configurator.erb",
70
+ "lib/#{ project.path }/configurator.rb",
71
+ skip: true
72
+ )
73
+ end
74
+
75
+ # @private
76
+ def add_lib
77
+ template "lib.erb", "lib/#{ project.path }.rb", skip: true
78
+ insert_into_file(
79
+ "lib/#{ project.path }.rb",
80
+ from_template("lib_loader.erb"),
81
+ after: /\n\s*module #{ project.const }\n/
82
+ )
83
+ end
84
+
85
+ # @private
86
+ def add_dependency
87
+ return unless dependency?
88
+ insert_into_file(
89
+ "lib/#{ project.path }/configurator.rb",
90
+ from_template("dependency.erb"),
91
+ after: "class << self\n"
92
+ )
93
+ end
94
+
95
+ # @private
96
+ def add_gemfile
97
+ return unless injection?
98
+ copy_file "Gemfile", skip: true
99
+ append_to_file "Gemfile", "gem \"#{ gemname }\", group: :test"
100
+ end
101
+
102
+ # @private
103
+ def add_injection
104
+ return unless injection?
105
+ insert_into_file(
106
+ "spec/dummy/config/initializers/#{ project.file }.rb",
107
+ "\nrequire \"#{ gemname }\"",
108
+ before: /\n*#{ project.type }/,
109
+ skip: true
110
+ )
111
+ end
112
+
113
+ # @private
114
+ def set_injection
115
+ return unless injection?
116
+ insert_into_file(
117
+ "spec/dummy/config/initializers/#{ project.file }.rb",
118
+ "\n #{ dependency } = #{ injection }",
119
+ before: /\nend/,
120
+ skip: true
121
+ )
122
+ end
123
+
124
+ private
125
+
126
+ def project
127
+ @project ||= Hexx::CLI::Name.new ::File.basename(destination_root)
128
+ end
129
+
130
+ def dependency
131
+ @dependency ||= name ? name.to_s.snake_case : nil
132
+ end
133
+
134
+ def injection
135
+ @injection ||= options.fetch("injection", "").camel_case
136
+ end
137
+
138
+ def gemname
139
+ @gemname ||= options.fetch("gemname", "").snake_case
140
+ end
141
+
142
+ def dependency?
143
+ dependency ? true : false
144
+ end
145
+
146
+ def injection?
147
+ dependency? && !injection.blank? && !gemname.blank?
148
+ end
149
+
150
+ end # module Hexx
151
+
152
+ end # module Dependencies
153
+
154
+ end # class CLI
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ module Hexx
4
+
5
+ module Dependencies
6
+
7
+ # The semantic version of the module.
8
+ # @see http://semver.org/ Semantic versioning 2.0
9
+ VERSION = "0.0.1".freeze
10
+
11
+ end # module Dependencies
12
+
13
+ end # module Hexx
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ module Hexx
4
+
5
+ # The namespace for 'hexx-dependencies' module
6
+ module Dependencies
7
+
8
+ require_relative "dependencies/cli"
9
+
10
+ end # module Dependencies
11
+
12
+ end # module Hexx
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ require "hexx-cli"
3
+
4
+ # The shared namespace for hexx-based modules
5
+ module Hexx
6
+
7
+ require_relative "hexx/dependencies"
8
+ require_relative "hexx/dependencies/version"
9
+
10
+ end # module Hexx
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ require "hexx-rspec"
3
+
4
+ # Loads runtime metrics
5
+ Hexx::RSpec.load_metrics_for(self)
6
+
7
+ # Loads the code under test
8
+ require "hexx-dependencies"
@@ -0,0 +1,145 @@
1
+ # encoding: utf-8
2
+
3
+ describe Hexx::Dependencies::CLI, :sandbox, :capture do
4
+
5
+ describe ".start" do
6
+
7
+ subject { try_in_sandbox { described_class.start params } }
8
+
9
+ shared_examples "creating a loader mechanism" do
10
+
11
+ before { subject }
12
+
13
+ it "[adds dummy loader]" do
14
+ content = read_in_sandbox "spec/spec_helper.rb"
15
+ expect(content).to include "require_relative \"dummy/lib/dummy\""
16
+ end
17
+
18
+ it "[adds dummy lib]" do
19
+ content = read_in_sandbox "spec/dummy/lib/dummy.rb"
20
+ expect(content).to include "ENV[\"PATH_TO_INITIALIZERS\"] ="
21
+ expect(content).to include "\"../../config/initializers\""
22
+ expect(content).to include "require \"sandbox\""
23
+ end
24
+
25
+ it "[adds the initializer]" do
26
+ content = read_in_sandbox "spec/dummy/config/initializers/sandbox.rb"
27
+ expect(content).to include "Sandbox.configure do"
28
+ end
29
+
30
+ it "[adds gem configurator]" do
31
+ content = read_in_sandbox "lib/sandbox/configurator.rb"
32
+ expect(content).to include "class << self"
33
+ expect(content).to include "def configure"
34
+ end
35
+
36
+ it "[adds gem lib]" do
37
+ content = read_in_sandbox "lib/sandbox.rb"
38
+ expect(content).to include "require_relative \"sandbox/configurator\""
39
+ expect(content).to include "ENV[\"PATH_TO_INITIALIZERS\"]"
40
+ expect(content).to include "sandbox.rb"
41
+ end
42
+
43
+ end # shared_examples
44
+
45
+ shared_examples "providing a dependency" do
46
+
47
+ before { subject }
48
+
49
+ it "[adds the attribute]" do
50
+ content = read_in_sandbox "lib/sandbox/configurator.rb"
51
+ expect(content).to include "attr_accessor :#{ name }"
52
+ end
53
+
54
+ end # shared_examples
55
+
56
+ shared_examples "injecting a dependency" do
57
+
58
+ before { subject }
59
+
60
+ it "[adds gem]" do
61
+ content = read_in_sandbox "Gemfile"
62
+ expect(content).to include "gem \"#{ gemname }\", group: :test"
63
+ end
64
+
65
+ it "[adds injection]" do
66
+ content = read_in_sandbox "spec/dummy/config/initializers/sandbox.rb"
67
+ expect(content).to include "require \"#{ gemname }\""
68
+ expect(content).to include "#{ name } = #{ injection }"
69
+ end
70
+
71
+ end # shared_examples
72
+
73
+ context "without params" do
74
+
75
+ let(:params) { %w() }
76
+
77
+ it_behaves_like "creating a loader mechanism"
78
+
79
+ end # context
80
+
81
+ context "foo" do
82
+
83
+ let(:params) { %w(foo) }
84
+
85
+ it_behaves_like "creating a loader mechanism"
86
+
87
+ it_behaves_like "providing a dependency" do
88
+ let(:name) { "foo" }
89
+ end
90
+
91
+ end # context
92
+
93
+ context "foo -i bar -g baz" do
94
+
95
+ let(:params) { %w(foo -i bar -g baz) }
96
+
97
+ it_behaves_like "creating a loader mechanism"
98
+
99
+ it_behaves_like "providing a dependency" do
100
+ let(:name) { "foo" }
101
+ end
102
+
103
+ it_behaves_like "injecting a dependency" do
104
+ let(:name) { "foo" }
105
+ let(:injection) { "Bar" }
106
+ let(:gemname) { "baz" }
107
+ end
108
+
109
+ end # context
110
+
111
+ context "foo -i Bar" do
112
+
113
+ let(:params) { %w(foo -i Bar) }
114
+
115
+ it_behaves_like "creating a loader mechanism"
116
+
117
+ it_behaves_like "providing a dependency" do
118
+ let(:name) { "foo" }
119
+ end
120
+
121
+ end # context
122
+
123
+ context "foo -g baz" do
124
+
125
+ let(:params) { %w(foo -g baz) }
126
+
127
+ it_behaves_like "creating a loader mechanism"
128
+
129
+ it_behaves_like "providing a dependency" do
130
+ let(:name) { "foo" }
131
+ end
132
+
133
+ end # context
134
+
135
+ context "-i bar -g baz" do
136
+
137
+ let(:params) { %w(-i bar -g baz) }
138
+
139
+ it_behaves_like "creating a loader mechanism"
140
+
141
+ end # context
142
+
143
+ end # describe .start
144
+
145
+ end # describe Hexx::Dependencies::CLI
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hexx-dependencies
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Kozin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hexx-cli
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.0'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.0.3
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '0.0'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.0.3
33
+ - !ruby/object:Gem::Dependency
34
+ name: hexx-rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0.3'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.3'
47
+ description: Gem dependency scaffolder.
48
+ email: andrew.kozin@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files:
52
+ - README.md
53
+ - LICENSE
54
+ files:
55
+ - ".gitignore"
56
+ - ".metrics"
57
+ - ".rspec"
58
+ - ".rubocop.yml"
59
+ - ".travis.yml"
60
+ - ".yardopts"
61
+ - Gemfile
62
+ - Guardfile
63
+ - LICENSE
64
+ - README.md
65
+ - Rakefile
66
+ - config/metrics/STYLEGUIDE
67
+ - config/metrics/cane.yml
68
+ - config/metrics/churn.yml
69
+ - config/metrics/flay.yml
70
+ - config/metrics/metric_fu.yml
71
+ - config/metrics/reek.yml
72
+ - config/metrics/roodi.yml
73
+ - config/metrics/rubocop.yml
74
+ - config/metrics/saikuro.yml
75
+ - config/metrics/simplecov.yml
76
+ - config/metrics/yardstick.yml
77
+ - hexx-dependencies.gemspec
78
+ - lib/hexx-dependencies.rb
79
+ - lib/hexx/dependencies.rb
80
+ - lib/hexx/dependencies/cli.rb
81
+ - lib/hexx/dependencies/cli/Gemfile
82
+ - lib/hexx/dependencies/cli/configurator.erb
83
+ - lib/hexx/dependencies/cli/dependency.erb
84
+ - lib/hexx/dependencies/cli/dummy.erb
85
+ - lib/hexx/dependencies/cli/initializer.erb
86
+ - lib/hexx/dependencies/cli/lib.erb
87
+ - lib/hexx/dependencies/cli/lib_loader.erb
88
+ - lib/hexx/dependencies/cli/spec_helper.erb
89
+ - lib/hexx/dependencies/version.rb
90
+ - spec/spec_helper.rb
91
+ - spec/tests/cli_spec.rb
92
+ homepage: https://github.com/nepalez/hexx-dependencies
93
+ licenses:
94
+ - MIT
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '2.0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubyforge_project:
112
+ rubygems_version: 2.4.6
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Creates the loader mechanism and defines an external dependency for the host
116
+ module.
117
+ test_files:
118
+ - spec/spec_helper.rb
119
+ - spec/tests/cli_spec.rb
120
+ has_rdoc: