article_fixture_gen 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rubocop.yml +6 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +49 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +220 -0
  9. data/Rakefile +48 -0
  10. data/article_fixture_gen.gemspec +55 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +16 -0
  13. data/config.reek +8 -0
  14. data/data/all_specs.yml +127 -0
  15. data/data/validations.yml +35 -0
  16. data/exe/article_fixture_gen +16 -0
  17. data/lib/article_fixture_gen/cli/config.rb +57 -0
  18. data/lib/article_fixture_gen/cli/dump_config.rb +43 -0
  19. data/lib/article_fixture_gen/cli.rb +5 -0
  20. data/lib/article_fixture_gen/config/builder.rb +99 -0
  21. data/lib/article_fixture_gen/config/constants.rb +25 -0
  22. data/lib/article_fixture_gen/config/data.rb +26 -0
  23. data/lib/article_fixture_gen/config/option_validator.rb +74 -0
  24. data/lib/article_fixture_gen/config.rb +45 -0
  25. data/lib/article_fixture_gen/data/article.rb +55 -0
  26. data/lib/article_fixture_gen/data/article_content.rb +64 -0
  27. data/lib/article_fixture_gen/data/build_fragment_list.rb +68 -0
  28. data/lib/article_fixture_gen/data/build_target_entry_list.rb +68 -0
  29. data/lib/article_fixture_gen/data/build_word_list.rb +140 -0
  30. data/lib/article_fixture_gen/data/marker_array.rb +29 -0
  31. data/lib/article_fixture_gen/data/marker_tag_pair.rb +25 -0
  32. data/lib/article_fixture_gen/data/mtp_decorated_markup.rb +67 -0
  33. data/lib/article_fixture_gen/data/node_markup.rb +25 -0
  34. data/lib/article_fixture_gen/data/parent_element_for.rb +18 -0
  35. data/lib/article_fixture_gen/data/pmtp_attributes.rb +44 -0
  36. data/lib/article_fixture_gen/data/pmtp_decorated_markup.rb +27 -0
  37. data/lib/article_fixture_gen/data/pmtp_decorator_params.rb +16 -0
  38. data/lib/article_fixture_gen/data/replace_child_nodes_using_new_child.rb +67 -0
  39. data/lib/article_fixture_gen/data/single_marker_tag_pair.rb +31 -0
  40. data/lib/article_fixture_gen/data/smtp_attributes.rb +30 -0
  41. data/lib/article_fixture_gen/data/smtp_decorated_markup.rb +27 -0
  42. data/lib/article_fixture_gen/data/smtp_decorator_params.rb +16 -0
  43. data/lib/article_fixture_gen/data/split_text_at_target_word.rb +59 -0
  44. data/lib/article_fixture_gen/exe/config.rb +42 -0
  45. data/lib/article_fixture_gen/exe/generate_config.rb +51 -0
  46. data/lib/article_fixture_gen/exe/option_parser/trollop/option_spec.rb +30 -0
  47. data/lib/article_fixture_gen/exe/option_parser/trollop/option_spec_item.rb +16 -0
  48. data/lib/article_fixture_gen/exe/option_parser/trollop/options_and_mods.rb +57 -0
  49. data/lib/article_fixture_gen/exe/option_parser/trollop/options_with_defaults.rb +45 -0
  50. data/lib/article_fixture_gen/exe/option_parser/trollop/validator.rb +63 -0
  51. data/lib/article_fixture_gen/exe/option_parser/trollop.rb +49 -0
  52. data/lib/article_fixture_gen/exe/option_parser.rb +13 -0
  53. data/lib/article_fixture_gen/support/logging.rb +25 -0
  54. data/lib/article_fixture_gen/version.rb +6 -0
  55. data/lib/article_fixture_gen.rb +10 -0
  56. data/lib/tasks/prolog_flog_task.rb +12 -0
  57. data/vendor/ruby/2.3.0/bin/article_fixture_gen +22 -0
  58. metadata +515 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 10ed666ba0848073a4ecb39cf4fb96a9791e0c5f
4
+ data.tar.gz: babc44735968ddd244c7f638420aaa6f8529bf7d
5
+ SHA512:
6
+ metadata.gz: b702163928ebce2462dc13c86896fe6ee3292e971dd5f80c018df61e2d9d9b381b43446c5d438623458791c50bc3b27c15d90cc29d8bbf383ccab7d0a9012995
7
+ data.tar.gz: 167d8cb59264aefe445bab24f39a64a66f0b1d63f6503d10e21901682c3261b7a4cf84637e9211036fda84c3efe76f470123c9690a357910042991126fd844db
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /log/
8
+ /o-rdoc/
9
+ /pkg/
10
+ /spec/reports/
11
+ /tmp/
12
+ /bin/
13
+ !/bin/benchmarks
14
+ !/bin/console
15
+ !/bin/setup
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+
2
+ AllCops:
3
+ TargetRubyVersion: 2.3
4
+
5
+ Style/Alias:
6
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at jdickey@seven-sigma.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in article_fixture_gen.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Jeff Dickey
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,220 @@
1
+ # ArticleFixtureGen
2
+
3
+ This Gem implements a utility, `article_fixture_gen`, which generates blog-style article/post [*fixture*](https://en.wikipedia.org/wiki/Test_fixture) data for use in development testing. Initially, the output is in [YAML](https://en.wikipedia.org/wiki/YAML) format.
4
+
5
+ Why another article-data generator? This optionally generates "marker tag pairs" in the articles' body mark­up. These in turn are used to simulate user action affecting data; see below for a more complete descrip­tion. This feature was the original justification for developing the utility.
6
+
7
+ ----
8
+
9
+ ## Contents
10
+
11
+ 1. [Installation](#Installation)
12
+ 2. [Usage](#Usage)
13
+ 3. [Options](#Options)
14
+ 1. [Command-Line Options](#command-line-options)
15
+ 2. [Configuration-File Options](#configuration-file-options)
16
+ 4. [What Are Marker Tag Pairs?](#what-are-marker-tag-pairs-)
17
+ 1. [Single-Marker Tag Pair](#single-marker-tag-pair)
18
+ 2. [Paired-Marker Tag Pair](#paired-marker-tag-pair)
19
+ 5. [Article Fixture-Data Format](#article-fixture-data-format)
20
+ 6. [Development](#development)
21
+ 1. [Running Tests](#running-tests)
22
+ 2. [Feasible Future Features](#feasible-future-features)
23
+ 7. [Contributing](#contributing)
24
+ 1. [Process](#process)
25
+ 2. [Notes on Contributing](#notes-on-contributing)
26
+ 8. [License](#license)
27
+
28
+ ----
29
+
30
+ ## Installation
31
+
32
+ Add this line to your application's Gemfile:
33
+
34
+ ```ruby
35
+ gem 'article_fixture_gen'
36
+ ```
37
+
38
+ And then execute:
39
+
40
+ $ bundle
41
+
42
+ Or install it yourself as:
43
+
44
+ $ gem install article_fixture_gen
45
+
46
+ ## Usage
47
+
48
+ From the command line, running
49
+
50
+ ```
51
+ $ article_fixture_gen
52
+ ```
53
+
54
+ with no existing configuration as described below, will produce YAML output, sent to standard output, for five *articles* that can then be loaded to create test-fixture entities in your application development.
55
+
56
+ ## Options
57
+
58
+ Each of these options may be specified either from the command line or from a configuration file. Configuration specified on the command line overrides conflicting settings specified in a configuration file; in other words, the effective value of a particular option is determined based on
59
+
60
+ 1. the specified default value, which *may* be overridden by
61
+ 2. a value specified in a configuration file, which may be overridden by
62
+ 3. a value specified on the command line.
63
+
64
+ Specifying an invalid value for any setting in a configuration file and/or on the command line will cause the invalid value to be ignored.
65
+
66
+ For any option which is one of a pair of min/max options, such as `--para-count-min` and `--para-count-max`, if the effective value of the `*-min` setting is *greater than* the effective value of the`*-max` setting, then execution will be aborted with a suitable error message. Specifying the same effective value for both will, of course, function as a fixed value, eliminating randomised variation. When the `*-min` and `*-max` settings have different values, then the value used at any given time will be a random value between the minimum and maximum values, inclusive.
67
+
68
+ ### Command-Line Options
69
+
70
+ #### `--article-count`
71
+
72
+ Specifies the number of [article fixtures](#article-fixture-data-format) to generate. Valid values are positive integers; the default is 5 (equivalent to `--article-count 5`). Not specifying the option, or specifying an invalid value, will use the default.
73
+
74
+ #### `—config`
75
+
76
+ Specifies the filename of a [configuration file](#configuration-file-options) containing settings for this utility. If no configura­tion file is specified, and one exists in the `afg-config.yml` file in the current directory, it will be used.
77
+
78
+ #### `—generate-config`
79
+
80
+ Specifies the filename of a [configuration file](#configuration-file-options) to which all currently-effective option settings will be written. If the filename specified here is the same as that specified for the `—config` option above, then the file will be written to only after any existing settings are read. This allows the user to, for example, set the one or two options that she knows she cares about, generate a full configuration file with all settings, and experiment from there.
81
+
82
+ #### `--para-count-max`
83
+
84
+ Specifies the maximum number of (HTML) paragraphs in each generated fixture. This defaults to 10 (equivalent to `--para-count-max 10`) and, if specified, must be at least 1.
85
+
86
+ #### `--para-count-min`
87
+
88
+ Specifies the minimum number of (HTML) paragraphs in each generated fixture. This defaults to 2 (equivalent to `--para-count-min 2` and, if specified, must be at least 1.
89
+
90
+ #### `--pmtp-count`
91
+
92
+ Specifies the number of [paired-marker tag](#paired-marker-tag-pair) pairs to generate. This defaults to 2 (equivalent to `--pmtp-count 2`) and, if specified, may be any integer greater than or equal to 0. (Note that a combination of short content (paragraph/sentence count) with a high pMTP count is inadvisa­ble, as each pMTP **must** contain one or more words and each pMTP **must not** overlap another.)
93
+
94
+ #### `--pmtp-text`
95
+
96
+ Specifies the text portion of [paired-marker tag](#paired-marker-tag-pair) pairs' `id` attribute values. This defaults to `paired-mtp` (thus equivalent to specifying `--pmtp-text paired-mtp`) and, if specified, may be any non-empty contiguous text string made up of alphabetic characters optionally interspersed with hyphen (`-`) characters, so long as neither the first nor last characters are hyphens.
97
+
98
+ #### `--sent-count-max`
99
+
100
+ Specifies the maximum number of sentences in each paragraph within each generated fixture. This defaults to 8 (equivalent to `--sent-count-max 8`) and, if specified, must be at least 1.
101
+
102
+ #### `--sent-count-min`
103
+
104
+ Specifies the minimum number of sentences in each paragraph within each generated fixture. This defaults to 1 (equivalent to `--sent-count-min 1`), which is the minimum allowed value.
105
+
106
+ #### `--smtp-count`
107
+
108
+ Specifies the number of [single-marker tag](#single-marker-tag-pair) pairs to generate within the content. This defaults to 4 (equivalent to `--smtp-count 4`) and, if specified, may be any integer greater than or equal to 0. A relatively high sMTP/word count ratio doesn't have the same impact that it does for pMTPs, since it's permissible to have multiple immediately adjacent single-marker tag pairs.
109
+
110
+ #### `--smtp-text`
111
+
112
+ Specifies the text portion of [single-marker tag](#single-marker-tag-pair) pairs' `id` attribute values. This defaults to `single-mtp` (thus equivalent to specifying `--smtp-text single-mtp`) and, if specified, may be any non-empty contiguous text string made up of alphabetic characters optionally interspersed with hyphen (`-`) characters, so long as neither the first nor last characters are hyphens.
113
+
114
+ ### Configuration-File Options
115
+
116
+ Option settings may be defined in a YAML-formatted configuration file and loaded into the utili­ty via the `—config` command-line option. An example configuration file which simply lists all de­fault settings is shown below:
117
+
118
+ ```yaml
119
+ ---
120
+ :article_count: 5
121
+ :para_count:
122
+ :max: 10
123
+ :min: 2
124
+ :pmtp_count: 2
125
+ :pmtp_text: paired-mtp
126
+ :sent_count:
127
+ :max: 8
128
+ :min: 1
129
+ :smtp_count: 4
130
+ :smtp_text: single-mtp
131
+ ```
132
+
133
+ ## What Are Marker Tag Pairs?
134
+
135
+ A *marker tag pair*, or *MTP,* is a specifically-formatted `<a></a>` tag pair, where
136
+
137
+ 1. no content separates the opening and closing tags;
138
+ 2. the opening tag has an `href` attribute whose value is the empty string; and
139
+ 3. the opening tag has an `id` attribute, whose value is formatted differently based on whether it is a single-marker or paired-marker tag pair, but in any case will start with a sequence of text characters (alphabetic or hyphens), followed by a
140
+
141
+ ### Single-Marker Tag Pair
142
+
143
+ A single-marker tag pair (*sMTP*) is, logically enough, one `<a></a>` tag pair, where the `id` attri­bute of the opening tag follows the format `TEXT-uuid`, where `TEXT` can be any sequence of alphabetic characters, possibly intermixed with hyphen (`-`) characters. The `uuid` placeholder represents a [UUID](https://en.wikipedia.org/wiki/Universally_unique_identifier).
144
+
145
+ ### Paired-Marker Tag Pair
146
+
147
+ A paired-marker tag pair (*pMTP*) is a sequence of two `<a></a>` tag pairs, where the `id` attribute of each opening tag follows the format `TEXT-uuid-begin` for the first of the two tag pairs, and `TEXT-uuid-end` for the second. The `TEXT` and `uuid` placeholders follow the same conven­tions as for sMTPs, with the restriction that both tag pairs' `TEXT` and `uuid` placeholders **must** be identical, and the `-begin` MTP **must** occur before the `-end` MTP.
148
+
149
+ ## Article Fixture-Data Format
150
+
151
+ Each conceptual Article has the following attributes, included in the YAML output:
152
+
153
+ 1. A `:title`, which is a simple text string of between three and ten (random) words;
154
+ 2. An `:author_name`, which is a text string, containing a randomly-generated given and "family" name fol­lowing simple Western convention;
155
+ 3. A `:body`, which is a string of (valid, well-formed) HTML (as XHTML/HTML5) content comprising one or more `<p></p>` tag pairs with random generated text inside the paragraphs. Optional settings may cause additional HTML to be inserted into the paragraphs' text; however, each is still guaranteed to be valid and well-formed. Note that multiple paragraphs *are not* enclosed within a containing `<div></div> or other tag pair; if the HTML tool you use (such as [Ox](https://github.com/ohler55/ox)) chokes on such multiple elements without a shared containing element, you'll need additional processing once the YAML has been parsed;
156
+ 4. An array of `:keywords`, which are zero to at most ten random short strings of one or more words each. There is no guarantee that any two generated Article entries will share any keywords, but no keywords will be repeated within any given Article;
157
+ 5. An `:image_url`, which is a string in the form `http://www.example.com/image_NUM.FMT`, where `NUM` is text for a one- to four-digit number (1 to 9999 inclusive) and `FMT` is either `png` or `jpg`. Both components are randomly selected each time;
158
+ 6. A `:created_at` timestamp, which is a YAML-formatted timestamp with sub-second (formatted as pico­second) resolution;
159
+
160
+ Your Article may not need all of these fields; they were used for different applications within our organisa­tion. Future releases are expected to support filtering the then-supported attributes.
161
+
162
+ ## Development
163
+
164
+ After checking out the repo, run `bin/setup` to install dependencies (which as of now must already be in­stalled on your local system). Then, run `bin/rake test` to run the tests, or `bin/rake` to run tests and, if tests are successful, further static-analysis tools ([RuboCop](https://github.com/bbatsov/rubocop), [Flay](https://github.com/seattlerb/flay), [Flog](https://github.com/seattlerb/flog), and [Reek](https://github.com/troessner/reek)).
165
+
166
+ To install *your build* of this Gem onto your local machine, run `bin/rake install`. We recom­mend that you uninstall any previously-installed "official" Gem to increase your confi­dence that your tests are running against your build. You should then be able to run the `article_fixture_gen` command-line tool.
167
+
168
+ ### Running Tests
169
+
170
+ Running tests *other than command-line tests* (within the `test/exe/article_fixture_gen/` directory) works just as you would expect for individual MiniTest::Spec test scripts; you can run a command line such as `ruby test/article_fixture_gen/data/article_test.rb` to run a single test-spec file. Also, running `rake` and `rake test` works just as you'd expect for running the complete set of tests.
171
+
172
+ To run individual command-line tests, two changes are necessary:
173
+
174
+ 1. Install your current version of the Gem in your local Gem repo with the command line `rake install`;
175
+ 2. After successfully installing, run a single test prefixing the command line with `bundle exec`, as in `bundle exec ruby test/exe/article_fixture_gen/version_test.rb`.
176
+
177
+ If anyone knows how to streamline this, to write the command-line tests so that they can be run from the command line without `bundle exec` as is done for all other tests, *please* submit a pull request!
178
+
179
+ ### Feasible Future Features
180
+
181
+ #### Suppressing Field Output
182
+
183
+ The attributes specified above may not be necessary in all uses of the utility. To suppress out­put of undesired fields, new options may be supported; for example, `--no-image-url` would sup­press the `:image_url` attribute.
184
+
185
+ #### Other Ideas?
186
+
187
+ Do you see something we missed that you'd find useful? Open an [issue and PR](#process) and let's have a chat about it!
188
+
189
+ ## Contributing
190
+
191
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jdickey/article_fixture_gen. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to ad­here to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
192
+
193
+ ### Process
194
+
195
+ If you wish to submit a new feature to the Gem, please [open an issue](https://github.com/jdickey/article_fixture_gen/issues/new) to discuss your idea with the main­tainer and other interested community members. Issue threads are a great place to thrash out the details of what you're trying to accomplish and how your work would affect other code and/or community mem­bers. If you need help with something, or aren't sure how to choose between different ideas to accomplish some detail of what you're setting out to do, this is the place to discuss that. There is *no such thing as a stu­pid question that you don't know the answer to* (once you've researched in your search engine of choice, of course; please do respect people's time and attention).
196
+
197
+ The processes for proposing a new feature or a fix to an open bug-report issue are very similar:
198
+
199
+ 1. Make sure that you have forked this Gem's [repository on GitHub](https://github.com/jdickey/article_fixture_gen) to your own GitHub account. (If you don't yet have a GitHub account, [join](https://github.com/join?source=header-home); it's free.)
200
+ 2. If you're proposing a new feature, [open an issue](https://github.com/jdickey/article_fixture_gen) as suggested above. If you're addressing an existing issue, *thanks;* you don't need to open a new one.
201
+ 3. Clone *your* copy of the repo to your local development system.
202
+ 4. Create a new Git branch for your work. It's best to give it a reasonably short name that's suggestive of what you're specifically trying to accomplish.
203
+ 1. If you're adding a new feature, please use a descriptive name for your feature branch. `output-as-fooml` is a much more descriptive name than `my-branch` when you're working on adding the ability to output FooML instead of YAML, for example.
204
+ 2. If you're adding a fix for an existing issue *other than* a new feature which you've opened to propose a new feature, then use the branch name `issue-nnnn`, where `nnnn` is the issue number in Github. For example, if you're working on Issue #4972, then you'd ordinarily name your branch `issue-4172`.
205
+ 3. **Do not** work on your copy of the `master` branch! Any pull request (see below) that you later submit for changes you've made on `master` will be rejected, and you will be asked to submit your pro­posed changes on a branch that branches from a commit on the upstream `master` branch.
206
+ 5. Now write great (tests and) code!
207
+ 6. As soon as you have something to show, *even if it's not complete yet* (but it passes what tests you have), [push your branch](https://help.github.com/articles/pushing-to-a-remote/) to *your forked repo* on GitHub and open a [new pull request](https://github.com/jdickey/article_fixture_gen/compare) ("PR") for *your branch* com­pared to `master` on the [upstream](https://github.com/jdickey/article_fixture_gen) repository. That lets the maintainer and other community mem­bers review your code and tests, comment, help out, and so on.
208
+ 7. Continuing with your pull request, it's usually better if you make small, incremental changes in each commit in a sequence. We (endeavour to) practice [behaviour-driven development](https://en.wikipedia.org/wiki/Behavior-driven_development): write tests for the simplest thing that could possibly work; see the tests fail; then make them pass, commit, and go on to the next simplest thing. Don't get hung up on lots of refac­toring until you have code that does everything you want it to do; once you have a legiti­mately complete green bar, *that's* the time to apply SOLID principles and patterns to DRY things up. Better to have (temporary) duplication than choose the wrong abstraction.
209
+
210
+ ### Notes on Contributing
211
+
212
+ Don't be discouraged if it takes several commits to complete your work and then several more to get everybody agreeing that it's complete and well done. ("Useful" and "worth adding" should have been settled at the issue stage, before you started working on your PR.) That's because…
213
+
214
+ When pull requests are *merged* into the `master` branch, they are [*squashed*](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Squashing-Commits) so that all changes are applied to `master` in a single commit. This means that, even if you have a dozen or more commits in your PR where you've been *very* incremental, and even changed direction once or twice, what matters is the final result; not what it took to get there.
215
+
216
+ Once your PR has been merged, it's a good idea to pull the upstream `master` branch to your development system (`git pull upstream master`) and then push it to your fork (`git push origin master`). (What? You don't *have* an `upstream` remote as shown by `git remote -v`? Run the command `git remote add upstream https://github.com/TheProlog/prolog_minitest_matchers.git` from your local development directory, and now you do.)
217
+
218
+ ## License
219
+
220
+ The Gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,48 @@
1
+
2
+ require "bundler/gem_tasks"
3
+ require "rake/testtask"
4
+
5
+ require 'rake/tasklib'
6
+ require 'flay'
7
+ require 'flay_task'
8
+ require 'tasks/prolog_flog_task'
9
+ require 'reek/rake/task'
10
+ require 'rubocop/rake_task'
11
+
12
+ Rake::TestTask.new(:test) do |t|
13
+ t.libs << "test"
14
+ t.libs << "lib"
15
+ t.test_files = FileList['test/**/*_test.rb']
16
+ end
17
+
18
+ RuboCop::RakeTask.new(:rubocop) do |task|
19
+ task.patterns = [
20
+ 'lib/**/*.rb',
21
+ 'test/**/*.rb'
22
+ ]
23
+ task.formatters = ['simple', 'd']
24
+ task.fail_on_error = true
25
+ # task.options << '--rails'
26
+ task.options << '--display-cop-names'
27
+ end
28
+
29
+ Reek::Rake::Task.new do |t|
30
+ t.config_file = 'config.reek'
31
+ t.source_files = 'lib/**/*.rb'
32
+ t.reek_opts = '--sort-by smelliness -s'
33
+ end
34
+
35
+ FlayTask.new do |t|
36
+ t.verbose = true
37
+ t.dirs = %w(app lib)
38
+ end
39
+
40
+ FlogTask.new do |t|
41
+ t.verbose = true
42
+ t.threshold = 600 # default is 200
43
+ t.methods_only = true
44
+ t.dirs = %w(lib)
45
+ end
46
+
47
+ task(:default).clear
48
+ task default: [:test, :rubocop, :flay, :flog, :reek]
@@ -0,0 +1,55 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'article_fixture_gen/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "article_fixture_gen"
8
+ spec.version = ArticleFixtureGen::VERSION
9
+ spec.authors = ["Jeff Dickey"]
10
+ spec.email = ["jdickey@seven-sigma.com"]
11
+ spec.required_ruby_version = ">= 2.3.0"
12
+
13
+ spec.summary = %q{Generate blog post/article fixture data, with embedded marker tag pairs.}
14
+ # spec.description = %q{TODO: Write a longer description or delete this line.}
15
+ spec.homepage = "https://github.com/jdickey/article_fixture_gen"
16
+ spec.license = "MIT"
17
+
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
20
+ # if spec.respond_to?(:metadata)
21
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
22
+ # else
23
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_dependency "awesome_print", "~> 1.7", ">= 1.7.0"
32
+ spec.add_dependency "ffaker", "~> 2.2", ">= 2.2.0"
33
+ spec.add_dependency "ox", "~> 2.4", ">= 2.4.4"
34
+ spec.add_dependency "prolog-dry_types", "~> 0.3", ">= 0.3.0"
35
+ spec.add_dependency "semantic_logger", "~> 3.3", ">= 3.3.0"
36
+ spec.add_dependency "trollop", "~> 2.1", ">= 2.1.2"
37
+
38
+ spec.add_development_dependency "bundler", "~> 1.12", ">= 1.12.5"
39
+ spec.add_development_dependency "rake", "~> 11.2", ">= 11.2.2"
40
+ spec.add_development_dependency "minitest", "~> 5.9", ">= 5.9.0"
41
+
42
+ spec.add_development_dependency "minitest-matchers", "~> 1.4", ">= 1.4.1"
43
+ spec.add_development_dependency "minitest-profile" # , "~> 1.4", ">= 1.4.1"
44
+ spec.add_development_dependency "minitest-reporters", "~> 1.1", ">= 1.1.11"
45
+ spec.add_development_dependency "minitest-tagz", "~> 1.5", ">= 1.5.1"
46
+ spec.add_development_dependency "prolog_minitest_matchers", "~> 0.3", ">= 0.3.1"
47
+
48
+ spec.add_development_dependency "flay", "~> 2.8", ">= 2.8.0"
49
+ spec.add_development_dependency "flog", "~> 4.4", ">= 4.4.0"
50
+ spec.add_development_dependency "reek", "~> 4", ">= 4.2.4"
51
+ spec.add_development_dependency "rubocop", "~> 0.42", ">= 0.42.0"
52
+ spec.add_development_dependency "simplecov", "~> 0.12", ">= 0.12.0"
53
+ spec.add_development_dependency "pry-byebug", "~> 3.4", ">= 3.4.0"
54
+ spec.add_development_dependency "pry-doc", "~> 0.9", ">= 0.9.0"
55
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "article_fixture_gen"
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
data/bin/setup ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env bash
2
+ # set -euo pipefail
3
+ # IFS=$'\n\t'
4
+ # set -vx
5
+
6
+ rm -rf .bundle Gemfile.lock
7
+
8
+ bundle install --local
9
+
10
+ if [[ -d $RBENV_ROOT ]]
11
+ then
12
+ rbenv rehash
13
+ fi
14
+
15
+ mkdir -p log
16
+ bundle binstub --force flay flog pry rake reek rubocop
data/config.reek ADDED
@@ -0,0 +1,8 @@
1
+
2
+ LongParameterList:
3
+ max_params: 4 # If it's good enough for Sandi, it's good enough for us.
4
+
5
+ # NestedIterators:
6
+ # max_allowed_nesting: 2
7
+ # ignore_iterators:
8
+ # - lambda
@@ -0,0 +1,127 @@
1
+ ---
2
+ - !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpec
3
+ item: !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpecItem
4
+ key: :article_count
5
+ desc: Number of article fixtures to generate
6
+ options:
7
+ :default: 5
8
+ :short: :none
9
+ :type: :int
10
+ :long: article-count
11
+ :multi: false
12
+ :desc: Number of article fixtures to generate
13
+ - !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpec
14
+ item: !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpecItem
15
+ key: :config
16
+ desc: Modify default configuration by applying contents of a YAML file
17
+ options:
18
+ :type: :string
19
+ :short: :none
20
+ :long: config
21
+ :multi: false
22
+ :desc: Modify default configuration by applying contents of a YAML file
23
+ - !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpec
24
+ item: !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpecItem
25
+ key: :generate_config
26
+ desc: Export configuration to a YAML file after initialisation is complete.
27
+ options:
28
+ :type: :string
29
+ :short: :none
30
+ :long: generate-config
31
+ :multi: false
32
+ :desc: Export configuration to a YAML file after initialisation is complete.
33
+ - !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpec
34
+ item: !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpecItem
35
+ key: :para_count_max
36
+ desc: Maximum number of (HTML) paragraphs in each generated fixture.
37
+ options:
38
+ :default: 10
39
+ :short: :none
40
+ :type: :int
41
+ :long: para-count-max
42
+ :multi: false
43
+ :desc: Maximum number of (HTML) paragraphs in each generated fixture.
44
+ - !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpec
45
+ item: !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpecItem
46
+ key: :para_count_min
47
+ desc: Minimum number of (HTML) paragraphs in each generated fixture.
48
+ options:
49
+ :default: 2
50
+ :short: :none
51
+ :type: :int
52
+ :long: para-count-min
53
+ :multi: false
54
+ :desc: Minimum number of (HTML) paragraphs in each generated fixture.
55
+ - !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpec
56
+ item: !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpecItem
57
+ key: :pmtp_count
58
+ desc: Specifies the number of paired-marker tag pairs to generate.
59
+ options:
60
+ :default: 2
61
+ :short: :none
62
+ :type: :int
63
+ :long: pmtp-count
64
+ :multi: false
65
+ :desc: Specifies the number of paired-marker tag pairs to generate.
66
+ - !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpec
67
+ item: !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpecItem
68
+ key: :pmtp_text
69
+ desc: Specifies the text portion of paired-marker tag pairs' :id attribute values.
70
+ options:
71
+ :default: paired-mtp
72
+ :short: :none
73
+ :type: :string
74
+ :long: pmtp-text
75
+ :multi: false
76
+ :desc: Specifies the text portion of paired-marker tag pairs' :id attribute
77
+ values.
78
+ - !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpec
79
+ item: !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpecItem
80
+ key: :sent_count_max
81
+ desc: Specifies the maximum number of sentences in each paragraph within each
82
+ generated fixture.
83
+ options:
84
+ :default: 8
85
+ :short: :none
86
+ :type: :int
87
+ :long: sent-count-max
88
+ :multi: false
89
+ :desc: Specifies the maximum number of sentences in each paragraph within each
90
+ generated fixture.
91
+ - !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpec
92
+ item: !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpecItem
93
+ key: :sent_count_min
94
+ desc: Specifies the minimum number of sentences in each paragraph within each
95
+ generated fixture.
96
+ options:
97
+ :default: 1
98
+ :short: :none
99
+ :type: :int
100
+ :long: sent-count-min
101
+ :multi: false
102
+ :desc: Specifies the minimum number of sentences in each paragraph within each
103
+ generated fixture.
104
+ - !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpec
105
+ item: !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpecItem
106
+ key: :smtp_count
107
+ desc: Specifies the number of single-marker tag pairs to generate within the content.
108
+ options:
109
+ :default: 4
110
+ :short: :none
111
+ :type: :int
112
+ :long: smtp-count
113
+ :multi: false
114
+ :desc: Specifies the number of single-marker tag pairs to generate within the
115
+ content.
116
+ - !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpec
117
+ item: !ruby/object:ArticleFixtureGen::Exe::Trollop::OptionSpecItem
118
+ key: :smtp_text
119
+ desc: Specifies the text portion of single-marker tag pairs' :id attribute values.
120
+ options:
121
+ :default: single-mtp
122
+ :short: :none
123
+ :type: :string
124
+ :long: smtp-text
125
+ :multi: false
126
+ :desc: Specifies the text portion of single-marker tag pairs' :id attribute
127
+ values.
@@ -0,0 +1,35 @@
1
+ ---
2
+ - :key: :para_count_max
3
+ :str: must be at least 1
4
+ :fails_with: "-> (options) { options[:para_count_max] < 1 }"
5
+ - :key: :para_count_max
6
+ :str: must be >= the value for --para-count-min
7
+ :fails_with: "-> (options) { options[:para_count_max] < options[:para_count_min]
8
+ }"
9
+ - :key: :para_count_min
10
+ :str: must be at least 1
11
+ :fails_with: "-> (options) { options[:para_count_min] < 1 }"
12
+ - :key: :para_count_min
13
+ :str: must be <= the value for --para-count-max
14
+ :fails_with: "-> (options) { options[:para_count_max] < options[:para_count_min]
15
+ }"
16
+ - :key: :pmtp_text
17
+ :str: may not be empty
18
+ :fails_with: "-> (options) { options[:pmtp_text].to_s.strip.empty? }"
19
+ - :key: :sent_count_max
20
+ :str: must be at least 1
21
+ :fails_with: "-> (options) { options[:sent_count_max] < 1 }"
22
+ - :key: :sent_count_max
23
+ :str: must be >= the value for --sent-count-min
24
+ :fails_with: "-> (options) { options[:sent_count_max] < options[:sent_count_min]
25
+ }"
26
+ - :key: :sent_count_min
27
+ :str: must be at least 1
28
+ :fails_with: "-> (options) { options[:sent_count_min] < 1 }"
29
+ - :key: :sent_count_min
30
+ :str: must be <= the value for --sent-count-max
31
+ :fails_with: "-> (options) { options[:sent_count_max] < options[:sent_count_min]
32
+ }"
33
+ - :key: :smtp_text
34
+ :str: may not be empty
35
+ :fails_with: "-> (options) { options[:smtp_text].to_s.strip.empty? }"