pinpress 1.4.2 → 1.5.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: 0e914899e1c35ca22202b9ec594bfaa096d10835
4
- data.tar.gz: 8547f9bb8e6a29818f6fe24aaaf64c1aec487fa7
3
+ metadata.gz: cb9834c1b4b146171b5dd3775335edc642590a30
4
+ data.tar.gz: 43363332876a9e29eec3a8fee3ca921a0bad00c1
5
5
  SHA512:
6
- metadata.gz: 7cbf914686ec155cdf2bf989a912fbf307fcb43152f161f27100639884e5162dfb5bf7009c316ae50badb326c7df96ada8d21f0c9df988ca1b32a76340e40ca1
7
- data.tar.gz: 8b8033020e7f7394c042441496b30381b96efeea00446f6197f8ad23ad5594d2c929153596d14251f80bdca90a914f270cbb0d2a65f03591d42b169f9c5bee90
6
+ metadata.gz: dad5319aac8cef3d99bb986beb9eb3dac341acb97ab019ae5a812cd36a935135a6a6a10eb1b648bf0148213059416fd783ed3055de1788b2c23d961de3ad3a9c
7
+ data.tar.gz: 37711b8fc8f9db2968133dff075424eb0ddf6c1a1398692e9d5a041c739e41425ebda9f070645e9d29d309296815910f0e90989f41acf369d29631e2436ae64f
data/HISTORY.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 1.5.0 (2014-05-21)
2
+
3
+ * Applied default tags and ignored tags to templates, rather than globally
4
+ * `last` commands will run every time, even if they've never run before
5
+ * Small refactorings
6
+
1
7
  # 1.4.2 (2014-05-16)
2
8
 
3
9
  * Some small refactorings
data/bin/pinpress CHANGED
@@ -148,7 +148,7 @@ command :pins do |c|
148
148
  opts = {}
149
149
  opts.merge!(todt: Chronic.parse(options[:e])) if options[:e]
150
150
  opts.merge!(fromdt: Chronic.parse(options[:s])) if options[:s]
151
- opts.merge!(PinPress.merge_common_options(options))
151
+ opts.merge!(PinPress.merge_common_options(options, template_name, PinPress::Template::TYPE_PIN))
152
152
 
153
153
  # Request pin data from Pinboard and output the return data.
154
154
  output = PinPress.pin_yield(template, opts)
@@ -168,24 +168,25 @@ command :pins do |c|
168
168
  # and/or the presence of a default template.
169
169
  template_name, template = PinPress.init_template(options[:m], PinPress::Template::TYPE_PIN)
170
170
 
171
+ opts = {}
172
+
171
173
  last_run_date = configuration.pin_templates.find { |t| t.keys[0] == template_name.to_sym }.values[0].last_run
172
174
  if last_run_date
173
175
  # Set one option: the start date. Set it to the last-run date + 1.
174
- opts = {}
175
176
  opts.merge!(fromdt: DateTime.parse(last_run_date) + 1)
176
- opts.merge!(PinPress.merge_common_options(options))
177
+ end
177
178
 
178
- # Request pin data from Pinboard and output the return data.
179
- output = PinPress.pin_yield(template, opts)
180
- puts output if output
179
+ # Set our common options.
180
+ opts.merge!(PinPress.merge_common_options(options, template_name, PinPress::Template::TYPE_PIN))
181
181
 
182
- # Save the last-run date to the configuration file.
183
- configuration.pin_templates.find { |t| t.keys[0] == template_name.to_sym}.values[0].last_run = Time.now.utc.iso8601
184
- configuration.save
185
- else
186
- messenger.warn("`pinpress pins` hasn't been run before.")
187
- end
188
- end
182
+ # Request pin data from Pinboard and output the return data.
183
+ output = PinPress.pin_yield(template, opts)
184
+ puts output if output
185
+
186
+ # Save the last-run date to the configuration file.
187
+ configuration.pin_templates.find { |t| t.keys[0] == template_name.to_sym}.values[0].last_run = Time.now.utc.iso8601
188
+ configuration.save
189
+ end
189
190
  end
190
191
  end
191
192
 
@@ -214,7 +215,7 @@ command :tags do |c|
214
215
  opts = {}
215
216
  opts.merge!(todt: Chronic.parse(options[:e])) if options[:e]
216
217
  opts.merge!(fromdt: Chronic.parse(options[:s])) if options[:s]
217
- opts.merge!(PinPress.merge_common_options(options))
218
+ opts.merge!(PinPress.merge_common_options(options, template_name, PinPress::Template::TYPE_PIN))
218
219
 
219
220
  # Request tag data from Pinboard and output the return data.
220
221
  output = PinPress.tag_yield(template, opts)
@@ -233,27 +234,28 @@ command :tags do |c|
233
234
  # and/or the presence of a default template.
234
235
  template_name, template = PinPress.init_template(options[:m], PinPress::Template::TYPE_TAG)
235
236
 
237
+ opts = {}
238
+
236
239
  last_run_date = configuration.tag_templates.find { |t| t.keys[0] == template_name.to_sym }.values[0].last_run
237
240
  if last_run_date
238
241
  PinPress.verbose = global_options[:v]
239
242
 
240
243
  # Set one option: the start date. Set it to the last-run date + 1.
241
- opts = {}
242
244
  opts.merge!(fromdt: DateTime.parse(last_run_date) + 1)
243
- opts.merge!(PinPress.merge_common_options(options))
244
-
245
- # Request tag data from Pinboard and output the return data.
246
- output = PinPress.tag_yield(template, opts)
247
- puts output if output
248
-
249
- # Save the last-run date to the configuration file.
250
- t_config = configuration.tag_templates.find { |t| t.keys[0] == template_name.to_sym}.values[0]
251
- t_config.last_run = Time.now.utc.iso8601
252
- configuration.save
253
- else
254
- messenger.warn("`pinpress tags` hasn't been run before.")
255
245
  end
256
- end
246
+
247
+ # Set our common options.
248
+ opts.merge!(PinPress.merge_common_options(options, template_name, PinPress::Template::TYPE_PIN))
249
+
250
+ # Request tag data from Pinboard and output the return data.
251
+ output = PinPress.tag_yield(template, opts)
252
+ puts output if output
253
+
254
+ # Save the last-run date to the configuration file.
255
+ t_config = configuration.tag_templates.find { |t| t.keys[0] == template_name.to_sym}.values[0]
256
+ t_config.last_run = Time.now.utc.iso8601
257
+ configuration.save
258
+ end
257
259
  end
258
260
  end
259
261
 
data/lib/pinpress.rb CHANGED
@@ -159,18 +159,25 @@ module PinPress
159
159
  # and tag requests.
160
160
  # @param [Hash] options
161
161
  # @return [Hash]
162
- def merge_common_options(options)
162
+ def merge_common_options(options, template_name, template_type)
163
+ case template_type
164
+ when PinPress::Template::TYPE_PIN
165
+ section = configuration.pin_templates.find { |t| t.keys[0] == template_name.to_sym}.values[0]
166
+ when PinPress::Template::TYPE_TAG
167
+ section = configuration.tag_templates.find { |t| t.keys[0] == template_name.to_sym}.values[0]
168
+ end
169
+
163
170
  opts = {}
164
171
  if options[:n]
165
172
  opts.merge!(results: options[:n])
166
- elsif configuration.pinpress.default_num_results
167
- opts.merge!(results: configuration.pinpress.default_num_results)
173
+ elsif section.default_num_results
174
+ opts.merge!(results: section.default_num_results)
168
175
  end
169
176
 
170
177
  if options[:t]
171
178
  opts.merge!(tag: options[:t])
172
- elsif configuration.pinpress.default_tags
173
- opts.merge!(tag: configuration.pinpress.default_tags.join(','))
179
+ elsif section.default_tags
180
+ opts.merge!(tag: section.default_tags.join(','))
174
181
  end
175
182
  opts
176
183
  end
@@ -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.4.2'
31
+ VERSION = '1.5.0'
32
32
  end
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.4.2
4
+ version: 1.5.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-05-17 00:00:00.000000000 Z
11
+ date: 2014-05-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aruba