orderly_garden 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 65be954c3ee21801615b979c34e9c7b357755879
4
+ data.tar.gz: 7b2a8ca405d5d3322ccccc7b5998f86c3e2c2bdf
5
+ SHA512:
6
+ metadata.gz: f155b50d2a9efbe55ef0651f5e571fadd6e5efcc9ca1b29a48bd1fa47f2872fae401c6f28ee9e22160f313a8d2ac2e8d84caf50550e1901047dfb33826c93431
7
+ data.tar.gz: 6afc74ce6db4041a7d248adb8faa1dbd01bac04bbf43ea08912d9ba97e420c6887368dc058370acb52049203e0c0cf6097f85f2a5a218a1b1c84f06070fbf66c
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ *.bundle
10
+ *.so
11
+ *.o
12
+ *.a
13
+ mkmf.log
14
+ /.rubocop.yml
File without changes
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # rubocop:disable Style/LeadingCommentSpace
2
+ #ruby-gemset=orderly_garden
3
+ # rubocop:enable Style/LeadingCommentSpace
4
+ source "https://rubygems.org"
5
+ ruby "2.2.3"
6
+
7
+ # Specify your gem's dependencies in orderly_garden.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,42 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ orderly_garden (0.1.0)
5
+ bundler-audit (> 0)
6
+ rake (~> 10.0)
7
+ rubocop (> 0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.1.0)
13
+ astrolabe (1.3.1)
14
+ parser (~> 2.2)
15
+ bundler-audit (0.4.0)
16
+ bundler (~> 1.2)
17
+ thor (~> 0.18)
18
+ parser (2.2.3.0)
19
+ ast (>= 1.1, < 3.0)
20
+ powerpack (0.1.1)
21
+ rainbow (2.0.0)
22
+ rake (10.4.2)
23
+ rubocop (0.35.1)
24
+ astrolabe (~> 1.3)
25
+ parser (>= 2.2.3.0, < 3.0)
26
+ powerpack (~> 0.1)
27
+ rainbow (>= 1.99.1, < 3.0)
28
+ ruby-progressbar (~> 1.7)
29
+ tins (<= 1.6.0)
30
+ ruby-progressbar (1.7.5)
31
+ thor (0.19.1)
32
+ tins (1.6.0)
33
+
34
+ PLATFORMS
35
+ ruby
36
+
37
+ DEPENDENCIES
38
+ bundler (~> 1.7)
39
+ orderly_garden!
40
+
41
+ BUNDLED WITH
42
+ 1.10.6
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Jon Frisby
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # OrderlyGarden
2
+
3
+ A set of tools for Rake and Ruby workflows, to help keep things neat and tidy.
4
+
5
+ * `parent_task`: Automatically run all sub-tasks in a namespace when the namespace-named task is run.
6
+ * Limit the number of Rake threads to a sane number by default.
7
+ * Lint metric for code volume if `cloc` is installed.
8
+ * Ruby style enforcement, and slightly saner Rubocop defaults.
9
+ * Dependency checking with `bundler-audit`, and `bundle outdated`.
10
+ * `with_tempfile`: Manage a temp file for you, and optionally replace a destination path with it upon success.
11
+ * `write_file`: Write an array of strings to a file ensuring they're joined by newlines and have a trailing newline.
12
+
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem "orderly_garden", require: false, git: "git@github.com:MrJoy/orderly_garden.git"
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ ```bash
25
+ bundle
26
+ ```
27
+
28
+ Or install it yourself as:
29
+
30
+ ```bash
31
+ gem install orderly_garden
32
+ ```
33
+
34
+
35
+ ## Usage
36
+
37
+ TODO: Write usage instructions here. Hint, try `rake -T`.
38
+
39
+ ### Setup
40
+
41
+ 1. In `Rakefile`, add this -- replacing the domain name with the URL of your private Docker registry:
42
+ ```ruby
43
+ require "rubygems"
44
+ require "bundler/setup"
45
+ Bundler.require(:default, :development, :test)
46
+ require "orderly_gardem"
47
+ OrderlyGarden.init!
48
+ ```
49
+ 1. Create a file named `.rubocop.local.yml` with your own Rubocop rules / configuration.
50
+ * This will be merged with the saner defaults provided by `orderly_garden` when running `rake lint:rubocop`.
51
+ 1. Add `/.rubocop.yml` to your `.gitignore` file, as this will be auto-generated.
52
+
53
+ ### Running The Tools
54
+
55
+ ```bash
56
+ rake lint # Run all `lint:*` tasks. Includes `bundler-audit` and `Rubocop` by default.
57
+ ```
58
+
59
+ ### Custom Lint Tasks
60
+
61
+ To add a task that gets executed when you run `rake lint`, simply create it in the `lint` namespace:
62
+
63
+ ```ruby
64
+ namespace :lint do
65
+ desc "Some sort of lint check for your project. Will be included in `rake lint` automatically."
66
+ task :my_check do
67
+ end
68
+ end
69
+ ```
70
+
71
+ ### Making Your Own Auto-Discovery Task Groups
72
+
73
+ ```ruby
74
+ desc "Run all `my_group:*` tasks."
75
+ parent_task :my_group
76
+
77
+ namespace :my_group do
78
+ desc "Some task to include in `rake my_group`."
79
+ task :some_task do
80
+ end
81
+ end
82
+ ```
83
+
84
+
85
+ ## Contributing
86
+
87
+ 1. Fork it ( https://github.com/MrJoy/orderly_garden/fork )
88
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
89
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
90
+ 4. Push to the branch (`git push origin my-new-feature`)
91
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ $LOAD_PATH << "./lib"
4
+
5
+ require "orderly_garden"
6
+ OrderlyGarden.init!
@@ -0,0 +1,109 @@
1
+ # TODO: Eliminate all Bundler binstub files properly.
2
+ AllCops:
3
+ Exclude:
4
+ - bin/bundle
5
+ - bin/bundle-audit
6
+ - bin/rails
7
+ - bin/rake
8
+ - bin/spring
9
+ - db/schema.rb
10
+ - tmp/**/*
11
+
12
+ Lint/FormatParameterMismatch:
13
+ Enabled: true
14
+
15
+ # Lint/OptionHash:
16
+ # Enabled: true
17
+
18
+ Metrics/LineLength:
19
+ Max: 100
20
+
21
+ Metrics/MethodLength:
22
+ Exclude:
23
+ - 'db/migrate/*'
24
+
25
+ Performance/StringReplacement:
26
+ Enabled: true
27
+
28
+ Style/AccessModifierIndentation:
29
+ EnforcedStyle: outdent
30
+
31
+ Style/AlignHash:
32
+ EnforcedColonStyle: table
33
+ # TODO: Err, maybe keys here?
34
+ EnforcedLastArgumentHashStyle: ignore_implicit
35
+
36
+ Style/CollectionMethods:
37
+ PreferredMethods:
38
+ find: detect
39
+ inject: reduce
40
+ collect: map
41
+ find_all: select
42
+
43
+ # Allow comments to be aligned to one another.
44
+ Style/CommentIndentation:
45
+ Enabled: false
46
+
47
+ # Don't bother with class documentation for Rails application class, and DB
48
+ # migrations.
49
+ Style/Documentation:
50
+ Exclude:
51
+ - 'db/migrate/*'
52
+ - 'config/application.rb'
53
+ - '**/version.rb'
54
+
55
+ # We like the truthiness operator.
56
+ Style/DoubleNegation:
57
+ Enabled: false
58
+
59
+ # Style/DotPosition:
60
+ # EnforcedStyle: trailing
61
+
62
+ Style/EmptyLineBetweenDefs:
63
+ AllowAdjacentOneLineDefs: true
64
+
65
+ Style/ExtraSpacing:
66
+ AllowForAlignment: true
67
+
68
+ Style/FormatString:
69
+ EnforcedStyle: 'String#%'
70
+ SupportedStyles: 'String#%'
71
+
72
+ # Style/GuardClause:
73
+ # Enabled: false
74
+
75
+ Style/IfUnlessModifier:
76
+ Enabled: false
77
+
78
+ Style/LineEndConcatenation:
79
+ Enabled: false
80
+
81
+ Style/RegexpLiteral:
82
+ AllowInnerSlashes: false
83
+
84
+ Style/RescueEnsureAlignment:
85
+ Enabled: true
86
+
87
+ # Style/RescueModifier:
88
+ # Enabled: false
89
+
90
+ # We like terse methods.
91
+ Style/SingleLineMethods:
92
+ Enabled: false
93
+
94
+ Style/SpaceAroundOperators:
95
+ MultiSpaceAllowedForOperators:
96
+ - '='
97
+ - '=>'
98
+ - '||='
99
+ - '+='
100
+ - '-='
101
+ - '*='
102
+ - '/='
103
+
104
+ Style/StringLiterals:
105
+ EnforcedStyle: double_quotes
106
+
107
+ Style/TrailingComma:
108
+ EnforcedStyleForMultiline: comma
109
+ SupportedStyles: comma
@@ -0,0 +1,36 @@
1
+ module OrderlyGarden
2
+ # Rake DSL constructs.
3
+ module DSL
4
+ # Create and manage a temp file, replacing `fname` with the temp file, if `fname` is provided.
5
+ def with_tempfile(fname = nil, &block)
6
+ Tempfile.open("tmp") do |f|
7
+ block.call(f.path, f.path.shellescape)
8
+ FileUtils.cp(f.path, fname) unless fname.nil?
9
+ end
10
+ end
11
+
12
+ # Write an array of strings to a file, adding newline separators, and
13
+ # ensuring a trailing newline at the end of a file.
14
+ def write_file(file_name, file_contents)
15
+ contents = file_contents
16
+ .flatten
17
+ .select { |line| line }
18
+ .join("\n")
19
+ File.open(file_name, "w") do |fh|
20
+ fh.write(contents)
21
+ fh.write("\n")
22
+ end
23
+ end
24
+
25
+ # Define a task named `name` that runs all tasks under an identically named `namespace`.
26
+ def parent_task(name)
27
+ task name do
28
+ Rake::Task
29
+ .tasks
30
+ .select { |t| t.name =~ /^#{name}:/ }
31
+ .sort { |a, b| a.name <=> b.name }
32
+ .each(&:execute)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,11 @@
1
+ # rubocop:disable Style/Documentation
2
+ # Monkey-patch `String` and `Pathname` with some handy-dandy helpers.
3
+
4
+ class String
5
+ def to_pathname; Pathname.new(self); end
6
+ end
7
+
8
+ class Pathname
9
+ def to_pathname; self; end
10
+ end
11
+ # rubocop:enable Style/Documentation
@@ -0,0 +1,3 @@
1
+ module OrderlyGarden
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,36 @@
1
+ require "pathname"
2
+ require "shellwords"
3
+
4
+ require "rake/clean"
5
+
6
+ # A set of tools for Rake and Ruby workflows, to help keep things neat and tidy.
7
+ module OrderlyGarden
8
+ # Initialize `orderly_garden`. Configures Rake, and loads some handy tasks.
9
+ def self.init!
10
+ # TODO: Pare this to CPU count, or possibly half that because hyperthreading usually is not our
11
+ # TODO: friend.
12
+ Rake.application.options.thread_pool_size ||= 4
13
+ # Time.zone = 'America/Los_Angeles'
14
+
15
+ task_files.each { |fname| load fname }
16
+ end
17
+
18
+ protected
19
+
20
+ def self.task_files
21
+ task_dir = File.expand_path("../../../tasks", __FILE__)
22
+ raw_task_files = FileList["#{task_dir}/**/*.rake"] +
23
+ FileList["tasks/**/*.rake"]
24
+ raw_task_files
25
+ .map { |fname| File.expand_path(fname) }
26
+ .sort
27
+ .uniq
28
+ end
29
+ end
30
+
31
+ require "orderly_garden/monkey_patches"
32
+ require "orderly_garden/version"
33
+ require "orderly_garden/dsl"
34
+
35
+ # TODO: Make this optional.
36
+ include OrderlyGarden::DSL
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "orderly_garden/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "orderly_garden"
8
+ spec.version = OrderlyGarden::VERSION
9
+ spec.authors = ["Jon Frisby"]
10
+ spec.email = ["jfrisby@mrjoy.com"]
11
+ spec.summary = "A set of tools for Rake and Ruby workflows, to help keep things neat and"\
12
+ " tidy."
13
+ spec.homepage = "https://github.com/MrJoy/orderly_garden"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+
23
+ spec.add_runtime_dependency "rake", "~> 10.0"
24
+ spec.add_runtime_dependency "bundler-audit", "> 0"
25
+ spec.add_runtime_dependency "rubocop", "> 0"
26
+ end
data/tasks/lint.rake ADDED
@@ -0,0 +1,55 @@
1
+ RUBOCOP_HEADING = "# #{('WARNING! ' * 7).rstrip}\n"\
2
+ "# AUTO-GENERATED FILE! DO NOT EDIT DIRECTLY!\n"\
3
+ "\n"\
4
+ "# Override from `.rubocop.local.yml` and re-run `rake lint:rubocop` instead!\n"
5
+
6
+ namespace :lint do
7
+ desc "Run Rubocop against the codebase."
8
+ task :rubocop do
9
+ require "yaml"
10
+ puts "Running Rubocop..."
11
+ defaults_file = File.expand_path("../../config/rubocop_rules.yml", __FILE__)
12
+ defaults = YAML.load(File.read(defaults_file))
13
+ local_opts = ".rubocop.local.yml"
14
+ overrides = YAML.load(File.read(local_opts)) if File.exist?(local_opts)
15
+ overrides ||= {}
16
+
17
+ # Be slightly intelligent about merging AllCops, but allow overriding things:
18
+ overrides["AllCops"] ||= {}
19
+ o_allcops = overrides["AllCops"]
20
+ d_allcops = defaults["AllCops"] || {}
21
+ o_allcops["Exclude"] ||= d_allcops["Exclude"] if d_allcops.key?("Exclude")
22
+ o_allcops["Include"] ||= d_allcops["Include"] if d_allcops.key?("Include")
23
+
24
+ results = (RUBOCOP_HEADING + defaults.merge(overrides).to_yaml).rstrip
25
+ write_file(".rubocop.yml", [results])
26
+ sh "rubocop --display-cop-names"
27
+ end
28
+
29
+ desc "Run bundler-audit against the Gemfile."
30
+ task :'bundler-audit' do
31
+ require "bundler/audit/cli"
32
+
33
+ %w(update check).each do |command|
34
+ Bundler::Audit::CLI.start [command]
35
+ end
36
+ end
37
+
38
+ if `which clock`.strip != ""
39
+ desc "Show LOC metrics for project using cloc."
40
+ task :cloc do
41
+ # TODO: Make this list customizable.
42
+ sh "cloc . --exclude-dir=coverage,.bundle,tmp"
43
+ end
44
+ end
45
+
46
+ desc "Check for outdated gems."
47
+ task :bundler do
48
+ # Don't error-out if this fails, since we may not be able to update some
49
+ # deps.
50
+ sh "bundle outdated || true"
51
+ end
52
+ end
53
+
54
+ desc "Run all lint checks against the code."
55
+ parent_task :lint
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: orderly_garden
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jon Frisby
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler-audit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - jfrisby@mrjoy.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rubocop.local.yml"
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - config/rubocop_rules.yml
84
+ - lib/orderly_garden.rb
85
+ - lib/orderly_garden/dsl.rb
86
+ - lib/orderly_garden/monkey_patches.rb
87
+ - lib/orderly_garden/version.rb
88
+ - orderly_garden.gemspec
89
+ - tasks/lint.rake
90
+ homepage: https://github.com/MrJoy/orderly_garden
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.5.0
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: A set of tools for Rake and Ruby workflows, to help keep things neat and
114
+ tidy.
115
+ test_files: []