params_debugger 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ (The MIT License)
2
+
3
+ Copyright © 2010
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 NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
data/README.textile ADDED
@@ -0,0 +1,51 @@
1
+ h2. About Params Debugger
2
+
3
+ Prints the last parameters line from your log file giving the action
4
+
5
+ h2. Installation
6
+
7
+ sudo gem install params_debugger
8
+
9
+ h2. Usage
10
+
11
+ params_debugger action
12
+
13
+ Example:
14
+
15
+ params_debugger update
16
+ params_debugger create
17
+
18
+ h2. Options
19
+
20
+ h3. -p
21
+
22
+ Shows the original result
23
+
24
+ Example:
25
+
26
+ params_debugger -p save
27
+
28
+ h2. License
29
+
30
+ (The MIT License)
31
+
32
+ Copyright © 2010
33
+
34
+ Permission is hereby granted, free of charge, to any person obtaining
35
+ a copy of this software and associated documentation files (the
36
+ ‘Software’), to deal in the Software without restriction, including
37
+ without limitation the rights to use, copy, modify, merge, publish,
38
+ distribute, sublicense, and/or sell copies of the Software, and to
39
+ permit persons to whom the Software is furnished to do so, subject to
40
+ the following conditions:
41
+
42
+ The above copyright notice and this permission notice shall be
43
+ included in all copies or substantial portions of the Software.
44
+
45
+ THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND,
46
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
47
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
48
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
49
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
50
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
51
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require File.expand_path(File.dirname(__FILE__) + '/../lib/params_debugger/debugger')
3
+
4
+ debugger = ParamsDebugger::Debugger.new(STDOUT, ARGV)
5
+
6
+ debugger.start
@@ -0,0 +1,59 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/parser')
2
+ require 'yaml'
3
+
4
+ module ParamsDebugger
5
+ class Debugger
6
+ def initialize output, args
7
+ @output = output
8
+ @args = args
9
+ end
10
+
11
+ def start
12
+ actions.each do |action|
13
+ if plain_version? options
14
+ @output.puts parameters action
15
+ else
16
+ @output.puts humanize(parameters action)
17
+ end
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ def humanize parameters
24
+ if parameters.match /^\{.*\}$/
25
+ eval "#{parameters}.to_yaml"
26
+ else
27
+ parameters
28
+ end
29
+ end
30
+
31
+ def parameters action
32
+ result = cat action
33
+
34
+ result.gsub!(/^\s*Parameters:\s*/, '')
35
+
36
+ result.strip
37
+ end
38
+
39
+ def cat action
40
+ `cat #{log} | grep Parameters | grep #{action} | tail -1`
41
+ end
42
+
43
+ def actions
44
+ @actions ||= ParamsDebugger::Parser::parse_actions @args
45
+ end
46
+
47
+ def options
48
+ @options ||= ParamsDebugger::Parser::parse_options @args
49
+ end
50
+
51
+ def log
52
+ @log ||= ParamsDebugger::Parser::parse_log options
53
+ end
54
+
55
+ def plain_version? options
56
+ options.include?('plain') || options.include?('p')
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,31 @@
1
+ module ParamsDebugger
2
+ class Parser
3
+ DEFAULT_LOG = :development
4
+
5
+ def self.parse_options args
6
+ options = []
7
+
8
+ args.each do |arg|
9
+ options << arg.delete('-') if arg.match /^-/
10
+ end
11
+
12
+ options
13
+ end
14
+
15
+ def self.parse_actions args
16
+ actions = []
17
+
18
+ args.each do |arg|
19
+ actions << arg unless arg.match /^-/
20
+ end
21
+
22
+ actions
23
+ end
24
+
25
+ def self.parse_log options
26
+ log = DEFAULT_LOG
27
+
28
+ "log/#{log}.log"
29
+ end
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: params_debugger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bruno Grasselli
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-04-11 00:00:00 -03:00
13
+ default_executable: params_debugger
14
+ dependencies: []
15
+
16
+ description: Prints the last parameters line from your log file giving the action
17
+ email: bruno.grasselli@gmail.com
18
+ executables:
19
+ - params_debugger
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - README.textile
26
+ - LICENSE
27
+ - bin/params_debugger
28
+ - lib/params_debugger/debugger.rb
29
+ - lib/params_debugger/parser.rb
30
+ has_rdoc: true
31
+ homepage: http://brunograsselli.com.br
32
+ licenses: []
33
+
34
+ post_install_message:
35
+ rdoc_options: []
36
+
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ version:
51
+ requirements: []
52
+
53
+ rubyforge_project:
54
+ rubygems_version: 1.3.5
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: Paramameters debugger
58
+ test_files: []
59
+