trop 0.4.27 → 0.5.33

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 75869b68687d11168656dfabd3d6f149f3891ed8dc85b0e32293263e891abf07
4
- data.tar.gz: e7989351fb9da6f4440fe4edb0f93550d8af5a0494b21112b1a6dff7eb6d8882
3
+ metadata.gz: 13ae332650b6d142dfdf98e3de802130d2d4e62daa0ccfe43bbc93cbc954ba64
4
+ data.tar.gz: ccab3a9d0a5c0c9ae17d938afe034cdd3b7a84a33578d53c2a229197dd2fcd1d
5
5
  SHA512:
6
- metadata.gz: 6cc4635b6de94084d2e115e1b5f4fdc0a4f4008f7ae03afdb292d29385dba200b3af643b5f3e2a2589e3f3b5b72422c47ad6501581de8e8347c6de310aa46698
7
- data.tar.gz: 2f1fc6721badaa71c1c4dbf915568fcd5faccb7efc5c2ca91477364d8d280f91ccf103b58c4a2b435a066efb60a831b3509df370a77be6c13880bc4930d1da6c
6
+ metadata.gz: f4c2748eddd5efa8a082287d5a172293c376a8f319180768a71c1366b575d25bc98acc8b27b733db7d6dec717a5db05970ffe21ec3332b9ee010d8e0007cdd01
7
+ data.tar.gz: ac435121e471c62f3c306b82583a729bbcb28d9f459c0571579ecc76eeb82526198f6a3677b975dcaf5fb28e96c6b04c03a866517f721a8f9104c28acfad21b2
data/Gemfile CHANGED
@@ -23,9 +23,14 @@ end
23
23
 
24
24
  gem 'dotenv'
25
25
  gem 'bundler', '~> 2.0.1'
26
- gem "bundler_geminabox"
27
26
 
28
27
  gem 'sentry-raven'
29
28
  gem 'colorize'
30
29
 
31
- gem "bundler-geminabox", "~> 1.0"
30
+ gem "bundler-geminabox", "1.0"
31
+
32
+ gem "git-version-bump", "~> 0.16.0"
33
+
34
+ gem "gem-release", "~> 2.0"
35
+
36
+ gem "faraday", "0.15.4"
data/Rakefile CHANGED
@@ -1,10 +1,9 @@
1
1
  require 'rubygems'
2
- require 'bundler/gem_tasks'
3
- require 'bundler/endpoint_specification'
4
2
  require 'rake'
5
- require 'bump'
6
3
  require 'fileutils'
7
- require 'gem_version'
4
+
5
+ require_relative './lib/trop'
6
+
8
7
 
9
8
  begin
10
9
  Bundler.setup(:default, :development)
@@ -14,61 +13,6 @@ rescue Bundler::BundlerError => e
14
13
  exit e.status_code
15
14
  end
16
15
 
17
- desc 'Generate a gemspecx file.'
18
- task :gemspecx do
19
- spec_dir = File.join( FileUtils.getwd,"*.gemspec")
20
- spec_path = Dir.glob( spec_dir ).first
21
- spec_gem = Gem::Specification::load(spec_path)
22
- spec_str = pp spec_gem
23
- puts spec_str
24
- puts spec_path
25
- File.open("gemspecx.gemspecx", 'w') do |f|
26
- f.write spec_gem.to_ruby
27
- end
28
- end
29
-
30
- desc 'Generate a gemspec file.'
31
- task :gemspec do
32
- spec_dir = File.join( FileUtils.getwd,"*.gemspec")
33
- spec_path = Dir.glob( spec_dir ).first
34
- spec_gem = Gem::Specification::load(spec_path) do |s|
35
- s.version = Trop::VERSION
36
- end
37
- File.open(spec_path, 'w') do |f|
38
- f.write spec_gem.to_ruby
39
- end
40
- GemVersion.increment_version
41
- GemVersion.commit_and_push
42
- GemVersion.next_version
43
- end
44
-
45
- task :patch do
46
- system 'bump patch --replace-in trop.gemspec --replace-in ./lib/trop/version.rb --replace-in next_gem_version'
47
- end
48
- task :min do
49
- system 'bump minor --replace-in trop.gemspec --replace-in ./lib/trop/version.rb --replace-in next_gem_version'
50
- end
51
-
52
- task gembox: :build do
53
- Dir.chdir('./pkg') do
54
- system 'gem inabox *.gem --host=http://localhost:9292 -o '
55
- end
56
- end
57
- #Jeweler::Tasks.new do |gem|
58
- # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
59
- # gem.name = 'trop'
60
- # gem.homepage = 'http://gitlab.wfschmitt.net/rails/trop'
61
- # gem.license = 'MIT'
62
- # gem.summary = %(trop is troppuS)
63
- # gem.description = %(trop is support)
64
- # gem.email = 'wfschmittx@gmail.com'
65
- # gem.authors = ['werner'gcaa
66
- # gem.files = %w[LICENSE.txt README.md README.rakes.md Gemfile Rakefile TODO.md VERSION lib/trop/config.bundler.tpl lib/trop/core-ext.rb lib/trop/file_finder.rb lib/trop/filefind.rb lib/trop/infogit.rb lib/trop/os.rb lib/trop/shell_deb_verb.rb lib/trop/version.rb]
67
- #end
68
- #$SAFE = 0
69
- #Jeweler::RubygemsDotOrgTasks.new
70
-
71
-
72
16
  require 'rake/testtask'
73
17
  Rake::TestTask.new(:test) do |test|
74
18
  test.libs << 'lib' << 'test'
@@ -76,34 +20,11 @@ Rake::TestTask.new(:test) do |test|
76
20
  test.verbose = true
77
21
  end
78
22
 
79
- task :nexta do
80
- puts 'hallo nexta'
81
- puts `rake patch`
82
- puts `rake gemspec`
83
- puts `git add --all`
84
- puts `git commit -m"save" --all`
85
- puts `git save`
86
- puts `git push`
87
- # puts `git commit -m"save"`
88
- end
89
-
90
- task next: %i[test build] do
91
- Rake::Task['nexta'].execute
92
- Rake::Task['build'].execute
93
- Rake::Task['install'].execute
94
- puts `gem inabox`
95
- end
96
-
97
- desc 'prepare deployment in public'
98
- task :deploy do
99
- `mkdir -p ./public`
100
- FileUtils.cp(%w[LICENSE.txt README.md README.rakes.md TODO.md], 'public', verbose: true)
101
- end
102
-
103
23
  desc 'Code coverage detail'
104
24
  task :simplecov do
105
25
  ENV['COVERAGE'] = 'true'
106
26
  Rake::Task['test'].execute
107
27
  end
108
28
 
29
+
109
30
  task default: :test
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.33
1
+ 1.0.0
data/bin/setup CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/bin/bash
2
2
 
3
- IFS=$'\n\t'
3
+ IFS=$/
4
4
 
5
5
  if [[ -f .envrc.example ]] && ! [[ -f .envrc ]]; then
6
6
  cp -v .envrc.example .envrc
@@ -10,6 +10,8 @@ if [[ -f .envrc.local.example ]] && ! [[ -f .envrc.local ]]; then
10
10
  cp -v .envrc.local.example .envrc.local
11
11
  fi
12
12
 
13
+ gem inabox --host=http://localhost:9292
14
+
13
15
  touch .envrc .envrc.local
14
16
  # Do any other automated setup that you need to do here
15
17
 
@@ -0,0 +1,24 @@
1
+ require 'bundler'
2
+ require 'bundler/gem_tasks'
3
+ #require 'bundler-geminabox/gem_tasks'
4
+ require 'bundler/endpoint_specification'
5
+ require 'bump'
6
+ require 'gem_version'
7
+ require 'git-version-bump/rake-tasks'
8
+
9
+
10
+ module GemHelper
11
+
12
+ def self.rewrite_gemspec
13
+ spec_path = FileUtils.getwd + '/' + Trop::GEMSPEC_NAME
14
+ spec_gem = Gem::Specification::load(spec_path)
15
+ spec_gem.version = GemVersion.next_version
16
+ File.open(spec_path, 'w') {|f| f.write spec_gem.to_ruby }
17
+ unless Trop::Sh::silent?
18
+ File.open("gemspecx.gemspecx", 'w') {|f| f.write spec_gem.to_ruby }
19
+ end
20
+
21
+ return spec_gem.version
22
+ end
23
+
24
+ end
@@ -2,6 +2,7 @@
2
2
  require 'rake/file_utils_ext'
3
3
  require_relative 'core-ext'
4
4
 
5
+
5
6
  #def bash_cmd(cmd)
6
7
  # # sh <<-EOS.strip_heredoc, {verbose: false}
7
8
  # sh <<-EOS << cmd
@@ -24,18 +25,32 @@ module Trop
24
25
  return !!@@verbose
25
26
  end
26
27
 
27
- def self.verbose!(mode = true)
28
- if mode.false?
29
- @@verbose = false
30
- ENV['VERBOSE'] = nil
31
- else
32
- @@verbose = true
33
- end
28
+ def self.verbose!
29
+ @@verbose = true
30
+ ENV['VERBOSE'] = "true"
34
31
  return !!@@verbose
35
32
  end
36
33
 
37
- def self.silent!(mode = true)
38
- return !::Trop::Sh.verbose!(!mode)
34
+ def self.silence_streams(*streams)
35
+ @@on_hold = streams.collect { |stream| stream.dup }
36
+ streams.each do |stream|
37
+ stream.reopen(RUBY_PLATFORM =~ /mswin/ ? 'NUL:' : '/dev/null')
38
+ stream.sync = true
39
+ end
40
+ yield
41
+ ensure
42
+ streams.each_with_index do |stream, i|
43
+ stream.reopen(@@on_hold[i])
44
+ end
45
+ end
46
+
47
+
48
+ def self.silent!
49
+ @@verbose = false
50
+ @@debug = false
51
+ ENV['VERBOSE'] = nil
52
+ ENV['DEBUG'] = nil
53
+ return !!@@verbose && !!@@debug
39
54
  end
40
55
 
41
56
  def self.silent?
@@ -57,5 +72,46 @@ module Trop
57
72
  end
58
73
  return @@debug
59
74
  end
75
+
76
+
77
+ def self.systemlocal(cmds)
78
+ cmd = ''
79
+ return [-1, ''] if cmds.nil? || cmds.blank?
80
+
81
+ if cmds.is_a? Array
82
+ cmds.each {|s| cmd = cmd + s.to_s + ' ' unless s.blank?}
83
+ else
84
+ cmd = cmds.to_s
85
+ end
86
+ puts "commands: #{cmd} " if Trop::Sh::debug?
87
+ return [-1, ''] if cmd.blank?
88
+ puts " #{cmd} ".colorize(:green) if Trop::Sh::verbose?
89
+
90
+ # execute system call with return in stdout
91
+ stdout = `#{cmd}`
92
+ # silent if successful or not verbose
93
+ if $CHILD_STATUS.success?
94
+ puts stdout.to_s.colorize(:green) if Trop::Sh::verbose?
95
+ return [0, stdout]
96
+ end
97
+ # error case
98
+ puts " #{cmd} ".colorize(:red)
99
+ puts " #{stdout}".colorize(:red)
100
+ [-1, stdout]
101
+ end
102
+
103
+ def self.cwd(*cmds)
104
+ wd = Pathname.new(RAKE_RUN_DIR).join('output')
105
+ Dir.chdir(wd) do
106
+ ret, out = systemlocal(cmds)
107
+ return [ret, out]
108
+ end
109
+ end
110
+
111
+ def self.sh(*cmds)
112
+ ret, out = systemlocal(cmds)
113
+ return [ret, out]
114
+ end
60
115
  end
61
116
  end
117
+
data/lib/trop/version.rb CHANGED
@@ -1,3 +1,6 @@
1
1
  module Trop
2
- VERSION = '0.4.29'
2
+ VERSION = '0.4.52'
3
+ VERSION_NAME = 'trop'
4
+ GEMSPEC_NAME = VERSION_NAME + '.gemspec'
5
+ VERSION_FILE = File.expand_path('version.rb', __dir__)
3
6
  end
@@ -0,0 +1,2 @@
1
+ require 'dotenv'
2
+ Dotenv.overload('.envrc', '.envrc.local') # overwrite local ENVs, needed by PATH
@@ -0,0 +1,46 @@
1
+
2
+ require_relative '../lib/trop'
3
+
4
+ namespace :gem do
5
+ Trop::Sh::silent!
6
+ DEVNULL = Gem.win_platform? ? "NUL" : "/dev/null"
7
+ task :gembox do
8
+ Dir.chdir('./pkg') do
9
+ Trop::Sh::systemlocal 'gem inabox *.gem --host=http://localhost:9292 -o '
10
+ end
11
+ end
12
+
13
+ task :next do
14
+ # self.dirty_tree?
15
+ # Are we in a dirty, dirty tree?
16
+ Trop::Sh::silent!
17
+ status,msg = Trop::Sh::systemlocal("git diff --no-ext-diff HEAD 2> #{DEVNULL}" )
18
+ stat2,msg2 = Trop::Sh::systemlocal("git diff-index --cached HEAD 2> #{DEVNULL}")
19
+ clean = (!status && !stat2) && msg.empty? && msg2.empty?
20
+ clean = msg.empty? && msg2.empty?
21
+
22
+ if !clean
23
+ Trop::Sh::verbose!
24
+ puts msg
25
+ puts " repo is not clean please stash or commit"
26
+ else
27
+ vers1 = vers2 = nil
28
+ Trop::Sh::silence_streams(STDOUT) {
29
+ vers1 = GemVersion.increment_version
30
+ vers2 = GemHelper.rewrite_gemspec
31
+ GemVersion.commit_and_push {|g| g.add(Trop::VERSION_FILE) && g.add(Trop::GEMSPEC_NAME)}
32
+ }
33
+
34
+ puts "incr. version build and push #{vers1} #{vers2}"
35
+ Trop::Sh::systemlocal('rake build')
36
+ Trop::Sh::systemlocal('rake release')
37
+ end
38
+ end
39
+
40
+ desc 'prepare deployment in public'
41
+ task :deploy do
42
+ `mkdir -p ./public`
43
+ FileUtils.cp(%w[LICENSE.txt README.md README.rakes.md TODO.md], 'public', verbose: true)
44
+ end
45
+
46
+ end
@@ -0,0 +1,51 @@
1
+
2
+ require_relative '../lib/trop'
3
+
4
+
5
+ if ENV['CI'].nil?
6
+ require 'sentry-raven'
7
+ Raven.configure do |config| #
8
+ config.silence_ready = true # unless Shell.cwd
9
+ envtest = ENV['SENTRY_DSN'] || 'https://1119c5fd4e7e47b7948c62b22b182fdf@sentry.io/1448013'
10
+ config.dsn = envtest
11
+ config.release = Trop::InfoGit::GitProject.commit_id
12
+ config.ssl_verification = false
13
+ puts "Using dsn #{envtest}".yellow #if Shell.verbose?
14
+ # puts "with comit-id: #{InfoGit::GitProject.commit_id}".yellow if Shell.verbose?
15
+ end
16
+ end
17
+
18
+
19
+ namespace :raven do
20
+ desc 'trigger a dummy event on sentry'
21
+ task :trigger do
22
+ return 1 / 0
23
+ end
24
+ end
25
+
26
+
27
+ # desc 'register a version to sentry'
28
+ # task :deploy do
29
+ # curl http://worker.hbi.ad.harman.com:9000/api/hooks/release/builtin/2/1947c904f6a75a932b0110940151fb12460b699ae1cbb5079c095675197d47e4/
30
+ # commit_id = InfoGit::GitProject.commit_id
31
+ # cmd = <<-EOF.tr!("\n", ' ')
32
+ # curl https://sentry.io/api/hooks/release/builtin/1272992/43a5fce123b9c2f2b8f799489ff49f07ffb615d79e37114e3f29fb03f1e06150/
33
+ # -X POST
34
+ # -H 'Content-Type: application/json'
35
+ # -d '{"version": "#{commit_id}"}'
36
+ # EOF
37
+ # puts cmd
38
+ # system cmd#
39
+
40
+ # sh ('
41
+ # ACCESS_TOKEN=0e63f4a39ce44cf48fb1cc94c75b0ea8
42
+ # ENVIRONMENT=production
43
+ # LOCAL_USERNAME=`whoami`
44
+ # REVISION=`git log -n 1 --pretty=format:"%H"`
45
+ # curl https://api.rollbar.com/api/1/deploy/ \
46
+ # -F access_token=$ACCESS_TOKEN \
47
+ # -F environment=$ENVIRONMENT \
48
+ # -F revision=$REVISION \
49
+ # -F local_username=$LOCAL_USERNAME')
50
+ # end
51
+ #end
@@ -0,0 +1,46 @@
1
+ IDIR = 'doc/internal/'.freeze
2
+ # frozen_string_literal: false
3
+
4
+ desc 'tad (test and docs)'
5
+ task :tad do
6
+ puts 'Working in: ' + Dir.getwd.to_str
7
+ #`cd #{IDIR}; git add *; git commit -m"safe old logs" -a; rm *.log; cd -`
8
+ #`rake routes | tee #{IDIR}routes.log `
9
+ # `rake initializers | tee #{IDIR}initializers.log`
10
+ `rake notes:rb | tee #{IDIR}notes.todo.log`
11
+ `rake notes:md | tee #{IDIR}notes.md.log`
12
+ `rake notes:all | tee #{IDIR}notes.log`
13
+ #`rake stats | tee #{IDIR}stats.log`
14
+ #`rake test 2>&1 | tee #{IDIR}rake_test.log`
15
+ #`rake spec 2>&1 | tee #{IDIR}rake_spec.log`
16
+ #`git add *; git commit -m"safe old logs" -a`
17
+ end
18
+
19
+ namespace :notes do
20
+ require File.dirname(__FILE__) + '/source_annotation_extractor'
21
+
22
+ desc 'Enumerate a custom annotation, specify with ANNOTATION=CUSTOM'
23
+ task :custom do
24
+ SourceAnnotationExtractor.enumerate ENV['ANNOTATION']
25
+ end
26
+
27
+ desc 'Enumerate all annotations (use notes:optimize, :fixme, :todo for focus)'
28
+ task :css do
29
+ SourceAnnotationExtractor::Annotation.register_extensions('css', 'scss', 'sass', 'less', 'js') { |tag| %r{\/\/\s*(#{tag}):?\s*(.*)$} }
30
+ SourceAnnotationExtractor.enumerate 'OPTIMIZE|FIXME|TODO', tag: true
31
+ SourceAnnotationExtractor.enumerate 'TODO|LATER', dirs: %w[doc,lib], tag: true
32
+ end
33
+ desc 'Enumerate all markdowns' ## custom annotation, specify with ANNOTATION=CUSTOM
34
+ task :md do
35
+ SourceAnnotationExtractor::Annotation.register_extensions('md') { |tag| /(#{tag}):?\s*(.*)$/ }
36
+ SourceAnnotationExtractor.enumerate 'TODO|LATER|FIXME', dirs: %w(. ../biosonlinux)
37
+ # dirs: ['.','doc','lib','test','artefacts','../biosonlinux'], tag: true
38
+ end
39
+ desc 'Enumerate all rubies' ## custom annotation, specify with ANNOTATION=CUSTOM
40
+ task :rb do
41
+ SourceAnnotationExtractor::Annotation.register_extensions('erb') { |tag| /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/ }
42
+ SourceAnnotationExtractor::Annotation.register_extensions('builder', 'rb', 'rake', 'yml', 'yaml', 'ruby') { |tag| /#\s*(#{tag}):?\s*(.*)$/ }
43
+ SourceAnnotationExtractor.enumerate 'OPTIMIZE|FIXME|TODO|LATER', dirs: %w[app/admin app/controllers bin/lib db config test spec .], tag: true
44
+ end
45
+ #
46
+ end
@@ -0,0 +1,141 @@
1
+ # Implements the logic behind the rake tasks for annotations like
2
+ #
3
+ # rails notes
4
+ # rails notes:optimize
5
+ #
6
+ # and friends. See <tt>rails -T notes</tt> and <tt>railties/lib/rails/tasks/annotations.rake</tt>.
7
+ #
8
+ # Annotation objects are triplets <tt>:line</tt>, <tt>:tag</tt>, <tt>:text</tt> that
9
+ # represent the line where the annotation lives, its tag, and its text. Note
10
+ # the filename is not stored.
11
+ #
12
+ # Annotations are looked for in comments and modulus whitespace they have to
13
+ # start with the tag optionally followed by a colon. Everything up to the end
14
+ # of the line (or closing ERB comment tag) is considered to be their text.
15
+ # noinspection RubyClassVariableUsageInspection
16
+ class SourceAnnotationExtractor
17
+ Annotation = Struct.new(:line, :tag, :text) do
18
+ def self.directories
19
+ @directories ||= %w[bin doc filter lib templates test] + (ENV['SOURCE_ANNOTATION_DIRECTORIES'] || '').split(',')
20
+ end
21
+
22
+ # Registers additional directories to be included
23
+ # SourceAnnotationExtractor::Annotation.register_directories("spec","another")
24
+ def self.register_directories(*dirs)
25
+ directories.push(*dirs)
26
+ end
27
+
28
+ def self.extensions
29
+ @extensions ||= {}
30
+ end
31
+
32
+ # Registers new Annotations File Extensions
33
+ # SourceAnnotationExtractor::Annotation.register_extensions("css", "scss", "sass", "less", "js") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
34
+ def self.register_extensions(*exts, &block)
35
+ extensions[/\.(#{exts.join('|')})$/] = block
36
+ end
37
+
38
+ #register_extensions('builder', 'rb', 'rake', 'yml', 'yaml', 'ruby') { |tag| /#\s*(#{tag}):?\s*(.*)$/ }
39
+ #register_extensions('css', 'js') { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
40
+ #register_extensions('erb') { |tag| /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/ }
41
+
42
+ # Returns a representation of the annotation that looks like this:
43
+ #
44
+ # [126] [TODO] This algorithm is simple and clearly correct, make it faster.
45
+ #
46
+ # If +options+ has a flag <tt>:tag</tt> the tag is shown as in the example above.
47
+ # Otherwise the string contains just line and text.
48
+ def to_s(options = {})
49
+ s = "[#{line.to_s.rjust(options[:indent])}] "
50
+ s << "[#{tag}] " if options[:tag]
51
+ s << text
52
+ end
53
+ end
54
+
55
+ # Prints all annotations with tag +tag+ under the root directories +app+,
56
+ # +config+, +db+, +lib+, and +test+ (recursively).
57
+ #
58
+ # Additional directories may be added using a comma-delimited list set using
59
+ # <tt>ENV['SOURCE_ANNOTATION_DIRECTORIES']</tt>.
60
+ #
61
+ # Directories may also be explicitly set using the <tt>:dirs</tt> key in +options+.
62
+ #
63
+ # SourceAnnotationExtractor.enumerate 'TODO|FIXME', dirs: %w(app lib), tag: true
64
+ #
65
+ # If +options+ has a <tt>:tag</tt> flag, it will be passed to each annotation's +to_s+.
66
+ #
67
+ # See <tt>#find_in</tt> for a list of file extensions that will be taken into account.
68
+ #
69
+ # This class method is the single entry point for the rake tasks.
70
+ def self.enumerate(tag, options = {})
71
+ extractor = new(tag)
72
+ dirs = options.delete(:dirs) || Annotation.directories
73
+ puts dirs.to_s
74
+ extractor.display(extractor.find(dirs), options)
75
+ end
76
+
77
+ attr_reader :tag
78
+
79
+ def initialize(tag)
80
+ @tag = tag
81
+ end
82
+
83
+ # Returns a hash that maps filenames under +dirs+ (recursively) to arrays
84
+ # with their annotations.
85
+ def find(dirs)
86
+ dirs.inject({}) { |h, dir| h.update(find_in(dir)) }
87
+ end
88
+
89
+ # Returns a hash that maps filenames under +dir+ (recursively) to arrays
90
+ # with their annotations. Only files with annotations are included. Files
91
+ # with extension +.builder+, +.rb+, +.rake+, +.yml+, +.yaml+, +.ruby+,
92
+ # +.css+, +.js+ and +.erb+ are taken into account.
93
+ def find_in(dir)
94
+ results = {}
95
+
96
+ Dir.glob("#{dir}/*") do |item|
97
+ next if File.basename(item)[0] == '.'
98
+
99
+ if File.directory?(item)
100
+ results.update(find_in(item))
101
+ else
102
+ extension = Annotation.extensions.detect do |regexp, _block|
103
+ regexp.match(item)
104
+ end
105
+
106
+ if extension
107
+ pattern = extension.last.call(tag)
108
+ results.update(extract_annotations_from(item, pattern)) if pattern
109
+ end
110
+ end
111
+ end
112
+
113
+ results
114
+ end
115
+
116
+ # If +file+ is the filename of a file that contains annotations this method returns
117
+ # a hash with a single entry that maps +file+ to an array of its annotations.
118
+ # Otherwise it returns an empty hash.
119
+ def extract_annotations_from(file, pattern)
120
+ lineno = 0
121
+ result = File.readlines(file, encoding: Encoding::BINARY).inject([]) do |list, line|
122
+ lineno += 1
123
+ next list unless line =~ pattern
124
+ list << Annotation.new(lineno, Regexp.last_match(1), Regexp.last_match(2))
125
+ end
126
+ result.empty? ? {} : { file => result }
127
+ end
128
+
129
+ # Prints the mapping from filenames to annotations in +results+ ordered by filename.
130
+ # The +options+ hash is passed to each annotation's +to_s+.
131
+ def display(results, options = {})
132
+ options[:indent] = results.flat_map { |f, a| a.map(&:line) }.max.to_s.size
133
+ results.keys.sort.each do |file|
134
+ puts "#{file}:"
135
+ results[file].each do |note|
136
+ puts " * #{note.to_s(options)}"
137
+ end
138
+ puts
139
+ end
140
+ end
141
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.27
4
+ version: 0.5.33
5
5
  platform: ruby
6
6
  authors:
7
7
  - werner
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.1'
47
+ version: '1.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.1'
54
+ version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: sentry-raven
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -216,10 +216,16 @@ files:
216
216
  - lib/trop/core-ext.rb
217
217
  - lib/trop/file_finder.rb
218
218
  - lib/trop/filefind.rb
219
+ - lib/trop/gem_tasks.rb
219
220
  - lib/trop/infogit.rb
220
221
  - lib/trop/os.rb
221
222
  - lib/trop/shell_deb_verb.rb
222
223
  - lib/trop/version.rb
224
+ - rakelib/envrc.rake
225
+ - rakelib/gem_version.rake
226
+ - rakelib/raven.rake
227
+ - rakelib/source_annotation.rake
228
+ - rakelib/source_annotation_extractor.rb
223
229
  homepage: http://gitlab.wfschmitt.net/rails/trop
224
230
  licenses:
225
231
  - MIT