[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [websites/inqlude] /: Get libraries of topics
From:       nanduni-nin <nandunibw () gmail ! com>
Date:       2016-10-15 22:49:42
Message-ID: E1bvXlu-0003rJ-RE () code ! kde ! org
[Download RAW message or body]

Git commit 334ecf1d540f8aebd6b3da3e340b79364ee43fe8 by nanduni-nin.
Committed on 15/08/2016 at 23:53.
Pushed by cschumac into branch 'master'.

Get libraries of topics

Retrieve libraries that belong to a specific topic.

Supersedes: #60

M  +9    -0    lib/manifest_handler.rb
M  +4    -0    lib/view.rb
M  +6    -0    spec/data/inqlude-all.json
M  +3    -0    spec/data/manifests/bleedingedge/bleedingedge.2012-01-01.manifest
M  +3    -0    spec/data/manifests/commercial/commercial.manifest
M  +8    -0    spec/unit/manifest_handler_spec.rb
M  +9    -0    spec/unit/view_spec.rb

http://commits.kde.org/websites/inqlude/334ecf1d540f8aebd6b3da3e340b79364ee43fe8

diff --git a/lib/manifest_handler.rb b/lib/manifest_handler.rb
index 7bf35be..e99dcfb 100644
--- a/lib/manifest_handler.rb
+++ b/lib/manifest_handler.rb
@@ -79,6 +79,15 @@ class ManifestHandler
     raise InqludeError.new("Unable to find manifest '#{name}'")
   end
 
+  def topic name
+    return @libraries.select do |l|
+      manifest = l.latest_manifest
+      if manifest.topics
+        manifest.topics.include? name
+      end
+    end
+  end
+
   def read_remote
     @libraries.clear
     @manifests.clear
diff --git a/lib/view.rb b/lib/view.rb
index adf3b7f..b094a0e 100644
--- a/lib/view.rb
+++ b/lib/view.rb
@@ -223,6 +223,10 @@ class View
   def group
     @manifest_handler.group(@group_name)
   end
+
+  def topic name
+    @manifest_handler.topic(name)
+  end
   
   def disqus_enabled?
     @enable_disqus
diff --git a/spec/data/inqlude-all.json b/spec/data/inqlude-all.json
index 4dc8243..ba74703 100644
--- a/spec/data/inqlude-all.json
+++ b/spec/data/inqlude-all.json
@@ -36,6 +36,9 @@
     "release_date": "2012-01-01",
     "version": "edge",
     "summary": "Bleeding edge version of a library",
+    "topics": [
+      "API"
+    ],
     "urls": {
       "homepage": "http://example.org",
       "download": "http://example.org/download"
@@ -60,6 +63,9 @@
     "$schema": "http://inqlude.org/schema/generic-manifest-v1#",
     "name": "commercial",
     "summary": "Commercial library",
+    "topics": [
+      "Data"
+    ],
     "urls": {
       "homepage": "http://commercial.example.org"
     },
diff --git a/spec/data/manifests/bleedingedge/bleedingedge.2012-01-01.manifest \
b/spec/data/manifests/bleedingedge/bleedingedge.2012-01-01.manifest index \
                d060ff4..0435aed 100644
--- a/spec/data/manifests/bleedingedge/bleedingedge.2012-01-01.manifest
+++ b/spec/data/manifests/bleedingedge/bleedingedge.2012-01-01.manifest
@@ -4,6 +4,9 @@
   "release_date": "2012-01-01",
   "version": "edge",
   "summary": "Bleeding edge version of a library",
+  "topics": [
+    "API"
+  ],
   "urls": {
     "homepage": "http://example.org",
     "download": "http://example.org/download"
diff --git a/spec/data/manifests/commercial/commercial.manifest \
b/spec/data/manifests/commercial/commercial.manifest index 5a1ab7a..5c35cd3 100644
--- a/spec/data/manifests/commercial/commercial.manifest
+++ b/spec/data/manifests/commercial/commercial.manifest
@@ -2,6 +2,9 @@
   "$schema": "http://inqlude.org/schema/generic-manifest-v1#",
   "name": "commercial",
   "summary": "Commercial library",
+  "topics": [
+    "Data"
+  ],
   "urls": {
     "homepage": "http://commercial.example.org"
   },
diff --git a/spec/unit/manifest_handler_spec.rb b/spec/unit/manifest_handler_spec.rb
index 627b6f6..fe6d47e 100644
--- a/spec/unit/manifest_handler_spec.rb
+++ b/spec/unit/manifest_handler_spec.rb
@@ -97,6 +97,14 @@ describe ManifestHandler do
     end
   end
 
+  describe "#topic" do
+    it "returns all libraries of a topic" do
+      libraries = mh.topic("API")
+      expect( libraries.count ).to eq 2
+      expect( libraries.first.manifests.last.name ).to eq "awesomelib"
+    end
+  end
+
   describe "#library" do
 
     it "returns one library" do
diff --git a/spec/unit/view_spec.rb b/spec/unit/view_spec.rb
index cc55ccc..bb5dc56 100644
--- a/spec/unit/view_spec.rb
+++ b/spec/unit/view_spec.rb
@@ -54,6 +54,15 @@ describe View do
       expect(v.group.count).to eq mh.group("kde-frameworks").count
       expect(v.group.first.name).to eq mh.group("kde-frameworks").first.name
     end
+
+    it "returns topic" do
+      mh = ManifestHandler.new settings
+      mh.read_remote
+      v = View.new mh
+
+      expect(v.topic("API").count).to eq 2
+      expect(v.topic("API").first.name).to eq 'awesomelib'
+    end
   end
   
   context "generic manifest and one release" do


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic