sprintly-data-ruby 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e196f4d69f4a89a1cb6ff49b0db66fa251b2fecb
4
- data.tar.gz: 764dc77b570e98d85edc834120fa08387b99cfdd
3
+ metadata.gz: 06e8b3045ff45dd6dee0cfd7d516ef749c9ef5b5
4
+ data.tar.gz: 904354afb6b74a903bbab5629f09b30f47ffd9ff
5
5
  SHA512:
6
- metadata.gz: c85be25bba59f3a465436d135bda95ad1e22fcaddd66a97023313a24526bf0bf30b609c396ad978ce6a4ace3498264078ab84b01a324b328c89b8d96af77ce11
7
- data.tar.gz: 5a530239dd525ebcc17b2fc67e6d2a574883671db4006f7e1a84306025fff6504e61a666c9060e3d470baa6881f8f8bb10157b216464a765d5d380de407f0a78
6
+ metadata.gz: f851594f9bd583f36b51f91272ce976ec1807885e7ba9a9da65f384b388b2433130d9a33d4c5c4ff35a0a8f619d0b84e4f90904f88623088a4c6b1a346d772c0
7
+ data.tar.gz: 35bb0061625ab88cd14c9a9d1dd548e04fcbd058f5600e15324a2896c32ecc5ce268b42d284baae28e8be517c6ed64ddbe1d7f1076139a086f86a50d712961d5
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ test/fixtures
@@ -2,5 +2,6 @@ require_relative "sprintly-data-ruby/version"
2
2
 
3
3
  require_relative "sprintly-data-ruby/connection"
4
4
  require_relative "sprintly-data-ruby/item"
5
+ require_relative "sprintly-data-ruby/product"
5
6
 
6
7
  module Sprintly; end
@@ -2,15 +2,20 @@ require 'json'
2
2
 
3
3
  module Sprintly
4
4
  class Item
5
- ATTRIBUTES = [
5
+ WHITELISTED_ATTRIBUTES = [
6
6
  "status", "description", "tags", "title",
7
7
  "progress", "number", "created_by",
8
8
  "score", "sort", "type", "assigned_to"
9
9
  ].freeze
10
10
 
11
+ def self.for_product(product_id)
12
+ response = Sprintly::Connection.get("products/#{product_id}/items.json")
13
+ raw_items = JSON.parse(response.body)
14
+ raw_items.map { |raw_item| new(raw_item) }
15
+ end
16
+
11
17
  def initialize(raw_item)
12
- # Not using an OpenStruct so we can filter which attributes we want
13
- ATTRIBUTES.each do |attr|
18
+ WHITELISTED_ATTRIBUTES.each do |attr|
14
19
  if raw_item.has_key?(attr)
15
20
  instance_variable_set("@#{attr}", raw_item[attr])
16
21
  singleton_class.class_eval do
@@ -19,11 +24,5 @@ module Sprintly
19
24
  end
20
25
  end
21
26
  end
22
-
23
- def self.for_product(product_id)
24
- response = Sprintly::Connection.get("products/#{product_id}/items.json")
25
- raw_items = JSON.parse(response.body)
26
- raw_items.map { |raw_item| new(raw_item) }
27
- end
28
27
  end
29
28
  end
@@ -0,0 +1,33 @@
1
+ require 'json'
2
+
3
+ module Sprintly
4
+ class Product
5
+ WHITELISTED_ATTRIBUTES = [
6
+ "archived", "name", "admin",
7
+ "created_at", "webhook", "email", "id"
8
+ ].freeze
9
+
10
+ def self.all
11
+ response = Sprintly::Connection.get("products.json")
12
+ raw_products = JSON.parse(response.body)
13
+ raw_products.map { |raw_product| new(raw_product) }
14
+ end
15
+
16
+ def initialize(raw_product)
17
+ WHITELISTED_ATTRIBUTES.each do |attr|
18
+ if raw_product.has_key?(attr)
19
+ instance_variable_set("@#{attr}", raw_product[attr])
20
+ singleton_class.class_eval do
21
+ attr_reader "#{attr}"
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ def get_items_by_status(status)
28
+ items = Sprintly::Item.for_product(self.id)
29
+ items.select { |item| item.status == status }
30
+ end
31
+
32
+ end
33
+ end
@@ -1,3 +1,3 @@
1
1
  module Sprintly
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprintly-data-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Quick Left
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-10 00:00:00.000000000 Z
11
+ date: 2015-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -129,6 +129,7 @@ executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
+ - ".gitignore"
132
133
  - ".ruby-version"
133
134
  - CODE_OF_CONDUCT.md
134
135
  - Gemfile
@@ -141,7 +142,9 @@ files:
141
142
  - lib/sprintly-data-ruby.rb
142
143
  - lib/sprintly-data-ruby/connection.rb
143
144
  - lib/sprintly-data-ruby/item.rb
145
+ - lib/sprintly-data-ruby/product.rb
144
146
  - lib/sprintly-data-ruby/version.rb
147
+ - sprintly-data-ruby-0.1.0.gem
145
148
  - sprintly-data-ruby.gemspec
146
149
  homepage: https://github.com/quickleft/sprintly-data-ruby
147
150
  licenses: