keyp 0.0.5 → 0.0.6

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: f6d6251ce2d9255c0f752a0e7981934c8bb3c5e4
4
- data.tar.gz: 494b0741cf77583966b6a3317830ac8b53c1a778
3
+ metadata.gz: bff8c5655d1b350b28208c20add4b0b3cf884fd2
4
+ data.tar.gz: 53a122d43fda4ec7267bd77aea3626dc2e16dba6
5
5
  SHA512:
6
- metadata.gz: cfb27e7d76e1813682f996029cc55026dfca82ed34fa70113dce8785fcbe3b992cd624c58e183bcc41527eee751d0fca832c33cc78810b27d91e14d4ab2b57b9
7
- data.tar.gz: 3a3fb3beb457d303817333042c657b13d91c6ebc2d8104ade092d94e2e77d022909573621f6ec5665e18d7d68bc0bad393e762acfa7113402baa08152faebd0b
6
+ metadata.gz: cf0bbf2bc59d7a578afd69641032677ab6ff61f7d78331603a63e30fab9bd3dfd68e88756e9c74d0566f189d438bf92ebe91c9ad43ee7bef74b9379d5dac793b
7
+ data.tar.gz: baddf04bce4de7c751da7acf783a9527d00c31690cfa7d1a7697c402509c5cd912a9f2d1b4266d95d9f0eec08e79438b4628c2b1e3fd155559d04ef1797b2cc1
data/README.md CHANGED
@@ -93,7 +93,7 @@ TODO: Write more detailed documentation, For now, see the quick start above and
93
93
  $ keyp --help
94
94
 
95
95
  ## Release Notes
96
-
96
+ * v 0.0.5 - Fixed iso8601 error
97
97
  * v 0.0.4 - Fixed missing file error
98
98
 
99
99
  ## Development plan/Features to implement
data/lib/keyp/bag.rb CHANGED
@@ -47,7 +47,7 @@ module Keyp
47
47
  # not the most efficient thing, but simpler and safe enough for now
48
48
 
49
49
  unless File.exist? keypfile
50
- puts "Keyper.initialize, create_bag #{keypfile}"
50
+ puts "Bag.initialize, create_bag #{keypfile}"
51
51
  Keyp::create_bag(name)
52
52
  end
53
53
  file_data = load(keypfile)
@@ -78,8 +78,10 @@ module Keyp
78
78
  # TODO: check if data has been modified
79
79
  # maybe there is a way hash tells us its been modified. If not then
80
80
  # just check if key,val is already in hash and matches
81
- @data[key] = value
82
- @dirty = true
81
+ unless @data.key?(key) && @data[key] == value
82
+ @data[key] = value
83
+ @dirty = true
84
+ end
83
85
  else
84
86
  raise "Bag #{@name} is read only"
85
87
  end
@@ -134,9 +136,8 @@ module Keyp
134
136
  overwrite = options[:overwrite] || false
135
137
  pattern = options[:sysvar] if options.key?(:sysvar)
136
138
 
137
- pattern ||= '(...)'
138
-
139
- bag.data.each do |key,value|
139
+ pattern ||= /(...)/
140
+ @data.each do |key,value|
140
141
  if pattern.match(key)
141
142
  # TODO: add overwrite checking
142
143
  ENV[key] = value
data/lib/keyp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Keyp
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/spec/bag_spec.rb CHANGED
@@ -23,6 +23,7 @@ describe Keyp::Bag do
23
23
  @bag = Keyp::Bag.new 'grue_eats_you'
24
24
  @bag['LIGHTS'] = 'out'
25
25
  end
26
+
26
27
  it "should return a non-empty hash" do
27
28
  @bag.data.size.should > 0
28
29
  end
@@ -31,12 +32,10 @@ describe Keyp::Bag do
31
32
  context "environment variables" do
32
33
  before (:each) do
33
34
  # TODO: pseudo random bag name generation to a helper
34
- bag_name = "grue_eats_you_when_it_is_dark_#{Time.now.strftime("%Y%m%d%H%M")}"
35
+ bag_name = "grue_eats_you_when_it_is_dark_#{Time.now.strftime("%Y%m%d%H%M%S%L")}"
35
36
  @bag = Keyp::Bag.new bag_name
36
37
  end
37
- it "should copy all vars"
38
- =begin
39
- do
38
+ it "should copy all vars" do
40
39
  testvars = {
41
40
  'ALPHA' => 'First in the phonetic alphabet',
42
41
  'BRAVO' => 'Second in the phonetic alphabet',
@@ -45,12 +44,58 @@ describe Keyp::Bag do
45
44
 
46
45
  testvars.each { |key, value| @bag[key] = value }
47
46
 
48
- @bag.add_to_env
47
+ added = @bag.add_to_env
49
48
  testvars.each do |key, value|
50
49
  ENV[key].should_not == nil
51
50
  ENV[key].should == value
52
51
  end
53
52
  end
54
- =end
55
53
  end
54
+
55
+ context "bag state" do
56
+
57
+ before (:each) do
58
+ # TODO: pseudo random bag name generation to a helper
59
+ bag_name = "grue_eats_you_when_it_is_dark_#{Time.now.strftime("%Y%m%d%H%M%S%L")}"
60
+ @bag = Keyp::Bag.new bag_name
61
+ end
62
+
63
+ it 'should not set the dirty flag when no items are in the bag' do
64
+ @bag.empty?.should == true
65
+ @bag.dirty.should == false
66
+ end
67
+
68
+ it 'should set the dirty flag if a new key is created' do
69
+ @bag['KEY1'] = 'value1'
70
+ @bag.empty?.should == false
71
+ @bag.dirty.should == true
72
+
73
+ end
74
+
75
+ it 'should not set the dirty flag after save' do
76
+ @bag.empty?.should == true
77
+ @bag['KEY1'] = 'value1'
78
+ @bag.save
79
+ @bag.dirty.should == false
80
+ end
81
+ it 'should set the dirty flag if a key is given a new value' do
82
+ @bag.empty?.should == true
83
+ @bag['KEY1'] = 'value1'
84
+ @bag.dirty.should == true
85
+ end
86
+
87
+ it 'should not set the dirty flag if a key is assigned a value equal to its existing value' do
88
+ @bag.empty?.should == true
89
+ @bag['KEY1'] = 'value1'
90
+ @bag.save
91
+ @bag.dirty.should == false
92
+ @bag['KEY1'] = 'value1'
93
+ @bag.dirty.should == false
94
+ end
95
+ end
96
+
97
+ it 'should return a key with data member'
98
+ it 'should return a key acting as a hash'
99
+ it 'should allow assigning a key if not read only'
100
+ it 'should not allow assigning a key if read only'
56
101
  end
data/spec/keyp_spec.rb CHANGED
@@ -5,7 +5,7 @@ describe Keyp do
5
5
  context "CONSTANTS" do
6
6
  it 'should return correct version string' do
7
7
  #Keyp.version_string.should == "Keyp version #{Keyp::VERSION}"
8
- Keyp::VERSION.should == '0.0.5'
8
+ Keyp::VERSION.should == '0.0.6'
9
9
  end
10
10
 
11
11
  it 'should specify default store' do
@@ -44,20 +44,14 @@ describe Keyp do
44
44
 
45
45
  it "should say a bag does not exist" do
46
46
  # TODO: add bag name generation to a helper
47
- bag_name = "grue_eats_you_when_it_is_dark_#{Time.now.strftime("%Y%m%d%H%M")}"
47
+ bag_name = "grue_eats_you_when_it_is_dark_#{Time.now.strftime("%Y%m%d%H%M%S%L")}"
48
48
  Keyp.exist?(bag_name).should_not == true
49
49
  end
50
50
 
51
51
  end
52
52
 
53
53
 
54
- it 'should return a key with data member'
55
- it 'should return a key acting as a hash'
56
- it 'should allow assigning a key if not read only'
57
- it 'should not allow assigning a key if read only'
58
- it 'should set the dirty flag if a new key is created'
59
- it 'should set the dirty flag if a key is given a new value'
60
- it 'should not set the dirty flag if a key is assigned a value equal to its existing value'
54
+
61
55
 
62
56
  # Braindump of tests
63
57
  # Should show no keys if empty bag
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keyp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Baldwin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-01 00:00:00.000000000 Z
11
+ date: 2014-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli