apple-news 0.2.5 → 0.3.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: 1999f6d65250e429481b63570bdc37ef5acaa55b
4
- data.tar.gz: 6cf8e0310a8905d0a65cbbf72c924f51534c0891
3
+ metadata.gz: d9d7cd19f246e56cf2f9f34e75a9f13e4b04af03
4
+ data.tar.gz: 035e174af117ae59fb88c0cb7ad7853a46c992e0
5
5
  SHA512:
6
- metadata.gz: 87939702ec210d09593df11c1e39dc67476cdabd2248a2df1f574b5e171ab00a316979cc322a3ff7f87f86ecf9984c19e6a4493953f4a8001943eca46cf97b93
7
- data.tar.gz: 195138eb2d3924e504ba9f2f6cfc74cc5a92703990a0800213949dbbe88b90a1b647a79a49c9064e49a3f2e4d3393865765e390f1e46125d0b72fa51b09b8cf5
6
+ metadata.gz: bb0246860bc592b2c3998f271af6c408ddce0700f0f249a968867764306596530661248ffd2788271accc3e445e415ec525d5b5342107c818fcd5b37dca1cb9b
7
+ data.tar.gz: 34243c49afbcbeac6263777b5dfeb5ae021c7427f53c5fcc2a1a3d1f15ae5ea1d4dd0516114ec9f0691217cdacefb117fc60f0298d9087583056bab4dcfeb40f
@@ -10,6 +10,7 @@ require 'net/http/post/multipart'
10
10
  require 'apple-news/multipart_post_patch'
11
11
  require 'stringio'
12
12
  require 'open-uri'
13
+ require 'fileutils'
13
14
 
14
15
  require "apple-news/version"
15
16
  require "apple-news/properties"
@@ -34,6 +34,11 @@ module AppleNews
34
34
  hydrate! if !id.nil? && data.keys.size == 0
35
35
  end
36
36
 
37
+ def reload
38
+ return false if id.nil?
39
+ hydrate!
40
+ end
41
+
37
42
  private
38
43
 
39
44
  def hydrate!
@@ -41,7 +46,7 @@ module AppleNews
41
46
 
42
47
  # Some special properties that need to be manually set.
43
48
  @document = Document.new(data.delete('document'))
44
- @share_url = data.delete('share_url')
49
+ @share_url = data.delete('shareUrl')
45
50
  @state = data.delete('state')
46
51
 
47
52
  load_properties(data)
@@ -36,6 +36,20 @@ module AppleNews
36
36
  true
37
37
  end
38
38
 
39
+ def save_to_disk!(path)
40
+ FileUtils.mkdir_p(path)
41
+
42
+ # Write the article.json
43
+ File.write(File.join(path, "article.json"), JSON.dump(document.as_json))
44
+
45
+ # Write all of the bundled files
46
+ @files.each do |name, file|
47
+ File.write(File.join(path, name), file.read)
48
+ end
49
+
50
+ true
51
+ end
52
+
39
53
  private
40
54
 
41
55
  def endpoint_url
@@ -1,3 +1,3 @@
1
1
  module AppleNews
2
- VERSION = "0.2.5"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apple-news
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan LeFevre
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-03 00:00:00.000000000 Z
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler