ssd 0.1.2 → 0.1.3
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 +4 -4
 - data/README.md +24 -16
 - data/bin/console +0 -4
 - data/bin/repl.rb +41 -0
 - data/lib/ssd.rb +29 -30
 - data/lib/ssd/version.rb +1 -1
 - data/specs/ssd_spec.rb +22 -12
 - metadata +3 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: deeb33a039ae9fe9134ce820c77d31dbebdac967
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a5ff690e9e4104f532d4f05065899ea5cd49c45c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2be1fd3a716666afba008493a4c177315682e46afc679d3099058d512c7b04579420c012bac67b96ca1bc8b832c3cc87e644bd2f127d3bcf896f3588899cb15a
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 0ed3aed894aefe020752028fb59901bb983c205c9746ceeb40ce7f5cfbd92f23eeb08c9fea7c9955e58d014fcfd7644130f84a2c8a120dd99a9d000eafac1bcc
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -4,18 +4,23 @@ SSD (Simply-Smart-Data) is an append-only, file-based, immutable key-value store 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            Key Features
         
     | 
| 
       6 
6 
     | 
    
         
             
            =================
         
     | 
| 
       7 
     | 
    
         
            -
            - Scalable file 
     | 
| 
       8 
     | 
    
         
            -
            - Immutable (timestamped inserts).
         
     | 
| 
       9 
     | 
    
         
            -
            - Fault tolerance (transactional operations).
         
     | 
| 
       10 
     | 
    
         
            -
            - Measurably low technical debt (consciously clean small-sized library that wouldn't complect your codebase).
         
     | 
| 
       11 
     | 
    
         
            -
            - Zero external dependencies 
     | 
| 
       12 
     | 
    
         
            -
            - Schemaless (easily meets your Application evolution needs).
         
     | 
| 
       13 
     | 
    
         
            -
            - Append-only (easily keeps track of Applications Data timeline).
         
     | 
| 
       14 
     | 
    
         
            -
            - Key-based rolling-forward\rolling-back 
     | 
| 
       15 
     | 
    
         
            -
            -  
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
            - **Scalable file**-based design (each key gets its own file).
         
     | 
| 
      
 8 
     | 
    
         
            +
            - **Immutable** (timestamped inserts as **accountants don't use erasers, otherwise they go to jail**).
         
     | 
| 
      
 9 
     | 
    
         
            +
            - **Fault tolerance** (transactional operations).
         
     | 
| 
      
 10 
     | 
    
         
            +
            - **Measurably low technical debt** (consciously clean small-sized library that wouldn't complect your codebase).
         
     | 
| 
      
 11 
     | 
    
         
            +
            - **Zero external dependencies**.
         
     | 
| 
      
 12 
     | 
    
         
            +
            - **Schemaless** (easily meets your Application evolution needs).
         
     | 
| 
      
 13 
     | 
    
         
            +
            - **Append-only** (easily keeps track of Applications Data timeline).
         
     | 
| 
      
 14 
     | 
    
         
            +
            - **Key-based rolling-forward\rolling-back**.
         
     | 
| 
      
 15 
     | 
    
         
            +
            - **Super easy to learn and use** (up & running in mins).
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            TODO
         
     | 
| 
      
 18 
     | 
    
         
            +
            ======
         
     | 
| 
      
 19 
     | 
    
         
            +
            - **Strict Security-first policy SHA256 Encryption** (implment your own logging for intercepting keys required for decrypting data).
         
     | 
| 
      
 20 
     | 
    
         
            +
            - **JSON objects** (based on ruby's native pstore).
         
     | 
| 
      
 21 
     | 
    
         
            +
            - **RESTful HTTP/JSON API Endpoint**.
         
     | 
| 
      
 22 
     | 
    
         
            +
            - REPL console
         
     | 
| 
      
 23 
     | 
    
         
            +
            - Server Web-based Admin Interface
         
     | 
| 
       19 
24 
     | 
    
         | 
| 
       20 
25 
     | 
    
         
             
            Use Cases
         
     | 
| 
       21 
26 
     | 
    
         
             
            ==========
         
     | 
| 
         @@ -28,14 +33,17 @@ module MyApp 
     | 
|
| 
       28 
33 
     | 
    
         
             
             class User
         
     | 
| 
       29 
34 
     | 
    
         
             
              include SSD
         
     | 
| 
       30 
35 
     | 
    
         
             
              attr_accessor :id # ssd key
         
     | 
| 
      
 36 
     | 
    
         
            +
              
         
     | 
| 
      
 37 
     | 
    
         
            +
              def initialize id
         
     | 
| 
      
 38 
     | 
    
         
            +
               @ssd = id
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
       31 
40 
     | 
    
         
             
             end
         
     | 
| 
       32 
41 
     | 
    
         | 
| 
       33 
42 
     | 
    
         
             
             class API < Sinatra::Base
         
     | 
| 
       34 
43 
     | 
    
         
             
               get '/' do 
         
     | 
| 
       35 
     | 
    
         
            -
                 @user = User.new		# Initialize an object form any Class that `include SSD`
         
     | 
| 
       36 
     | 
    
         
            -
                 @user. 
     | 
| 
       37 
     | 
    
         
            -
                 @user. 
     | 
| 
       38 
     | 
    
         
            -
                 User.ssd("generated_id")  	# Later to read it via Class.ssd(id)
         
     | 
| 
      
 44 
     | 
    
         
            +
                 @user = User.new("generated_id")		# Initialize an object form any Class that `include SSD` and assign it a :ssd key 
         
     | 
| 
      
 45 
     | 
    
         
            +
                 @user.append! 				# Do an `append!` operation and viola! DONE 
         
     | 
| 
      
 46 
     | 
    
         
            +
                 @user = User.ssd("generated_id")  			# Afterwards read it via Class.ssd(:ssd)
         
     | 
| 
       39 
47 
     | 
    
         
             
               end
         
     | 
| 
       40 
48 
     | 
    
         
             
             end
         
     | 
| 
       41 
49 
     | 
    
         
             
            end
         
     | 
    
        data/bin/console
    CHANGED
    
    | 
         @@ -6,9 +6,5 @@ require "ssd" 
     | 
|
| 
       6 
6 
     | 
    
         
             
            # You can add fixtures and/or initialization code here to make experimenting
         
     | 
| 
       7 
7 
     | 
    
         
             
            # with your gem easier. You can also use a different console, if you like.
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            # (If you use this, don't forget to add pry to your Gemfile!)
         
     | 
| 
       10 
     | 
    
         
            -
            # require "pry"
         
     | 
| 
       11 
     | 
    
         
            -
            # Pry.start
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
9 
     | 
    
         
             
            require "irb"
         
     | 
| 
       14 
10 
     | 
    
         
             
            IRB.start
         
     | 
    
        data/bin/repl.rb
    ADDED
    
    | 
         @@ -0,0 +1,41 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            puts "SSD Console -h for help"
         
     | 
| 
      
 2 
     | 
    
         
            +
            puts " "
         
     | 
| 
      
 3 
     | 
    
         
            +
            puts " "
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            def colorize(text, color_code)
         
     | 
| 
      
 6 
     | 
    
         
            +
              "#{color_code}#{text}e[0m"
         
     | 
| 
      
 7 
     | 
    
         
            +
            end
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            def red(text); colorize(text, "e[31m"); end
         
     | 
| 
      
 10 
     | 
    
         
            +
            def green(text); colorize(text, "e[32m"); end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            # Actual work
         
     | 
| 
      
 13 
     | 
    
         
            +
            puts 'Importing categories [ ' + green('DONE') + ' ]'
         
     | 
| 
      
 14 
     | 
    
         
            +
            # Actual work
         
     | 
| 
      
 15 
     | 
    
         
            +
            puts 'Importing tags       [' + red('FAILED') + ']'
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            # Handle the input, this would probably run some method
         
     | 
| 
      
 18 
     | 
    
         
            +
            # as a part of the DSL you'd have to create. Place this
         
     | 
| 
      
 19 
     | 
    
         
            +
            # repl as your command line interface to your service.
         
     | 
| 
      
 20 
     | 
    
         
            +
            def handle_input(input)
         
     | 
| 
      
 21 
     | 
    
         
            +
              result = eval(input)
         
     | 
| 
      
 22 
     | 
    
         
            +
              puts(" => #{result}")
         
     | 
| 
      
 23 
     | 
    
         
            +
            end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            # This is a lambda that runs the content of the block
         
     | 
| 
      
 26 
     | 
    
         
            +
            # after the input is chomped.
         
     | 
| 
      
 27 
     | 
    
         
            +
            repl = -> prompt do
         
     | 
| 
      
 28 
     | 
    
         
            +
              begin
         
     | 
| 
      
 29 
     | 
    
         
            +
                print prompt
         
     | 
| 
      
 30 
     | 
    
         
            +
                handle_input(gets.chomp!)
         
     | 
| 
      
 31 
     | 
    
         
            +
              rescue "Error"
         
     | 
| 
      
 32 
     | 
    
         
            +
                raise "ERROR"
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            # After evaling and returning, fire up the prompt lambda
         
     | 
| 
      
 37 
     | 
    
         
            +
            # again, this loops after every input and exits with
         
     | 
| 
      
 38 
     | 
    
         
            +
            # exit or a HUP.
         
     | 
| 
      
 39 
     | 
    
         
            +
            loop do
         
     | 
| 
      
 40 
     | 
    
         
            +
              repl["SSD> "]
         
     | 
| 
      
 41 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/ssd.rb
    CHANGED
    
    | 
         @@ -23,12 +23,12 @@ module SSD 
     | 
|
| 
       23 
23 
     | 
    
         
             
                  @@ssd_name  		= base.new.class.to_s.downcase
         
     | 
| 
       24 
24 
     | 
    
         
             
                end
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
                attr_accessor : 
     | 
| 
      
 26 
     | 
    
         
            +
                attr_accessor :ssd
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
                def  
     | 
| 
       29 
     | 
    
         
            -
                  @ 
     | 
| 
      
 28 
     | 
    
         
            +
                def ssd= value
         
     | 
| 
      
 29 
     | 
    
         
            +
                  @ssd	= value
         
     | 
| 
       30 
30 
     | 
    
         
             
                  FileUtils::mkdir_p ".ssd/#{@@ssd_name}"
         
     | 
| 
       31 
     | 
    
         
            -
                  @@ssd_path 		= ".ssd/#{@@ssd_name}/#{@ 
     | 
| 
      
 31 
     | 
    
         
            +
                  @@ssd_path 		= ".ssd/#{@@ssd_name}/#{@ssd}.ssd" 
         
     | 
| 
       32 
32 
     | 
    
         
             
                  @@ssd_db 			= PStore.new @@ssd_path, true
         
     | 
| 
       33 
33 
     | 
    
         
             
                  @@ssd_db.ultra_safe 	= true
         
     | 
| 
       34 
34 
     | 
    
         
             
                  @@ssd_db.transaction(true) {}
         
     | 
| 
         @@ -44,14 +44,13 @@ module SSD 
     | 
|
| 
       44 
44 
     | 
    
         | 
| 
       45 
45 
     | 
    
         
             
                def []= 
         
     | 
| 
       46 
46 
     | 
    
         
             
                  begin  
         
     | 
| 
       47 
     | 
    
         
            -
            	if !@ 
     | 
| 
      
 47 
     | 
    
         
            +
            	if !@ssd.nil? then 
         
     | 
| 
       48 
48 
     | 
    
         
             
            	  @@ssd_db.transaction do
         
     | 
| 
       49 
     | 
    
         
            -
            	    #todo should be somthing like??? timestamp instead of  
     | 
| 
       50 
     | 
    
         
            -
            	    #@@ssd_db[id.to_sym] = self 
         
     | 
| 
      
 49 
     | 
    
         
            +
            	    #todo should be somthing like??? timestamp instead of ssd as a key?? and use .last while reading
         
     | 
| 
       51 
50 
     | 
    
         
             
            	    @@ssd_db[Time.now.utc.to_s + "_" + Random.new_seed.to_s ] = self 
         
     | 
| 
       52 
51 
     | 
    
         
             
            	  end
         
     | 
| 
       53 
52 
     | 
    
         
             
            	else
         
     | 
| 
       54 
     | 
    
         
            -
            	  raise 'ssd  
     | 
| 
      
 53 
     | 
    
         
            +
            	  raise 'ssd key can not be nil. see more (documentation url)'  
         
     | 
| 
       55 
54 
     | 
    
         
             
            	end
         
     | 
| 
       56 
55 
     | 
    
         
             
                  end  
         
     | 
| 
       57 
56 
     | 
    
         
             
                end
         
     | 
| 
         @@ -72,50 +71,50 @@ module SSD 
     | 
|
| 
       72 
71 
     | 
    
         
             
                  #@@ssd_db
         
     | 
| 
       73 
72 
     | 
    
         
             
                end 
         
     | 
| 
       74 
73 
     | 
    
         | 
| 
       75 
     | 
    
         
            -
                def setup  
     | 
| 
       76 
     | 
    
         
            -
                  @@ 
     | 
| 
      
 74 
     | 
    
         
            +
                def setup ssd 
         
     | 
| 
      
 75 
     | 
    
         
            +
                  @@ssd = ssd
         
     | 
| 
       77 
76 
     | 
    
         
             
                  FileUtils::mkdir_p ".ssd/#{@@ssd_name}"
         
     | 
| 
       78 
     | 
    
         
            -
                  @@ssd_path 		= ".ssd/#{@@ssd_name}/#{@@ 
     | 
| 
      
 77 
     | 
    
         
            +
                  @@ssd_path 		= ".ssd/#{@@ssd_name}/#{@@ssd}.ssd" 
         
     | 
| 
       79 
78 
     | 
    
         
             
                  @@ssd_db 			= PStore.new @@ssd_path, true
         
     | 
| 
       80 
79 
     | 
    
         
             
                  @@ssd_db.ultra_safe 	= true
         
     | 
| 
       81 
80 
     | 
    
         
             
                  @@ssd_db.transaction(true) {}
         
     | 
| 
       82 
81 
     | 
    
         
             
                  return @@ssd_db
         
     | 
| 
       83 
82 
     | 
    
         
             
                end
         
     | 
| 
       84 
83 
     | 
    
         | 
| 
       85 
     | 
    
         
            -
                def last_key  
     | 
| 
       86 
     | 
    
         
            -
                  setup  
     | 
| 
      
 84 
     | 
    
         
            +
                def last_key ssd 
         
     | 
| 
      
 85 
     | 
    
         
            +
                  setup ssd
         
     | 
| 
       87 
86 
     | 
    
         
             
                  last_key = @@ssd_db.transaction true do
         
     | 
| 
       88 
87 
     | 
    
         
             
            	@@ssd_db.roots
         
     | 
| 
       89 
88 
     | 
    
         
             
                  end
         
     | 
| 
       90 
89 
     | 
    
         
             
                  last_key.last
         
     | 
| 
       91 
90 
     | 
    
         
             
                end
         
     | 
| 
       92 
91 
     | 
    
         | 
| 
       93 
     | 
    
         
            -
                def keys  
     | 
| 
       94 
     | 
    
         
            -
                  setup  
     | 
| 
      
 92 
     | 
    
         
            +
                def keys ssd
         
     | 
| 
      
 93 
     | 
    
         
            +
                  setup ssd
         
     | 
| 
       95 
94 
     | 
    
         
             
                  @@ssd_db.transaction true do
         
     | 
| 
       96 
95 
     | 
    
         
             
            	@@ssd_db.roots
         
     | 
| 
       97 
96 
     | 
    
         
             
                  end
         
     | 
| 
       98 
97 
     | 
    
         
             
                end
         
     | 
| 
       99 
98 
     | 
    
         | 
| 
       100 
     | 
    
         
            -
                def key?  
     | 
| 
       101 
     | 
    
         
            -
                  setup  
     | 
| 
      
 99 
     | 
    
         
            +
                def key? ssd 
         
     | 
| 
      
 100 
     | 
    
         
            +
                  setup ssd
         
     | 
| 
       102 
101 
     | 
    
         
             
                  @@ssd_db.transaction true do
         
     | 
| 
       103 
     | 
    
         
            -
            	@@ssd_db.root?  
     | 
| 
      
 102 
     | 
    
         
            +
            	@@ssd_db.root? ssd 
         
     | 
| 
       104 
103 
     | 
    
         
             
                  end
         
     | 
| 
       105 
104 
     | 
    
         
             
                end
         
     | 
| 
       106 
105 
     | 
    
         | 
| 
       107 
106 
     | 
    
         
             
                alias exists? key?
         
     | 
| 
       108 
107 
     | 
    
         | 
| 
       109 
     | 
    
         
            -
                def []  
     | 
| 
       110 
     | 
    
         
            -
                  setup  
     | 
| 
      
 108 
     | 
    
         
            +
                def [] ssd 
         
     | 
| 
      
 109 
     | 
    
         
            +
                  setup ssd 
         
     | 
| 
       111 
110 
     | 
    
         
             
                  @@ssd_db.transaction true do
         
     | 
| 
       112 
     | 
    
         
            -
            	@@ssd_db[ 
     | 
| 
      
 111 
     | 
    
         
            +
            	@@ssd_db[ssd]
         
     | 
| 
       113 
112 
     | 
    
         
             
                  end
         
     | 
| 
       114 
113 
     | 
    
         
             
                end
         
     | 
| 
       115 
114 
     | 
    
         | 
| 
       116 
     | 
    
         
            -
                def ssd  
     | 
| 
       117 
     | 
    
         
            -
                  #TODO add raise if  
     | 
| 
       118 
     | 
    
         
            -
                  last_key = (last_key  
     | 
| 
      
 115 
     | 
    
         
            +
                def ssd ssd 
         
     | 
| 
      
 116 
     | 
    
         
            +
                  #TODO add raise if ssd.nil?
         
     | 
| 
      
 117 
     | 
    
         
            +
                  last_key = (last_key ssd) 
         
     | 
| 
       119 
118 
     | 
    
         
             
                  @@ssd_db.transaction true do
         
     | 
| 
       120 
119 
     | 
    
         
             
            	@@ssd_db.fetch last_key
         
     | 
| 
       121 
120 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -124,20 +123,20 @@ module SSD 
     | 
|
| 
       124 
123 
     | 
    
         
             
                #alias get fetch 
         
     | 
| 
       125 
124 
     | 
    
         
             
                #alias find fetch 
         
     | 
| 
       126 
125 
     | 
    
         | 
| 
       127 
     | 
    
         
            -
                def delete * 
     | 
| 
      
 126 
     | 
    
         
            +
                def delete *ssds
         
     | 
| 
       128 
127 
     | 
    
         
             
                  @@ssd_db.transaction do
         
     | 
| 
       129 
     | 
    
         
            -
            	 
     | 
| 
       130 
     | 
    
         
            -
            	  @@ssd_db.delete  
     | 
| 
      
 128 
     | 
    
         
            +
            	ssds.each do |ssd|
         
     | 
| 
      
 129 
     | 
    
         
            +
            	  @@ssd_db.delete ssd.to_sym
         
     | 
| 
       131 
130 
     | 
    
         
             
            	end
         
     | 
| 
       132 
131 
     | 
    
         
             
            	@@ssd_db.commit
         
     | 
| 
       133 
132 
     | 
    
         
             
                  end
         
     | 
| 
       134 
133 
     | 
    
         
             
                end
         
     | 
| 
       135 
134 
     | 
    
         
             
                alias remove delete
         
     | 
| 
       136 
135 
     | 
    
         | 
| 
       137 
     | 
    
         
            -
                def count  
     | 
| 
       138 
     | 
    
         
            -
                  setup  
     | 
| 
      
 136 
     | 
    
         
            +
                def count ssd
         
     | 
| 
      
 137 
     | 
    
         
            +
                  setup ssd 
         
     | 
| 
       139 
138 
     | 
    
         
             
                  $log.info("count")
         
     | 
| 
       140 
     | 
    
         
            -
                  return keys( 
     | 
| 
      
 139 
     | 
    
         
            +
                  return keys(ssd).count
         
     | 
| 
       141 
140 
     | 
    
         
             
                end
         
     | 
| 
       142 
141 
     | 
    
         
             
              end
         
     | 
| 
       143 
142 
     | 
    
         | 
    
        data/lib/ssd/version.rb
    CHANGED
    
    
    
        data/specs/ssd_spec.rb
    CHANGED
    
    | 
         @@ -3,21 +3,31 @@ require_relative "./spec_helper" 
     | 
|
| 
       3 
3 
     | 
    
         
             
            describe SSD do
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
              before do
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                class User
         
     | 
| 
       7 
8 
     | 
    
         
             
                  include SSD
         
     | 
| 
       8 
     | 
    
         
            -
                  attr_accessor :first_name, :last_name, :location
         
     | 
| 
      
 9 
     | 
    
         
            +
                  attr_accessor :id, :first_name, :last_name, :location
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                  def initialize id=""
         
     | 
| 
      
 12 
     | 
    
         
            +
            	@ssd = id
         
     | 
| 
      
 13 
     | 
    
         
            +
                  end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  def id= id
         
     | 
| 
      
 16 
     | 
    
         
            +
            	@id = id
         
     | 
| 
      
 17 
     | 
    
         
            +
            	@ssd = @id
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end
         
     | 
| 
       9 
19 
     | 
    
         
             
                end
         
     | 
| 
       10 
20 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
                @ 
     | 
| 
      
 21 
     | 
    
         
            +
                @generated_ssd = Random.new.seed
         
     | 
| 
       12 
22 
     | 
    
         
             
              end
         
     | 
| 
       13 
23 
     | 
    
         | 
| 
       14 
24 
     | 
    
         
             
              describe "#append!" do
         
     | 
| 
       15 
25 
     | 
    
         
             
                it "saves an object to the database" do
         
     | 
| 
       16 
26 
     | 
    
         
             
                  #skip
         
     | 
| 
       17 
27 
     | 
    
         
             
                  @user 	= User.new
         
     | 
| 
       18 
     | 
    
         
            -
                  @user. 
     | 
| 
      
 28 
     | 
    
         
            +
                  @user.ssd = @generated_ssd
         
     | 
| 
       19 
29 
     | 
    
         
             
                  @user.append!
         
     | 
| 
       20 
     | 
    
         
            -
                  @user. 
     | 
| 
      
 30 
     | 
    
         
            +
                  @user.ssd.must_equal @generated_ssd
         
     | 
| 
       21 
31 
     | 
    
         
             
                end
         
     | 
| 
       22 
32 
     | 
    
         
             
              end
         
     | 
| 
       23 
33 
     | 
    
         | 
| 
         @@ -25,10 +35,10 @@ describe SSD do 
     | 
|
| 
       25 
35 
     | 
    
         
             
                it "fetches an object from the database" do
         
     | 
| 
       26 
36 
     | 
    
         
             
                  #    skip
         
     | 
| 
       27 
37 
     | 
    
         
             
                  @user 	= User.new
         
     | 
| 
       28 
     | 
    
         
            -
                  @user. 
     | 
| 
      
 38 
     | 
    
         
            +
                  @user.ssd = @generated_ssd
         
     | 
| 
       29 
39 
     | 
    
         
             
                  @user.append!
         
     | 
| 
       30 
     | 
    
         
            -
                  user = User.ssd(@ 
     | 
| 
       31 
     | 
    
         
            -
                  user. 
     | 
| 
      
 40 
     | 
    
         
            +
                  user = User.ssd(@generated_ssd)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  user.ssd.must_equal @generated_ssd
         
     | 
| 
       32 
42 
     | 
    
         
             
                end
         
     | 
| 
       33 
43 
     | 
    
         
             
              end
         
     | 
| 
       34 
44 
     | 
    
         | 
| 
         @@ -36,19 +46,19 @@ describe SSD do 
     | 
|
| 
       36 
46 
     | 
    
         
             
                it "it keeps adding new objects" do
         
     | 
| 
       37 
47 
     | 
    
         
             
                  @user 		= User.new
         
     | 
| 
       38 
48 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
                  @user. 
     | 
| 
      
 49 
     | 
    
         
            +
                  @user.ssd		= @generated_ssd 
         
     | 
| 
       40 
50 
     | 
    
         
             
                  @user.location	= "Egypt"
         
     | 
| 
       41 
51 
     | 
    
         
             
                  @user.append!
         
     | 
| 
       42 
52 
     | 
    
         | 
| 
       43 
     | 
    
         
            -
                  @user = User.ssd(@ 
     | 
| 
      
 53 
     | 
    
         
            +
                  @user = User.ssd(@generated_ssd)
         
     | 
| 
       44 
54 
     | 
    
         
             
                  @user.location = "Brazil"
         
     | 
| 
       45 
55 
     | 
    
         
             
                  @user.append!
         
     | 
| 
       46 
56 
     | 
    
         | 
| 
       47 
     | 
    
         
            -
                  @user = User.ssd(@ 
     | 
| 
      
 57 
     | 
    
         
            +
                  @user = User.ssd(@generated_ssd)
         
     | 
| 
       48 
58 
     | 
    
         
             
                  @user.location = "France"
         
     | 
| 
       49 
59 
     | 
    
         
             
                  @user.append!
         
     | 
| 
       50 
60 
     | 
    
         | 
| 
       51 
     | 
    
         
            -
                  User.count(@ 
     | 
| 
      
 61 
     | 
    
         
            +
                  User.count(@generated_ssd).must_equal 3
         
     | 
| 
       52 
62 
     | 
    
         
             
                end
         
     | 
| 
       53 
63 
     | 
    
         
             
              end
         
     | 
| 
       54 
64 
     | 
    
         | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: ssd
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - zotherstupidguy
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2016-09- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-09-11 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -67,6 +67,7 @@ files: 
     | 
|
| 
       67 
67 
     | 
    
         
             
            - README.md
         
     | 
| 
       68 
68 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       69 
69 
     | 
    
         
             
            - bin/console
         
     | 
| 
      
 70 
     | 
    
         
            +
            - bin/repl.rb
         
     | 
| 
       70 
71 
     | 
    
         
             
            - bin/setup
         
     | 
| 
       71 
72 
     | 
    
         
             
            - lib/encrypt.rb
         
     | 
| 
       72 
73 
     | 
    
         
             
            - lib/ssd.rb
         
     |