nsume 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +7 -0
- data/bin/nsume +6 -0
- data/lib/generators/_data/navbar.yml +12 -0
- data/lib/generators/_includes/navbar.liquid +31 -0
- data/lib/generators/_layouts/default.html +43 -0
- data/lib/generators/_layouts/post.html +7 -0
- data/lib/generators/assets/ico/favicon.ico +0 -0
- data/lib/generators/assets/img/octonsume.png +0 -0
- data/lib/generators/assets/themes/github/github.css +714 -0
- data/lib/generators/blog/index.html +11 -0
- data/lib/generators/changelog/index.html +11 -0
- data/lib/generators/index.html +14 -0
- data/lib/generators/vendor/autodoc/document.md.erb +16 -0
- data/lib/generators/vendor/autodoc/footer.md.erb +11 -0
- data/lib/generators/vendor/autodoc/header.md.erb +11 -0
- data/lib/nsume/cli.rb +91 -0
- data/lib/nsume/dev_helper.rb +23 -0
- data/lib/nsume/prepare.rb +119 -0
- data/lib/nsume/version.rb +3 -0
- data/lib/nsume.rb +44 -0
- data/lib/templates/_config.yml.erb +14 -0
- data/lib/templates/post.md.erb +6 -0
- data/nsume.gemspec +26 -0
- data/spec/nsume/version_spec.rb +7 -0
- metadata +130 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
<%# coding: UTF-8 -%>
|
2
|
+
## <%= title %>
|
3
|
+
<%= description %>
|
4
|
+
<%= parameters_section %>
|
5
|
+
|
6
|
+
### Request
|
7
|
+
```
|
8
|
+
<%= method %> <%= request.path %><%= request_query %><%= request_body_section %>
|
9
|
+
```
|
10
|
+
|
11
|
+
### Response
|
12
|
+
`<%= response.status %> <%= response.message %>`
|
13
|
+
|
14
|
+
```
|
15
|
+
<%= response_body_section %>
|
16
|
+
```
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%# coding: UTF-8 -%>
|
2
|
+
|
3
|
+
{% assign filename = page.title | downcase | append:'.html' %}
|
4
|
+
|
5
|
+
## State Diagram
|
6
|
+
|
7
|
+
![erd]({{ site.baseurl }}{{ page.url | remove: filename | replace: 'api', 'state' }}<%= pathname.basename(".*").to_s.singularize.capitalize + "_state.png" %>)
|
8
|
+
|
9
|
+
## Entity-Relationship Diagram
|
10
|
+
|
11
|
+
![erd]({{ site.baseurl }}{{ page.url | remove: filename | replace: 'api', 'erd' }}<%= pathname.basename(".*").to_s.singularize + ".png" %>)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%# coding: UTF-8 -%>
|
2
|
+
---
|
3
|
+
layout: default
|
4
|
+
title: <%= pathname.basename(".*").to_s.capitalize %>
|
5
|
+
---
|
6
|
+
|
7
|
+
| Method | Resource | Description |
|
8
|
+
|:-------:|:---------|:------------|
|
9
|
+
<% documents.each do |document| -%>
|
10
|
+
| <%= document.method %> | [<%= document.resource %>](#toc_0) | <%= document.description %> |
|
11
|
+
<% end -%>
|
data/lib/nsume/cli.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'erb'
|
3
|
+
require 'faraday'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module Nsume
|
7
|
+
class Cli < Thor
|
8
|
+
namespace 'nsume'
|
9
|
+
map '-v' => :version
|
10
|
+
map '-sw' => :switch
|
11
|
+
|
12
|
+
method_option :site, type: :string, aliases: '-s', default: 'site', desc: 'Site name'
|
13
|
+
method_option :theme, type: :string, aliases: '-t', default: 'flatly', desc: 'Site theme'
|
14
|
+
method_option :navbar, type: :string, aliases: '-n', default: 'blog', desc: 'Site navbar [blog] or [api]'
|
15
|
+
desc 'init [PATH]', 'initializes a new nSume.'
|
16
|
+
def init(path=Dir.pwd)
|
17
|
+
Nsume::DevHelper.mlog __method__
|
18
|
+
|
19
|
+
Nsume::Prepare.generator options
|
20
|
+
Nsume::Prepare.jquery
|
21
|
+
Nsume::Prepare.bootstrap
|
22
|
+
Nsume::Prepare.bootswatch_css
|
23
|
+
Nsume::Prepare.bootswatch_js
|
24
|
+
Nsume::Prepare.bootswatch_theme options['theme']
|
25
|
+
|
26
|
+
Nsume::DevHelper.log "Finished setting."
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'post [TITLE] [CONTENT]', 'Creates a posts.'
|
30
|
+
def post(title='title', content='')
|
31
|
+
Nsume::DevHelper.mlog __method__
|
32
|
+
|
33
|
+
name = "#{Date.today.strftime("%Y-%m-%d")}-#{title}.md"
|
34
|
+
path = File.expand_path(name, Nsume.posts_path)
|
35
|
+
file = ERB.new(Nsume.post_template).result(binding)
|
36
|
+
File.write(path, file)
|
37
|
+
|
38
|
+
Nsume::DevHelper.log "Created a posts."
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'switch [THEME]', 'Switch theme'
|
42
|
+
def switch(theme)
|
43
|
+
Nsume::DevHelper.mlog __method__
|
44
|
+
|
45
|
+
path = File.join(Nsume.source_path, '_config.yml')
|
46
|
+
raw = YAML.load_file(path)
|
47
|
+
raw['theme'] = theme
|
48
|
+
file = YAML.dump(raw)
|
49
|
+
File.write(path, file)
|
50
|
+
|
51
|
+
Nsume::Prepare.bootswatch_theme(theme)
|
52
|
+
end
|
53
|
+
|
54
|
+
desc 'theme', 'Show the current theme'
|
55
|
+
def theme
|
56
|
+
path = File.join(Nsume.source_path, '_config.yml')
|
57
|
+
raw = YAML.load_file(path)
|
58
|
+
puts raw['theme']
|
59
|
+
end
|
60
|
+
|
61
|
+
desc 'themes', 'List all themes'
|
62
|
+
def themes
|
63
|
+
puts [
|
64
|
+
'amelia',
|
65
|
+
'cerulean',
|
66
|
+
'cosmo',
|
67
|
+
'cyborg',
|
68
|
+
'flatly',
|
69
|
+
'journal',
|
70
|
+
'lumen',
|
71
|
+
'readable',
|
72
|
+
'simplex',
|
73
|
+
'slate',
|
74
|
+
'spacelab',
|
75
|
+
'superhero',
|
76
|
+
'united',
|
77
|
+
'yeti'
|
78
|
+
]
|
79
|
+
end
|
80
|
+
|
81
|
+
desc 'up', 'Start jekyll server.'
|
82
|
+
def up
|
83
|
+
system "cd #{Nsume.source_path} && jekyll server --watch"
|
84
|
+
end
|
85
|
+
|
86
|
+
desc 'version', 'Print the version and exit.'
|
87
|
+
def version
|
88
|
+
puts "nSume #{Nsume::VERSION}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'pp'
|
3
|
+
|
4
|
+
module Nsume
|
5
|
+
module DevHelper
|
6
|
+
@@logger ||= Logger.new(STDOUT)
|
7
|
+
@@logger.level = Logger::DEBUG
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def log(message )
|
11
|
+
@@logger.info(message)
|
12
|
+
end
|
13
|
+
|
14
|
+
def mlog(method)
|
15
|
+
@@logger.debug("Method is [#{method}]")
|
16
|
+
end
|
17
|
+
|
18
|
+
def elog(path)
|
19
|
+
@@logger.debug("File [#{File.basename(path)}] exists [#{File.exists?(path)}]")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
module Nsume
|
2
|
+
module Prepare
|
3
|
+
# Todo: default configure
|
4
|
+
class << self
|
5
|
+
def generator(options)
|
6
|
+
Nsume::DevHelper.mlog __method__
|
7
|
+
|
8
|
+
name = '_config.yml'
|
9
|
+
path = File.expand_path(name, Nsume.source_path)
|
10
|
+
unless File.exists?(path)
|
11
|
+
FileUtils.cp_r Nsume.generators_path + '/.', Nsume.source_path
|
12
|
+
file = ERB.new(Nsume.config_template).result(binding)
|
13
|
+
File.write(path, file)
|
14
|
+
|
15
|
+
raw = []
|
16
|
+
path = File.join(Nsume.source_path, '_data', 'navbar.yml')
|
17
|
+
YAML.load_file(path).each do |navbar|
|
18
|
+
case options['navbar']
|
19
|
+
when 'blog'
|
20
|
+
case navbar['lavel'].downcase
|
21
|
+
when 'blog', 'documentation'
|
22
|
+
raw << navbar
|
23
|
+
end
|
24
|
+
when 'api'
|
25
|
+
case navbar['lavel'].downcase
|
26
|
+
when 'api', 'changelog', 'documentation'
|
27
|
+
raw << navbar
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
file = YAML.dump(raw)
|
32
|
+
File.write(path, file)
|
33
|
+
end
|
34
|
+
|
35
|
+
Nsume::DevHelper.elog path
|
36
|
+
end
|
37
|
+
|
38
|
+
def jquery(version='1.10.2')
|
39
|
+
Nsume::DevHelper.mlog __method__
|
40
|
+
|
41
|
+
name = "jquery-#{version}.min.js"
|
42
|
+
path = File.expand_path('assets/jquery', Nsume.source_path)
|
43
|
+
FileUtils.mkdir_p(path) unless File.exists?(path)
|
44
|
+
|
45
|
+
path = File.expand_path(File.join(path, name), Nsume.source_path)
|
46
|
+
unless File.exists?(path)
|
47
|
+
file = Faraday.get("https://code.jquery.com/#{name}").body
|
48
|
+
File.write(path, file)
|
49
|
+
end
|
50
|
+
|
51
|
+
Nsume::DevHelper.elog path
|
52
|
+
end
|
53
|
+
|
54
|
+
def bootstrap(version='3.1.1')
|
55
|
+
Nsume::DevHelper.mlog __method__
|
56
|
+
|
57
|
+
name = 'bootstrap.min.js'
|
58
|
+
path = File.expand_path('assets/bootstrap/dist/js', Nsume.source_path)
|
59
|
+
FileUtils.mkdir_p(path) unless File.exists?(path)
|
60
|
+
|
61
|
+
path = File.expand_path(File.join(path, name), Nsume.source_path)
|
62
|
+
unless File.exists?(path)
|
63
|
+
file = Faraday.get("https://raw.github.com/twbs/bootstrap/v#{version}/dist/js/#{name}").body
|
64
|
+
File.write(path, file)
|
65
|
+
end
|
66
|
+
|
67
|
+
Nsume::DevHelper.elog path
|
68
|
+
end
|
69
|
+
|
70
|
+
def bootswatch_css(version='3.1.1')
|
71
|
+
Nsume::DevHelper.mlog __method__
|
72
|
+
|
73
|
+
name = 'bootswatch.min.css'
|
74
|
+
path = File.expand_path('assets/bootswatch/css', Nsume.source_path)
|
75
|
+
FileUtils.mkdir_p(path) unless File.exists?(path)
|
76
|
+
|
77
|
+
path = File.expand_path(File.join(path, name), Nsume.source_path)
|
78
|
+
unless File.exists?(path)
|
79
|
+
file = Faraday.get("https://raw.github.com/thomaspark/bootswatch/v#{version}/assets/css/#{name}").body
|
80
|
+
File.write(path, file)
|
81
|
+
end
|
82
|
+
|
83
|
+
Nsume::DevHelper.elog path
|
84
|
+
end
|
85
|
+
|
86
|
+
def bootswatch_js(version='3.1.1')
|
87
|
+
Nsume::DevHelper.mlog __method__
|
88
|
+
|
89
|
+
name = 'bootswatch.js'
|
90
|
+
path = File.expand_path('assets/bootswatch/js', Nsume.source_path)
|
91
|
+
FileUtils.mkdir_p(path) unless File.exists?(path)
|
92
|
+
|
93
|
+
path = File.expand_path(File.join(path, name), Nsume.source_path)
|
94
|
+
unless File.exists?(path)
|
95
|
+
file = Faraday.get("https://raw.github.com/thomaspark/bootswatch/v#{version}/assets/js/#{name}").body
|
96
|
+
File.write(path, file)
|
97
|
+
end
|
98
|
+
|
99
|
+
Nsume::DevHelper.elog path
|
100
|
+
end
|
101
|
+
|
102
|
+
def bootswatch_theme(theme='flatly', version='3.1.1')
|
103
|
+
Nsume::DevHelper.mlog __method__
|
104
|
+
|
105
|
+
name = 'bootstrap.min.css'
|
106
|
+
path = File.expand_path("assets/themes/#{theme}", Nsume.source_path)
|
107
|
+
FileUtils.mkdir_p(path) unless File.exists?(path)
|
108
|
+
|
109
|
+
path = File.expand_path(File.join(path, name), Nsume.source_path)
|
110
|
+
unless File.exists?(path)
|
111
|
+
file = Faraday.get("https://raw.github.com/thomaspark/bootswatch/v#{version}/#{theme}/#{name}").body
|
112
|
+
File.write(path, file)
|
113
|
+
end
|
114
|
+
|
115
|
+
Nsume::DevHelper.elog path
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
data/lib/nsume.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'thor'
|
3
|
+
|
4
|
+
require_relative 'nsume/cli'
|
5
|
+
require_relative 'nsume/prepare'
|
6
|
+
require_relative 'nsume/version'
|
7
|
+
require_relative 'nsume/dev_helper'
|
8
|
+
|
9
|
+
module Nsume
|
10
|
+
class << self
|
11
|
+
def root
|
12
|
+
@root ||= Pathname.new(File.expand_path('../', File.dirname(__FILE__)))
|
13
|
+
end
|
14
|
+
|
15
|
+
# TODO: move config
|
16
|
+
def source_path
|
17
|
+
path = Dir.pwd
|
18
|
+
path = File.join(path, 'tmp') if File.exists?(File.join(path, 'nsume.gemspec'))
|
19
|
+
path
|
20
|
+
end
|
21
|
+
|
22
|
+
def generators_path
|
23
|
+
Nsume.root.join('lib', 'generators').to_s
|
24
|
+
end
|
25
|
+
|
26
|
+
def templates_path
|
27
|
+
Nsume.root.join('lib', 'templates').to_s
|
28
|
+
end
|
29
|
+
|
30
|
+
def config_template
|
31
|
+
File.read(File.expand_path('_config.yml.erb', Nsume.templates_path))
|
32
|
+
end
|
33
|
+
|
34
|
+
def posts_path
|
35
|
+
path = File.expand_path('_posts', Nsume.source_path)
|
36
|
+
FileUtils.mkdir_p(path) unless File.exists?(path)
|
37
|
+
path
|
38
|
+
end
|
39
|
+
|
40
|
+
def post_template
|
41
|
+
File.read(File.expand_path('post.md.erb', Nsume.templates_path))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
markdown: redcarpet
|
2
|
+
redcarpet:
|
3
|
+
extensions: ['tables', 'with_toc_data']
|
4
|
+
pygments: true
|
5
|
+
|
6
|
+
baseurl: ''
|
7
|
+
encoding: UTF-8
|
8
|
+
|
9
|
+
exclude: ['README.md', 'vendor', 'tmp']
|
10
|
+
|
11
|
+
name: <%= options['site'] %>
|
12
|
+
copyright: <%= Time.now.year %>, <%= options['site'] %>
|
13
|
+
|
14
|
+
theme: <%= options['theme'] %>
|
data/nsume.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'nsume/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "nsume"
|
8
|
+
spec.version = Nsume::VERSION
|
9
|
+
spec.authors = ["ogom"]
|
10
|
+
spec.email = ["ogom@hotmail.co.jp"]
|
11
|
+
spec.summary = %q{naturally consume.}
|
12
|
+
spec.description = %q{naturally consume by ruby.}
|
13
|
+
spec.homepage = ""
|
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 "thor", "~> 0.18"
|
22
|
+
spec.add_dependency "faraday", "~> 0.9"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nsume
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ogom
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.18'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.18'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.9'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: naturally consume by ruby.
|
70
|
+
email:
|
71
|
+
- ogom@hotmail.co.jp
|
72
|
+
executables:
|
73
|
+
- nsume
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/nsume
|
83
|
+
- lib/generators/_data/navbar.yml
|
84
|
+
- lib/generators/_includes/navbar.liquid
|
85
|
+
- lib/generators/_layouts/default.html
|
86
|
+
- lib/generators/_layouts/post.html
|
87
|
+
- lib/generators/assets/ico/favicon.ico
|
88
|
+
- lib/generators/assets/img/octonsume.png
|
89
|
+
- lib/generators/assets/themes/github/github.css
|
90
|
+
- lib/generators/blog/index.html
|
91
|
+
- lib/generators/changelog/index.html
|
92
|
+
- lib/generators/index.html
|
93
|
+
- lib/generators/vendor/autodoc/document.md.erb
|
94
|
+
- lib/generators/vendor/autodoc/footer.md.erb
|
95
|
+
- lib/generators/vendor/autodoc/header.md.erb
|
96
|
+
- lib/nsume.rb
|
97
|
+
- lib/nsume/cli.rb
|
98
|
+
- lib/nsume/dev_helper.rb
|
99
|
+
- lib/nsume/prepare.rb
|
100
|
+
- lib/nsume/version.rb
|
101
|
+
- lib/templates/_config.yml.erb
|
102
|
+
- lib/templates/post.md.erb
|
103
|
+
- nsume.gemspec
|
104
|
+
- spec/nsume/version_spec.rb
|
105
|
+
homepage: ''
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.2.1
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: naturally consume.
|
129
|
+
test_files:
|
130
|
+
- spec/nsume/version_spec.rb
|