m2fm-autotag-subject 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4ede5757f24dd1e3b7d20381d57278ac587c10c8
4
+ data.tar.gz: 1fc8370089ac63007b04342ab72a0ac26a355de1
5
+ SHA512:
6
+ metadata.gz: 425e38f72fc4c074aadc58cd9a90253214a0896ca80cad24e5dbeb0be269dba7b7bb1724d120b4bfea3b1d2bfc718f16024798d5f102dd92325381d629706a35
7
+ data.tar.gz: ac2723373d02bff6d80a7b334917fbad3b3acf9a8c15614134089aed93e3bcf9316c42a09e568031dcf8514ca4d5455fd9ad749427cb8fb84a3bd30ea414aa87
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,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in m2fm-autotag-subject.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Kunal Shah
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,67 @@
1
+ # Mail2FrontMatter::AutotagSubject
2
+
3
+ [Mail2FrontMatter](https://github.com/whistlerbrk/mail2frontmatter) plugin for extracting tags from an email subject line by convention.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'm2fm-autotag-subject', require: false
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ ## Configuration
18
+
19
+ In your Mail2FrontMatter YAML configuration enable the plugin by adding it to your preprocessors:
20
+
21
+ ```yaml
22
+ protocol: imap
23
+ receiver: yourblogemail@yourdomain.com
24
+ senders: yourpersonal@yourdomain.com
25
+
26
+ preprocessors:
27
+ - key: 'autotag-subject'
28
+
29
+ mailman:
30
+ server: imap.gmail.com
31
+ port: 993
32
+ ssl: true
33
+ username: yourblogemail@yourdomain.com
34
+ password: yourpassword
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ Now when you send an email to ```yourblogemail@yourdomain.com``` your subject line will be parsed for tags within brackets like:
40
+
41
+ ```
42
+ to: yourblogemail@yourdomain.com
43
+ subject: [revelations, thoughts] My Amazing Revelation Today
44
+ body:
45
+ ...
46
+ ```
47
+
48
+ AutotagSubject will add 'revelations' and 'thoughts' and remove it from the the title. So your metadata will look like:
49
+
50
+ ```ruby
51
+ {
52
+ tags: ['revelations', 'thoughts']
53
+ title: "My Amazing Revelation Today"
54
+ }
55
+ ```
56
+
57
+ Which will later get transformed to YAML for your static site.
58
+
59
+ That's it!
60
+
61
+ ## Contributing
62
+
63
+ 1. Fork it ( https://github.com/[my-github-username]/m2fm-autotag-subject/fork )
64
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
65
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
66
+ 4. Push to the branch (`git push origin my-new-feature`)
67
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,20 @@
1
+ require 'mail2frontmatter'
2
+
3
+ module Mail2FrontMatter
4
+ class AutotagSubject < PreProcessor
5
+ def self.run(metadata, body)
6
+ parsed_subject = metadata[:subject].match(/(\[(.*)\])?(.*)/)
7
+
8
+ # [tag1, tag2] title of post
9
+ # [1] -> tags in quotes
10
+ # [2] -> tags without quotes
11
+ # [3] -> subject
12
+ if parsed_subject[2]
13
+ metadata[:subject] = parsed_subject[3].strip
14
+ metadata[:tags] = (metadata[:tags]||[] + parsed_subject[2].split(',').map(&:strip)).uniq
15
+ end
16
+
17
+ return metadata, body
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'm2fm-autotag-subject'
7
+ spec.version = '0.0.1'
8
+ spec.authors = ['Kunal Shah']
9
+ spec.email = ['me@kunalashah.com']
10
+ spec.summary = %q{mail2frontmatter plugin for extracting tags from subject lines}
11
+ spec.description = spec.summary
12
+ spec.homepage = 'https://github.com/whistlerbrk/m2fm-autotag-subject'
13
+ spec.license = 'MIT'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_dependency 'mail2frontmatter'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.7'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: m2fm-autotag-subject
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kunal Shah
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mail2frontmatter
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: mail2frontmatter plugin for extracting tags from subject lines
56
+ email:
57
+ - me@kunalashah.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/mail2frontmatter/autotag-subject.rb
68
+ - m2fm-autotag-subject.gemspec
69
+ homepage: https://github.com/whistlerbrk/m2fm-autotag-subject
70
+ licenses:
71
+ - MIT
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.4.5
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: mail2frontmatter plugin for extracting tags from subject lines
93
+ test_files: []