pinpress 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c8ccd16e480f7916a9d5f37fc1e53d8a202a166
4
- data.tar.gz: 0f614a325332b9e23fbdc8acc9299f3056eb4422
3
+ metadata.gz: 7cd530fc5ddd3f35de2e05761e796e86ba44fae9
4
+ data.tar.gz: 692a163f694f782fe1957e034fb46e2af85df559
5
5
  SHA512:
6
- metadata.gz: eefacf5d7d8198bf79bcf1ed739e1dd5892ab5b17b799a7a0d08eb91f3e964cdc703b1aa8d57b2512837409c1ff00f5caa991bfedb3fdadb8794d6a0711c526c
7
- data.tar.gz: abb18bfae40f56fe623be3684d3ead5c510fe0812fc6aba9da6c403c0117f4e1815a13153c74b51f0bc13fef3122850ff42e15c88d91242256a366304aeb96df
6
+ metadata.gz: a8bcd4d8a61d2350470a29f242c488e8a44500e2a02cfa2d6340ef342ee733a70acd9a2c30ffc25b70f10edf5892e1c770df0c12314c8ba53eae68979f649e08
7
+ data.tar.gz: ab778b6492687ed954aa334c9582c10583b121d608c0e65dd84c92f6660892d114eb0ee6d588ed84b1b2af0d367123d3caaff933c904d3e082cf920674c2ef17
data/HISTORY.md CHANGED
@@ -1,6 +1,10 @@
1
- # 1.0.2 (2014-04-17)
1
+ # 1.1.0 (2014-04-17)
2
2
 
3
- * Fixed a configuration version bug
3
+ * Added default tags
4
+ * Added default number of results
5
+ * Rubocop refactoring
6
+ * Documentation
7
+ * Several bugfixes
4
8
 
5
9
  # 1.0.1 (2014-04-17)
6
10
 
data/README.md CHANGED
@@ -9,7 +9,7 @@ PinPress is a simple CLI to create templates (HTML, Markdown, or otherwise) of P
9
9
 
10
10
  Every two weeks, I create a "link mash" for my website; this link mash consists of URLs that I find interesting and want to share with my readers. Previously, I would save those interesting URLs to an Evernote note and, every two weeks, manually create my link mash for use in Wordpress. <barf/>
11
11
 
12
- When I began using [Pinboard](http://pinboard.in "Pinboard") to save interesting links, I knew I needed a better method. This tool is the result: **Pin**board + Word**press**.
12
+ When I began using [Pinboard](http://pinboard.in "Pinboard") to save interesting links, I knew I needed a better method. This tool is the result: **Pin** board + Word **press**.
13
13
 
14
14
  # Prerequisites
15
15
 
@@ -34,7 +34,7 @@ SYNOPSIS
34
34
  pinpress [global options] command [command options] [arguments...]
35
35
 
36
36
  VERSION
37
- 1.0.2
37
+ 1.1.0
38
38
 
39
39
  GLOBAL OPTIONS
40
40
  --help - Show this message
@@ -73,97 +73,13 @@ $ pinpress init
73
73
 
74
74
  Initialization will prompt you to enter your Pinboard API token. Once, entered, this (and other pertinent data) will be stored in `~/.pinpress`.
75
75
 
76
- # Getting Pins
77
-
78
- ```
79
- $ pinpress pins
80
- # => <ul><li><b><a title="Using Drafts for Remote CLI" href="https://gist.github.com/hiilppp/10993803" target="_blank">Using Drafts for Remote CLI</a>.</b> As a text file is added to a directory to which this AppleScript is associated as Folder Action, the content of the received file is executed as shell script and the generated output sent to an iOS device.</li></ul>
81
- ```
82
-
83
- This simple command will return all pins from the user's account and output them based on the [Pin Template](https://github.com/bachya/PinPress#pin-templates "Pin Templates") provided.
84
-
85
- Pinpress also provides some flags that allow a user to define specific pins to grab:
86
-
87
- * `-s`: the start date to use (uses [Chronic](https://github.com/mojombo/chronic "Chronic"), which allows dates like "last Tuesday")
88
- * `-e`: the end date to use (also uses [Chronic](https://github.com/mojombo/chronic "Chronic"))
89
- * `-n`: the number of pins to return (e.g., 20)
90
- * `-t`: a CSV list of tags to grab (e.g., "tag1,tag2")
91
-
92
- ## Getting Pins From a Date Forward
93
-
94
- ```
95
- $ pinpress pins -s 2014-01-01
96
- ```
97
-
98
- ...returns all pins from January 1, 2014 to the current day.
99
-
100
- ## Getting Pins Until a Date
101
-
102
- ```
103
- $ pinpress pins -e 2014-01-01
104
- ```
105
-
106
- ...returns all pins up to January 1, 2014.
107
-
108
- ## Getting Pins Between a Date Range
109
-
110
- ```
111
- $ pinpress pins -s 2014-01-01 -e 2014-01-31
112
- ```
113
-
114
- ## Getting Tagged Pins
115
-
116
- ```
117
- $ pinpress pins -t "ruby,cli"
118
- ```
119
-
120
- ...returns all pins tagged "ruby" *and* "cli".
121
-
122
- # Getting Tags
123
-
124
- Pinpress can also work with tags in a Pinboard account:
125
-
126
- ```
127
- $ pinpress tags
128
- # => cli (1),github (1),applescript (1),osx (1),link-mash (1)
129
- ```
130
-
131
- This simple command will return all tags from the user's account and output them based on the [Tag Template](https://github.com/bachya/PinPress#tag-templates "Tag Templates") provided.
132
-
133
- Pinpress also provides some flags that allow a user to define specific tags to grab:
134
-
135
- * `-s`: the start date to use (uses [Chronic](https://github.com/mojombo/chronic "Chronic"), which allows dates like "last Tuesday")
136
- * `-e`: the end date to use (also uses [Chronic](https://github.com/mojombo/chronic "Chronic"))
137
-
138
- ## Getting Tags From a Date Forward
139
-
140
- ```
141
- $ pinpress tags -s 2014-01-01
142
- ```
143
-
144
- ...returns all tags used from January 1, 2014 to the current day. Note that for each tag returned, the data includes both the tag name and the number of times it was used.
145
-
146
- ## Getting Tags Until a Date
147
-
148
- ```
149
- $ pinpress tags -e 2014-01-01
150
- ```
151
-
152
- ...returns all tags used up to January 1, 2014.
153
-
154
- ## Getting Tags Between a Date Range
155
-
156
- ```
157
- $ pinpress tags -s 2014-01-01 -e 2014-01-31
158
- ```
159
-
160
76
  # Templates
161
77
 
162
- The first stop on the PinPress journey is templates. Templates are used to define how data should be output and are defined in `~/.pinpress` and come in two forms: **Pin Templates** and **Tag Templates**.
78
+ The first stop on the PinPress journey is templates. Templates are used to define how data should be output and are defined in `~/.pinpress`. They come in two forms: **Pin Templates** and **Tag Templates**.
163
79
 
164
80
  ## Pin Templates
165
81
 
166
- Pin Templates define how a pin should be output.
82
+ Pin Templates define how a pin from Pinboard should be output.
167
83
 
168
84
  ### Schema
169
85
 
@@ -176,7 +92,7 @@ pin_templates:
176
92
  closer: "</ul>"
177
93
  item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
178
94
  description %></a>.</b> <%= extended %></li>"
179
- item_separator: "\n"
95
+ /Users/abach/.pinpress: "\n"
180
96
  ```
181
97
 
182
98
  A Pin Template can have several different sub-keys:
@@ -185,7 +101,6 @@ A Pin Template can have several different sub-keys:
185
101
  * `opener` (*optional*): the text that should exist above the pins
186
102
  * `closer` (*optional*): the text that should exist above the pins
187
103
  * `item` (**required**): the formatted text that should be output for every pin
188
- * `item_separator` (**required**): the text that should exist between each pin ("item")
189
104
 
190
105
  ### Available Tokens
191
106
 
@@ -218,18 +133,10 @@ pinpress:
218
133
  # ... other keys ...
219
134
  pin_templates:
220
135
  - name: pinpress_default
221
- opener: "<ul>"
136
+ opener: "<ul>\n"
222
137
  closer: "</ul>"
223
138
  item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
224
- description %></a>.</b> <%= extended %></li>"
225
- item_separator: "\n"
226
- ```
227
-
228
- Using this example, here's what's output:
229
-
230
- ```
231
- $ pinpress pins -s 'yesterday'
232
- # => <ul><li><b><a title="Using Drafts for Remote CLI" href="https://gist.github.com/hiilppp/10993803" target="_blank">Using Drafts for Remote CLI</a>.</b> As a text file is added to a directory to which this AppleScript is associated as Folder Action, the content of the received file is executed as shell script and the generated output sent to an iOS device.</li></ul>
139
+ description %></a>.</b> <%= extended %></li>\N"
233
140
  ```
234
141
 
235
142
  ## Tag Templates
@@ -244,7 +151,7 @@ They, too, are defined in `~/.pinpress`:
244
151
  tag_templates:
245
152
  - name: pinpress_default
246
153
  item: "<%= tag %> (<%= count %>)"
247
- item_separator: ","
154
+ /Users/abach/.pinpress: ","
248
155
  ```
249
156
 
250
157
  A Pin Template can have several different sub-keys:
@@ -253,7 +160,6 @@ A Pin Template can have several different sub-keys:
253
160
  * `opener` (*optional*): the text that should exist above the pins
254
161
  * `closer` (*optional*): the text that should exist above the pins
255
162
  * `item` (**required**): the formatted text that should be output for every pin
256
- * `item_separator` (**required**): the text that should exist between each pin ("item")
257
163
 
258
164
  ### Available Tokens
259
165
 
@@ -282,17 +188,100 @@ pin_templates:
282
188
  # ... other keys ...
283
189
  tag_templates:
284
190
  - name: pinpress_default
285
- item: "<%= tag %> (<%= count %>)"
286
- item_separator: ","
191
+ item: "<%= tag %> (<%= count %>),"
192
+ ```
193
+
194
+ # Getting Pins
195
+
196
+ ```
197
+ $ pinpress pins
198
+ # => <ul><li><b><a title="Using Drafts for Remote CLI" href="https://gist.github.com/hiilppp/10993803" target="_blank">Using Drafts for Remote CLI</a>.</b> As a text file is added to a directory to which this AppleScript is associated as Folder Action, the content of the received file is executed as shell script and the generated output sent to an iOS device.</li></ul>
199
+ ```
200
+
201
+ This simple command will return all pins from the user's account and output them based on the [Pin Template](https://github.com/bachya/PinPress#pin-templates "Pin Templates") provided.
202
+
203
+ Pinpress also provides some flags that allow a user to define specific pins to grab:
204
+
205
+ * `-s`: the start date to use (uses [Chronic](https://github.com/mojombo/chronic "Chronic"), which allows dates like "last Tuesday")
206
+ * `-e`: the end date to use (also uses [Chronic](https://github.com/mojombo/chronic "Chronic"))
207
+ * `-n`: the number of pins to return (e.g., 20)
208
+ * `-t`: a CSV list of tags to grab (e.g., "tag1,tag2")
209
+
210
+ ## Getting Pins From a Date Forward
211
+
212
+ ```
213
+ $ pinpress pins -s 2014-01-01
214
+ ```
215
+
216
+ ...returns all pins from January 1, 2014 to the current day.
217
+
218
+ ## Getting Pins Until a Date
219
+
287
220
  ```
221
+ $ pinpress pins -e 2014-01-01
222
+ ```
223
+
224
+ ...returns all pins up to January 1, 2014.
225
+
226
+ ## Getting Pins Between a Date Range
288
227
 
289
- Using this example, here's what's output:
228
+ ```
229
+ $ pinpress pins -s 2014-01-01 -e 2014-01-31
230
+ ```
231
+
232
+ ## Getting Tagged Pins
290
233
 
291
234
  ```
292
- $ pinpress tags -s 'yesterday'
235
+ $ pinpress pins -t "ruby,cli"
236
+ ```
237
+
238
+ ...returns all pins tagged "ruby" *and* "cli".
239
+
240
+ # Getting Tags
241
+
242
+ Pinpress can also work with tags in a Pinboard account:
243
+
244
+ ```
245
+ $ pinpress tags
293
246
  # => cli (1),github (1),applescript (1),osx (1),link-mash (1)
294
247
  ```
295
248
 
249
+ This simple command will return all tags from the user's account and output them based on the [Tag Template](https://github.com/bachya/PinPress#tag-templates "Tag Templates") provided.
250
+
251
+ Pinpress also provides some flags that allow a user to define specific tags to grab:
252
+
253
+ * `-s`: the start date to use (uses [Chronic](https://github.com/mojombo/chronic "Chronic"), which allows dates like "last Tuesday")
254
+ * `-e`: the end date to use (also uses [Chronic](https://github.com/mojombo/chronic "Chronic"))
255
+
256
+ ## Getting Tags From a Date Forward
257
+
258
+ ```
259
+ $ pinpress tags -s 2014-01-01
260
+ ```
261
+
262
+ ...returns all tags used from January 1, 2014 to the current day. Note that for each tag returned, the data includes both the tag name and the number of times it was used.
263
+
264
+ ## Getting Tags Until a Date
265
+
266
+ ```
267
+ $ pinpress tags -e 2014-01-01
268
+ ```
269
+
270
+ ...returns all tags used up to January 1, 2014.
271
+
272
+ ## Getting Tags Between a Date Range
273
+
274
+ ```
275
+ $ pinpress tags -s 2014-01-01 -e 2014-01-31
276
+ ```
277
+
278
+ # Other Configuration Options
279
+
280
+ In addition to `default_pin_template` and `default_tag_template`, you can place some other special keys in the `pinpress` section of `~/.pinpress`:
281
+
282
+ * `default_tags`: the default tags to be used when getting pins (e.g., `'ruby,pinboard'`). This can be overridden by using the `-t` flag.
283
+ * `default_num_results`: the default number of results to return (e.g., '5'). This can be overridden by using the `-n` flag.
284
+
296
285
  # Known Issues & Future Releases
297
286
 
298
287
  Check out the Pinpress roadmap via the [Trello Board](https://trello.com/b/lmuC8TT0/pinpress "Pinpress Trello Board").
@@ -7,23 +7,31 @@ Feature: Initialization
7
7
  Given no file located at "/tmp/pp/.pinpress"
8
8
  When I run `pinpress init` interactively
9
9
  And I type ""
10
- And I type "12345"
10
+ And I type "bachya:12345"
11
11
  Then the exit status should be 0
12
12
  And the file "/tmp/pp/.pinpress" should contain:
13
13
  """
14
14
  ---
15
15
  pinpress:
16
16
  config_location: "/tmp/pp/.pinpress"
17
- default_template: pinpress_default
17
+ default_pin_template: pinpress_default
18
+ default_tag_template: pinpress_default
18
19
  log_level: WARN
19
- version: 1.0.1
20
- api_token: '12345'
21
- templates:
20
+ version: 1.1.0
21
+ api_token: bachya:12345
22
+ pin_templates:
22
23
  - name: pinpress_default
23
- opener: "<ul>"
24
- item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
25
- description %></a>.</b> <%= extended %></li>"
24
+ opener: |
25
+ <ul>
26
+ item: |
27
+ <li>
28
+ <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
29
+ <%= extended %>
30
+ </li>
26
31
  closer: "</ul>"
32
+ tag_templates:
33
+ - name: pinpress_default
34
+ item: "<%= tag %> (<%= count %>),"
27
35
  """
28
36
 
29
37
  Scenario: Reinitialization (refuse)
@@ -32,16 +40,24 @@ Feature: Initialization
32
40
  ---
33
41
  pinpress:
34
42
  config_location: "/tmp/pp/.pinpress"
35
- default_template: pinpress_default
43
+ default_pin_template: pinpress_default
44
+ default_tag_template: pinpress_default
36
45
  log_level: WARN
37
- version: 1.0.1
38
- api_token: '12345'
39
- templates:
46
+ version: 1.1.0
47
+ api_token: bachya:12345
48
+ pin_templates:
40
49
  - name: pinpress_default
41
- opener: "<ul>"
42
- item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
43
- description %></a>.</b> <%= extended %></li>"
50
+ opener: |
51
+ <ul>
52
+ item: |
53
+ <li>
54
+ <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
55
+ <%= extended %>
56
+ </li>
44
57
  closer: "</ul>"
58
+ tag_templates:
59
+ - name: pinpress_default
60
+ item: "<%= tag %> (<%= count %>),"
45
61
  """
46
62
  When I run `pinpress init` interactively
47
63
  And I type ""
@@ -53,37 +69,53 @@ Feature: Initialization
53
69
  ---
54
70
  pinpress:
55
71
  config_location: "/tmp/pp/.pinpress"
56
- default_template: pinpress_default
72
+ default_pin_template: pinpress_default
73
+ default_tag_template: pinpress_default
57
74
  log_level: WARN
58
- version: 1.0.1
59
- api_token: '12345'
60
- templates:
75
+ version: 1.1.0
76
+ api_token: bachya:12345
77
+ pin_templates:
61
78
  - name: pinpress_default
62
- opener: "<ul>"
63
- item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
64
- description %></a>.</b> <%= extended %></li>"
79
+ opener: |
80
+ <ul>
81
+ item: |
82
+ <li>
83
+ <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
84
+ <%= extended %>
85
+ </li>
65
86
  closer: "</ul>"
87
+ tag_templates:
88
+ - name: pinpress_default
89
+ item: "<%= tag %> (<%= count %>),"
66
90
  """
67
91
  When I run `pinpress init` interactively
68
92
  And I type "y"
69
93
  And I type ""
70
- And I type "12345"
94
+ And I type "bachya:12345"
71
95
  Then the exit status should be 0
72
96
  And the file "/tmp/pp/.pinpress" should contain:
73
97
  """
74
98
  ---
75
99
  pinpress:
76
100
  config_location: "/tmp/pp/.pinpress"
77
- default_template: pinpress_default
101
+ default_pin_template: pinpress_default
102
+ default_tag_template: pinpress_default
78
103
  log_level: WARN
79
- version: 1.0.1
80
- api_token: '12345'
81
- templates:
104
+ version: 1.1.0
105
+ api_token: bachya:12345
106
+ pin_templates:
82
107
  - name: pinpress_default
83
- opener: "<ul>"
84
- item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
85
- description %></a>.</b> <%= extended %></li>"
108
+ opener: |
109
+ <ul>
110
+ item: |
111
+ <li>
112
+ <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
113
+ <%= extended %>
114
+ </li>
86
115
  closer: "</ul>"
116
+ tag_templates:
117
+ - name: pinpress_default
118
+ item: "<%= tag %> (<%= count %>),"
87
119
  """
88
120
 
89
121
  Scenario: Reinitialization (from scratch)
@@ -92,34 +124,50 @@ Feature: Initialization
92
124
  ---
93
125
  pinpress:
94
126
  config_location: "/tmp/pp/.pinpress"
95
- default_template: pinpress_default
127
+ default_pin_template: pinpress_default
128
+ default_tag_template: pinpress_default
96
129
  log_level: WARN
97
- version: 1.0.1
98
- api_token: '12345'
99
- templates:
130
+ version: 1.1.0
131
+ api_token: bachya:12345
132
+ pin_templates:
100
133
  - name: pinpress_default
101
- opener: "<ul>"
102
- item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
103
- description %></a>.</b> <%= extended %></li>"
134
+ opener: |
135
+ <ul>
136
+ item: |
137
+ <li>
138
+ <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
139
+ <%= extended %>
140
+ </li>
104
141
  closer: "</ul>"
142
+ tag_templates:
143
+ - name: pinpress_default
144
+ item: "<%= tag %> (<%= count %>),"
105
145
  """
106
146
  When I run `pinpress init -s` interactively
107
147
  And I type ""
108
- And I type "12345"
148
+ And I type "bachya:12345"
109
149
  Then the exit status should be 0
110
150
  And the file "/tmp/pp/.pinpress" should contain:
111
151
  """
112
152
  ---
113
153
  pinpress:
114
154
  config_location: "/tmp/pp/.pinpress"
115
- default_template: pinpress_default
155
+ default_pin_template: pinpress_default
156
+ default_tag_template: pinpress_default
116
157
  log_level: WARN
117
- version: 1.0.1
118
- api_token: '12345'
119
- templates:
158
+ version: 1.1.0
159
+ api_token: bachya:12345
160
+ pin_templates:
120
161
  - name: pinpress_default
121
- opener: "<ul>"
122
- item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
123
- description %></a>.</b> <%= extended %></li>"
162
+ opener: |
163
+ <ul>
164
+ item: |
165
+ <li>
166
+ <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
167
+ <%= extended %>
168
+ </li>
124
169
  closer: "</ul>"
170
+ tag_templates:
171
+ - name: pinpress_default
172
+ item: "<%= tag %> (<%= count %>),"
125
173
  """
@@ -8,26 +8,33 @@ Feature: Templates
8
8
  ---
9
9
  pinpress:
10
10
  config_location: "/tmp/pp/.pinpress"
11
- default_template: pinpress_default
11
+ default_pin_template: pinpress_default
12
+ default_tag_template: pinpress_default
12
13
  log_level: WARN
13
- version: 1.0.1
14
- api_token: '12345'
15
- templates:
14
+ version: 1.1.0
15
+ api_token: bachya:12345
16
+ pin_templates:
16
17
  - name: pinpress_default
17
- opener: "<ul>"
18
- item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
19
- description %></a>.</b> <%= extended %></li>"
18
+ opener: |
19
+ <ul>
20
+ item: |
21
+ <li>
22
+ <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
23
+ <%= extended %>
24
+ </li>
20
25
  closer: "</ul>"
21
- - name: secondary
22
- item: "* <%= href %>"
26
+ tag_templates:
27
+ - name: pinpress_default
28
+ item: "<%= tag %> (<%= count %>),"
23
29
  """
24
- When I run `pinpress template` interactively
30
+ When I run `pinpress templates` interactively
25
31
  Then the exit status should be 0
26
32
  And the output should contain:
27
33
  """
28
- ---> AVAILABLE TEMPLATES
34
+ ---> AVAILABLE PIN TEMPLATES:
35
+ # 1. pinpress_default
36
+ ---> AVAILABLE TAG TEMPLATES:
29
37
  # 1. pinpress_default
30
- # 2. secondary
31
38
  """
32
39
 
33
40
  Scenario: List Templates (explicit)
@@ -36,78 +43,31 @@ Feature: Templates
36
43
  ---
37
44
  pinpress:
38
45
  config_location: "/tmp/pp/.pinpress"
39
- default_template: pinpress_default
46
+ default_pin_template: pinpress_default
47
+ default_tag_template: pinpress_default
40
48
  log_level: WARN
41
- version: 1.0.1
42
- api_token: '12345'
43
- templates:
49
+ version: 1.1.0
50
+ api_token: bachya:12345
51
+ pin_templates:
44
52
  - name: pinpress_default
45
- opener: "<ul>"
46
- item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
47
- description %></a>.</b> <%= extended %></li>"
53
+ opener: |
54
+ <ul>
55
+ item: |
56
+ <li>
57
+ <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
58
+ <%= extended %>
59
+ </li>
48
60
  closer: "</ul>"
49
- - name: secondary
50
- item: "* <%= href %>"
51
- """
52
- When I run `pinpress template list` interactively
53
- Then the exit status should be 0
54
- And the output should contain:
55
- """
56
- ---> AVAILABLE TEMPLATES
57
- # 1. pinpress_default
58
- # 2. secondary
59
- """
60
-
61
- Scenario: Choose Default Template
62
- Given a file located at "/tmp/pp/.pinpress" with the contents:
63
- """
64
- ---
65
- pinpress:
66
- config_location: "/tmp/pp/.pinpress"
67
- default_template: pinpress_default
68
- log_level: WARN
69
- version: 1.0.1
70
- api_token: '12345'
71
- templates:
61
+ tag_templates:
72
62
  - name: pinpress_default
73
- opener: "<ul>"
74
- item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
75
- description %></a>.</b> <%= extended %></li>"
76
- closer: "</ul>"
77
- - name: secondary
78
- item: "* <%= href %>"
63
+ item: "<%= tag %> (<%= count %>),"
79
64
  """
80
- When I run `pinpress template default` interactively
81
- And I type "4"
82
- And I type "0"
83
- And I type "asd"
84
- And I type "2"
65
+ When I run `pinpress templates list` interactively
85
66
  Then the exit status should be 0
86
67
  And the output should contain:
87
68
  """
88
- ---> CHOOSE A DEFAULT TEMPLATE
89
- # Current Default Template: pinpress_default
90
- # Choose a New Template:
69
+ ---> AVAILABLE PIN TEMPLATES:
70
+ # 1. pinpress_default
71
+ ---> AVAILABLE TAG TEMPLATES:
91
72
  # 1. pinpress_default
92
- # 2. secondary
93
- # Invalid choice: 4
94
- # Invalid choice: 0
95
- # Invalid choice: asd
96
- # New default template chosen: secondary
97
- """
98
- And the file "/tmp/pp/.pinpress" should contain:
99
73
  """
100
- ---
101
- pinpress:
102
- config_location: "/tmp/pp/.pinpress"
103
- default_template: secondary
104
- log_level: WARN
105
- version: 1.0.1
106
- api_token: '12345'
107
- templates:
108
- - name: pinpress_default
109
- opener: "<ul>"
110
- item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
111
- description %></a>.</b> <%= extended %></li>"
112
- closer: "</ul>"
113
- """
@@ -8,18 +8,24 @@ Feature: Templates
8
8
  ---
9
9
  pinpress:
10
10
  config_location: "/tmp/pp/.pinpress"
11
- default_template: pinpress_default
11
+ default_pin_template: pinpress_default
12
+ default_tag_template: pinpress_default
12
13
  log_level: WARN
13
- version: 1.0.1
14
- api_token: '12345'
15
- templates:
14
+ version: 1.1.0
15
+ api_token: bachya:12345
16
+ pin_templates:
16
17
  - name: pinpress_default
17
- opener: "<ul>"
18
- item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
19
- description %></a>.</b> <%= extended %></li>"
18
+ opener: |
19
+ <ul>
20
+ item: |
21
+ <li>
22
+ <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
23
+ <%= extended %>
24
+ </li>
20
25
  closer: "</ul>"
21
- - name: secondary
22
- item: "* <%= href %>"
26
+ tag_templates:
27
+ - name: pinpress_default
28
+ item: "<%= tag %> (<%= count %>),"
23
29
  """
24
30
  When I run `pinpress pins` interactively
25
31
  Then the exit status should be 1
@@ -10,49 +10,12 @@ module PinPress
10
10
  # Stores whether initalization has completed.
11
11
  # @return [Boolean]
12
12
  attr_reader :initialized
13
-
13
+
14
14
  # Stores whether verbose output is turned on.
15
15
  # @return [Boolean]
16
16
  attr_accessor :verbose
17
17
  end
18
18
 
19
- # Presents the user with a list of templates and
20
- # allows them to choose one.
21
- # @return [void]
22
- def self.choose_default_template
23
- templates = configuration.templates
24
- if !templates.nil?
25
- messenger.section('CHOOSE A DEFAULT TEMPLATE')
26
- messenger.success("Current Default Template: #{ configuration.pinpress[:default_template] }")
27
- messenger.info("Choose a New Template:")
28
- templates.each_with_index do |template, index|
29
- messenger.info("#{ index + 1}. #{ template[:name] }")
30
- end
31
-
32
- # Loop through the possible template choices and collect the user's
33
- # input. If a valid choice is made, set the default; otherwise,
34
- # force the user to pick.
35
- valid_choice_made = false
36
- until valid_choice_made
37
- choice = messenger.prompt("Choose from the list above")
38
- array_index = choice.to_i - 1
39
-
40
- if array_index >= 0 && !templates[array_index].nil?
41
- default_template_name = templates[array_index][:name]
42
- configuration.pinpress[:default_template] = default_template_name
43
- configuration.save
44
-
45
- messenger.success("New default template chosen: #{ default_template_name }")
46
- valid_choice_made = true
47
- else
48
- messenger.error("Invalid choice: #{ choice }")
49
- end
50
- end
51
- else
52
- messenger.warn('No templates defined...')
53
- end
54
- end
55
-
56
19
  def self.execute_template(template_type, template_name)
57
20
  template_hash = PinPress.get_template_by_name(template_type, template_name)
58
21
  if !template_hash.nil?
@@ -72,23 +35,19 @@ module PinPress
72
35
  case template_type
73
36
  when Template::TEMPLATE_TYPE_PIN
74
37
  default_t_name = configuration.pinpress[:default_pin_template]
75
- if template_name.nil?
76
- t = configuration.pin_templates.find { |t| t[:name] == default_t_name }
77
- else
78
- t = configuration.pin_templates.find { |t| t[:name] == template_name }
79
- end
38
+ templates = configuration.pin_templates
80
39
  when Template::TEMPLATE_TYPE_TAG
81
40
  default_t_name = configuration.pinpress[:default_tag_template]
82
- if template_name.nil?
83
- t = configuration.tag_templates.find { |t| t[:name] == default_t_name }
84
- else
85
- t = configuration.tag_templates.find { |t| t[:name] == template_name }
86
- end
41
+ templates = configuration.tag_templates
87
42
  else
88
43
  fail 'Invalid template type given'
89
44
  end
90
45
 
91
- t
46
+ if template_name.nil?
47
+ return templates.find { |t| t[:name] == default_t_name }
48
+ else
49
+ return templates.find { |t| t[:name] == template_name }
50
+ end
92
51
  end
93
52
 
94
53
  # Initializes PinPress by downloading and
@@ -96,56 +55,69 @@ module PinPress
96
55
  # @param [Boolean] from_scratch
97
56
  # @return [void]
98
57
  def self.init(from_scratch = false)
99
- messenger.section_block('INITIALIZING') {
100
- if from_scratch
101
- configuration.reset
102
- configuration.add_section(:pinpress)
103
- configuration.add_section(:pin_templates)
104
- configuration.add_section(:tag_templates)
105
-
106
- default_pin_template = {
107
- name: 'pinpress_default',
108
- opener: '<ul>',
109
- item: '<li><b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b> <%= extended %></li>',
110
- item_separator: "\n",
111
- closer: '</ul>'
112
- }
113
-
114
- default_tag_template = {
115
- name: 'pinpress_default',
116
- item: "<%= tag %> (<%= count %>),",
117
- item_separator: ","
118
- }
119
-
120
- configuration.data['pin_templates'] = [default_pin_template]
121
- configuration.data['tag_templates'] = [default_tag_template]
122
-
123
- configuration.pinpress.merge!({
124
- config_location: configuration.config_path,
125
- default_pin_template: 'pinpress_default',
126
- default_tag_template: 'pinpress_default',
127
- log_level: 'WARN',
128
- version: PinPress::VERSION,
129
- })
130
- end
58
+ messenger.section('INITIALIZING...')
59
+ if from_scratch
60
+ configuration.reset
61
+ configuration.add_section(:pinpress)
62
+ configuration.add_section(:pin_templates)
63
+ configuration.add_section(:tag_templates)
64
+
65
+ default_pin_template = {
66
+ name: 'pinpress_default',
67
+ opener: "<ul>\n",
68
+ item: %q(<li>
69
+ <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
70
+ <%= extended %>
71
+ </li>) + "\n",
72
+ closer: '</ul>'
73
+ }
131
74
 
132
- pm = CLIUtils::Prefs.new(PinPress::PREF_FILES['INIT'], configuration)
133
- pm.ask
134
- configuration.ingest_prefs(pm)
75
+ default_tag_template = {
76
+ name: 'pinpress_default',
77
+ item: '<%= tag %> (<%= count %>),'
78
+ }
135
79
 
136
- messenger.debug { "Configuration values after pref collection: #{ configuration.data }" }
137
- configuration.save
138
- @initialized = true
80
+ configuration.data['pin_templates'] = [default_pin_template]
81
+ configuration.data['tag_templates'] = [default_tag_template]
82
+
83
+ configuration.pinpress.merge!(
84
+ config_location: configuration.config_path,
85
+ default_pin_template: 'pinpress_default',
86
+ default_tag_template: 'pinpress_default',
87
+ log_level: 'WARN',
88
+ version: PinPress::VERSION
89
+ )
90
+ end
91
+
92
+ pm = CLIUtils::Prefs.new(PinPress::PREF_FILES['INIT'], configuration)
93
+ pm.ask
94
+ configuration.ingest_prefs(pm)
95
+
96
+ messenger.debug {
97
+ "Configuration values after pref collection: #{ configuration.data }"
139
98
  }
99
+ configuration.save
100
+ @initialized = true
140
101
  end
141
102
 
142
103
  # Present a list of installed templates to the user
143
104
  # @return [void]
144
105
  def self.list_templates
145
- templates = configuration.templates
146
- if !templates.nil?
147
- messenger.section('AVAILABLE TEMPLATES')
148
- templates.each_with_index do |template, index|
106
+ pin_templates = configuration.pin_templates
107
+ tag_templates = configuration.tag_templates
108
+
109
+ messenger.section('AVAILABLE PIN TEMPLATES:')
110
+ if !pin_templates.nil?
111
+ pin_templates.each_with_index do |template, index|
112
+ messenger.info("#{ index + 1 }. #{ template[:name] }")
113
+ end
114
+ else
115
+ messenger.warn('No templates defined...')
116
+ end
117
+
118
+ messenger.section('AVAILABLE TAG TEMPLATES:')
119
+ if !tag_templates.nil?
120
+ tag_templates.each_with_index do |template, index|
149
121
  messenger.info("#{ index + 1 }. #{ template[:name] }")
150
122
  end
151
123
  else
@@ -1,3 +1,5 @@
1
+ # The PinPress module, which wraps everything
2
+ # in this gem.
1
3
  module PinPress
2
4
  # The default local filepath of the Siftter Redux config file
3
5
  CONFIG_FILEPATH = File.join(ENV['HOME'], '.pinpress')
@@ -6,19 +8,25 @@ module PinPress
6
8
  LOG_FILEPATH = File.join(ENV['HOME'], '.pinpress_log')
7
9
 
8
10
  # The Gem's description
9
- DESCRIPTION = 'A Pinboard application that allows for the creation of "pin templates" in almost any conceivable format.'
11
+ DESCRIPTION = %q(A Pinboard application that allows for the creation of
12
+ pin and tag templates in almost any conceivable format.)
10
13
 
11
14
  # The last version to require a config update
12
- NEWEST_CONFIG_VERSION = '1.0.0'
15
+ NEWEST_CONFIG_VERSION = '1.1.0'
13
16
 
14
17
  # Hash of preference files
15
18
  PREF_FILES = {
16
- 'INIT' => File.join(File.dirname(__FILE__), '..', '..', 'res/preference_prompts.yaml')
19
+ 'INIT' => File.join(
20
+ File.dirname(__FILE__),
21
+ '..',
22
+ '..',
23
+ 'res/preference_prompts.yaml'
24
+ )
17
25
  }
18
26
 
19
27
  # The Gem's summary
20
28
  SUMMARY = 'A simple CLI to create HTML templates of Pinboard data.'
21
29
 
22
30
  # The Gem's version
23
- VERSION = '1.0.2'
31
+ VERSION = '1.1.0'
24
32
  end
@@ -1,5 +1,7 @@
1
1
  module PinPress
2
+ # A template for a pin; even though
3
+ # currently empty, allows for future
4
+ # flexibility.
2
5
  class PinTemplate < Template
3
-
4
6
  end
5
- end
7
+ end
@@ -1,5 +1,7 @@
1
1
  module PinPress
2
+ # A template for a tag; even though
3
+ # currently empty, allows for future
4
+ # flexibility.
2
5
  class TagTemplate < Template
3
-
4
6
  end
5
- end
7
+ end
@@ -1,16 +1,41 @@
1
1
  module PinPress
2
+ # A template for outputting Pinboard data
2
3
  class Template
4
+ # Defines a pin template
5
+ # @return [Fixnum]
3
6
  TEMPLATE_TYPE_PIN = 1
7
+
8
+ # Defines a tag template
9
+ # @return [Fixnum]
4
10
  TEMPLATE_TYPE_TAG = 2
5
11
 
12
+ # Holds the "closer" (the string that
13
+ # should come after all template items
14
+ # are output)
15
+ # @return [String]
6
16
  attr_accessor :closer
17
+
18
+ # Holds the string that defines what
19
+ # an item should look like.
20
+ # @return [String]
7
21
  attr_accessor :item
8
- attr_accessor :item_separator
22
+
23
+ # Holds the name of the template.
24
+ # @return [String]
9
25
  attr_accessor :name
26
+
27
+ # Holds the "opener" (the string that
28
+ # should come before all template items
29
+ # are output)
30
+ # @return [String]
10
31
  attr_accessor :opener
11
32
 
33
+ # Initializes this class by ingesting
34
+ # passed parameters.
35
+ # @param [Hash]
36
+ # @return [void]
12
37
  def initialize(params = {})
13
38
  params.each { |key, value| send("#{ key }=", value) }
14
39
  end
15
40
  end
16
- end
41
+ end
@@ -1,28 +1,19 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'pinpress/constants'
5
-
6
- Gem::Specification.new do |spec|
1
+ require File.join([File.dirname(__FILE__), 'lib', 'pinpress', 'constants.rb'])
2
+ Gem::Specification.new do |spec|
7
3
  spec.name = 'pinpress'
8
4
  spec.version = PinPress::VERSION
9
- spec.authors = ['Aaron Bach']
10
- spec.email = ['bachya1208@googlemail.com']
5
+ spec.authors = ["Aaron Bach"]
6
+ spec.email = ["bachya1208@googlemail.com"]
11
7
  spec.summary = PinPress::SUMMARY
12
8
  spec.description = PinPress::DESCRIPTION
13
- spec.homepage = 'https://github.com/bachya/PinPress'
9
+ spec.homepage = 'http://www.bachyaproductions.com/pinpress-joining-pinboard-wordpress/'
14
10
  spec.license = 'MIT'
15
- spec.platform = Gem::Platform::RUBY
16
11
 
17
- spec.require_paths = ["lib"]
18
- spec.files = `git ls-files`.split("\n")
12
+ spec.files = `git ls-files -z`.split("\x0")
19
13
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
14
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
-
22
- spec.license = 'MIT'
23
- spec.rdoc_options = ['--charset=UTF-8']
24
- spec.extra_rdoc_files = %w[README.md HISTORY.md LICENSE]
25
-
15
+ spec.require_paths = ["lib"]
16
+
26
17
  spec.add_development_dependency('rake', '10.1.1')
27
18
  spec.add_development_dependency('rdoc', '4.1.1')
28
19
  spec.add_development_dependency('aruba', '0.5.4')
@@ -31,3 +22,4 @@ Gem::Specification.new do |spec|
31
22
  spec.add_runtime_dependency('gli','2.9.0')
32
23
  spec.add_runtime_dependency('pinboard', '0.1.1')
33
24
  end
25
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pinpress
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Bach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-18 00:00:00.000000000 Z
11
+ date: 2014-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -108,24 +108,21 @@ dependencies:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.1.1
111
- description: A Pinboard application that allows for the creation of "pin templates"
112
- in almost any conceivable format.
111
+ description: |-
112
+ A Pinboard application that allows for the creation of
113
+ pin and tag templates in almost any conceivable format.
113
114
  email:
114
115
  - bachya1208@googlemail.com
115
116
  executables:
116
117
  - PinPress
117
118
  extensions: []
118
- extra_rdoc_files:
119
- - README.md
120
- - HISTORY.md
121
- - LICENSE
119
+ extra_rdoc_files: []
122
120
  files:
123
121
  - ".gitignore"
124
122
  - ".travis.yml"
125
123
  - Gemfile
126
124
  - HISTORY.md
127
125
  - LICENSE
128
- - PinPress.gemspec
129
126
  - README.md
130
127
  - Rakefile
131
128
  - bin/PinPress
@@ -140,17 +137,17 @@ files:
140
137
  - lib/PinPress/templates/pin_template.rb
141
138
  - lib/PinPress/templates/tag_template.rb
142
139
  - lib/PinPress/templates/template.rb
140
+ - pinpress.gemspec
143
141
  - res/preference_prompts.yaml
144
142
  - res/sample_config.yaml
145
143
  - test/default_test.rb
146
144
  - test/test_helper.rb
147
- homepage: https://github.com/bachya/PinPress
145
+ homepage: http://www.bachyaproductions.com/pinpress-joining-pinboard-wordpress/
148
146
  licenses:
149
147
  - MIT
150
148
  metadata: {}
151
149
  post_install_message:
152
- rdoc_options:
153
- - "--charset=UTF-8"
150
+ rdoc_options: []
154
151
  require_paths:
155
152
  - lib
156
153
  required_ruby_version: !ruby/object:Gem::Requirement