docset 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 244fd14362adb76ebd7de747bd779482a799466e
4
+ data.tar.gz: 9110bab293d00ce88bf0415fd7ce9b57992258be
5
+ SHA512:
6
+ metadata.gz: f3c7e9b75c1ed65150bd11b3c2d6ad70fd1fe3c3892d7e4c64092cb7399606440d1a3d3eb84989bf79cb9141bfb27bb169fa75abcee042fe9b728be5abb6c998
7
+ data.tar.gz: c2608d2b39adcbf97337243780c6ab120c44a23dd9dab21c21ad7ffcd71b86ba32a951af50616674171c8c6b7e5e2346ad4694bec679df188541b17c61a61a6c
Binary file
Binary file
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.14.6
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at hanachin@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in docset.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Seiei Miyagi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,40 @@
1
+ # Docset
2
+
3
+ [![Build Status](https://travis-ci.org/yasslab/docset.svg?branch=master)](https://travis-ci.org/yasslab/docset)
4
+
5
+ A library for [Dash docset](https://kapeli.com/docsets) generation.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'docset'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install docset
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/yasslab/docset. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "docset"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'docset/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "docset"
8
+ spec.version = Docset::VERSION
9
+ spec.authors = ["siman-man", "Seiei Miyagi"]
10
+ spec.email = ["k128585@ie.u-ryukyu.ac.jp", "hanachin@gmail.com"]
11
+
12
+ spec.summary = %q{a library for docset generation}
13
+ spec.homepage = "https://github.com/yasslab/docset"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "sqlite3", "~> 1.3"
24
+ spec.add_development_dependency "bundler", "~> 1.14"
25
+ spec.add_development_dependency "nokogiri", "~> 1.7"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ end
@@ -0,0 +1,8 @@
1
+ require "docset/version"
2
+ require "docset/base"
3
+ require "docset/index_db"
4
+ require "docset/plist"
5
+
6
+ module Docset
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,68 @@
1
+ require 'fileutils'
2
+
3
+ module Docset
4
+ class Base
5
+ attr_reader :path
6
+
7
+ def initialize(path)
8
+ @path = path
9
+ FileUtils.mkdir_p(documents_path)
10
+ @db = IndexDB.new(docset_index_db_path)
11
+ @db.init
12
+ end
13
+
14
+ def add_content(from, to = '')
15
+ dest_path = File.join(contents_path, to)
16
+ FileUtils.mkdir_p(File.dirname(dest_path))
17
+ FileUtils.cp_r(from, dest_path)
18
+ end
19
+
20
+ def add_document(from, to = '')
21
+ dest_path = File.join(documents_path, to)
22
+ FileUtils.mkdir_p(File.dirname(dest_path))
23
+ FileUtils.cp_r(from, dest_path)
24
+ end
25
+
26
+ def add_index(name, type, path)
27
+ @db.add_index(name, type, path)
28
+ end
29
+
30
+ def add_plist(plist)
31
+ File.write(plist_path, plist.to_s)
32
+ end
33
+
34
+ def write_content(to, content)
35
+ dest_path = File.join(contents_path, to)
36
+ FileUtils.mkdir_p(File.dirname(dest_path))
37
+ File.write(dest_path, content)
38
+ end
39
+
40
+ def write_document(to, document)
41
+ dest_path = File.join(documents_path, to)
42
+ FileUtils.mkdir_p(File.dirname(dest_path))
43
+ File.write(dest_path, document)
44
+ end
45
+
46
+ private
47
+
48
+ def contents_path
49
+ File.join(path, 'Contents')
50
+ end
51
+
52
+ def docset_index_db_path
53
+ File.join(resources_path, 'docSet.dsidx')
54
+ end
55
+
56
+ def documents_path
57
+ File.join(resources_path, 'Documents')
58
+ end
59
+
60
+ def plist_path
61
+ File.join(contents_path, 'Info.plist')
62
+ end
63
+
64
+ def resources_path
65
+ File.join(contents_path, 'Resources')
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,24 @@
1
+ require 'sqlite3'
2
+
3
+ module Docset
4
+ class IndexDB
5
+ def initialize(file)
6
+ @db = SQLite3::Database.new(file)
7
+ @db.busy_timeout(5000)
8
+ end
9
+
10
+ def init
11
+ @db.execute_batch(<<~SQL)
12
+ DROP TABLE IF EXISTS searchIndex;
13
+ CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);
14
+ CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path);
15
+ SQL
16
+ end
17
+
18
+ def add_index(name, type, path)
19
+ @db.prepare("INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES (?, ?, ?);") do |stmt|
20
+ stmt.execute([name, type, path])
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,41 @@
1
+ require 'erb'
2
+
3
+ module Docset
4
+ class Plist
5
+ def initialize(id:, name:, family:, js: true)
6
+ @id = id
7
+ @name = name
8
+ @family = family
9
+ @js = js
10
+ end
11
+
12
+ def to_s
13
+ ERB.new(template, nil, '-').result(binding)
14
+ end
15
+
16
+ private
17
+
18
+ def template
19
+ <<~TEMPLATE
20
+ <?xml version="1.0" encoding="UTF-8"?>
21
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
22
+ <plist version="1.0">
23
+ <dict>
24
+ <key>CFBundleIdentifier</key>
25
+ <string><%= @id %></string>
26
+ <key>CFBundleName</key>
27
+ <string><%= @name %></string>
28
+ <key>DocSetPlatformFamily</key>
29
+ <string><%= @family %></string>
30
+ <key>isDashDocset</key>
31
+ <true/>
32
+ <%- if @js -%>
33
+ <key>isJavaScriptEnabled</key>
34
+ <true/>
35
+ <%- end -%>
36
+ </dict>
37
+ </plist>
38
+ TEMPLATE
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module Docset
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: docset
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - siman-man
8
+ - Seiei Miyagi
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain:
12
+ - |
13
+ -----BEGIN CERTIFICATE-----
14
+ MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhoYW5h
15
+ Y2hpbjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
16
+ MB4XDTE3MDUwNDE0NDYxOVoXDTE4MDUwNDE0NDYxOVowPzERMA8GA1UEAwwIaGFu
17
+ YWNoaW4xFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
18
+ bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAN03A8Jvk7k0aVLmIHrj
19
+ soZLOppADifbdH+FoXUfWXFeu9x/hq8UsuMyTuSF6oNZRihzk7yakKBcv8B44wc2
20
+ Kfui97h+UOqBib5oPZOrJjW34dSfnHgdsPskZRK1yvMW0X88q7K+9iBT78Xpkf40
21
+ XkDh7mEyA0sC25n8BBTg3HpPMNXtQazR0UrtSH/Uyu2t7Sy4QQVKFYfVdfITfMoG
22
+ i7X/2cXs0ao6dLOK8H1lodxZ+2Dc5UQCrerVXKvVjAgZhJIN7qgbpAfuc+KFpGhq
23
+ pvkFaoOJ/NCg54DDiJYhZMm2X3NtjRRE3Ujt4bwO6vVlr5aPU2/vPCvsiyF1PmO+
24
+ a+UCAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFMug
25
+ kMbzYl73rLFxRlmgKeNAiSZjMB0GA1UdEQQWMBSBEmhhbmFjaGluQGdtYWlsLmNv
26
+ bTAdBgNVHRIEFjAUgRJoYW5hY2hpbkBnbWFpbC5jb20wDQYJKoZIhvcNAQEFBQAD
27
+ ggEBAFBV/OUPBF6DhEe/Q1bojFYwRdLI+JbDAoH97GRuBzKokbW7a4k5EGMw4aLx
28
+ RXH75W+vmsG1z/RE7lpD+T7Uf+ZuGwCIhFsGiZBcbBbinz4MEsqjGwu2/OPOgbYK
29
+ alk+o48ier71CaSsfz83hSAzklJ7g6BocJCWROXuVzX9eCw7YB3F4xNzdw8HxHkA
30
+ WbyMQMURxOX5Em9t+EgSU9Odx0tJgnhygUSdTJknavnpaZUa2odWS4+wagh8nXxS
31
+ +zDzgwp9Z4A8i47ioz1YEGIkQhDKZeGQznwkht0zsrtswEAiOisL5uJDtWvQiwt6
32
+ a9nBgrpUm8NHrucdUDtMYjixgmU=
33
+ -----END CERTIFICATE-----
34
+ date: 2017-05-18 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: sqlite3
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.3'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.3'
50
+ - !ruby/object:Gem::Dependency
51
+ name: bundler
52
+ requirement: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '1.14'
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '1.14'
64
+ - !ruby/object:Gem::Dependency
65
+ name: nokogiri
66
+ requirement: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '1.7'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '1.7'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '10.0'
85
+ type: :development
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '10.0'
92
+ - !ruby/object:Gem::Dependency
93
+ name: rspec
94
+ requirement: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - "~>"
97
+ - !ruby/object:Gem::Version
98
+ version: '3.0'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - "~>"
104
+ - !ruby/object:Gem::Version
105
+ version: '3.0'
106
+ description:
107
+ email:
108
+ - k128585@ie.u-ryukyu.ac.jp
109
+ - hanachin@gmail.com
110
+ executables: []
111
+ extensions: []
112
+ extra_rdoc_files: []
113
+ files:
114
+ - ".gitignore"
115
+ - ".rspec"
116
+ - ".travis.yml"
117
+ - CODE_OF_CONDUCT.md
118
+ - Gemfile
119
+ - LICENSE.txt
120
+ - README.md
121
+ - Rakefile
122
+ - bin/console
123
+ - bin/setup
124
+ - docset.gemspec
125
+ - lib/docset.rb
126
+ - lib/docset/base.rb
127
+ - lib/docset/index_db.rb
128
+ - lib/docset/plist.rb
129
+ - lib/docset/version.rb
130
+ homepage: https://github.com/yasslab/docset
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.6.11
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: a library for docset generation
154
+ test_files: []
Binary file