trefoil 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: adc7d1dd5401c32dd327285a1ce3e19abcfadad43ccc6a0b77cd8fb84ef10fce
4
- data.tar.gz: 4fe016b919392ce8b3c6cab0869f6ad8426a2b58926493411fc8a2e681a5d643
3
+ metadata.gz: 4f1a4186b852b09088347a46d27e9f85e139c15d43d00878489f5f953911bb66
4
+ data.tar.gz: 5ad9c8ebf46635cf4eeec8199627157553d6d213a88c367c5adb15b2393db113
5
5
  SHA512:
6
- metadata.gz: eb556fef835e6de55617d0ebe1a5208a8823caa847ea72d7cef592604092db83d4c6dcefc3bdb79921a5556f08e8f5c7fa6fc5d5e69466c169a84b5ef4b94c6f
7
- data.tar.gz: f4e10541ee9e963e4bd80dfc973d08117fbc033e939945814d074747b188f64f63eb5d1f2ea9f50fc5d2643673c415ae2062d257fa5d6023d66040e81ff30739
6
+ metadata.gz: 75c45ae63bdbce88799aeb3f003c75847ca2629f6162361084e933dc6653138d2af3efd89176a8c6e0f5c4038cb0da70300995a17c25611f8b8e7953c99b4141
7
+ data.tar.gz: cbfc8d0b14f02c4c7c4c22d641c32423fbb4fcc0ac57eb49683142878e18495ede7cc7122473bb75c2a5ed9fc14c563e3c986ad86f9af7d04320e9a036744c72
@@ -3,3 +3,8 @@ Metrics:
3
3
 
4
4
  AllCops:
5
5
  TargetRubyVersion: 2.3
6
+
7
+ Naming/UncommunicativeMethodParamName:
8
+ AllowedNames:
9
+ - op
10
+ - id
@@ -79,7 +79,7 @@ module Trefoil
79
79
  pages = @client.get("#{name}/catalog.json")
80
80
  pages.each do |page|
81
81
  page[:threads].each do |op|
82
- @catalog << op
82
+ @catalog << ThreadStub.new(@client, self, op[:no], op)
83
83
  end
84
84
  end
85
85
  end
@@ -32,6 +32,7 @@ module Trefoil
32
32
  when 400..500
33
33
  raise 'Error making a request' # TODO: Better error handling
34
34
  else
35
+ p endpoint
35
36
  raise 'Unhandled status code' # TODO: better code handling
36
37
  end
37
38
  end
@@ -30,15 +30,15 @@ module Trefoil
30
30
  # Whether this post has an image associated with it
31
31
  # @return [true, false]
32
32
  def image?
33
- !@data[:filename].is_nil?
33
+ !@data[:filename].nil?
34
34
  end
35
35
 
36
- # Url to the image of this post, if any.
36
+ # Image object of this post, if any.
37
37
  # @return [Image, nil] An Image or nil if no image is present.
38
- def image_url
38
+ def image
39
39
  return nil unless image?
40
40
 
41
- Image.new(@data)
41
+ Image.new(@data, @board)
42
42
  end
43
43
 
44
44
  # Url to this post
@@ -20,7 +20,7 @@ module Trefoil
20
20
  # An array of all posts in the thread
21
21
  # @return [Array<Post>] All posts in this thread since last update
22
22
  def posts
23
- @posts = fetch_posts if @posts.nil?
23
+ fetch_posts if @posts.nil?
24
24
  @posts
25
25
  end
26
26
 
@@ -39,9 +39,20 @@ module Trefoil
39
39
 
40
40
  # Fetch all posts into
41
41
  def fetch_posts
42
- @client.get("/#{@board}/thread/#{@id}.json")[:posts].each do |post|
42
+ @posts = []
43
+ @client.get("/#{@board.name}/thread/#{@id}.json")[:posts].each do |post|
43
44
  @posts << Post.new(@client, @board, self, post)
44
45
  end
45
46
  end
46
47
  end
48
+
49
+ # Used for catalog
50
+ class ThreadStub < Thread
51
+ attr_reader :op
52
+
53
+ def initialize(client, board, id, op)
54
+ @op = op
55
+ super(client, board, id)
56
+ end
57
+ end
47
58
  end
@@ -3,5 +3,5 @@
3
3
  # Trefoil container module
4
4
  module Trefoil
5
5
  # Trefoil version number
6
- VERSION = '0.1.0'
6
+ VERSION = '0.1.1'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trefoil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - swarley