html_notes 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .idea/*
6
+ docs
7
+
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color --format documentation
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in html_notes.gemspec
4
+ gemspec
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = HTML Notes
2
+
3
+ == Installing
4
+
5
+ $ gem install html_notes
6
+
7
+ == Usage
8
+
9
+ $ html_notes
10
+
11
+ == License
12
+
13
+
14
+ "THE BEER-WARE LICENSE":
15
+
16
+ As long as you retain this notice you
17
+ can do whatever you want with this stuff. If we meet some day, and you think
18
+ this stuff is worth it, you can buy me a beer.
19
+
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require "bundler"
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require "rspec/core/rake_task"
5
+ RSpec::Core::RakeTask.new
6
+
7
+ require 'rdoc/task'
8
+ RDoc::Task.new do |t|
9
+ t.rdoc_dir = "docs"
10
+ t.title = "HTML Notes"
11
+ t.options << "-m" << "README.rdoc"
12
+ end
@@ -0,0 +1,97 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html>
3
+ <head>
4
+ <meta charset='UTF-8' />
5
+ <title>Output of HTML Notes </title>
6
+ <style type="text/css">
7
+ body {
8
+ color: #333;
9
+ background: #eee;
10
+ padding: 0 20px;
11
+ }
12
+ h1 {
13
+ color: #4E4E4E;
14
+ }
15
+ p {
16
+ margin: 5px 0;
17
+ }
18
+ table {
19
+ background: white;
20
+ border: 1px solid #666;
21
+ border-collapse: collapse;
22
+ margin: 10px 0;
23
+ font-size: 14px;
24
+ }
25
+ table th, table td {
26
+ padding: 4px;
27
+ border: 1px solid #D0D0D0;
28
+ }
29
+ table th {
30
+ background-color: #DFC;
31
+ color: #337022;
32
+ }
33
+ table td.filename {
34
+ color: #ED1556;
35
+ }
36
+ table tr:hover {
37
+ background-color: #FFFFC0;
38
+ }
39
+ ul {
40
+ clear: both;
41
+ display: inline-block;
42
+ padding: 0;
43
+ margin: 0;
44
+ }
45
+ ul li {
46
+ list-style: none;
47
+ float: left;
48
+ }
49
+ </style>
50
+ </head>
51
+ <body>
52
+ <h1>html_notes output</h1>
53
+ <p>
54
+ <% if @rows.empty? %>
55
+ No notations found.
56
+ <% else %>
57
+ Found <%= @rows.size %> notations.
58
+ <% end %>
59
+ </p>
60
+ <ul>
61
+ <% @notation_names.each do |notation| %>
62
+ <li><input type="checkbox" value="<%= notation.strip %>" /><%= notation.strip %></li>
63
+ <% end %>
64
+ </ul>
65
+ <table>
66
+ <tr>
67
+ <th>Filename</th>
68
+ <th>Line Number</th>
69
+ <th>Notation</th>
70
+ <th>Text</th>
71
+ </tr>
72
+ <% @rows.each do |row| %>
73
+ <tr class="<%= row.notation.strip %>">
74
+ <td><%= row.file %></td>
75
+ <td><%= row.line %></td>
76
+ <td><%= row.notation %></td>
77
+ <td><%= row.text %></td>
78
+ </tr>
79
+ <% end %>
80
+ </table>
81
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
82
+ <script type="text/javascript">
83
+ $(function() {
84
+ $('ul li').show();
85
+ $('input[type=checkbox]').prop('checked', true).click(function() {
86
+ if ($(this).attr('checked')) {
87
+ $(this).prop('checked', true);
88
+ $('.'+$(this).val()).show();
89
+ } else {
90
+ $(this).prop('checked', false);
91
+ $('.'+$(this).val()).hide();
92
+ }
93
+ });
94
+ });
95
+ </script>
96
+ </body>
97
+ </html>
data/bin/html_notes ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "html_notes"
4
+ HTMLNotes.start
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "html_notes/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "html_notes"
7
+ s.version = HTMLNotes::Version::STRING
8
+ s.authors = ["Rafael Macedo"]
9
+ s.email = ["macedo.rafaelfernandes@gmail.com"]
10
+ s.homepage = "http://github.com/rafaelmacedo/html_notes"
11
+ s.summary = "An interface html to view annotations in source files"
12
+ s.description = s.summary
13
+
14
+ s.rubyforge_project = "html_notes"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ s.add_dependency "notes", "~> 0.0.2"
23
+ s.add_dependency "erubis"
24
+ s.add_development_dependency "rspec", "~> 2.6.0"
25
+ end
data/lib/html_notes.rb ADDED
@@ -0,0 +1,27 @@
1
+ module HTMLNotes
2
+ autoload :Version, "html_notes/version"
3
+ autoload :Parser, "html_notes/parser"
4
+
5
+ class << self
6
+ def start
7
+ @rows = `notes`.split("\n").inject([]) do |rows, line|
8
+ rows << HTMLNotes::Parser.new(line)
9
+ end
10
+ output_html
11
+ end
12
+
13
+ def output_html
14
+ require 'erubis'
15
+ template = File.read(File.join(File.dirname(__FILE__), "..", "assets", "template.html.erb"))
16
+
17
+ File.open("notes.html", "w+") do |file|
18
+ eruby = Erubis::Eruby.new(template)
19
+ file.puts eruby.evaluate(:rows => @rows, :notation_names => notation_names)
20
+ end
21
+ end
22
+
23
+ def notation_names
24
+ @rows.map(&:notation).uniq
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,10 @@
1
+ module HTMLNotes
2
+ class Parser
3
+
4
+ attr_reader :file, :line, :notation, :text
5
+
6
+ def initialize(line)
7
+ @file, @line, @notation, @text = line.split(':')
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ module HTMLNotes
2
+ module Version
3
+ MAJOR = '0'
4
+ MINOR = '1'
5
+ PATCH = '0'
6
+ STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ require "spec_helper"
2
+
3
+ describe HTMLNotes::Parser do
4
+ it "should split the result from notes gem in attributes" do
5
+ @parser = HTMLNotes::Parser.new('features/step_definitions/web_steps.rb:76: TODO: Add support for checkbox, select or option')
6
+ @parser.file.should == 'features/step_definitions/web_steps.rb'
7
+ @parser.line.should == '76'
8
+ @parser.notation.should == ' TODO'
9
+ @parser.text.should == ' Add support for checkbox, select or option'
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ require "spec_helper"
2
+
3
+ describe HTMLNotes do
4
+ it "has a version" do
5
+ HTMLNotes::Version::STRING.should match(/^\d+\.\d+\.\d+$/)
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ ENV["BUNDLE_GEMFILE"] = File.dirname(__FILE__) + "/../Gemfile"
2
+
3
+
4
+ require "bundler/setup"
5
+ Bundler.setup
6
+
7
+ require "html_notes"
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: html_notes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Rafael Macedo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-21 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: notes
16
+ requirement: &80323960 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *80323960
25
+ - !ruby/object:Gem::Dependency
26
+ name: erubis
27
+ requirement: &80501930 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *80501930
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &80804680 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 2.6.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *80804680
47
+ description: An interface html to view annotations in source files
48
+ email:
49
+ - macedo.rafaelfernandes@gmail.com
50
+ executables:
51
+ - html_notes
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - .rspec
57
+ - Gemfile
58
+ - README.rdoc
59
+ - Rakefile
60
+ - assets/template.html.erb
61
+ - bin/html_notes
62
+ - html_notes.gemspec
63
+ - lib/html_notes.rb
64
+ - lib/html_notes/parser.rb
65
+ - lib/html_notes/version.rb
66
+ - spec/html_notes/parser_spec.rb
67
+ - spec/html_notes_spec.rb
68
+ - spec/spec_helper.rb
69
+ homepage: http://github.com/rafaelmacedo/html_notes
70
+ licenses: []
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ! '>='
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project: html_notes
89
+ rubygems_version: 1.8.10
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: An interface html to view annotations in source files
93
+ test_files: []