nanahoshi 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2f94acb94f46bdae0e4f5796d5012f177a3b5509
4
+ data.tar.gz: 87fe486f3f53eb4ec7040fda5cf640cd088007f5
5
+ SHA512:
6
+ metadata.gz: e2d2c8037304e1ee6818d1cc25a0a327b25abf9a8a66101658ceaa245f5e6b29621dc2ecf9c26d0af02f1e46bad08503c79debf2571410c298f504b6e686e811
7
+ data.tar.gz: 690eb3987543debfe4c7d7778c1cf0b95f20399dbf2d09d62052657fe8cf62122891ee121a0803fc1043afcccc2b6a595af33849d7d926ed3ae74147b6c0ecba
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,23 @@
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 = 'Nanahoshi'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
@@ -0,0 +1,24 @@
1
+ require 'bundler'
2
+ class Nanahoshi::InfoController < ApplicationController
3
+ def index
4
+ lookup = Bundler.load.specs.to_hash
5
+ hash = lookup.each_with_object({}) do |(gemname, specs), hash|
6
+ hash[gemname] = specs.map do |spec|
7
+ spec.dependencies.select{|dependency|dependency.type == :runtime}.map(&:name)
8
+ end.flatten.uniq
9
+ end
10
+
11
+ gem_names = hash.keys
12
+ @nodes = gem_names.map{|gem_name|{name: gem_name}}
13
+
14
+ @edges = []
15
+ hash.each do |gem, deps|
16
+ source_index = gem_names.index(gem)
17
+ dependence_edges = deps.map do |dep|
18
+ {source: source_index, target: gem_names.index(dep)}
19
+ end
20
+
21
+ @edges.concat(dependence_edges)
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,60 @@
1
+ <style>
2
+ body{mergin:8px}
3
+
4
+ .link {stroke: #666; stroke-width: 1.5px;}
5
+
6
+ circle {
7
+ fill: #ccc;
8
+ stroke: #333;
9
+ stroke-width: 1.5px;
10
+ }
11
+
12
+ text {
13
+ font: 10px sans-serif;
14
+ pointer-events: none;
15
+ text-shadow: 0 1px 0 #fff, 1px 0 0 #fff, 0 -1px 0 #fff, -1px 0 0 #fff;
16
+ }
17
+ </style>
18
+ <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
19
+ <script>
20
+ var nodes = <%= @nodes.to_json.html_safe %>;
21
+ var links = <%= @edges.to_json.html_safe %>;
22
+
23
+ var width = (window.innerWidth || 950) - 16;
24
+ var height = (window.innerHeight || 500) - 16;
25
+ var force = d3.layout.force().nodes(nodes).links(links).size([width, height])
26
+ .linkDistance(60).charge(-300).on("tick", tick).start();
27
+
28
+ var svg = d3.select("body").append("svg").attr("width", width).attr("height", height);
29
+
30
+ svg.append("defs").append("marker")
31
+ .attr("id", "arrow-head").attr("viewBox", "0 -5 10 10")
32
+ .attr("refX", 15).attr("refY", -1.5)
33
+ .attr("markerWidth", 6).attr("markerHeight", 6).attr("orient", "auto")
34
+ .append("path").attr("d", "M0,-5L10,0L0,5");
35
+
36
+ var line = svg.append("g").attr("class", "line-group")
37
+ .selectAll("line").data(links).enter()
38
+ .append("line").attr("class", "link").attr("marker-end", "url(#arrow-head)");
39
+
40
+ var circle = svg.append("g").attr("class", "circle-group")
41
+ .selectAll("circle").data(nodes).enter()
42
+ .append("circle").attr("r", 6).call(force.drag);
43
+
44
+ var text = svg.append("g").attr("class", "text-group")
45
+ .selectAll("text").data(nodes).enter()
46
+ .append("text").attr("x", 8).attr("y", ".31em")
47
+ .text(function(d) { return d.name; });
48
+
49
+ function tick() {
50
+ line.attr("x1", function(d) { return d.source.x; })
51
+ .attr("y1", function(d) { return d.source.y; })
52
+ .attr("x2", function(d) { return d.target.x; })
53
+ .attr("y2", function(d) { return d.target.y; });
54
+ circle.attr("transform", transform);
55
+ text.attr("transform", transform);
56
+ }
57
+ function transform(d) {
58
+ return "translate(" + d.x + "," + d.y + ")";
59
+ }
60
+ </script>
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ get 'rails/info/gems', controller: 'nanahoshi/info', action: 'index'
3
+ end
data/lib/nanahoshi.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "nanahoshi/engine"
2
+
3
+ module Nanahoshi
4
+ end
@@ -0,0 +1,7 @@
1
+ module Nanahoshi
2
+ class Engine < ::Rails::Engine
3
+ config.generators do |g|
4
+ g.test_framework :rspec
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Nanahoshi
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :nanahoshi do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nanahoshi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - yousuketto
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-22 00:00:00.000000000 Z
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: 3.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Nanahoshi is web ui for gem dependencies graph.
42
+ email:
43
+ - yosuketto@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - Rakefile
50
+ - app/controllers/nanahoshi/info_controller.rb
51
+ - app/views/nanahoshi/info/index.html.erb
52
+ - config/routes.rb
53
+ - lib/nanahoshi.rb
54
+ - lib/nanahoshi/engine.rb
55
+ - lib/nanahoshi/version.rb
56
+ - lib/tasks/nanahoshi_tasks.rake
57
+ homepage: https://github.com/yousuketto/nanahoshi
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.2.2
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Nanahoshi is web ui for gem dependencies graph.
81
+ test_files: []