capistrano-dirty 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
+ SHA256:
3
+ metadata.gz: b13040de6aa2aeba42516f5ed39789a2a341995dac53b934e5f4a8d135363c17
4
+ data.tar.gz: 19fbf1f9ec96d7bbf28ac0ca3ec79ebef2135403a22e81647b27d7d9a3b75fcc
5
+ SHA512:
6
+ metadata.gz: c33c464f37998e370cbf2d9f938eca9d21ec27ca86170a5273b39d23e538712dcf0a551be42c81995a947ef7fab46de65ab6c34484694dd217261b26b20cf620
7
+ data.tar.gz: ddeca26bcac57423c9f48487f5e476d0956e161425739037b1055e00a524a8aaf8745f3a1133f8c0079dfa5a9a8bf14995fab316ab17bc375338ac0cc4c9cc3c
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in capistrano-dirty.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,52 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ capistrano-dirty (0.0.1)
5
+ capistrano (>= 3.0.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ airbrussh (1.3.0)
11
+ sshkit (>= 1.6.1, != 1.7.0)
12
+ capistrano (3.10.1)
13
+ airbrussh (>= 1.0.0)
14
+ i18n
15
+ rake (>= 10.0.0)
16
+ sshkit (>= 1.9.0)
17
+ concurrent-ruby (1.0.5)
18
+ diff-lcs (1.3)
19
+ i18n (1.0.0)
20
+ concurrent-ruby (~> 1.0)
21
+ net-scp (1.2.1)
22
+ net-ssh (>= 2.6.5)
23
+ net-ssh (4.2.0)
24
+ rake (10.5.0)
25
+ rspec (3.7.0)
26
+ rspec-core (~> 3.7.0)
27
+ rspec-expectations (~> 3.7.0)
28
+ rspec-mocks (~> 3.7.0)
29
+ rspec-core (3.7.1)
30
+ rspec-support (~> 3.7.0)
31
+ rspec-expectations (3.7.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.7.0)
34
+ rspec-mocks (3.7.0)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.7.0)
37
+ rspec-support (3.7.1)
38
+ sshkit (1.16.0)
39
+ net-scp (>= 1.1.2)
40
+ net-ssh (>= 2.8.0)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ bundler (~> 1.16)
47
+ capistrano-dirty!
48
+ rake (~> 10.0)
49
+ rspec (~> 3.0)
50
+
51
+ BUNDLED WITH
52
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Jamie Schembri
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,41 @@
1
+ # Capistrano::Dirty
2
+
3
+ A little capistrano task for checking if a codebase is dirty, against a couple of patterns (e.g. FIXMEs, git conflict markers...).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'capistrano-dirty'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install capistrano-dirty
20
+
21
+
22
+ To expose the Capistrano task, add the following to your Capfile:
23
+
24
+ ```ruby
25
+ require 'capistrano_dirty'
26
+ load 'capistrano_dirty/tasks.rake'
27
+ ```
28
+
29
+ Finally, to fail deploys when something is found, you can do something like this in your Capfile:
30
+
31
+ ```ruby
32
+ before 'deploy:check', 'capistrano_dirty:check'
33
+ ```
34
+
35
+ ## Contributing
36
+
37
+ Bug reports and pull requests are welcome on GitHub at https://github.com/bluerail/capistrano-dirty
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "capistrano/dirty"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "capistrano_dirty/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "capistrano-dirty"
7
+ spec.version = CapistranoDirty::VERSION
8
+ spec.authors = ["Jamie Schembri"]
9
+ spec.email = ["jamie@lico.nl"]
10
+
11
+ spec.summary = %q{Checks for dirty strings in a codebase}
12
+ spec.description = "Checks for dirty strings in a codebase based on a list of patterns. "\
13
+ "This may be used to prevent deployment if found."
14
+ spec.homepage = "https://github.com/bluerail/capistrano-dirty"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+
28
+ spec.add_dependency "capistrano", ">= 3.0.0"
29
+ end
@@ -0,0 +1,29 @@
1
+ module CapistranoDirty
2
+ require 'capistrano_dirty/pattern_finder'
3
+ require 'capistrano_dirty/pattern_match'
4
+
5
+ PATTERNS = {
6
+ 'Git conflict markers' => /^[<>=]{7}/,
7
+ 'FIXME' => /FIXME/,
8
+ 'Pry' => /binding\.pry/
9
+ }.freeze
10
+
11
+ def self.dirty?(path = nil)
12
+ path ||= Dir.pwd
13
+
14
+ Dir["#{path}/**/*"].each do |filename|
15
+ next unless File.file?(filename) # skip directories
16
+
17
+ file = File.read(filename)
18
+ PATTERNS.each do |name, pattern|
19
+ matches = CapistranoDirty::PatternFinder.match(file, pattern)
20
+
21
+ relative_filename = filename.sub(%r{\A#{path}/?}, '')
22
+
23
+ return PatternMatch.new(name, relative_filename) if matches
24
+ end
25
+ end
26
+
27
+ false
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ module CapistranoDirty::PatternFinder
2
+ # Adding a line with this string and the name of the pattern above
3
+ # the line on which the pattern matches will ignore it.
4
+ DISABLE_STRING_LOOKAHEAD = /(?! # capistrano-dirty:disable)/
5
+
6
+ # If there is a match in the file, return the filename
7
+ def self.match(file, pattern)
8
+ regex = build_regex(pattern)
9
+
10
+ file.match(regex)
11
+ end
12
+
13
+ def self.build_regex(pattern)
14
+ Regexp.new([pattern, DISABLE_STRING_LOOKAHEAD].map(&:source).join)
15
+ end
16
+
17
+ def self.disable_string(name)
18
+ [DISABLE_STRING_PREFIX, name].join(' ')
19
+ end
20
+ end
@@ -0,0 +1,18 @@
1
+ class CapistranoDirty::PatternMatch
2
+ attr_reader :pattern_name, :file_path
3
+
4
+ def initialize(pattern_name, file_path)
5
+ @pattern_name = pattern_name
6
+ @file_path = file_path
7
+ end
8
+
9
+ def to_s
10
+ "#{@pattern_name} found in #{@file_path}"
11
+ end
12
+
13
+ def ==(other)
14
+ other.is_a?(CapistranoDirty::PatternMatch) &&
15
+ @pattern_name == other.pattern_name &&
16
+ @file_path == other.file_path
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ namespace :capistrano_dirty do
2
+ desc 'checks for dirty strings in the codebase'
3
+ task :check do
4
+ pattern_match = CapistranoDirty.dirty?
5
+
6
+ raise pattern_match.to_s if pattern_match
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module CapistranoDirty
2
+ VERSION = '0.0.1'.freeze
3
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-dirty
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jamie Schembri
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-02-19 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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: :development
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: capistrano
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0
69
+ description: Checks for dirty strings in a codebase based on a list of patterns. This
70
+ may be used to prevent deployment if found.
71
+ email:
72
+ - jamie@lico.nl
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - capistrano-dirty.gemspec
88
+ - lib/capistrano_dirty.rb
89
+ - lib/capistrano_dirty/pattern_finder.rb
90
+ - lib/capistrano_dirty/pattern_match.rb
91
+ - lib/capistrano_dirty/tasks.rake
92
+ - lib/capistrano_dirty/version.rb
93
+ homepage: https://github.com/bluerail/capistrano-dirty
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.7.3
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Checks for dirty strings in a codebase
117
+ test_files: []