gui_debugger 0.0.2 → 0.0.3

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
  SHA1:
3
- metadata.gz: 1404ed38708bb8b69b6fccfda9ba71695e1fd0ad
4
- data.tar.gz: 44db585140be44efccd0459f0f8cb67cb517d993
3
+ metadata.gz: 2407125f0b0ff8af9b236cde524115bbd3ec4740
4
+ data.tar.gz: 93186cb28be27860da5b4cfc727d351966d6976f
5
5
  SHA512:
6
- metadata.gz: 5ec677177351b16e00ecf65f27133fd2693985aa212a6dca28e9b89f2b15a6c7ada941695d8f54272b23f97a233c3149caab70484e251688388dc88df5164c01
7
- data.tar.gz: 37ed4ba4cdcac07bbfdd2026d4777395e609c5dbe69a568796955015e8eea311b2d7eba40b1ebf9f17b07ec16c16a147b5950b7de71a796c71919c8dcf2ac2d7
6
+ metadata.gz: 05e9b9197ea56259a1bc21fcaf709d884ca9d956ef39ecf300a6a8e4286e7b15b4efba95d36d5389c73ab833fe543c0381f4c3333fe345d013b4d4b9764dda67
7
+ data.tar.gz: 45a5949e68382e861ae9630e9302d39ae65cd1a634719f995daf9b82b3de5291f6a1a46e67bf1ea67cd2b2ab584cf021232d3d2e73dcbe36fe8f017b4f643932
@@ -1,6 +1,4 @@
1
- Copyright (c) 2013 NorimasaAndo
2
-
3
- MIT License
1
+ Copyright 2014 NorimasaAndo
4
2
 
5
3
  Permission is hereby granted, free of charge, to any person obtaining
6
4
  a copy of this software and associated documentation files (the
@@ -1,6 +1,4 @@
1
- # GuiDebugger
2
-
3
- TODO: Write a gem description
1
+ = GuiDebugger
4
2
 
5
3
  ## Installation
6
4
 
@@ -18,7 +16,7 @@ Or install it yourself as:
18
16
 
19
17
  ## Usage
20
18
 
21
- TODO: Write usage instructions here
19
+ binding.debug
22
20
 
23
21
  ## Contributing
24
22
 
data/Rakefile CHANGED
@@ -1 +1,32 @@
1
- require "bundler/gem_tasks"
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'GuiDebugger'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+
32
+ task default: :test
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module GuiDebugger
4
2
  class DebugContext
5
3
 
@@ -40,8 +38,9 @@ module GuiDebugger
40
38
  GuiDebugger.escape str
41
39
  end
42
40
 
43
- def stack_frame
44
- @callers.map { |stack| { short_path: short_path(stack) } }
41
+ def stack_frames
42
+ frames = @callers.map.with_index { |stack, index| { path: short_path(stack), index: index } }
43
+ frames.reject { |frame| frame[:index] == 0 }
45
44
  end
46
45
 
47
46
  def full_path(stack)
@@ -65,8 +64,7 @@ module GuiDebugger
65
64
 
66
65
  def send_code(index, code)
67
66
  return "" if code.blank?
68
- code = URI.unescape(code)
69
- @callers[index.to_i].eval(code).to_s
67
+ @callers[index.to_i].eval(URI.unescape(code)).to_s
70
68
  end
71
69
  end
72
70
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'erubis'
4
2
 
5
3
  module GuiDebugger
@@ -8,11 +6,9 @@ module GuiDebugger
8
6
  File.expand_path("../templates/#{template_name}.html.erb", __FILE__)
9
7
  end
10
8
 
11
- def self.display
9
+ def self.show
12
10
  text = File.read(template("main"))
13
- html = Erubis::Eruby.new(text).evaluate(context: GuiDebugger.debug_context)
14
-
15
- [200, { "Content-Type" => "text/html; charset=utf-8" }, [html]]
11
+ Erubis::Eruby.new(text).evaluate(context: GuiDebugger.debug_context)
16
12
  end
17
13
  end
18
14
  end
@@ -1,12 +1,5 @@
1
- # encoding: utf-8
2
-
3
- require 'active_support'
4
- require "gui_debugger/debug_context.rb"
5
-
6
1
  module GuiDebugger
7
2
  module GuiDebug
8
- extend ActiveSupport::Concern
9
-
10
3
  def debug
11
4
  GuiDebugger.debug_context = DebugContext.new(binding, binding.callers)
12
5
  throw :gui_debugger
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module GuiDebugger
4
2
  class Middleware
5
3
 
@@ -9,14 +7,14 @@ module GuiDebugger
9
7
 
10
8
  def call(env)
11
9
  if %r{\A/__gui_debugger/(?<method>\w+)(/(?<index>\d+))?(/(?<val>.+))?} =~ env["PATH_INFO"]
12
- data = GuiDebugger.debug_context.send(method, *[index, val].compact)
13
- [200, { "Content-Type" => "text/plain; charset=utf-8" }, [JSON.dump({ data: data })]]
10
+ result = GuiDebugger.debug_context.send(method, *[index, val].compact)
11
+ [200, { "Content-Type" => "text/plain; charset=utf-8" }, [JSON.dump({ result: result })]]
14
12
  else
15
13
  catch(:gui_debugger) do
16
14
  return @app.call(env)
17
15
  end
18
16
 
19
- DebugPage::display
17
+ [200, { "Content-Type" => "text/html; charset=utf-8" }, [DebugPage.show]]
20
18
  end
21
19
  end
22
20
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module GuiDebugger
4
2
  class Railtie < Rails::Railtie
5
3
  initializer "gui_debugger.configuration" do
@@ -4,39 +4,30 @@
4
4
  <title>DebugPage</title>
5
5
  <meta charset="utf-8">
6
6
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
7
- <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
8
- <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap-theme.min.css">
7
+ <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
8
+ <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">
9
9
  <style>
10
- .contents {
11
- padding: 80px 0 0 0;
10
+ article {
11
+ padding-top: 80px;
12
12
  }
13
- .non-active {
14
- display: none;
15
- }
16
- .stack_frame {
17
- height: 250px;
18
- overflow: auto;
19
- }
20
- .eval {
21
- max-width: 850px;
13
+ section {
22
14
  margin-bottom: 20px;
23
15
  }
24
16
  .source {
25
- height: 350px;
26
17
  overflow: auto;
27
18
  margin-bottom: 10px;
28
19
  }
20
+ .result {
21
+ margin-top: 15px;
22
+ }
29
23
  .variables {
30
- height: 400px;
31
24
  overflow: auto;
32
25
  line-height: 10px;
33
26
  }
34
27
  .variables ul li {
35
28
  list-style: none;
36
- }
37
- .result {
38
- height: 250px;
39
- overflow: auto;
29
+ margin-left: -140px;
30
+ margin-top: -5px;
40
31
  }
41
32
  </style>
42
33
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.min.js"></script>
@@ -44,51 +35,40 @@
44
35
  </head>
45
36
  <body ng-controller="DebugCtrl">
46
37
 
47
- <div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
48
- <div class="container">
49
- <div class="navbar-header">
50
- <a class="navbar-brand" href="#">Debug page</a>
51
- </div>
52
- </div>
53
- </div>
54
-
55
38
  <div class="container">
56
- <div class="contents">
57
- <div class="row">
58
- <div class="eval col-md-7">
59
- <div class="source" ng-bind-html="source" ng-init="disp_stack_frame('1')"></div>
39
+ <header class="navbar navbar-inverse navbar-fixed-top" role="navigation">
40
+ <div class="navbar-header">
41
+ <a class="navbar-brand" href="#">Debug page</a>
42
+ </div>
43
+ </header>
44
+
45
+ <article class="contents">
46
+ <section class="row">
47
+ <div class="col-md-8">
48
+ <select class="form-control" ng-model="stack_frame_index" ng-change="disp_stack_frame()" ng-options="frame['index'] as frame['path'] for frame in stack_frames"></select>
49
+ </div>
50
+ </section>
51
+
52
+ <section class="row">
53
+ <div class="col-md-9">
54
+ <div class="source" ng-bind-html="source" ng-init="disp_stack_frame()"></div>
60
55
  <form ng-submit="send_code()">
61
56
  <input type="text" ng-model="code" size="80" placeholder="enter code here...">
62
57
  <input class="btn-primary" type="submit" value="send">
63
58
  </form>
59
+ <div class="result">
60
+ <pre ng-bind-html="disp" style="white-space: pre;"></pre>
61
+ </div>
64
62
  </div>
65
- <pre class="variables col-md-offset-7">
63
+ <pre class="variables">
66
64
  <ul>
67
- <li style="margin-left:-110px; margin-top:-5px;" ng-repeat="val in vals">
65
+ <li ng-repeat="val in vals">
68
66
  <a href="" ng-click="instance_variable_get(val)" ng-bind="val"></a>
69
67
  </li>
70
68
  </ul>
71
69
  </pre>
72
- </div>
73
-
74
- <div class="clearfix"></div>
75
-
76
- <div class="row">
77
- <div class="col-md-7 result">
78
- <pre ng-bind-html="disp" style="white-space: pre;"></pre>
79
- </div>
80
-
81
- <div class="list-group col-md-offset-7 stack_frame">
82
- <% @context.stack_frame.each_with_index do |stack, index| %>
83
- <% next if index == 0 %>
84
- <a href="" class="list-group-item" ng-class='{"active":selected_index == <%= index %>}' ng-click="disp_stack_frame('<%= index %>')">
85
- <%= stack[:short_path] %>
86
- </a>
87
- <% end %>
88
- </div>
89
- </div>
90
-
91
- </div><!-- /.contents -->
70
+ </section>
71
+ </article><!-- /.contents -->
92
72
  </div><!-- /.container -->
93
73
 
94
74
  <script>
@@ -120,37 +100,37 @@
120
100
 
121
101
  debugApp.controller('DebugCtrl', ['$scope', 'InstanceVal', 'InstanceValList', 'DispStackFrame', 'SendCode', '$sce',
122
102
  function($scope, InstanceVal, InstanceValList, DispStackFrame, SendCode, $sce) {
103
+ $scope.stack_frames = <%= @context.stack_frames.to_json %>;
104
+ $scope.stack_frame_index = $scope.stack_frames[0].index;
105
+
123
106
  $scope.instance_variable_get = function(val) {
124
- InstanceVal.query({ index: $scope.selected_index, val: val }, function(res) {
125
- $scope.disp = $sce.trustAsHtml(res.data);
107
+ InstanceVal.query({ index: $scope.stack_frame_index, val: val }, function(response) {
108
+ $scope.disp = $sce.trustAsHtml(response.result);
126
109
  });
127
110
  };
128
111
 
129
- $scope.disp_stack_frame = function(index) {
130
- DispStackFrame.query({ index: index }, function(res) {
131
- $scope.source = $sce.trustAsHtml(res.data);
112
+ $scope.disp_stack_frame = function() {
113
+ DispStackFrame.query({ index: $scope.stack_frame_index }, function(response) {
114
+ $scope.source = $sce.trustAsHtml(response.result);
132
115
  });
133
- $scope.selected_index = index;
134
- $scope.instance_variables(index)
116
+ $scope.instance_variables()
135
117
  };
136
118
 
137
- $scope.instance_variables = function(index) {
138
- InstanceValList.query({ index: index }, function(res) {
139
- $scope.vals = res.data;
119
+ $scope.instance_variables = function() {
120
+ InstanceValList.query({ index: $scope.stack_frame_index }, function(response) {
121
+ $scope.vals = response.result;
140
122
  });
141
123
  };
142
124
 
143
125
  $scope.send_code = function() {
144
- SendCode.query({ index: $scope.selected_index, code: $scope.code }, function(res) {
145
- $scope.disp = $sce.trustAsHtml(res.data);
126
+ SendCode.query({ index: $scope.stack_frame_index, code: $scope.code }, function(response) {
127
+ $scope.disp = $sce.trustAsHtml(response.result);
146
128
  });
147
129
  };
148
-
149
- $scope.selected_index = 1;
150
130
  }]);
151
131
  </script>
152
132
 
153
133
  <script src="https://code.jquery.com/jquery.js"></script>
154
- <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
134
+ <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
155
135
  </body>
156
136
  </html>
@@ -1,3 +1,3 @@
1
1
  module GuiDebugger
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/gui_debugger.rb CHANGED
@@ -1,13 +1,12 @@
1
- require "gui_debugger/version"
2
- require "gui_debugger/gui_debug"
3
- require "gui_debugger/debug_page"
4
- require "gui_debugger/middleware"
5
-
6
1
  module GuiDebugger
7
2
 
3
+ autoload :GuiDebug, 'gui_debugger/gui_debug'
4
+ autoload :DebugPage, 'gui_debugger/debug_page'
5
+ autoload :Middleware, 'gui_debugger/middleware'
6
+ autoload :DebugContext, 'gui_debugger/debug_context.rb'
7
+
8
8
  class << self
9
- # retain only one context for debug when guidebug
10
- # method is called.
9
+ # retain a context for debug
11
10
  attr_accessor :debug_context
12
11
  end
13
12
 
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :gui_debugger do
3
+ # # Task goes here
4
+ # end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gui_debugger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - NorimasaAndo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-01 00:00:00.000000000 Z
11
+ date: 2014-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.1.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.1.1
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +122,34 @@ dependencies:
108
122
  - - ">="
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: coderay
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 1.0.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 1.0.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: sqlite3
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
111
153
  description: ''
112
154
  email:
113
155
  - norimasa.ando@gmail.com
@@ -115,12 +157,9 @@ executables: []
115
157
  extensions: []
116
158
  extra_rdoc_files: []
117
159
  files:
118
- - ".gitignore"
119
- - Gemfile
120
- - LICENSE.txt
121
- - README.md
160
+ - MIT-LICENSE
161
+ - README.rdoc
122
162
  - Rakefile
123
- - gui_debugger.gemspec
124
163
  - lib/gui_debugger.rb
125
164
  - lib/gui_debugger/debug_context.rb
126
165
  - lib/gui_debugger/debug_page.rb
@@ -129,9 +168,8 @@ files:
129
168
  - lib/gui_debugger/railtie.rb
130
169
  - lib/gui_debugger/templates/main.html.erb
131
170
  - lib/gui_debugger/version.rb
132
- - spec/gui_debugger_spec.rb
133
- - spec/spec_helper.rb
134
- homepage: https://github.com/yurup/gui_debugger
171
+ - lib/tasks/gui_debugger_tasks.rake
172
+ homepage: https://github.com/worldtravel1013/gui_debugger
135
173
  licenses:
136
174
  - MIT
137
175
  metadata: {}
@@ -151,10 +189,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
189
  version: '0'
152
190
  requirements: []
153
191
  rubyforge_project:
154
- rubygems_version: 2.2.0
192
+ rubygems_version: 2.2.2
155
193
  signing_key:
156
194
  specification_version: 4
157
195
  summary: ''
158
- test_files:
159
- - spec/gui_debugger_spec.rb
160
- - spec/spec_helper.rb
196
+ test_files: []
data/.gitignore DELETED
@@ -1,18 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- *.swp
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in gui_debugger.gemspec
4
- gemspec
data/gui_debugger.gemspec DELETED
@@ -1,29 +0,0 @@
1
- # coding: utf-8
2
-
3
- lib = File.expand_path('../lib', __FILE__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'gui_debugger/version'
6
-
7
- Gem::Specification.new do |s|
8
- s.name = "gui_debugger"
9
- s.version = GuiDebugger::VERSION
10
- s.authors = ["NorimasaAndo"]
11
- s.email = ["norimasa.ando@gmail.com"]
12
- s.description = ""
13
- s.summary = ""
14
- s.homepage = "https://github.com/yurup/gui_debugger"
15
- s.license = "MIT"
16
-
17
- s.files = `git ls-files`.split($/)
18
- s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
20
- s.require_paths = ["lib"]
21
-
22
- s.add_development_dependency "bundler", "~> 1.3"
23
- s.add_development_dependency "rake"
24
- s.add_development_dependency "rspec", "~> 2.9"
25
- s.add_development_dependency "pry"
26
- s.add_development_dependency "actionpack", "~> 4.0"
27
- s.add_development_dependency "binding_of_caller"
28
- s.add_development_dependency "erubis"
29
- end
@@ -1,7 +0,0 @@
1
- require "spec_helper"
2
- require "pry"
3
-
4
- describe GuiDebugger do
5
- it "pending..." do
6
- end
7
- end
data/spec/spec_helper.rb DELETED
@@ -1,2 +0,0 @@
1
- $LOAD_PATH << File.expand_path("../lib", __FILE__)
2
- require "gui_debugger"