pinpress 1.1.1 → 1.1.2

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: 470b3cfe5ce7dcb5b42e75d3b25bc28e7e4ee1fb
4
- data.tar.gz: db44436726bde6f1764066ad00cbe573af7bc49d
3
+ metadata.gz: d7185070529faee2eb5ebac9bfc6d005c4d113e0
4
+ data.tar.gz: 26790b6920af2b9902084df5c7dd6bd784011904
5
5
  SHA512:
6
- metadata.gz: 064bebde43fe8a7f6f3f6ce06a27c5edcc044cf43d7656e7c9d3146e6520e45cd985d5767a23133d432aaa67673417c6ef146a64ead7c29c819633b927a59821
7
- data.tar.gz: 1565d6c2de0d61e60229f466b42446e15fad10b5743151ba8417f827bfb56eec17db83bf01c04a79615725265df924f238e57253856b7047821dc5f21e3d3d20
6
+ metadata.gz: 8dadda3e5c48457e5c4dc5e64cc8919a8e6b98c23090ff71e7b526479d3e91dc3e507a4b51e44d49f04c451870e4c6ba56847ce5ac1fe0b7d9edc009578b19d5
7
+ data.tar.gz: 532c8aca16572c57625febb2b2ec00fb7be283a2ab88f7f4bfb188bb3cf80c3f2f201dc645dab500525e6b399d5ea077a5eb65bce426076678df3baafea45580
data/.gitignore CHANGED
@@ -2,6 +2,8 @@
2
2
  doc
3
3
  pkg
4
4
  .yardoc
5
- bin
6
5
  .tmp
7
6
  results.html
7
+ Gemfile.lock
8
+ .simplecov
9
+ coverage
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'simplecov', :require => false, :group => :test
4
+
3
5
  gemspec
data/README.md CHANGED
@@ -1,6 +1,5 @@
1
1
  PinPress
2
2
  ========
3
- [![Build Status](https://travis-ci.org/bachya/PinPress.svg?branch=master)](https://travis-ci.org/bachya/PinPress)
4
3
  [![Gem Version](https://badge.fury.io/rb/pinpress.svg)](http://badge.fury.io/rb/pinpress)
5
4
 
6
5
  PinPress is a simple CLI to create templates (HTML, Markdown, or otherwise) of Pinboard pins and tags.
@@ -28,14 +27,14 @@ Syntax and usage can be accessed by running `pinpress help`:
28
27
  ```
29
28
  $ pinpress help
30
29
  NAME
31
- pinpress - A Pinboard application that allows for the creation of
30
+ pinpress - A Pinboard application that allows for the creation of
32
31
  "pin templates" in almost any conceivable format.
33
32
 
34
33
  SYNOPSIS
35
34
  pinpress [global options] command [command options] [arguments...]
36
35
 
37
36
  VERSION
38
- 1.1.1
37
+ 1.1.2
39
38
 
40
39
  GLOBAL OPTIONS
41
40
  --help - Show this message
@@ -76,7 +75,7 @@ Initialization will prompt you to enter your Pinboard API token. Once, entered,
76
75
 
77
76
  # Templates
78
77
 
79
- 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**.
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**.
80
79
 
81
80
  ## Pin Templates
82
81
 
@@ -223,7 +222,7 @@ Pinpress also provides some flags that allow a user to define specific pins to g
223
222
  * `-s`: the start date to use (uses [Chronic](https://github.com/mojombo/chronic "Chronic"), which allows dates like "last Tuesday")
224
223
  * `-e`: the end date to use (also uses [Chronic](https://github.com/mojombo/chronic "Chronic"))
225
224
  * `-n`: the number of pins to return (e.g., 20)
226
- * `-t`: a CSV list of tags to grab (e.g., "tag1,tag2")
225
+ * `-t`: a CSV list of tags (e.g., "tag1,tag2") that must exist for the returned pins
227
226
 
228
227
  Naturally, these switches can be combined in any number of ways.
229
228
 
@@ -272,6 +271,7 @@ Pinpress also provides some flags that allow a user to define specific tags to g
272
271
 
273
272
  * `-s`: the start date to use (uses [Chronic](https://github.com/mojombo/chronic "Chronic"), which allows dates like "last Tuesday")
274
273
  * `-e`: the end date to use (also uses [Chronic](https://github.com/mojombo/chronic "Chronic"))
274
+ * `-t`: a CSV list of tags (e.g., "tag1,tag2") to examine for association (see [below](#getting-tags-that-have-been-used-with-other-tags)).
275
275
 
276
276
  ## Getting Tags From a Date Forward
277
277
 
@@ -295,11 +295,19 @@ $ pinpress tags -e 2014-01-01
295
295
  $ pinpress tags -s 2014-01-01 -e 2014-01-31
296
296
  ```
297
297
 
298
+ ## Getting Tags that Have Been Used With Other Tags
299
+
300
+ ```
301
+ $ pinpress tags -t 'tag1,tag2' -s 2014-01-01
302
+ ```
303
+
304
+ ...returns all tags that have been used *alongside* `tag1` and `tag2`, starting on Jarnuary 1, 2014.
305
+
298
306
  # Other Configuration Options
299
307
 
300
308
  In addition to `default_pin_template` and `default_tag_template`, you can place some other special keys in the `pinpress` section of `~/.pinpress`:
301
309
 
302
- * `default_tags`: the default tags to be used when getting pins (e.g., `'ruby,pinboard'`). This can be overridden by using the `-t` flag.
310
+ * `default_tags`: the default tags (e.g., `'ruby,pinboard'`) to be used when getting pins or associated tags. This can be overridden by using the `-t` flag.
303
311
  * `default_num_results`: the default number of results to return (e.g., '5'). This can be overridden by using the `-n` flag.
304
312
 
305
313
  # Known Issues & Future Releases
@@ -330,4 +338,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
330
338
 
331
339
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
332
340
 
333
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
341
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile CHANGED
@@ -22,18 +22,23 @@ CLEAN << CUKE_RESULTS
22
22
  desc 'Run Cucumber features'
23
23
  Cucumber::Rake::Task.new(:features) do |t|
24
24
  opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
25
- opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
26
- t.cucumber_opts = opts
25
+ opts += " --tags @active"
26
+ t.cucumber_opts = opts
27
27
  t.fork = false
28
28
  end
29
29
 
30
+ require 'yard'
31
+ desc 'Create YARD documentation'
32
+ YARD::Rake::YardocTask.new do |t|
33
+ end
34
+
30
35
  desc "Release PinPress version #{ version }"
31
36
  task :release => :build do
32
37
  unless `git branch` =~ /^\* master$/
33
38
  puts "You must be on the master branch to release!"
34
39
  exit!
35
40
  end
36
-
41
+
37
42
  sh "git commit --allow-empty -a -m 'Release #{ version }'"
38
43
  sh "git tag v#{ version }"
39
44
  sh "git push origin master"
@@ -48,4 +53,4 @@ task :build do
48
53
  FileUtils.mv("./pinpress-#{ version }.gem", "pkg")
49
54
  end
50
55
 
51
- task :default => [:test, :features]
56
+ task :default => [:features] #:yard, :test, :features
data/bin/pinpress ADDED
@@ -0,0 +1,258 @@
1
+ #!/usr/bin/env ruby
2
+ # Encoding: utf-8
3
+ #--------------------------------------------------------------------
4
+ # PinPress
5
+ #
6
+ # A Pinboard application that allows for the creation of
7
+ # "pin templates" in almost any conceivable format.
8
+ #
9
+ # Copyright (c) 2014
10
+ # Aaron Bach <bachya1208@gmail.com>
11
+ #
12
+ # Permission is hereby granted, free of charge, to any person
13
+ # obtaining a copy of this software and associated documentation
14
+ # files (the "Software"), to deal in the Software without
15
+ # restriction, including without limitation the rights to use,
16
+ # copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ # copies of the Software, and to permit persons to whom the
18
+ # Software is furnished to do so, subject to the following
19
+ # conditions:
20
+ #
21
+ # The above copyright notice and this permission notice shall be
22
+ # included in all copies or substantial portions of the Software.
23
+ #
24
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
26
+ # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
28
+ # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
29
+ # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
30
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
31
+ # OTHER DEALINGS IN THE SOFTWARE.
32
+ #--------------------------------------------------------------------
33
+ require 'chronic'
34
+ require 'cliutils'
35
+ require 'gli'
36
+ require 'pinboard'
37
+ require 'pinpress'
38
+
39
+ include CLIUtils::Configuration
40
+ include CLIUtils::Messaging
41
+ include GLI::App
42
+
43
+ # ======================================================
44
+ # App Info
45
+ # ======================================================
46
+ program_desc PinPress::DESCRIPTION
47
+ version PinPress::VERSION
48
+
49
+ # ======================================================
50
+ # Global Flags and Switches
51
+ # ======================================================
52
+
53
+ # ======================================================
54
+ # Pre, Post, and Error
55
+ # ======================================================
56
+ pre do |global, command, options, args|
57
+ # Load PinPress configuration module.
58
+ load_configuration(PinPress::CONFIG_FILEPATH)
59
+ file_logger = Logger.new(PinPress::LOG_FILEPATH)
60
+ file_logger.level = LOG_LEVELS[configuration.pinpress[:log_level] || 'DEBUG']
61
+ messenger.attach(LOGFILE: file_logger)
62
+
63
+ if File.exist?(PinPress::CONFIG_FILEPATH)
64
+ # Set the current and last config versions in the Configurator.
65
+ configuration.current_version = configuration.pinpress[:version]
66
+ configuration.last_version = PinPress::NEWEST_CONFIG_VERSION
67
+
68
+ # Compare the two versions and, if needed, update.
69
+ configuration.compare_version do |c, l|
70
+ messenger.debug { "Upgrading from #{ c } to #{ l }" }
71
+ PinPress.update_config_file
72
+ exit!(0)
73
+ end
74
+ else
75
+ # Force the user to init if they try to run any command
76
+ # other than `init` first.
77
+ PinPress.init(true)
78
+ exit!(0)
79
+ end
80
+ true
81
+ end
82
+
83
+ post do |global, command, options, args|
84
+
85
+ end
86
+
87
+ on_error do |exception|
88
+ messenger.error(exception.to_s)
89
+ exit!(1)
90
+ true
91
+ end
92
+
93
+ # ======================================================
94
+ # Commands
95
+ # ======================================================
96
+ # ------------------------------------------------------
97
+ # init command
98
+ #
99
+ # Initializes the app by asking the user for information
100
+ # needed to run.
101
+ # ------------------------------------------------------
102
+ desc 'Install and initialize dependencies'
103
+ command :init do |c|
104
+ c.switch([:s], desc: 'Run init from scratch')
105
+ c.action do |global_options, options, args|
106
+ if options[:s]
107
+ PinPress.init(true)
108
+ else
109
+ long_message = "You've already initialized PinPress. Do it again?"
110
+ PinPress.init if messenger.prompt(long_message, 'N').downcase == 'y'
111
+ end
112
+ end
113
+ end
114
+
115
+ # ------------------------------------------------------
116
+ # pins command
117
+ #
118
+ # Gets pins from Pinboard.
119
+ # ------------------------------------------------------
120
+ desc 'Get pins from Pinboard'
121
+ command :pins do |c|
122
+ c.flag([:e], desc: 'The end date to pull pins to')
123
+ c.flag([:n], desc: 'The number of results to return')
124
+ c.flag([:s], desc: 'The start date to pull pins from')
125
+ c.flag([:t], desc: 'The tags to use (e.g., "ruby,pinboard")')
126
+
127
+ c.action do |global_options, options, args|
128
+ # Two scenarios covered here:
129
+ # 1. If the user passes a valid name, grab that template.
130
+ # 2. If no name is passed, grabbed the default template
131
+ # If both of these conditions fail, an error message is shown.
132
+ t_type = PinPress::Template::TEMPLATE_TYPE_PIN
133
+ t_name = args.empty? ? nil : args[0]
134
+
135
+ PinPress.execute_template(t_type, t_name) do |template, client|
136
+ # Create a Pinboard client and set options based on
137
+ # PinPress flags.
138
+ opts = {}
139
+ opts.merge!(todt: Chronic.parse(options[:e])) if options[:e]
140
+ opts.merge!(fromdt: Chronic.parse(options[:s])) if options[:s]
141
+
142
+ if options[:n]
143
+ opts.merge!(results: options[:n])
144
+ elsif configuration.pinpress[:default_num_results]
145
+ opts.merge!(results: configuration.pinpress[:default_num_results])
146
+ end
147
+
148
+ if options[:t]
149
+ opts.merge!(tag: options[:t])
150
+ elsif configuration.pinpress[:default_tags]
151
+ opts.merge!(tag: configuration.pinpress[:default_tags])
152
+ end
153
+
154
+ begin
155
+ pins = client.posts(opts)
156
+ if !pins.empty?
157
+ print template.opener if template.opener
158
+ pins.each do |p|
159
+ href = p[:href]
160
+ description = p[:description]
161
+ extended = p[:extended]
162
+ tag = p[:tag]
163
+ time = p[:time]
164
+ replace = p[:replace]
165
+ shared = p[:shared]
166
+ toread = p[:toread]
167
+
168
+ print ERB.new(template.item).result(binding) if template.item
169
+ end
170
+ print template.closer if template.closer
171
+ else
172
+ messenger.warn('No matching pins...')
173
+ end
174
+ rescue StandardError => e
175
+ messenger.debug(e.to_s)
176
+ raise "Pinboard API failed; are you sure you've run " \
177
+ " `pinpress init` (and that your API key is correct)?"
178
+ end
179
+ end
180
+ end
181
+ end
182
+
183
+ # ------------------------------------------------------
184
+ # tags command
185
+ #
186
+ # Gets pins from Pinboard.
187
+ # ------------------------------------------------------
188
+ desc 'Get tags from Pinboard'
189
+ command :tags do |c|
190
+ c.flag([:e], desc: 'The end date to pull pins to')
191
+ c.flag([:t], desc: 'The tags to use (e.g., "ruby,pinboard")')
192
+ c.flag([:s], desc: 'The start date to pull pins from')
193
+
194
+ c.desc 'Gets the unique tags based on the passed criteria'
195
+ c.action do |global_options, options, args|
196
+ t_type = PinPress::Template::TEMPLATE_TYPE_TAG
197
+ t_name = args.empty? ? nil : args[0]
198
+
199
+ PinPress.execute_template(t_type, t_name) do |template, client|
200
+ tags = []
201
+ opts = {}
202
+ opts.merge!(todt: Chronic.parse(options[:e])) if options[:e]
203
+ opts.merge!(fromdt: Chronic.parse(options[:s])) if options[:s]
204
+
205
+ if options[:t]
206
+ opts.merge!(tag: options[:t])
207
+ elsif configuration.pinpress[:default_tags]
208
+ opts.merge!(tag: configuration.pinpress[:default_tags])
209
+ end
210
+
211
+ begin
212
+ pins = client.posts(opts)
213
+ pins.each { |p| tags += p[:tag] }
214
+ tags = tags.uniq.map { |t| { tag: t, count: tags.count(t) } }
215
+
216
+ if !tags.empty?
217
+ print template.opener if template.opener
218
+ tags.each do |t|
219
+ unless t[:tag] == opts[:tag]
220
+ tag = t[:tag]
221
+ count = t[:count]
222
+ end
223
+
224
+ print ERB.new(template.item).result(binding) if template.item
225
+ end
226
+ print template.closer if template.closer
227
+ else
228
+ message.warn('No matching tags...')
229
+ end
230
+ rescue StandardError => e
231
+ messenger.debug(e.to_s)
232
+ raise "Pinboard API failed; are you sure you've run " \
233
+ " `pinpress init` (and that your API key is correct)?"
234
+ end
235
+ end
236
+ end
237
+ end
238
+
239
+ # ------------------------------------------------------
240
+ # templates command
241
+ #
242
+ # Manages pin templates.
243
+ # ------------------------------------------------------
244
+ desc 'Work with templates for pin output'
245
+ command :templates do |c|
246
+ c.desc 'List current templates'
247
+ c.command :list do |list|
248
+ list.action do |global_options, options, args|
249
+ PinPress.list_templates
250
+ end
251
+ end
252
+ c.default_command :list
253
+ end
254
+
255
+ # ======================================================
256
+ # Run!
257
+ # ======================================================
258
+ exit run(ARGV)
@@ -1,3 +1,4 @@
1
+ @active
1
2
  Feature: UI
2
3
  As a user, when I ask for help, I should be presented
3
4
  with instructions on how to run the app.
@@ -1,3 +1,4 @@
1
+ @active
1
2
  Feature: Initialization
2
3
  As a user, when I initialize PinPress,
3
4
  I should be guided through the process as
@@ -9,60 +10,25 @@ Feature: Initialization
9
10
  And I type ""
10
11
  And I type "bachya:12345"
11
12
  Then the exit status should be 0
12
- And the file "/tmp/pp/.pinpress" should contain:
13
- """
14
- ---
15
- pinpress:
16
- config_location: "/tmp/pp/.pinpress"
17
- default_pin_template: pinpress_default
18
- default_tag_template: pinpress_default
19
- log_level: WARN
20
- version: 1.1.0
21
- api_token: bachya:12345
22
- pin_templates:
23
- - name: pinpress_default
24
- opener: |
25
- <ul>
26
- item: |
27
- <li>
28
- <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
29
- <%= extended %>
30
- </li>
31
- closer: "</ul>"
32
- tag_templates:
33
- - name: pinpress_default
34
- item: "<%= tag %> (<%= count %>),"
35
- """
13
+ And the following files should exist:
14
+ | /tmp/pp/.pinpress |
36
15
 
37
16
  Scenario: Reinitialization (refuse)
38
17
  Given a file located at "/tmp/pp/.pinpress" with the contents:
39
- """
40
- ---
41
- pinpress:
42
- config_location: "/tmp/pp/.pinpress"
43
- default_pin_template: pinpress_default
44
- default_tag_template: pinpress_default
45
- log_level: WARN
46
- version: 1.1.0
47
- api_token: bachya:12345
48
- pin_templates:
49
- - name: pinpress_default
50
- opener: |
51
- <ul>
52
- item: |
53
- <li>
54
- <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
55
- <%= extended %>
56
- </li>
57
- closer: "</ul>"
58
- tag_templates:
59
- - name: pinpress_default
60
- item: "<%= tag %> (<%= count %>),"
61
- """
62
- When I run `pinpress init` interactively
63
- And I type ""
64
- Then the exit status should be 0
65
-
18
+ """
19
+ ---
20
+ pinpress:
21
+ config_location: "/tmp/pp/.pinpress"
22
+ default_pin_template: pinpress_default
23
+ default_tag_template: pinpress_default
24
+ log_level: WARN
25
+ version: 1.1.1
26
+ api_token: bachya:12345
27
+ """
28
+ When I run `pinpress init` interactively
29
+ And I type ""
30
+ Then the exit status should be 0
31
+
66
32
  Scenario: Reinitialization (accept)
67
33
  Given a file located at "/tmp/pp/.pinpress" with the contents:
68
34
  """
@@ -72,52 +38,17 @@ Feature: Initialization
72
38
  default_pin_template: pinpress_default
73
39
  default_tag_template: pinpress_default
74
40
  log_level: WARN
75
- version: 1.1.0
41
+ version: 1.1.1
76
42
  api_token: bachya:12345
77
- pin_templates:
78
- - name: pinpress_default
79
- opener: |
80
- <ul>
81
- item: |
82
- <li>
83
- <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
84
- <%= extended %>
85
- </li>
86
- closer: "</ul>"
87
- tag_templates:
88
- - name: pinpress_default
89
- item: "<%= tag %> (<%= count %>),"
90
43
  """
91
44
  When I run `pinpress init` interactively
92
45
  And I type "y"
93
46
  And I type ""
94
47
  And I type "bachya:12345"
95
48
  Then the exit status should be 0
96
- And the file "/tmp/pp/.pinpress" should contain:
97
- """
98
- ---
99
- pinpress:
100
- config_location: "/tmp/pp/.pinpress"
101
- default_pin_template: pinpress_default
102
- default_tag_template: pinpress_default
103
- log_level: WARN
104
- version: 1.1.0
105
- api_token: bachya:12345
106
- pin_templates:
107
- - name: pinpress_default
108
- opener: |
109
- <ul>
110
- item: |
111
- <li>
112
- <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
113
- <%= extended %>
114
- </li>
115
- closer: "</ul>"
116
- tag_templates:
117
- - name: pinpress_default
118
- item: "<%= tag %> (<%= count %>),"
119
- """
120
-
49
+ And the following files should exist:
50
+ | /tmp/pp/.pinpress |
51
+
121
52
  Scenario: Reinitialization (from scratch)
122
53
  Given a file located at "/tmp/pp/.pinpress" with the contents:
123
54
  """
@@ -127,47 +58,12 @@ Feature: Initialization
127
58
  default_pin_template: pinpress_default
128
59
  default_tag_template: pinpress_default
129
60
  log_level: WARN
130
- version: 1.1.0
61
+ version: 1.1.1
131
62
  api_token: bachya:12345
132
- pin_templates:
133
- - name: pinpress_default
134
- opener: |
135
- <ul>
136
- item: |
137
- <li>
138
- <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
139
- <%= extended %>
140
- </li>
141
- closer: "</ul>"
142
- tag_templates:
143
- - name: pinpress_default
144
- item: "<%= tag %> (<%= count %>),"
145
63
  """
146
64
  When I run `pinpress init -s` interactively
147
65
  And I type ""
148
66
  And I type "bachya:12345"
149
67
  Then the exit status should be 0
150
- And the file "/tmp/pp/.pinpress" should contain:
151
- """
152
- ---
153
- pinpress:
154
- config_location: "/tmp/pp/.pinpress"
155
- default_pin_template: pinpress_default
156
- default_tag_template: pinpress_default
157
- log_level: WARN
158
- version: 1.1.0
159
- api_token: bachya:12345
160
- pin_templates:
161
- - name: pinpress_default
162
- opener: |
163
- <ul>
164
- item: |
165
- <li>
166
- <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
167
- <%= extended %>
168
- </li>
169
- closer: "</ul>"
170
- tag_templates:
171
- - name: pinpress_default
172
- item: "<%= tag %> (<%= count %>),"
173
- """
68
+ And the following files should exist:
69
+ | /tmp/pp/.pinpress |
@@ -1,7 +1,8 @@
1
+ @active
1
2
  Feature: Templates
2
3
  As a user, I should be able to list available
3
4
  templates and choose one.
4
-
5
+
5
6
  Scenario: List Templates (implicit)
6
7
  Given a file located at "/tmp/pp/.pinpress" with the contents:
7
8
  """
@@ -11,21 +12,12 @@ Feature: Templates
11
12
  default_pin_template: pinpress_default
12
13
  default_tag_template: pinpress_default
13
14
  log_level: WARN
14
- version: 1.1.0
15
+ version: 1.1.1
15
16
  api_token: bachya:12345
16
17
  pin_templates:
17
18
  - name: pinpress_default
18
- opener: |
19
- <ul>
20
- item: |
21
- <li>
22
- <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
23
- <%= extended %>
24
- </li>
25
- closer: "</ul>"
26
19
  tag_templates:
27
20
  - name: pinpress_default
28
- item: "<%= tag %> (<%= count %>),"
29
21
  """
30
22
  When I run `pinpress templates` interactively
31
23
  Then the exit status should be 0
@@ -36,7 +28,7 @@ Feature: Templates
36
28
  ---> AVAILABLE TAG TEMPLATES:
37
29
  # 1. pinpress_default
38
30
  """
39
-
31
+
40
32
  Scenario: List Templates (explicit)
41
33
  Given a file located at "/tmp/pp/.pinpress" with the contents:
42
34
  """
@@ -46,21 +38,12 @@ Feature: Templates
46
38
  default_pin_template: pinpress_default
47
39
  default_tag_template: pinpress_default
48
40
  log_level: WARN
49
- version: 1.1.0
41
+ version: 1.1.1
50
42
  api_token: bachya:12345
51
43
  pin_templates:
52
44
  - name: pinpress_default
53
- opener: |
54
- <ul>
55
- item: |
56
- <li>
57
- <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
58
- <%= extended %>
59
- </li>
60
- closer: "</ul>"
61
45
  tag_templates:
62
46
  - name: pinpress_default
63
- item: "<%= tag %> (<%= count %>),"
64
47
  """
65
48
  When I run `pinpress templates list` interactively
66
49
  Then the exit status should be 0
@@ -1,7 +1,8 @@
1
+ @active
1
2
  Feature: Templates
2
3
  As a user, I should be able get pins from Pinboard
3
4
  and have them inherit certain templates.
4
-
5
+
5
6
  Scenario: Invalid API Key
6
7
  Given a file located at "/tmp/pp/.pinpress" with the contents:
7
8
  """
@@ -11,21 +12,8 @@ Feature: Templates
11
12
  default_pin_template: pinpress_default
12
13
  default_tag_template: pinpress_default
13
14
  log_level: WARN
14
- version: 1.1.0
15
+ version: 1.1.1
15
16
  api_token: bachya:12345
16
- pin_templates:
17
- - name: pinpress_default
18
- opener: |
19
- <ul>
20
- item: |
21
- <li>
22
- <b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b>
23
- <%= extended %>
24
- </li>
25
- closer: "</ul>"
26
- tag_templates:
27
- - name: pinpress_default
28
- item: "<%= tag %> (<%= count %>),"
29
17
  """
30
18
  When I run `pinpress pins` interactively
31
19
  Then the exit status should be 1
@@ -1,4 +1,6 @@
1
+ require 'simplecov'
1
2
  require 'aruba/cucumber'
3
+ require 'cucumber/rspec/doubles'
2
4
 
3
5
  ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
4
6
  LIB_DIR = File.join(File.expand_path(File.dirname(__FILE__)),'..','..','lib')
data/lib/pinpress.rb CHANGED
@@ -16,6 +16,12 @@ module PinPress
16
16
  attr_accessor :verbose
17
17
  end
18
18
 
19
+ # Establishes the template to use and yields a block with that
20
+ # template an a Pinboard client.
21
+ # @param [Fixnum] template_type Either a Pin or Tag template
22
+ # @param [String] template_name The neame of the template to use
23
+ # @yield
24
+ # @return [void]
19
25
  def self.execute_template(template_type, template_name)
20
26
  template_hash = PinPress.get_template_by_name(template_type, template_name)
21
27
  if !template_hash.nil?
@@ -62,13 +68,18 @@ module PinPress
62
68
  configuration.add_section(:pin_templates)
63
69
  configuration.add_section(:tag_templates)
64
70
 
71
+ configuration.pinpress.merge!(
72
+ config_location: configuration.config_path,
73
+ default_pin_template: 'pinpress_default',
74
+ default_tag_template: 'pinpress_default',
75
+ log_level: 'WARN',
76
+ version: PinPress::VERSION
77
+ )
78
+
65
79
  default_pin_template = {
66
80
  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",
81
+ opener: '<ul>',
82
+ item: '<li><b><a title="<%= description %>" href="<%= href %>" target="_blank"><%= description %></a>.</b><%= extended %></li>',
72
83
  closer: '</ul>'
73
84
  }
74
85
 
@@ -79,14 +90,6 @@ module PinPress
79
90
 
80
91
  configuration.data['pin_templates'] = [default_pin_template]
81
92
  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
93
  end
91
94
 
92
95
  pm = CLIUtils::Prefs.new(PinPress::PREF_FILES['INIT'], configuration)
@@ -28,5 +28,5 @@ module PinPress
28
28
  SUMMARY = 'A simple CLI to create HTML templates of Pinboard data.'
29
29
 
30
30
  # The Gem's version
31
- VERSION = '1.1.1'
31
+ VERSION = '1.1.2'
32
32
  end
@@ -3,5 +3,11 @@ module PinPress
3
3
  # currently empty, allows for future
4
4
  # flexibility.
5
5
  class PinTemplate < Template
6
+ # Initializes a new Pin Template.
7
+ # @param [Hash] params
8
+ # @return [void]
9
+ def initialize(params = {})
10
+ super(params)
11
+ end
6
12
  end
7
13
  end
@@ -3,5 +3,11 @@ module PinPress
3
3
  # currently empty, allows for future
4
4
  # flexibility.
5
5
  class TagTemplate < Template
6
+ # Initializes a new Tag Template.
7
+ # @param [Hash] params
8
+ # @return [void]
9
+ def initialize(params = {})
10
+ super(params)
11
+ end
6
12
  end
7
13
  end
@@ -32,7 +32,7 @@ module PinPress
32
32
 
33
33
  # Initializes this class by ingesting
34
34
  # passed parameters.
35
- # @param [Hash]
35
+ # @param [Hash] params
36
36
  # @return [void]
37
37
  def initialize(params = {})
38
38
  params.each { |key, value| send("#{ key }=", value) }
data/pinpress.gemspec CHANGED
@@ -14,12 +14,14 @@ Gem::Specification.new do |spec|
14
14
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
15
15
  spec.require_paths = ["lib"]
16
16
 
17
+ spec.add_development_dependency('aruba', '0.5.4')
17
18
  spec.add_development_dependency('rake', '10.1.1')
18
19
  spec.add_development_dependency('rdoc', '4.1.1')
19
- spec.add_development_dependency('aruba', '0.5.4')
20
+ spec.add_development_dependency('rspec', '2.14.1')
21
+ spec.add_development_dependency('yard', '0.8.7.4')
20
22
  spec.add_runtime_dependency('chronic', '0.10.2')
21
- spec.add_runtime_dependency('cliutils', '~> 2.0')
22
- spec.add_runtime_dependency('gli','2.9.0')
23
+ spec.add_runtime_dependency('cliutils', '~> 2.1')
24
+ spec.add_runtime_dependency('gli', '2.9.0')
23
25
  spec.add_runtime_dependency('pinboard', '0.1.1')
24
26
  end
25
27
 
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ require File.join(File.dirname(__FILE__), '..', 'lib/pinpress/templates/template')
4
+ require File.join(File.dirname(__FILE__), '..', 'lib/pinpress/templates/pin_template')
5
+
6
+ class TestPinTemplate < Test::Unit::TestCase
7
+ def test_initialization
8
+ parameters = {
9
+ closer: '</ul>',
10
+ item: '<li></li>',
11
+ name: 'default',
12
+ opener: '</ul>',
13
+ }
14
+
15
+ t = PinPress::PinTemplate.new(parameters)
16
+ assert_equal(t.closer, parameters[:closer])
17
+ assert_equal(t.item, parameters[:item])
18
+ assert_equal(t.name, parameters[:name])
19
+ assert_equal(t.opener, parameters[:opener])
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ require 'test_helper'
2
+
3
+ require File.join(File.dirname(__FILE__), '..', 'lib/pinpress/templates/template')
4
+
5
+ class TestPinPressTemplate < Test::Unit::TestCase
6
+ def test_initialization
7
+ parameters = {
8
+ closer: '</ul>',
9
+ item: '<li></li>',
10
+ name: 'default',
11
+ opener: '</ul>',
12
+ }
13
+
14
+ t = PinPress::Template.new(parameters)
15
+ assert_equal(t.closer, parameters[:closer])
16
+ assert_equal(t.item, parameters[:item])
17
+ assert_equal(t.name, parameters[:name])
18
+ assert_equal(t.opener, parameters[:opener])
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ require 'test_helper'
2
+
3
+ require File.join(File.dirname(__FILE__), '..', 'lib/pinpress/templates/template')
4
+ require File.join(File.dirname(__FILE__), '..', 'lib/pinpress/templates/tag_template')
5
+
6
+ class TestTagTemplate < Test::Unit::TestCase
7
+ def test_initialization
8
+ parameters = {
9
+ closer: '</ul>',
10
+ item: '<li></li>',
11
+ name: 'default',
12
+ opener: '</ul>',
13
+ }
14
+
15
+ t = PinPress::TagTemplate.new(parameters)
16
+ assert_equal(t.closer, parameters[:closer])
17
+ assert_equal(t.item, parameters[:item])
18
+ assert_equal(t.name, parameters[:name])
19
+ assert_equal(t.opener, parameters[:opener])
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ ---
2
+ pinpress:
3
+ config_location: "/tmp/test.config"
4
+ default_pin_template: pinpress_default
5
+ default_tag_template: pinpress_default
6
+ log_level: WARN
7
+ version: 1.1.1
8
+ api_token: bachya:12345
9
+ pin_templates:
10
+ - name: pinpress_default
11
+ opener: "<ul>"
12
+ item: "<li><b><a title=\"<%= description %>\" href=\"<%= href %>\" target=\"_blank\"><%=
13
+ description %></a>.</b> <%= extended %></li>"
14
+ closer: "</ul>"
15
+ tag_templates:
16
+ - name: pinpress_default
17
+ item: "<%= tag %>,"
data/test/test_helper.rb CHANGED
@@ -1,9 +1,6 @@
1
+ require 'simplecov'
1
2
  require 'test/unit'
2
3
 
3
- # Add test libraries you want to use here, e.g. mocha
4
-
5
4
  class Test::Unit::TestCase
6
5
 
7
- # Add global extensions to the test case class here
8
-
9
6
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pinpress
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
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-19 00:00:00.000000000 Z
11
+ date: 2014-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aruba
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.5.4
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.5.4
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rake
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,19 +53,33 @@ dependencies:
39
53
  - !ruby/object:Gem::Version
40
54
  version: 4.1.1
41
55
  - !ruby/object:Gem::Dependency
42
- name: aruba
56
+ name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
59
  - - '='
46
60
  - !ruby/object:Gem::Version
47
- version: 0.5.4
61
+ version: 2.14.1
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - '='
53
67
  - !ruby/object:Gem::Version
54
- version: 0.5.4
68
+ version: 2.14.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 0.8.7.4
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 0.8.7.4
55
83
  - !ruby/object:Gem::Dependency
56
84
  name: chronic
57
85
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +100,14 @@ dependencies:
72
100
  requirements:
73
101
  - - "~>"
74
102
  - !ruby/object:Gem::Version
75
- version: '2.0'
103
+ version: '2.1'
76
104
  type: :runtime
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
108
  - - "~>"
81
109
  - !ruby/object:Gem::Version
82
- version: '2.0'
110
+ version: '2.1'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: gli
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -114,19 +142,17 @@ description: |-
114
142
  email:
115
143
  - bachya1208@googlemail.com
116
144
  executables:
117
- - PinPress
145
+ - pinpress
118
146
  extensions: []
119
147
  extra_rdoc_files: []
120
148
  files:
121
149
  - ".gitignore"
122
- - ".travis.yml"
123
150
  - Gemfile
124
- - Gemfile.lock
125
151
  - HISTORY.md
126
152
  - LICENSE
127
153
  - README.md
128
154
  - Rakefile
129
- - bin/PinPress
155
+ - bin/pinpress
130
156
  - features/1.ui.feature
131
157
  - features/2.initialization.feature
132
158
  - features/3.templates.feature
@@ -141,7 +167,10 @@ files:
141
167
  - pinpress.gemspec
142
168
  - res/preference_prompts.yaml
143
169
  - res/sample_config.yaml
144
- - test/default_test.rb
170
+ - test/pin_template_test.rb
171
+ - test/pinpress_template_test.rb
172
+ - test/tag_template_test.rb
173
+ - test/test_files/configuration.yaml
145
174
  - test/test_helper.rb
146
175
  homepage: http://www.bachyaproductions.com/pinpress-joining-pinboard-wordpress/
147
176
  licenses:
@@ -174,5 +203,9 @@ test_files:
174
203
  - features/4.pins.feature
175
204
  - features/step_definitions/pinpress_steps.rb
176
205
  - features/support/env.rb
177
- - test/default_test.rb
206
+ - test/pin_template_test.rb
207
+ - test/pinpress_template_test.rb
208
+ - test/tag_template_test.rb
209
+ - test/test_files/configuration.yaml
178
210
  - test/test_helper.rb
211
+ has_rdoc:
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1.0
4
- - 2.0.0
5
- - 1.9.3
6
- - jruby-19mode
data/Gemfile.lock DELETED
@@ -1,55 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- pinpress (1.1.1)
5
- chronic (= 0.10.2)
6
- cliutils (~> 2.0)
7
- gli (= 2.9.0)
8
- pinboard (= 0.1.1)
9
-
10
- GEM
11
- remote: https://rubygems.org/
12
- specs:
13
- aruba (0.5.4)
14
- childprocess (>= 0.3.6)
15
- cucumber (>= 1.1.1)
16
- rspec-expectations (>= 2.7.0)
17
- builder (3.2.2)
18
- childprocess (0.5.2)
19
- ffi (~> 1.0, >= 1.0.11)
20
- chronic (0.10.2)
21
- cliutils (2.0.2)
22
- cucumber (1.3.14)
23
- builder (>= 2.1.2)
24
- diff-lcs (>= 1.1.3)
25
- gherkin (~> 2.12)
26
- multi_json (>= 1.7.5, < 2.0)
27
- multi_test (>= 0.1.1)
28
- diff-lcs (1.2.5)
29
- ffi (1.9.3)
30
- gherkin (2.12.2)
31
- multi_json (~> 1.3)
32
- gli (2.9.0)
33
- httparty (0.11.0)
34
- multi_json (~> 1.0)
35
- multi_xml (>= 0.5.2)
36
- json (1.8.1)
37
- multi_json (1.9.2)
38
- multi_test (0.1.1)
39
- multi_xml (0.5.5)
40
- pinboard (0.1.1)
41
- httparty (= 0.11.0)
42
- rake (10.1.1)
43
- rdoc (4.1.1)
44
- json (~> 1.4)
45
- rspec-expectations (2.14.5)
46
- diff-lcs (>= 1.1.3, < 2.0)
47
-
48
- PLATFORMS
49
- ruby
50
-
51
- DEPENDENCIES
52
- aruba (= 0.5.4)
53
- pinpress!
54
- rake (= 10.1.1)
55
- rdoc (= 4.1.1)
data/test/default_test.rb DELETED
@@ -1,14 +0,0 @@
1
- require 'test_helper'
2
-
3
- class DefaultTest < Test::Unit::TestCase
4
-
5
- def setup
6
- end
7
-
8
- def teardown
9
- end
10
-
11
- def test_the_truth
12
- assert true
13
- end
14
- end