rubrowser 0.1.2 → 0.1.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: 3d1e814cf21c8e6a89504e7087deeded72c8d4a3
4
- data.tar.gz: b77604a0c9f9417bc3fa61021f3c313ee41fa8c4
3
+ metadata.gz: 98a6e065af01c9315496133bd1de3108a6c304c8
4
+ data.tar.gz: 666779a8c170e5b9fb52a7d67435fb28124991fa
5
5
  SHA512:
6
- metadata.gz: da0b7cdfc663e971e3cfc393e319fd60d3bdeab3991411d4d6a75ec386d05749495385be38bd245ca84ba6a443faac12b08cbed7e1d330301efd2fafc0773858
7
- data.tar.gz: 0e2e9037a14236096589596408fedfe50fb2500d2a8e8cce8241056fbc257cb40abf041da00a3babf11ef23fdfd0095793b0a3b0d8c5ac492ba472d69e97a49c
6
+ metadata.gz: 07db9f0754f43387becd50c5a1facb1872e76b1e982de3b6f06bc7a36949642982c76b64e5bc94e5c44648e5974ec78542911fcf79226e8cc40cbe99a1dd6f17
7
+ data.tar.gz: 12e93089491077c8fd52feed738b2169ceced4941eb2f154489ecc7af721e06ae66c6309300894d6be8c63bf021b5c9bdba26a4663b7897d4c99e164365dafee
data/Gemfile.lock CHANGED
@@ -1,11 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubrowser (0.1.0)
4
+ rubrowser (0.1.3)
5
5
  haml (~> 4.0, >= 4.0.0)
6
6
  parallel (~> 1.9, >= 1.9.0)
7
7
  parser (~> 2.3, >= 2.3.0)
8
- sinatra (~> 1.4, >= 1.4.0)
9
8
 
10
9
  GEM
11
10
  remote: https://rubygems.org/
@@ -16,13 +15,6 @@ GEM
16
15
  parallel (1.9.0)
17
16
  parser (2.3.1.2)
18
17
  ast (~> 2.2)
19
- rack (1.6.4)
20
- rack-protection (1.5.3)
21
- rack
22
- sinatra (1.4.7)
23
- rack (~> 1.5)
24
- rack-protection (~> 1.4)
25
- tilt (>= 1.3, < 3)
26
18
  tilt (2.0.5)
27
19
 
28
20
  PLATFORMS
data/bin/rubrowser CHANGED
@@ -2,4 +2,4 @@
2
2
  $LOAD_PATH.push File.expand_path('../../lib', __FILE__)
3
3
 
4
4
  require 'server'
5
- Rubrowser::Server.start
5
+ Rubrowser::Server.start(ARGV.empty? ? ['.'] : ARGV)
data/lib/data.rb CHANGED
@@ -4,12 +4,8 @@ require 'd3'
4
4
 
5
5
  module Rubrowser
6
6
  class Data
7
- def self.instance
8
- @_instance ||= new
9
- end
10
-
11
- def initialize
12
- @files = ARGV
7
+ def initialize(paths)
8
+ @files = paths
13
9
  @parsed = false
14
10
  end
15
11
 
data/lib/rubrowser.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rubrowser
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.1.3'.freeze
3
3
  end
data/lib/server.rb CHANGED
@@ -1,11 +1,34 @@
1
- require 'sinatra/base'
1
+ require 'webrick'
2
+ require 'haml'
2
3
  require 'data'
3
4
  require 'json'
4
5
 
5
6
  module Rubrowser
6
- class Server < Sinatra::Base
7
- get '/' do
8
- data = Rubrowser::Data.instance
7
+ class Server < WEBrick::HTTPServer
8
+ def self.start(paths)
9
+ new(paths).start
10
+ end
11
+
12
+ def initialize(paths)
13
+ super Port: 9000
14
+
15
+ @data = Rubrowser::Data.new(paths)
16
+ @data.parse
17
+
18
+ mount_proc '/' do |req, res|
19
+ res.body = root(req.path)
20
+ end
21
+
22
+ trap('INT') { shutdown }
23
+ end
24
+
25
+ private
26
+
27
+ attr_reader :data
28
+
29
+ def root(path)
30
+ return file(path) if file?(path)
31
+
9
32
  haml :index,
10
33
  locals: {
11
34
  constants: data.constants,
@@ -13,13 +36,24 @@ module Rubrowser
13
36
  }
14
37
  end
15
38
 
16
- def self.start
17
- Rubrowser::Data.instance.parse
18
- Thread.new do
19
- run! host: 'localhost',
20
- port: 9000,
21
- root: File.expand_path('../../', __FILE__)
22
- end.join
39
+ def file?(path)
40
+ path = resolve_file_path("/public#{path}")
41
+ File.file?(path)
42
+ end
43
+
44
+ def file(path)
45
+ File.read(resolve_file_path("/public#{path}"))
46
+ end
47
+
48
+ def haml(template, options = {})
49
+ path = resolve_file_path("/views/#{template}.haml")
50
+ file = File.open(path).read
51
+ locals = options.delete(:locals) || {}
52
+ Haml::Engine.new(file, options).render(self, locals)
53
+ end
54
+
55
+ def resolve_file_path(path)
56
+ File.expand_path("../..#{path}", __FILE__)
23
57
  end
24
58
  end
25
59
  end
data/readme.md CHANGED
@@ -23,6 +23,12 @@ gem install rubrowser
23
23
  rubrowser /path/to/project/or/file
24
24
  ```
25
25
 
26
+ or you can just visualize current directory
27
+
28
+ ```
29
+ rubrowser
30
+ ```
31
+
26
32
  it'll analyze the project and open port 9000, so you can access the graph from `localhost:9000`
27
33
 
28
34
  ## Features
data/rubrowser.gemspec CHANGED
@@ -7,15 +7,14 @@ Gem::Specification.new do |s|
7
7
  s.authors = ['Emad Elsaid']
8
8
  s.email = ['blazeeboy@gmail.com']
9
9
  s.homepage = 'https://github.com/blazeeboy/rubrowser'
10
- s.summary = 'a ruby code dependency graph interactive visualizer'
11
- s.description = 'a ruby code dependency graph interactive visualizer'
10
+ s.summary = 'A ruby interactive dependency graph visualizer'
11
+ s.description = 'A ruby interactive dependency graph visualizer'
12
12
  s.license = 'MIT'
13
13
 
14
14
  s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
15
15
  s.require_paths = ['../lib']
16
16
  s.executables << 'rubrowser'
17
17
 
18
- s.add_runtime_dependency 'sinatra', '~> 1.4', '>= 1.4.0'
19
18
  s.add_runtime_dependency 'parser', '~> 2.3', '>= 2.3.0'
20
19
  s.add_runtime_dependency 'parallel', '~> 1.9', '>= 1.9.0'
21
20
  s.add_runtime_dependency 'haml', '~> 4.0', '>= 4.0.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubrowser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emad Elsaid
@@ -10,26 +10,6 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2016-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: sinatra
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.4'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 1.4.0
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '1.4'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 1.4.0
33
13
  - !ruby/object:Gem::Dependency
34
14
  name: parser
35
15
  requirement: !ruby/object:Gem::Requirement
@@ -90,7 +70,7 @@ dependencies:
90
70
  - - ">="
91
71
  - !ruby/object:Gem::Version
92
72
  version: 4.0.0
93
- description: a ruby code dependency graph interactive visualizer
73
+ description: A ruby interactive dependency graph visualizer
94
74
  email:
95
75
  - blazeeboy@gmail.com
96
76
  executables:
@@ -140,6 +120,6 @@ rubyforge_project:
140
120
  rubygems_version: 2.6.3
141
121
  signing_key:
142
122
  specification_version: 4
143
- summary: a ruby code dependency graph interactive visualizer
123
+ summary: A ruby interactive dependency graph visualizer
144
124
  test_files: []
145
125
  has_rdoc: