mailbot 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0f4d24f529776193f5a69492e1bf7168a6dc8c19
4
- data.tar.gz: b12bfb405e21dd0d3331c2716079d8bcecd0daaf
3
+ metadata.gz: 1e66301008f9e4f8acabd353f4f9aba8375c15fe
4
+ data.tar.gz: 24644ab6f8c5fc3663dc131b93e4261de11ac68a
5
5
  SHA512:
6
- metadata.gz: c48005df6b2eb41f5a88a3e13f5b5f548dd04b9f08f211290c4c624418a76cda74b8bef450b519c73f4980614bb2e5fe3ec6692b284529e69ab79e13a7e4752a
7
- data.tar.gz: 9d1546b7fa3fb80ba215f3ab7dcb222251b0a91cfe855a72f535f24eda8b1560e18c07f8c34db004cee26fe467ccef33fb84d03e9361f4c26d327382282a3b1c
6
+ metadata.gz: c89aa1166015e253425b42db6f8bf3cfb03e6f3d132cdb3d7201b967e640a56261921eaced121b0d541df4db69a0f1402ceb76ad2884745c0b4a22d9d75142b6
7
+ data.tar.gz: 951f8980fc599cc72ecda68648539420c1919f0b19ebece41451a679f234f43478dd2bcd6f704dd993d9ef23dd8bb978c0f2b2f1f2c69d92309cb9b45aa727c9
data/README.md CHANGED
@@ -4,11 +4,33 @@ Learn with [Mailbox](http://www.mailboxapp.com/)
4
4
 
5
5
  ## Usage
6
6
 
7
+ ### Sync
8
+
9
+ Sync the specified file to Mailbox
10
+
11
+ ```
12
+ $ cd path-to-mailbot-sync-directory
13
+ $ mailbot sync
14
+ ```
15
+
16
+ #### Options
17
+
18
+ |Option|Description|Default Value|
19
+ |:-----|:----------|:------------|
20
+ |file|The path to the markdown file to sync|index.md|
21
+ |env|The path to the env file to sync|.env|
22
+
23
+ ### List
24
+
25
+ List all entries of the specified file
26
+
7
27
  ```
8
- $ mailbot sync --file study.md
28
+ $ cd path-to-mailbot-sync-directory
29
+ $ mailbot list
9
30
  ```
10
31
 
11
- ## Options
32
+ #### Options
12
33
 
13
- - file : The path to the markdown file to sync
14
- - env : The path to the env file to sync
34
+ |Option|Description|Default Value|
35
+ |:-----|:----------|:------------|
36
+ |file|The path to the markdown file to list|index.md|
@@ -9,6 +9,7 @@ require "mailgun"
9
9
  require "mailbot/command_factory"
10
10
  require "mailbot/commands/base"
11
11
  require "mailbot/commands/sync"
12
+ require "mailbot/commands/list"
12
13
  require "mailbot/logger"
13
14
  require "mailbot/entry"
14
15
  require "mailbot/errors"
@@ -25,6 +25,8 @@ module Mailbot
25
25
  case command_name
26
26
  when "sync"
27
27
  Commands::Sync
28
+ when "list"
29
+ Commands::List
28
30
  else
29
31
  raise Errors::CommandNotFound
30
32
  end
@@ -0,0 +1,38 @@
1
+ module Mailbot
2
+ module Commands
3
+ class List < Base
4
+
5
+ DEFAULT_MARKDOWN_FILE = "index.md"
6
+
7
+ # @param argv [Array] ARGV
8
+ def initialize(argv)
9
+ @argv = argv
10
+ end
11
+
12
+ # List all entries of the specified file
13
+ def execute
14
+ puts Mailbot::Repository.new(file).entries.map { |entry| colorized_subject entry }.map(&:strip).join("\n")
15
+ end
16
+
17
+ private
18
+
19
+ def colorized_subject(entry)
20
+ subject = entry.subject
21
+ subject = "\033[32m#{subject}\033[0m" unless entry.synced?
22
+ subject
23
+ end
24
+
25
+ def file
26
+ options[:file] || DEFAULT_MARKDOWN_FILE
27
+ end
28
+
29
+ def options
30
+ @options ||= Slop.parse!(@argv, help: true) do
31
+ banner "Usage: #{$0} list [options]"
32
+ on "file=", "Path to the markdown file to list"
33
+ end
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -10,7 +10,7 @@ module Mailbot
10
10
  @argv = argv
11
11
  end
12
12
 
13
- # Sync given file to Mailbox
13
+ # Sync the specified file to Mailbox
14
14
  def execute
15
15
  load_env!
16
16
  Mailbot::Repository.new(file).sync
@@ -24,6 +24,11 @@ module Mailbot
24
24
  end.map(&:text).join("\n"))
25
25
  end
26
26
 
27
+ # @return [Array<Mailbot::Entry>] An array of all entries in this repository
28
+ def entries
29
+ Mailbot::Entry::Parser.new.parse read
30
+ end
31
+
27
32
  private
28
33
 
29
34
  def write(text)
@@ -34,10 +39,6 @@ module Mailbot
34
39
  open(@path, "r:UTF-8").read
35
40
  end
36
41
 
37
- def entries
38
- Mailbot::Entry::Parser.new.parse read
39
- end
40
-
41
42
  end
42
43
 
43
44
  end
@@ -1,3 +1,3 @@
1
1
  module Mailbot
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailbot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - monzou
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-30 00:00:00.000000000 Z
11
+ date: 2014-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -126,6 +126,7 @@ files:
126
126
  - lib/mailbot.rb
127
127
  - lib/mailbot/command_factory.rb
128
128
  - lib/mailbot/commands/base.rb
129
+ - lib/mailbot/commands/list.rb
129
130
  - lib/mailbot/commands/sync.rb
130
131
  - lib/mailbot/entry.rb
131
132
  - lib/mailbot/errors.rb
@@ -157,10 +158,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  version: '0'
158
159
  requirements: []
159
160
  rubyforge_project:
160
- rubygems_version: 2.4.1
161
+ rubygems_version: 2.2.2
161
162
  signing_key:
162
163
  specification_version: 4
163
164
  summary: Learn with Mailbox
164
165
  test_files:
165
166
  - test/entry_test.rb
166
167
  - test/test_helper.rb
168
+ has_rdoc: