pinfo-rails 0.1.6 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pinfo-rails.rb +31 -13
  3. metadata +4 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d32f4f86d43b53c23b4f271b8ec372c9539d12d4
4
- data.tar.gz: 99f0fb1c4a2781070aeb23a489cebd05e38aa703
3
+ metadata.gz: 0a02435b36d1b19909149d6d3ea869e39dcee349
4
+ data.tar.gz: e1fc97d273a360e77861cd81485b46911bc37be1
5
5
  SHA512:
6
- metadata.gz: 13f61c9cc6619dc7dcfd5b4faec6716f000acd0336b5cfa2c2926d7680948ab8bd169d25c65efc8c63b5345ba791f21dc792e06661f0504fb7c3ef538c75ef72
7
- data.tar.gz: a726048235f50ab13fdc896b72da2be5dce4b36d71dd2276a6bc3c98a2bab64447c8666d390aa3f2bc3886e9177d955ea2c2a02cf5eca3108b19bc626c592e75
6
+ metadata.gz: 8445fdaebd4746d2af4f220a6b37fdf3475a3f341ecfc141184ed864d117c25c0e7fd2da00deb3ab973d1f16b59c933b38a9d9221bc6bcb5f3f9453b63ec18cd
7
+ data.tar.gz: 02908a0d2e8218fdbf716a99ed3e29b1caa1322c4994ce6520d8c55112b992627239d3c073d68d2ec9b0918bb90972785128d27d633934a76e864854a9efa7cf
@@ -1,16 +1,34 @@
1
1
  # coding: utf-8
2
- require 'colorize'
3
2
  require 'optparse'
4
3
  require 'ostruct'
5
4
  require 'yaml'
6
5
 
6
+ # extend String for colors
7
+ class String
8
+ COLORS = {
9
+ black: 30, light_black: 90,
10
+ red: 31, light_red: 91,
11
+ green: 32, light_green: 92,
12
+ yellow: 33, light_yellow: 93,
13
+ blue: 34, light_blue: 94,
14
+ magenta: 35, light_magenta: 95,
15
+ cyan: 36, light_cyan: 96,
16
+ white: 37, light_white: 97,
17
+ default: 39
18
+ }.freeze
19
+
20
+ def color( col )
21
+ "\e[#{COLORS[col]}m#{self}\e[0m"
22
+ end
23
+ end
24
+
7
25
  module PinfoRails
8
26
  NAME = 'pinfo-rails'.freeze
9
- DATE = '2016-10-12'.freeze
27
+ DATE = '2016-10-15'.freeze
10
28
  INFO = 'Rails project info'.freeze
11
- DESC = 'A gem to collect informations from a Rails project'.freeze
29
+ DESC = 'Command line utility to collect informations from a Rails project'.freeze
12
30
  AUTHORS = [ [ 'Mattia Roccoberton', 'mat@blocknot.es', 'http://blocknot.es' ] ].freeze
13
- VERSION = [ 0, 1, 6 ].freeze
31
+ VERSION = [ 0, 2, 2 ].freeze
14
32
 
15
33
  FILES = {
16
34
  conf_db: 'config/database.yml',
@@ -27,7 +45,7 @@ module PinfoRails
27
45
  PATTERNS = {
28
46
  cache: /\A\s*config.cache_classes.*|\A\s*config.action_controller.perform_caching.*/,
29
47
  deploy_info: /branch\s*,.*|user\s*,.*|domain\s*,.*|server.*/,
30
- deploy_tool: /'capistrano'|"capistrano|'capistrano-rails'|"capistrano-rails"|'mina'|"mina"/,
48
+ deploy_tool: /'capistrano'|"capistrano"|'capistrano-rails'|"capistrano-rails"|'mina'|"mina"/,
31
49
  deploy_user: /user.*/,
32
50
  rails: /'rails'.*|"rails".*/,
33
51
  ruby: /ruby\s+.*/,
@@ -107,7 +125,7 @@ module PinfoRails
107
125
  def self.check_deploy
108
126
  if @options.info[:deploy]
109
127
  @output += "\n"
110
- printline( 'Deploy tool', { color: :green, mode: :bold }, grep( FILES[:gemfile], PATTERNS[:deploy_tool] ) )
128
+ printline( 'Deploy tool', :light_green, grep( FILES[:gemfile], PATTERNS[:deploy_tool] ) )
111
129
  if @options[:verbose]
112
130
  printline FILES[:conf_dep], {}, ' '
113
131
  @output += cat FILES[:conf_dep]
@@ -121,16 +139,16 @@ module PinfoRails
121
139
 
122
140
  def self.check_requirements
123
141
  @options.reqs.split( ',' ).each do |req|
124
- printline( 'Required', :green, grep( FILES[:gemfile], Regexp.new( "['|\"][^'\"]*#{req}[^'\"]*['|\"]" ) ) )
142
+ printline( 'Required', :green, grep( FILES[:gemfile], Regexp.new( "'[^']*#{req}[^']*'.*|\"[^\"]*#{req}[^\"]*\".*" ) ) )
125
143
  end
126
144
  end
127
145
 
128
146
  def self.check_rails
129
- printline( 'Rails', { color: :green, mode: :bold }, grep( FILES[:gemfile], PATTERNS[:rails] ) )
147
+ printline( 'Rails', :light_green, grep( FILES[:gemfile], PATTERNS[:rails] ) )
130
148
  end
131
149
 
132
150
  def self.check_ruby
133
- printline( 'Ruby (current)', { color: :green, mode: :bold }, RUBY_VERSION + ' p' + RUBY_PATCHLEVEL.to_s )
151
+ printline( 'Ruby (current)', :light_green, RUBY_VERSION + ' p' + RUBY_PATCHLEVEL.to_s )
134
152
  printline( 'Ruby (.rvmrc)', :green, grep( FILES[:rvmrc], PATTERNS[:rvmrc] ) )
135
153
  ruby_ver = cat( FILES[:ruby_ver] ).strip
136
154
  printline( 'Ruby (.ruby-version)', :green, ruby_ver )
@@ -154,7 +172,7 @@ module PinfoRails
154
172
  lines = []
155
173
  if File.exist? file
156
174
  File.read( file ).each_line do |line|
157
- lines.push( Regexp.last_match.to_s.strip ) if !( line.strip =~ /^#.*$/ ) && line =~ expression
175
+ lines.push( Regexp.last_match[1].nil? ? Regexp.last_match.to_s.strip : Regexp.last_match[1].to_s.strip ) if !( line.strip =~ /^#.*$/ ) && line =~ expression
158
176
  end
159
177
  end
160
178
  ( lines.length > 1 ? "\n " : '' ) + lines.join( "\n " )
@@ -170,7 +188,7 @@ module PinfoRails
170
188
  return unless cnt > 0
171
189
  @output += '- ' + intro + ': '
172
190
  # @output += "\n " if cnt > 1
173
- @output += @options[:styles] ? strings.map( &:to_s ).join( '; ' ).colorize( styles ) : strings.map( &:to_s ).join( '; ' )
191
+ @output += @options[:styles] ? strings.map( &:to_s ).join( '; ' ).color( styles ) : strings.map( &:to_s ).join( '; ' )
174
192
  @output += "\n"
175
193
  end
176
194
 
@@ -223,11 +241,11 @@ module PinfoRails
223
241
  puts opts
224
242
  exit
225
243
  end
226
- opts.on_tail('--about', 'Show about') do
244
+ opts.on_tail('-A', '--about', 'Show about') do
227
245
  puts INFO + ' v' + VERSION.join('.') + "\n" + DESC + "\nby " + AUTHORS.first.join( ', ' )
228
246
  exit
229
247
  end
230
- opts.on_tail('--version', 'Show version') do
248
+ opts.on_tail('-V', '--version', 'Show version') do
231
249
  puts VERSION.join('.')
232
250
  exit
233
251
  end
metadata CHANGED
@@ -1,30 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pinfo-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattia Roccoberton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-12 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: colorize
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 0.8.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.8.0
27
- description: A gem to collect informations from a Rails project
11
+ date: 2016-10-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Command line utility to collect informations from a Rails project
28
14
  email: mat@blocknot.es
29
15
  executables:
30
16
  - pinfo