rtfd 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,19 @@
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
+ .idea
19
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Alexander Logunov
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.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # Rtfd
2
+
3
+ Rdft is a Sinatra application which serves github Post-Receive Hooks, updating repositores and shows documentation for it with yard. Rtfd is provided as Rack application.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rtfd'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rtfd
18
+
19
+ ## Usage
20
+
21
+ We expect you make config file: /config/rtfd/repos.yml
22
+
23
+ The simple example of this file
24
+
25
+ repos_path: repos
26
+ repos:
27
+ sinatra: git://github.com/sinatra/sinatra.git
28
+ yard: git://github.com/lsegal/yard.git
29
+
30
+ You can use Rtfd::Application in you application now!
31
+
32
+ Check Simple demo application that uses rtfd: https://github.com/BrandyMint/rtfd_demo_app
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ require "sinatra"
2
+ class Rtfd::Application < Sinatra::Base
3
+ use YARD::Server::RackMiddleware, :libraries => Rtfd::Yard.libraries, :options => Rtfd::Yard.options
4
+ post '/github_hook' do
5
+ Rtfd::GithubHandler.new.handle params
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ require 'json'
2
+ class Rtfd::GithubHandler
3
+ def handle params
4
+ payload = JSON.parse(params[:payload])
5
+ $stdout.puts "I got some JSON from github: #{payload.inspect}"
6
+ repo = Rtfd.repos.find{|repo| repo.first==payload['repository']['name'] and 'refs/heads/master'==payload['ref']}
7
+ update repo, payload if repo
8
+ end
9
+
10
+ def update repo, payload
11
+ if payload['forced'] or !Dir.exist?("#{Rtfd.repos_path}/#{repo.first}")
12
+ clone repo
13
+ else
14
+ pull repo
15
+ end
16
+ end
17
+
18
+ def pull repo
19
+ $stdout.puts "Pulling #{repo.first}"
20
+ system "cd #{Rtfd.repos_path}/#{repo.first}; git pull; yard doc;"
21
+ end
22
+
23
+ def clone repo
24
+ $stdout.puts "Clonning #{repo.first}"
25
+ system "cd #{Rtfd.repos_path}; rm -rf #{repo.first}; git clone #{repo[1]}; cd #{repo.first}; yard doc;"
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module Rtfd
2
+ VERSION = "0.0.1"
3
+ end
data/lib/rtfd/yard.rb ADDED
@@ -0,0 +1,15 @@
1
+ require "yard"
2
+ module Rtfd::Yard
3
+ def self.libraries
4
+ libraries = {}
5
+ Rtfd.repos.each do |repo|
6
+ name = repo[0]
7
+ libraries[name] = [YARD::Server::LibraryVersion.new(name, nil, "#{Rtfd.repos_path}/#{name}/.yardoc")]
8
+ end
9
+ libraries
10
+ end
11
+
12
+ def self.options
13
+ {incremental:true}
14
+ end
15
+ end
data/lib/rtfd.rb ADDED
@@ -0,0 +1,21 @@
1
+ module Rtfd
2
+ def self.repos_path
3
+ @repos_path ||= self.load_settings[0]
4
+ end
5
+
6
+ def self.repos
7
+ @repos ||= self.load_settings[1]
8
+ end
9
+
10
+ def self.load_settings
11
+ settings = YAML::load(File.open('config/rtfd/repos.yml'))
12
+ @repos_path = File.absolute_path(settings['repos_path'])
13
+ @repos = settings['repos']
14
+ [@repos_path, @repos]
15
+ end
16
+ end
17
+
18
+ require "rtfd/github_handler"
19
+ require "rtfd/yard"
20
+ require "rtfd/application"
21
+ require "rtfd/version"
data/rtfd.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rtfd/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "rtfd"
8
+ gem.version = Rtfd::VERSION
9
+ gem.authors = ["Alexander Logunov"]
10
+ gem.email = ["unlovedru@gmail.com"]
11
+ gem.description = "Rdft is a Sinatra application which serves github Post-Receive Hooks, updating repositores and shows documentation for it with yard. Rtfd is provided as Rack application."
12
+ gem.summary = "Automatized documentation server based on yard"
13
+ gem.homepage = "https://github.com/BrandyMint/rtfd"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'sinatra', '1.3.3'
21
+ gem.add_dependency 'yard', '0.8.3'
22
+ gem.add_dependency 'redcarpet', '2.2.1'
23
+
24
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rtfd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alexander Logunov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sinatra
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.3.3
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.3.3
30
+ - !ruby/object:Gem::Dependency
31
+ name: yard
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - '='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.8.3
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.8.3
46
+ - !ruby/object:Gem::Dependency
47
+ name: redcarpet
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: 2.2.1
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.2.1
62
+ description: Rdft is a Sinatra application which serves github Post-Receive Hooks,
63
+ updating repositores and shows documentation for it with yard. Rtfd is provided
64
+ as Rack application.
65
+ email:
66
+ - unlovedru@gmail.com
67
+ executables: []
68
+ extensions: []
69
+ extra_rdoc_files: []
70
+ files:
71
+ - .gitignore
72
+ - Gemfile
73
+ - LICENSE.txt
74
+ - README.md
75
+ - Rakefile
76
+ - lib/rtfd.rb
77
+ - lib/rtfd/application.rb
78
+ - lib/rtfd/github_handler.rb
79
+ - lib/rtfd/version.rb
80
+ - lib/rtfd/yard.rb
81
+ - rtfd.gemspec
82
+ homepage: https://github.com/BrandyMint/rtfd
83
+ licenses: []
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ none: false
96
+ requirements:
97
+ - - ! '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 1.8.24
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: Automatized documentation server based on yard
106
+ test_files: []
107
+ has_rdoc: