tomdoccery 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a2862a2dc5a0955693481ef95c4dadc3bf2ea5df
4
+ data.tar.gz: 8f1110334a8d241aaff208891436aca417ce908d
5
+ SHA512:
6
+ metadata.gz: 5a09804b9116b5df62cbfb7156dc55adb15dc66ecb8e7eb77e7a969fcac5d64876abae707f5e1bac5ce6fc8983d3030ebe711e08c2263f567fe7d6a20342d464
7
+ data.tar.gz: ee09fa93babaf6bef4ca9b30236d50ea464e36668377b15db40191e3eb6d6eea058aefc8796236bbddf41519af0d9d440a8471994b4c8c8406d3ea815aeabea7
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tomdoccery.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Tim
2
+
3
+ MIT License
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
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Tomdoccery (beta)
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+ ```
7
+ gem 'tomdoccery'
8
+ bundle
9
+ ```
10
+
11
+ Or install it yourself as:
12
+ ```
13
+ gem install tomdoccery
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ Mount it in your config/routes.rb file:
19
+ ```
20
+ require 'tomdoccery/web'
21
+ mount Tomdoccery::Web => '/tomdoc'
22
+ ```
23
+ You can use any url.
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,40 @@
1
+ require "tomdoccery/version"
2
+
3
+ module Tomdoccery
4
+ class Base
5
+ attr_reader :menu_items
6
+ attr_reader :directory
7
+ attr_reader :models
8
+
9
+ def initialize
10
+ @directory = './app/models/'
11
+ @models = Dir.glob('./app/models/*')
12
+ @menu_items = set_menu_items
13
+ end
14
+
15
+ def set_menu_items
16
+ @models.map do |path|
17
+ a = path.split('/')
18
+ name = a[a.length-1]
19
+ camel = name.gsub!('.rb', '').gsub!(/^[a-z]|_+[a-z]/) { |a| a.upcase }.gsub('_', '')
20
+ { display: camel, link: name.downcase }
21
+ end
22
+ end
23
+
24
+ def blocks(model)
25
+ blocks = parse_model(File.read(@directory + model + '.rb'))
26
+ blocks.map do |b|
27
+ parse_block(b)
28
+ end
29
+ end
30
+
31
+ def parse_model(file)
32
+ file.scan(/^[ ]+(#[ ][Internal:|Public:|Deprecated:].*?def[ ].*?$)/m).flatten || []
33
+ end
34
+
35
+ def parse_block(block)
36
+ block.match(/(^[ ]?#[ ](Internal:|Public:|Deprecated:)[ ].*?#\n)(^[ ]*#[ ]Examples.*?#\n)(^[ ]*#[ ]Returns.*?\.)(.*)/m) || []
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ module Tomdoccery
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,29 @@
1
+ require 'sinatra/base'
2
+ module Tomdoccery
3
+ class Web < Sinatra::Base
4
+ dir = File.expand_path(File.dirname(__FILE__) + "/../../web")
5
+ set :public_folder, "#{dir}/assets"
6
+ set :views, "#{dir}/views"
7
+ set :root, "#{dir}/public"
8
+
9
+ before do
10
+ @prefix = env['SCRIPT_NAME']
11
+ end
12
+
13
+ def sanitize(s)
14
+ s.gsub!('#', '') rescue nil
15
+ end
16
+
17
+ get '/' do
18
+ redirect "#{ @prefix }/#{ Tomdoccery::Base.new.menu_items[0][:link] }"
19
+ slim :index
20
+ end
21
+
22
+ get '/:model' do |model|
23
+ tommy = Tomdoccery::Base.new
24
+ @menu_items = tommy.menu_items
25
+ @blocks = tommy.blocks(model)
26
+ slim :model
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tomdoccery/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tomdoccery"
8
+ spec.version = Tomdoccery::VERSION
9
+ spec.authors = ["Tim"]
10
+ spec.email = ["thogg4@gmail.com"]
11
+ spec.description = %q{tomdoccery}
12
+ spec.summary = %q{tomdoccery}
13
+ spec.homepage = "https://github.com/thogg4/tomdoccery"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'sinatra'
22
+ spec.add_dependency 'slim'
23
+ spec.add_dependency 'tomparse'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ end
@@ -0,0 +1,3 @@
1
+ li {
2
+ list-style-type: none;
3
+ }
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,15 @@
1
+ html
2
+ head
3
+ link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet"
4
+ link href='/'
5
+ body
6
+ .container
7
+ .row
8
+ .span4
9
+ ul.unstyled
10
+ - @menu_items.each do |item|
11
+ li
12
+ a href="#{@prefix}/#{item[:link]}" = item[:display]
13
+
14
+ .span8
15
+ == yield
@@ -0,0 +1,18 @@
1
+ - if @blocks.empty?
2
+
3
+ h3 You have not tomdoccified this model.
4
+
5
+ - else
6
+ - @blocks.each do |b|
7
+ .row
8
+ .span8
9
+ .page-header: h1 = b[5]
10
+
11
+ .description
12
+ p.lead = sanitize(b[1])
13
+ p = sanitize(b[3])
14
+ p = sanitize(b[4])
15
+
16
+ .row
17
+ .span8
18
+ p.muted If you have a tomdocced method that is not here, check for typos.
metadata ADDED
@@ -0,0 +1,127 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tomdoccery
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tim
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-04-10 00:00:00.000000000 Z
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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: slim
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: tomparse
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: tomdoccery
84
+ email:
85
+ - thogg4@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - lib/tomdoccery.rb
96
+ - lib/tomdoccery/version.rb
97
+ - lib/tomdoccery/web.rb
98
+ - tomdoccery.gemspec
99
+ - web/assets/styles.css
100
+ - web/views/index.slim
101
+ - web/views/layout.slim
102
+ - web/views/model.slim
103
+ homepage: https://github.com/thogg4/tomdoccery
104
+ licenses:
105
+ - MIT
106
+ metadata: {}
107
+ post_install_message:
108
+ rdoc_options: []
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ requirements: []
122
+ rubyforge_project:
123
+ rubygems_version: 2.0.0.rc.2
124
+ signing_key:
125
+ specification_version: 4
126
+ summary: tomdoccery
127
+ test_files: []