msgtrail 0.3.0

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
+ SHA256:
3
+ metadata.gz: f20d8895fa0862e0116d1a1ff97842346e8f9a0e3b06e49dcc988b2e93f06b16
4
+ data.tar.gz: 6a30c66b3906b3524fcc382acbd5d9234c58e84c9a14af9ea57ab1b3d80f9b97
5
+ SHA512:
6
+ metadata.gz: d0ddd27b5bc761974e69456f2e89980a214e439f23435b20fa7ca407d1d1c1ee1427a5fafdfde111b81ebe52074026ff677bd4efd78d8f39932fc491d55e6c2b
7
+ data.tar.gz: ddc3d8f5e6788dcb9f8f7190348239bf25a9275f8aa1104308ee5e29250d3d9a41b8c5ec637fcfa573304cea2c8f6b4e4a7135539836af15d87d14a47e45584b
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in msgtrail.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,48 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ msgtrail (0.2.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ addressable (2.6.0)
10
+ public_suffix (>= 2.0.2, < 4.0)
11
+ domain_name (0.5.20180417)
12
+ unf (>= 0.0.5, < 1.0.0)
13
+ dotenv (2.7.2)
14
+ http (4.1.1)
15
+ addressable (~> 2.3)
16
+ http-cookie (~> 1.0)
17
+ http-form_data (~> 2.0)
18
+ http_parser.rb (~> 0.6.0)
19
+ http-cookie (1.0.3)
20
+ domain_name (~> 0.5)
21
+ http-form_data (2.1.1)
22
+ http_parser.rb (0.6.0)
23
+ minitest (5.11.3)
24
+ multi_json (1.13.1)
25
+ public_suffix (3.0.3)
26
+ rake (10.5.0)
27
+ redcarpet (3.4.0)
28
+ tilt (2.0.9)
29
+ unf (0.1.4)
30
+ unf_ext
31
+ unf_ext (0.0.7.5)
32
+
33
+ PLATFORMS
34
+ ruby
35
+
36
+ DEPENDENCIES
37
+ bundler (~> 2.0)
38
+ dotenv (~> 2.7)
39
+ http (~> 4.1)
40
+ minitest (~> 5.0)
41
+ msgtrail!
42
+ multi_json (~> 1.13)
43
+ rake (~> 10.0)
44
+ redcarpet (~> 3.4)
45
+ tilt (~> 2.0)
46
+
47
+ BUNDLED WITH
48
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Erik van Eykelen
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.
data/README.md ADDED
@@ -0,0 +1 @@
1
+ TODO
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "msgtrail"
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__)
data/bin/setup ADDED
@@ -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
data/exe/msgtrail ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ require 'msgtrail/publish'
3
+ Dotenv.load
4
+ if ARGV[0]
5
+ Msgtrail::Publish::to_file_system(Dir.getwd, ARGV[0])
6
+ else
7
+ puts "#{$PROGRAM_NAME} version #{Msgtrail::VERSION}"
8
+ puts "Usage: #{$PROGRAM_NAME} {theme-directory-name}"
9
+ end
data/lib/msgtrail.rb ADDED
File without changes
@@ -0,0 +1,30 @@
1
+ module Msgtrail
2
+ class Article
3
+
4
+ TYPE_FILE = 'file'
5
+ TYPE_GIST = 'gist'
6
+ TYPE_TWEET = 'tweet'
7
+
8
+ #
9
+ # Using :bodies array for file, gists, and tweets even
10
+ # though for file-based articles only a single file is
11
+ # supported at the moment.
12
+ #
13
+ # For the sake of symmetry and future expansion :bodies
14
+ # is used for all three article types.
15
+ #
16
+
17
+ def self.fetch_file_based_article(working_directory, article)
18
+ article[:bodies] = MarkdownFile.file_bodies(working_directory, article)
19
+ end
20
+
21
+ def self.fetch_gist_based_article(article)
22
+ article[:bodies] = GitHub.gist_bodies(article[:gist_id])
23
+ end
24
+
25
+ def self.fetch_tweet_based_article(article)
26
+ article[:bodies] = Twitter.tweet_bodies(article[:tweet_ids])
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,63 @@
1
+ module Msgtrail
2
+ class Blog
3
+
4
+ attr_accessor :articles, :config
5
+
6
+ def initialize(config)
7
+ self.config = config
8
+ end
9
+
10
+ def fetch_blog_articles
11
+ begin
12
+ filepath = File.join(self.config.working_directory, self.config.settings.file_matter.blog_manifest_file)
13
+ manifest = File.read(filepath)
14
+ rescue
15
+ puts("Can't find blog manifest '#{filepath}'")
16
+ exit(2)
17
+ end
18
+ begin
19
+ self.articles = MultiJson.load(manifest, symbolize_keys: true)
20
+ rescue
21
+ puts("Invalid JSON in '#{filepath}'")
22
+ exit(2)
23
+ end
24
+ end
25
+
26
+ def prepare_output_directory
27
+ directory = File.join(self.config.working_directory, self.config.settings.file_matter.blog_directory)
28
+ begin
29
+ FileUtils.remove_dir(directory)
30
+ puts("Deleted '#{directory}'")
31
+ rescue
32
+ puts("Can't find '#{directory}'")
33
+ end
34
+ begin
35
+ FileUtils.mkdir(directory)
36
+ puts("Created '#{directory}'")
37
+ rescue
38
+ puts("Can't create '#{directory}'")
39
+ end
40
+ end
41
+
42
+ def fetch_article_content
43
+ self.articles.each do |article|
44
+ if article.has_key?(:file)
45
+ Article.fetch_file_based_article(self.config.working_directory, article)
46
+ elsif article.has_key?(:gist_id)
47
+ Article.fetch_gist_based_article(article)
48
+ elsif article.has_key?(:tweet_ids)
49
+ Article.fetch_tweet_based_article(article)
50
+ else
51
+ puts("Error preparing article based on '#{article}'")
52
+ end
53
+ end
54
+ end
55
+
56
+ def generate_article_slugs
57
+ self.articles.each do |article|
58
+ article[:slug] = Slug.generate(article[:title], article[:date], article[:time])
59
+ end
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,26 @@
1
+ module Msgtrail
2
+ class Config
3
+
4
+ CONFIG_FILE = 'config.json'.freeze
5
+
6
+ attr_accessor :settings, :working_directory
7
+
8
+ def initialize(working_directory)
9
+ self.working_directory = working_directory # Used by several classes
10
+ begin
11
+ filepath = File.join(working_directory, CONFIG_FILE)
12
+ config = File.read(filepath)
13
+ rescue
14
+ puts("Can't find '#{filepath}'")
15
+ exit(2)
16
+ end
17
+ begin
18
+ self.settings = MultiJson.load(config, symbolize_keys: true, object_class: OpenStruct)
19
+ rescue
20
+ puts("Invalid JSON in '#{filepath}'")
21
+ exit(2)
22
+ end
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,43 @@
1
+ module Msgtrail
2
+ class GitHub
3
+
4
+ SUPPORTED_MIME_TYPE = 'text/plain'.freeze
5
+ SUPPORTED_LANGUAGE = 'Markdown'.freeze
6
+ GIST_API_ENDPOINT = "https://api.github.com/gists/%s".freeze
7
+
8
+ def self.gist_bodies(gist_id)
9
+ json = fetch_gist(gist_id)
10
+ source = json[:html_url]
11
+ bodies = []
12
+ json[:files].each do |key, value|
13
+ if SUPPORTED_MIME_TYPE == value[:type] && SUPPORTED_LANGUAGE == value[:language]
14
+ bodies << {
15
+ body: value[:content],
16
+ source: source,
17
+ type: Article::TYPE_GIST
18
+ }
19
+ end
20
+ end
21
+ bodies
22
+ end
23
+
24
+ def self.fetch_gist(gist_id)
25
+ begin
26
+ url = GIST_API_ENDPOINT % gist_id
27
+ result = HTTP.get(url)
28
+ rescue
29
+ puts("Can't access '#{url}'")
30
+ exit(2)
31
+ end
32
+ begin
33
+ json = MultiJson.load(result.to_s, symbolize_keys: true)
34
+ rescue
35
+ puts("Invalid JSON from '#{url}'")
36
+ exit(2)
37
+ end
38
+ json
39
+ end
40
+
41
+ end
42
+ end
43
+
@@ -0,0 +1,23 @@
1
+ module Msgtrail
2
+ class MarkdownFile
3
+
4
+ def self.file_bodies(working_directory, article)
5
+ filepath = File.join(working_directory, article[:file])
6
+ begin
7
+ body = File.read(filepath)
8
+ rescue
9
+ puts("Can't find file '#{filepath}'")
10
+ exit(2)
11
+ end
12
+ [
13
+ {
14
+ body: body,
15
+ source: nil,
16
+ type: Article::TYPE_FILE
17
+ }
18
+ ]
19
+ end
20
+
21
+ end
22
+ end
23
+
@@ -0,0 +1,45 @@
1
+ require 'base64'
2
+ require 'dotenv'
3
+ require 'fileutils'
4
+ require 'http'
5
+ require 'msgtrail/article'
6
+ require 'msgtrail/blog'
7
+ require 'msgtrail/config'
8
+ require 'msgtrail/github'
9
+ require 'msgtrail/markdown_file'
10
+ require 'msgtrail/renderers'
11
+ require 'msgtrail/site'
12
+ require 'msgtrail/slug'
13
+ require 'msgtrail/twitter'
14
+ require 'multi_json'
15
+ require 'ostruct'
16
+ require 'redcarpet'
17
+ require 'tilt/erb'
18
+ require 'uri'
19
+
20
+ include ERB::Util
21
+
22
+ module Msgtrail
23
+ class Publish
24
+
25
+ def self.to_file_system(current_directory, directory_argument)
26
+ working_directory = File.join(current_directory, directory_argument)
27
+
28
+ config = Config.new(working_directory)
29
+
30
+ blog = Blog.new(config)
31
+ site = Site.new(config)
32
+
33
+ blog.fetch_blog_articles
34
+ blog.prepare_output_directory
35
+ blog.fetch_article_content
36
+ blog.generate_article_slugs
37
+
38
+ site.fetch_site_pages
39
+ site.generate_articles(blog.articles)
40
+
41
+ exit(0)
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,86 @@
1
+ module Msgtrail
2
+
3
+ class PageRenderer
4
+
5
+ attr_accessor :article, :articles, :config, :layout, :markdown, :template, :theme_directory
6
+
7
+ def initialize(layout_filepath, template_filepath, config)
8
+ self.article = {}
9
+ self.markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, fenced_code_blocks: true)
10
+ self.config = config
11
+ begin
12
+ self.layout = File.read(layout_filepath)
13
+ rescue
14
+ puts("Can't find '#{layout_filepath}'")
15
+ exit(2)
16
+ end
17
+ begin
18
+ self.template = File.read(template_filepath)
19
+ rescue
20
+ puts("Can't find '#{template_filepath}'")
21
+ exit(2)
22
+ end
23
+ end
24
+
25
+ def render
26
+ erbs = [self.template, self.layout] # Note order!
27
+ # Inject accepts value and block. Nil in inject(nil) sets initial value.
28
+ # First iteration: prev = nil and erb = self.template.
29
+ # Since self.template has no yield only a string is rendered.
30
+ # Second iteration: prev = rendered string and erb = self.layout.
31
+ # Since self.layout has yield, yield will be replaced by string in prev.
32
+ erbs.inject(nil) do |prev, erb|
33
+ _render(erb) { prev }
34
+ end
35
+ end
36
+
37
+ def _render(template)
38
+ ERB.new(template).result(binding)
39
+ end
40
+
41
+ def render_article(partial_filename, variables)
42
+ partial_filepath = File.join(self.theme_directory, "_#{partial_filename}.html.erb")
43
+ ArticlePartialRenderer.new(partial_filepath, variables).render
44
+ end
45
+
46
+ # Offer shortcut `cfg` to `settings.config` for use inside ERBs
47
+ def method_missing(missing_method_name, *args, &block)
48
+ if 'cfg' == missing_method_name.to_s
49
+ self.config.settings
50
+ else
51
+ super
52
+ end
53
+ end
54
+
55
+ def rfc2822_time(date, time)
56
+ ymd = date.split(/\D/).map(&:to_i)
57
+ hm = time.split(/\D/).map(&:to_i)
58
+ Time.new(ymd[0], ymd[1], ymd[2], hm[0], hm[1])
59
+ .getlocal(cfg.time_matter.utc_offset)
60
+ .rfc2822
61
+ end
62
+
63
+ end
64
+
65
+ class ArticlePartialRenderer
66
+
67
+ attr_accessor :markdown, :partial, :variables
68
+
69
+ def initialize(partial_filepath, variables)
70
+ begin
71
+ self.partial = File.read(partial_filepath)
72
+ rescue
73
+ puts("Can't find '#{partial_filepath}'")
74
+ exit(2)
75
+ end
76
+ self.markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, fenced_code_blocks: true)
77
+ self.variables = variables
78
+ end
79
+
80
+ def render
81
+ ERB.new(self.partial).result(binding)
82
+ end
83
+
84
+ end
85
+
86
+ end
@@ -0,0 +1,69 @@
1
+ module Msgtrail
2
+ class Site
3
+
4
+ attr_accessor :blog_directory, :config, :pages, :theme_directory
5
+
6
+ def initialize(config)
7
+ self.config = config
8
+ self.blog_directory = File.join(config.working_directory, config.settings.file_matter.blog_directory)
9
+ self.theme_directory = File.join(config.working_directory, config.settings.file_matter.theme_directory)
10
+ end
11
+
12
+ def fetch_site_pages
13
+ filepath = File.join(self.config.working_directory, self.config.settings.file_matter.site_manifest_file)
14
+ begin
15
+ manifest = File.read(filepath)
16
+ rescue
17
+ puts("Can't find site manifest '#{filepath}'")
18
+ exit(2)
19
+ end
20
+ begin
21
+ self.pages = MultiJson.load(manifest, symbolize_keys: true)
22
+ rescue
23
+ puts("Invalid JSON in '#{filepath}'")
24
+ exit(2)
25
+ end
26
+ end
27
+
28
+ def generate_articles(articles)
29
+ self.pages.each do |page|
30
+ layout_filepath = File.join(self.theme_directory, page[:layout])
31
+ template_filepath = File.join(self.theme_directory, page[:template])
32
+ if page[:iterator_subject] == false
33
+ renderer = PageRenderer.new(layout_filepath, template_filepath, self.config)
34
+ renderer.theme_directory = self.theme_directory
35
+ renderer.articles = articles
36
+ write_article_directory_and_file(page, renderer)
37
+ else
38
+ articles.each do |article|
39
+ renderer = PageRenderer.new(layout_filepath, template_filepath, self.config)
40
+ renderer.theme_directory = theme_directory
41
+ renderer.article = article
42
+ write_article_directory_and_file(page, renderer, article[:slug])
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ def write_article_directory_and_file(page, renderer, slug = nil)
49
+ # Create directory
50
+ article_directory = File.join(self.blog_directory, (page[:output_path] || "") % slug)
51
+ begin
52
+ FileUtils.mkdir_p(article_directory)
53
+ rescue
54
+ puts("Can't create '#{article_directory}'")
55
+ exit(2)
56
+ end
57
+ # Create file
58
+ index_filepath = File.join(self.blog_directory, (page[:output_path] || "") % slug, page[:output_file])
59
+ begin
60
+ File.write(index_filepath, renderer.render)
61
+ rescue
62
+ puts("Can't write '#{index_filepath}'")
63
+ exit(2)
64
+ end
65
+ puts("Created '#{index_filepath}'")
66
+ end
67
+
68
+ end
69
+ end
@@ -0,0 +1,57 @@
1
+ module Msgtrail
2
+ class Slug
3
+
4
+ def self.generate(title, date, time)
5
+ ymd = date.split(/\D/).map(&:to_i)
6
+ hm = time.split(/\D/).map(&:to_i)
7
+ datestamp = sprintf("%04d%02d%02d-%02d%02d", ymd[0], ymd[1], ymd[2], hm[0], hm[1])
8
+ bucketnameify("#{datestamp}-#{slugify(title)}")
9
+ end
10
+
11
+ # Create URL-safe slug
12
+ def self.slugify(title)
13
+ URI.escape(title)
14
+ .gsub(/%[0-9A-F]{2}/, '-')
15
+ .gsub(/-/, '-')
16
+ .downcase
17
+ end
18
+
19
+ # Create S3-safe slug.
20
+ #
21
+ # S3 bucket names must comply to these naming rules:
22
+ # - must be between 3 and 63 characters long
23
+ # - must be lowercase a-z
24
+ # - may use numbers 0-9
25
+ # - may use periods & dashes (and thus not _ or / or \)
26
+ # - must start with letter or number
27
+ # - may not end with dash
28
+ # - may not have consecutive periods
29
+ # - may not use dashes adjacent to periods (i.e. no .- or -.)
30
+ # - may not not be formatted as a IP address
31
+ #
32
+ # Reference: http://tinyurl.com/yycoeogm
33
+ #
34
+ # Note: although periods are allowed this methods rejects them for sake of simplicity
35
+ #
36
+ def self.bucketnameify(string)
37
+ #
38
+ # Steps:
39
+ # - change to lowercase
40
+ # - remove periods
41
+ # - truncate to 63 characters
42
+ # - replace invalid characters
43
+ # - replace leading dashes
44
+ # - replace trailing dashes
45
+ # - pad string with zeros if shorter than 3 characters
46
+ #
47
+ string.downcase
48
+ .gsub(/\.*/, '')
49
+ .slice(0..62)
50
+ .gsub(/[^a-z,0-9,-]/, '-')
51
+ .gsub(/\A-*/, '')
52
+ .gsub(/-*\Z/, '')
53
+ .ljust(3, '0')
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,73 @@
1
+ module Msgtrail
2
+ class Twitter
3
+
4
+ PRE_AUTHENTICATION = "Basic %s".freeze
5
+ POST_AUTHENTICATION = "Bearer %s".freeze
6
+ CONTENT_TYPE_HEADER = { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8' }.freeze
7
+ TWITTER_API_OAUTH_ENDPOINT = 'https://api.twitter.com/oauth2/token'.freeze
8
+ TWITTER_API_STATUS_ENDPOINT = "https://api.twitter.com/1.1/statuses/show.json?id=%s&tweet_mode=extended".freeze
9
+ TWITTER_AUTH_BODY = 'grant_type=client_credentials'.freeze
10
+ EXPECTED_TOKEN_TYPE = 'bearer'.freeze
11
+ TWITTER_STATUS_ENDPOINT = "https://twitter.com/statuses/%s".freeze
12
+
13
+ def self.tweet_bodies(tweet_ids)
14
+ tweet_ids.map { |tweet_id| fetch(tweet_id) }
15
+ end
16
+
17
+ def self.fetch(tweet_id)
18
+ if access_token = authenticate
19
+ full_tweet_text(access_token, tweet_id)
20
+ else
21
+ puts("Failed to authenticate with Twitter API")
22
+ end
23
+ end
24
+
25
+ def self.authenticate
26
+ api_key = ENV['TWITTER_CONSUMER_API_KEY']
27
+ secret = ENV['TWITTER_CONSUMER_SECRET_KEY']
28
+ credentials = Base64.strict_encode64("#{api_key}:#{secret}")
29
+ begin
30
+ result = HTTP.auth(PRE_AUTHENTICATION % credentials)
31
+ .headers(CONTENT_TYPE_HEADER)
32
+ .post(TWITTER_API_OAUTH_ENDPOINT, body: TWITTER_AUTH_BODY)
33
+ rescue
34
+ puts("Failed to authenticate with Twitter API")
35
+ exit(2)
36
+ end
37
+ begin
38
+ json = MultiJson.load(result.to_s, symbolize_keys: true)
39
+ rescue
40
+ puts("Invalid JSON from '#{TWITTER_API_OAUTH_ENDPOINT}'")
41
+ exit(2)
42
+ end
43
+ EXPECTED_TOKEN_TYPE == json[:token_type] ? json[:access_token] : nil
44
+ end
45
+
46
+ # There seem to be two ways to get to any tweet by its ID:
47
+ # 1. https://twitter.com/i/web/status/{id}
48
+ # 2. https://twitter.com/statuses/#{id}
49
+ # Using latter method.
50
+ def self.full_tweet_text(access_token, tweet_id)
51
+ url = TWITTER_API_STATUS_ENDPOINT % tweet_id
52
+ begin
53
+ result = HTTP.auth(POST_AUTHENTICATION % access_token)
54
+ .get(url)
55
+ rescue
56
+ puts("Failed to get tweet from '#{url}'")
57
+ exit(2)
58
+ end
59
+ begin
60
+ json = MultiJson.load(result.to_s, symbolize_keys: true)
61
+ rescue
62
+ puts("Invalid JSON from '#{url}'")
63
+ exit(2)
64
+ end
65
+ {
66
+ body: json[:full_text],
67
+ source: TWITTER_STATUS_ENDPOINT % tweet_id,
68
+ type: Article::TYPE_TWEET
69
+ }
70
+ end
71
+
72
+ end
73
+ end
@@ -0,0 +1,3 @@
1
+ module Msgtrail
2
+ VERSION = "0.3.0"
3
+ end
data/msgtrail.gemspec ADDED
@@ -0,0 +1,45 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "msgtrail/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "msgtrail"
8
+ spec.version = Msgtrail::VERSION
9
+ spec.authors = ["Erik van Eykelen"]
10
+ spec.email = ["erik.van.eykelen@bitgain.com"]
11
+
12
+ spec.summary = %q{A simple blog publication tool}
13
+ spec.homepage = "https://github.com/evaneykelen/msgtrail"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = "https://github.com/evaneykelen/msgtrail"
22
+ spec.metadata["changelog_uri"] = "https://github.com/evaneykelen/msgtrail/CHANGELOG.md"
23
+ else
24
+ raise "RubyGems 2.0 or newer is required to protect against " \
25
+ "public gem pushes."
26
+ end
27
+
28
+ # Specify which files should be added to the gem when it is released.
29
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
31
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
+ end
33
+ spec.bindir = "exe"
34
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
+ spec.require_paths = ["lib"]
36
+
37
+ spec.add_development_dependency "bundler", "~> 2.0"
38
+ spec.add_development_dependency "rake", "~> 10.0"
39
+ spec.add_development_dependency "minitest", "~> 5.0"
40
+ spec.add_development_dependency "http", "~> 4.1"
41
+ spec.add_development_dependency "dotenv", "~> 2.7"
42
+ spec.add_development_dependency "multi_json", "~> 1.13"
43
+ spec.add_development_dependency "redcarpet", "~> 3.4"
44
+ spec.add_development_dependency "tilt", "~> 2.0"
45
+ end
Binary file
Binary file
metadata ADDED
@@ -0,0 +1,182 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: msgtrail
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Erik van Eykelen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-04-08 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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
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
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: http
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: dotenv
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: multi_json
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.13'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.13'
97
+ - !ruby/object:Gem::Dependency
98
+ name: redcarpet
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: tilt
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.0'
125
+ description:
126
+ email:
127
+ - erik.van.eykelen@bitgain.com
128
+ executables:
129
+ - msgtrail
130
+ extensions: []
131
+ extra_rdoc_files: []
132
+ files:
133
+ - Gemfile
134
+ - Gemfile.lock
135
+ - LICENSE.txt
136
+ - README.md
137
+ - Rakefile
138
+ - bin/console
139
+ - bin/setup
140
+ - exe/msgtrail
141
+ - lib/msgtrail.rb
142
+ - lib/msgtrail/article.rb
143
+ - lib/msgtrail/blog.rb
144
+ - lib/msgtrail/config.rb
145
+ - lib/msgtrail/github.rb
146
+ - lib/msgtrail/markdown_file.rb
147
+ - lib/msgtrail/publish.rb
148
+ - lib/msgtrail/renderers.rb
149
+ - lib/msgtrail/site.rb
150
+ - lib/msgtrail/slug.rb
151
+ - lib/msgtrail/twitter.rb
152
+ - lib/msgtrail/version.rb
153
+ - msgtrail.gemspec
154
+ - pkg/msgtrail-0.1.0.gem
155
+ - pkg/msgtrail-0.2.0.gem
156
+ homepage: https://github.com/evaneykelen/msgtrail
157
+ licenses:
158
+ - MIT
159
+ metadata:
160
+ homepage_uri: https://github.com/evaneykelen/msgtrail
161
+ source_code_uri: https://github.com/evaneykelen/msgtrail
162
+ changelog_uri: https://github.com/evaneykelen/msgtrail/CHANGELOG.md
163
+ post_install_message:
164
+ rdoc_options: []
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ requirements: []
178
+ rubygems_version: 3.0.3
179
+ signing_key:
180
+ specification_version: 4
181
+ summary: A simple blog publication tool
182
+ test_files: []