simb 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: adf477739d735773b11bc6b294f9f75dddddd2ae
4
+ data.tar.gz: 56428869e4e6bd1b2ed0b45a46f90c496a6f6dc9
5
+ SHA512:
6
+ metadata.gz: a2bff165bd493364e1d714a03bdced612889c4d3cbe304fe461fe9ece75b94cf83446d474bd023855c5907f1344c519ed0759710acfbfced155f98a05e80bd3b
7
+ data.tar.gz: 44bab40228ce47ec82883b6dcad070f73d3cf2e6a16d04baa83189ac01d7ff21d729055b80d0b0e07ffab914f38b0c88a679ae40b76ac1f826b7cdc3dc33d2de
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in simb.gemspec
4
+ gemspec
5
+
6
+ gem 'thor'
7
+ gem 'jekyll'
8
+ gem 'github_api'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 charles-l
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,29 @@
1
+ # simb
2
+
3
+ A simple blogging util. Posts are generated by Jekyll and GitHub pages are used for hosting.
4
+
5
+ # basic usage
6
+
7
+ Create a blog:
8
+
9
+ simb blog my-awesome-blog
10
+
11
+ Make a post:
12
+
13
+ simb new-post sweet-post my-awesome-blog
14
+
15
+ Publish it:
16
+
17
+ simb publish my-awesome-blog
18
+
19
+ That's pretty much it.
20
+
21
+ # TODO
22
+ ```
23
+ - [x] Basic Jekyll wrapper
24
+ - [ ] Theme manager
25
+ - [ ] Add posts from any location (`simb add-post path/to/some/other/postdir`)
26
+ - [ ] Cleanup
27
+ - [ ] Remove second password request block
28
+ - [ ] Organize code ('cause it's bleh)
29
+ ```
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/simb ADDED
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+ require 'thor'
3
+ require 'github_api'
4
+
5
+ def editor file
6
+ system("#{ENV['EDITOR']} #{file}")
7
+ end
8
+
9
+ def add_header file, post_name
10
+ File.open(file, 'a') do |f|
11
+ f.puts "---"
12
+ f.puts "layout: post"
13
+ f.puts "title: #{post_name}"
14
+ f.puts "date: #{Time.now}"
15
+ f.puts "categories:"
16
+ f.puts "---"
17
+ end
18
+ end
19
+
20
+ def post_filename(post_name)
21
+ return "#{Time.now.strftime("%F")}-#{post_name.gsub(" ", "-")}.markdown"
22
+ end
23
+
24
+ class SimbCLI < Thor
25
+ ROOTDIR="#{ENV['HOME']}/.simb/"
26
+ desc "blog NAME", "create a new blog"
27
+ def blog(name)
28
+ puts ":: creating at #{ROOTDIR}#{name}"
29
+ `jekyll new #{ROOTDIR}#{name}`
30
+ end
31
+
32
+ desc "new-post POSTNAME BLOG", "create a new post for BLOG and open it in $EDITOR"
33
+ def new_post(post_name, blog)
34
+ file = "#{ROOTDIR}#{blog}/_posts/#{post_filename post_name}"
35
+ if File.exists? file
36
+ editor file
37
+ return
38
+ end
39
+ puts ":: creating new post '#{post_name}' in blog '#{blog}'"
40
+ `touch #{file}`
41
+ add_header file, post_name
42
+ editor file
43
+ end
44
+
45
+ desc "publish BLOG", "publish BLOG to github pages"
46
+ def publish(blog)
47
+ if Dir.exists?("#{ROOTDIR}#{blog}/.git/")
48
+ `cd #{ROOTDIR}#{blog} && git add --all && git commit -m "new posts (#{Time.now})" && git push origin gh-pages`
49
+ else
50
+ puts ":: creating new repository on GitHub"
51
+ user = ask "GitHub username:"
52
+ pass = ask "GitHub password:", echo: false
53
+ puts
54
+ begin
55
+ github = Github.new basic_auth: "#{user}:#{pass}"
56
+ github.repos.create name: "#{blog}",
57
+ description: "Blog for #{blog}",
58
+ private: false,
59
+ has_issues: false,
60
+ has_wiki: false,
61
+ has_downloads: false
62
+ Dir.chdir("#{ROOTDIR}#{blog}") do
63
+ `git init .`
64
+ `git remote add origin https://github.com/#{user}/#{blog}.git`
65
+ `git checkout -b gh-pages`
66
+ publish(blog) # go back and publish now
67
+ end
68
+ rescue Github::Error::Unauthorized
69
+ abort "Invalid credentials!"
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ SimbCLI.start(ARGV)
@@ -0,0 +1,3 @@
1
+ module Simb
2
+ VERSION = "0.0.1"
3
+ end
data/lib/simb.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "simb/version"
2
+
3
+ module Simb
4
+ # Your code goes here...
5
+ end
data/simb.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'simb/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "simb"
8
+ spec.version = Simb::VERSION
9
+ spec.authors = ["charles-l"]
10
+ spec.email = ["chuckiels2011@gmail.com"]
11
+ spec.summary = %q{Simple blogging util.}
12
+ spec.description = %q{A simple bloggin utility that uses Jekyll and GitHub pages.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - charles-l
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: A simple bloggin utility that uses Jekyll and GitHub pages.
42
+ email:
43
+ - chuckiels2011@gmail.com
44
+ executables:
45
+ - simb
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/simb
55
+ - lib/simb.rb
56
+ - lib/simb/version.rb
57
+ - simb.gemspec
58
+ homepage: ''
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.0.14
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Simple blogging util.
82
+ test_files: []