protopack 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,11 +22,15 @@ class Protopack::Package
22
22
  end
23
23
 
24
24
  def apply_missing
25
- sorted_items.select(&:missing?).each &:apply!
25
+ items = sorted_items.select(&:missing?)
26
+ items = items.select { |i| yield i } if block_given?
27
+ items.each &:apply!
26
28
  end
27
29
 
28
30
  def apply_all
29
- sorted_items.each &:apply!
31
+ items = sorted_items
32
+ items = items.select { |i| yield i } if block_given?
33
+ items.each &:apply!
30
34
  end
31
35
 
32
36
  def sorted_items
@@ -1,3 +1,3 @@
1
1
  module Protopack
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/protopack.gemspec CHANGED
@@ -1,4 +1,5 @@
1
- # -*- coding: utf-8 -*-
1
+ # -*- coding: utf-8; mode: ruby -*-
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'protopack/version'
@@ -51,6 +51,18 @@ describe Protopack::Package do
51
51
  Widget.all[4].height.should == 'camel'
52
52
  end
53
53
 
54
+ it "should install all items from a package subject to filtering" do
55
+ Widget.new :colour => "blue"
56
+ Widget.new :colour => "green"
57
+
58
+ Protopack::Package.find("standard-widgets").apply_all { |x| x.region == "Africa" }
59
+
60
+ Widget.all.map(&:colour).should == %w{ blue green yellow }
61
+ Widget.all[0].height.should == 'elephant'
62
+ Widget.all[1].height.should == 'zebra'
63
+ Widget.all[2].height.should == 'hyena'
64
+ end
65
+
54
66
  it "should install only missing items from a package, not overwriting existing items" do
55
67
  Widget.new :colour => "blue", :height => "not specified"
56
68
  Widget.new :colour => "green", :height => "not specified"
@@ -1,5 +1,6 @@
1
1
  id: black-widget
2
2
  type: Widget
3
+ region: Asia
3
4
  attributes:
4
5
  colour: black
5
6
  height: camel
@@ -1,6 +1,7 @@
1
1
  id: blue-widget
2
2
  type: Widget
3
3
  ordinal: 2
4
+ region: Africa
4
5
  attributes:
5
6
  colour: blue
6
7
  height: elephant
@@ -1,5 +1,6 @@
1
1
  id: green-widget
2
2
  type: Widget
3
+ region: Africa
3
4
  attributes:
4
5
  colour: green
5
6
  height: zebra
@@ -1,6 +1,7 @@
1
1
  id: red-widget
2
2
  type: Widget
3
3
  ordinal: 1
4
+ region: Asia
4
5
  attributes:
5
6
  colour: red
6
7
  height: tiger
@@ -1,6 +1,7 @@
1
1
  id: yellow-widget
2
2
  type: Widget
3
3
  ordinal: 99
4
+ region: Africa
4
5
  attributes:
5
6
  colour: yellow
6
7
  height: hyena
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protopack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-16 00:00:00.000000000 Z
12
+ date: 2013-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: hashie