leofs_manager_client 0.2.15 → 0.2.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -105,17 +105,33 @@ module LeoFSManager
105
105
  @checksum = h[:checksum]
106
106
  timestamp = h[:timestamp]
107
107
  @timestamp = timestamp.empty? ? timestamp : Time.parse(timestamp)
108
- @delete = h[:delete]
108
+ @delete = h[:delete] != 0 # bool
109
109
  @num_of_chunks = h[:num_of_chunks]
110
110
  end
111
111
  end
112
112
 
113
113
  # Storage Status Model
114
114
  class StorageStat
115
- attr_reader :total_of_objects
115
+ attr_reader :active_num_of_objects, :total_num_of_objects,
116
+ :active_size_of_objects, :total_size_of_objects,
117
+ :last_compaction_start, :last_compaction_end
118
+
119
+ alias total_of_objects total_num_of_objects # for compatibility
116
120
 
117
121
  def initialize(h)
118
- @total_of_objects = h[:total_of_objects]
122
+ @active_num_of_objects = h[:active_num_of_objects]
123
+ @total_num_of_objects = h[:total_num_of_objects]
124
+ @active_size_of_objects = h[:active_size_of_objects]
125
+ @total_size_of_objects = h[:total_size_of_objects]
126
+
127
+ last_compaction_start = h[:last_compaction_start]
128
+ if last_compaction_start && last_compaction_start != "____-_-__- __:__:__"
129
+ @last_compaction_start = Time.parse(h[:last_compaction_start])
130
+ end
131
+ last_compaction_end = h[:last_compaction_end]
132
+ if last_compaction_end && last_compaction_end != "____-_-__- __:__:__"
133
+ @last_compaction_end = Time.parse(h[:last_compaction_end])
134
+ end
119
135
  end
120
136
 
121
137
  def file_size
@@ -26,7 +26,7 @@ require "time"
26
26
  require_relative "leofs_manager_client/leofs_manager_models"
27
27
 
28
28
  module LeoFSManager
29
- VERSION = "0.2.15"
29
+ VERSION = "0.2.16"
30
30
 
31
31
  class Client
32
32
  CMD_VERSION = "version"
@@ -44,6 +44,53 @@ NoResultAPIs = {
44
44
  include LeoFSManager
45
45
 
46
46
  describe LeoFSManager do
47
+ describe StorageStat do
48
+ shared_examples_for StorageStat do
49
+ its(:active_num_of_objects) { should == 0 }
50
+ its(:total_num_of_objects) { should == 0 }
51
+ its(:active_size_of_objects) { should == 0 }
52
+ its(:total_size_of_objects) { should == 0 }
53
+ end
54
+
55
+ context "there is no last compaction" do
56
+ subject do
57
+ StorageStat.new(
58
+ :active_num_of_objects => 0,
59
+ :total_num_of_objects => 0,
60
+ :active_size_of_objects => 0,
61
+ :total_size_of_objects => 0,
62
+ :last_compaction_start => "____-_-__- __:__:__",
63
+ :last_compaction_end => "____-_-__- __:__:__"
64
+ )
65
+ end
66
+
67
+ it_behaves_like StorageStat
68
+
69
+ its(:last_compaction_start) { should be_nil }
70
+ its(:last_compaction_end) { should be_nil }
71
+ end
72
+
73
+ context "there is last compaction" do
74
+ let(:time_str) { Time.now.to_s }
75
+
76
+ subject do
77
+ StorageStat.new(
78
+ :active_num_of_objects => 0,
79
+ :total_num_of_objects => 0,
80
+ :active_size_of_objects => 0,
81
+ :total_size_of_objects => 0,
82
+ :last_compaction_start => time_str,
83
+ :last_compaction_end => time_str
84
+ )
85
+ end
86
+
87
+ it_behaves_like StorageStat
88
+
89
+ its(:last_compaction_start) { subject.to_s == time_str }
90
+ its(:last_compaction_end) { subject.to_s == time_str }
91
+ end
92
+ end
93
+
47
94
  describe Client do
48
95
  before(:all) do
49
96
  Dummy::Manager.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: leofs_manager_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.15
4
+ version: 0.2.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-30 00:00:00.000000000 Z
13
+ date: 2013-02-21 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: Client for LeoFS Manager
16
16
  email:
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  version: '0'
50
50
  requirements: []
51
51
  rubyforge_project:
52
- rubygems_version: 1.8.24
52
+ rubygems_version: 1.8.25
53
53
  signing_key:
54
54
  specification_version: 3
55
55
  summary: Client for LeoFS Manager