simbiotes 0.1.8 → 0.1.9
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/lib/generators/simbiotes/create_model/templates/simbiotes_module.rb.erb +5 -7
 - data/lib/generators/simbiotes/create_model/templates/simbiotes_module_model.rb.erb +7 -5
 - data/lib/generators/simbiotes/initializer/initializer_generator.rb +3 -1
 - data/lib/generators/simbiotes/initializer/templates/setting.rb.erb +3 -0
 - data/lib/generators/simbiotes/initializer/templates/simbiotes_module.rb.erb +6 -0
 - data/lib/simbiotes/portal.rb +11 -1
 - data/lib/simbiotes/server.rb +6 -5
 - data/lib/simbiotes/version.rb +1 -1
 - metadata +5 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: c51f1fa4ecf5a4bf4160a5d12bea91045c854d7a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 73b066227de266a112b3d84a2b95b5f924f4a5cd
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ea506f1a352a6fc5a11cf50b13fdf7da7584b1b80b3dfc587677ca1ea2028451ea8989bac5a8e831cb755eefda2d4ab955f9181c42f99f3594f00aae13beed5d
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 3ec816c891340934c6d0e378700ba1f7699e0b272dc5c5cfcdf124aa05cb60d991607583ba6e9e10e9c4ebb925f90a842d2d5511e23ada3ed18e81e3df452671
         
     | 
| 
         @@ -1,10 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module <%= module_name %>
         
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
       3 
     | 
    
         
            -
                 
     | 
| 
      
 2 
     | 
    
         
            +
              class <%= module_name %> < ApplicationRecord
         
     | 
| 
      
 3 
     | 
    
         
            +
                <% @targets[module_name].keys.each do |key| %>
         
     | 
| 
      
 4 
     | 
    
         
            +
                  has_one :<%= key.underscore.downcase.gsub(" ", "_")%>, dependent: :destroy
         
     | 
| 
      
 5 
     | 
    
         
            +
                  accepts_nested_attributes_for :<%= key.underscore.downcase.gsub(" ", "_")%>
         
     | 
| 
      
 6 
     | 
    
         
            +
                <% end %>
         
     | 
| 
       4 
7 
     | 
    
         
             
              end
         
     | 
| 
       5 
     | 
    
         
            -
              
         
     | 
| 
       6 
     | 
    
         
            -
              def self.sync_device_instances
         
     | 
| 
       7 
     | 
    
         
            -
                Simbiotes.sync_device_instances(self.name)
         
     | 
| 
       8 
     | 
    
         
            -
              end
         
     | 
| 
       9 
     | 
    
         
            -
                
         
     | 
| 
       10 
8 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,8 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module <%= module_name %>
         
     | 
| 
       2 
     | 
    
         
            -
               
     | 
| 
       3 
     | 
    
         
            -
                 
     | 
| 
       4 
     | 
    
         
            -
                  has_one :<%= key.underscore.downcase.gsub(" ", "_")%>, dependent: :destroy
         
     | 
| 
       5 
     | 
    
         
            -
                  accepts_nested_attributes_for :<%= key.underscore.downcase.gsub(" ", "_")%>
         
     | 
| 
       6 
     | 
    
         
            -
                <% end %>
         
     | 
| 
      
 2 
     | 
    
         
            +
              def self.table_name_prefix
         
     | 
| 
      
 3 
     | 
    
         
            +
                '<%= table_prefix %>'
         
     | 
| 
       7 
4 
     | 
    
         
             
              end
         
     | 
| 
      
 5 
     | 
    
         
            +
              
         
     | 
| 
      
 6 
     | 
    
         
            +
              def self.sync_device_instances
         
     | 
| 
      
 7 
     | 
    
         
            +
                Simbiotes.sync_device_instances(self.name)
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
                
         
     | 
| 
       8 
10 
     | 
    
         
             
            end
         
     | 
| 
         @@ -9,7 +9,9 @@ module Simbiotes 
     | 
|
| 
       9 
9 
     | 
    
         
             
                    template "simbiotes_targets.rb.erb", "config/initializers/simbiotes_targets.rb"
         
     | 
| 
       10 
10 
     | 
    
         
             
                  else
         
     | 
| 
       11 
11 
     | 
    
         
             
                    template "simbiotes.rb.erb", "config/initializers/simbiotes.rb"
         
     | 
| 
       12 
     | 
    
         
            -
                    template "simbiotes_settings.rb.erb", "db/migrate/#{date_string}_create_simbiotes_settings.rb" 
     | 
| 
      
 12 
     | 
    
         
            +
                    template "simbiotes_settings.rb.erb", "db/migrate/#{date_string}_create_simbiotes_settings.rb"
         
     | 
| 
      
 13 
     | 
    
         
            +
                    template "setting.rb.erb", "app/models/simbiotes_setting.rb"
         
     | 
| 
      
 14 
     | 
    
         
            +
                    #template "simbiotes_module.rb.erb", "app/models/simbiotes.rb"    
         
     | 
| 
       13 
15 
     | 
    
         
             
                  end
         
     | 
| 
       14 
16 
     | 
    
         
             
                end
         
     | 
| 
       15 
17 
     | 
    
         | 
    
        data/lib/simbiotes/portal.rb
    CHANGED
    
    | 
         @@ -132,7 +132,17 @@ module Simbiotes 
     | 
|
| 
       132 
132 
     | 
    
         
             
                end
         
     | 
| 
       133 
133 
     | 
    
         | 
| 
       134 
134 
     | 
    
         
             
                def self.generate_certificate(csr)
         
     | 
| 
       135 
     | 
    
         
            -
                   
     | 
| 
      
 135 
     | 
    
         
            +
                  csr_file = Tempfile.new
         
     | 
| 
      
 136 
     | 
    
         
            +
                  csr_file.write(csr)
         
     | 
| 
      
 137 
     | 
    
         
            +
                  csr_file.rewind
         
     | 
| 
      
 138 
     | 
    
         
            +
                  payload = {
         
     | 
| 
      
 139 
     | 
    
         
            +
                    :multipart => true,
         
     | 
| 
      
 140 
     | 
    
         
            +
                    :csr => csr_file,
         
     | 
| 
      
 141 
     | 
    
         
            +
                    :public_key => Simbiotes.configuration.public_key,
         
     | 
| 
      
 142 
     | 
    
         
            +
                    :private_key => Simbiotes.configuration.private_key
         
     | 
| 
      
 143 
     | 
    
         
            +
                  }
         
     | 
| 
      
 144 
     | 
    
         
            +
                  r = RestClient.post("#{Simbiotes.configuration.portal}api/generate_certificate", payload)
         
     | 
| 
      
 145 
     | 
    
         
            +
                  instance_hash = JSON.parse(r.body)
         
     | 
| 
       136 
146 
     | 
    
         
             
                  return instance_hash["certificate"]
         
     | 
| 
       137 
147 
     | 
    
         
             
                end
         
     | 
| 
       138 
148 
     | 
    
         | 
    
        data/lib/simbiotes/server.rb
    CHANGED
    
    | 
         @@ -82,16 +82,17 @@ module Simbiotes 
     | 
|
| 
       82 
82 
     | 
    
         
             
                  else
         
     | 
| 
       83 
83 
     | 
    
         
             
                    key = key.value
         
     | 
| 
       84 
84 
     | 
    
         
             
                  end
         
     | 
| 
       85 
     | 
    
         
            -
                  pass_phrase =  
     | 
| 
      
 85 
     | 
    
         
            +
                  pass_phrase = SimbiotesSetting.find_by(key: "key_pass_phrase").value
         
     | 
| 
       86 
86 
     | 
    
         
             
                  key = OpenSSL::PKey::RSA.new key, pass_phrase
         
     | 
| 
       87 
87 
     | 
    
         
             
                  return key
         
     | 
| 
       88 
88 
     | 
    
         
             
                end
         
     | 
| 
       89 
89 
     | 
    
         | 
| 
       90 
90 
     | 
    
         
             
                def self.cert
         
     | 
| 
       91 
     | 
    
         
            -
                  cert =  
     | 
| 
      
 91 
     | 
    
         
            +
                  cert = SimbiotesSetting.find_by(key: "cert")
         
     | 
| 
       92 
92 
     | 
    
         
             
                  if cert == nil
         
     | 
| 
       93 
93 
     | 
    
         
             
                    key = SimbiotesSetting.find_by(key: "key").value
         
     | 
| 
       94 
     | 
    
         
            -
                     
     | 
| 
      
 94 
     | 
    
         
            +
                    pass_phrase = SimbiotesSetting.find_by(key: "key_pass_phrase").value
         
     | 
| 
      
 95 
     | 
    
         
            +
                    key = OpenSSL::PKey::RSA.new key, pass_phrase
         
     | 
| 
       95 
96 
     | 
    
         
             
                    public_key = SimbiotesSetting.find_by(key: "public_key").value
         
     | 
| 
       96 
97 
     | 
    
         
             
                    public_key = OpenSSL::PKey::RSA.new public_key
         
     | 
| 
       97 
98 
     | 
    
         
             
                    cert = Server.generate_cert(key, public_key)
         
     | 
| 
         @@ -132,7 +133,7 @@ module Simbiotes 
     | 
|
| 
       132 
133 
     | 
    
         
             
                def self.generate_cert(key, public_key)
         
     | 
| 
       133 
134 
     | 
    
         
             
                  csr = OpenSSL::X509::Request.new
         
     | 
| 
       134 
135 
     | 
    
         
             
                  csr.version = 0
         
     | 
| 
       135 
     | 
    
         
            -
                  csr.subject =  
     | 
| 
      
 136 
     | 
    
         
            +
                  csr.subject = OpenSSL::X509::Name.parse 'CN=simbiotes.com'
         
     | 
| 
       136 
137 
     | 
    
         
             
                  csr.public_key = key.public_key
         
     | 
| 
       137 
138 
     | 
    
         
             
                  csr.sign key, OpenSSL::Digest::SHA1.new
         
     | 
| 
       138 
139 
     | 
    
         
             
                  cert = Simbiotes::Portal.generate_certificate(csr)
         
     | 
| 
         @@ -140,7 +141,7 @@ module Simbiotes 
     | 
|
| 
       140 
141 
     | 
    
         
             
                end
         
     | 
| 
       141 
142 
     | 
    
         | 
| 
       142 
143 
     | 
    
         
             
                def self.ca_cert
         
     | 
| 
       143 
     | 
    
         
            -
                  ca_cert =  
     | 
| 
      
 144 
     | 
    
         
            +
                  ca_cert = SimbiotesSetting.find_by(key: "ca_cert")
         
     | 
| 
       144 
145 
     | 
    
         
             
                  if ca_cert == nil
         
     | 
| 
       145 
146 
     | 
    
         
             
                    ca_cert = Simbiotes::Portal.generate_certificate(csr)
         
     | 
| 
       146 
147 
     | 
    
         
             
                    c = SimbiotesSetting.new
         
     | 
    
        data/lib/simbiotes/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: simbiotes
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.9
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - MicroArx Corporation
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-07-02 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rails
         
     | 
| 
         @@ -166,7 +166,9 @@ files: 
     | 
|
| 
       166 
166 
     | 
    
         
             
            - lib/generators/simbiotes/create_table/templates/create_table.rb.erb
         
     | 
| 
       167 
167 
     | 
    
         
             
            - lib/generators/simbiotes/initializer/USAGE
         
     | 
| 
       168 
168 
     | 
    
         
             
            - lib/generators/simbiotes/initializer/initializer_generator.rb
         
     | 
| 
      
 169 
     | 
    
         
            +
            - lib/generators/simbiotes/initializer/templates/setting.rb.erb
         
     | 
| 
       169 
170 
     | 
    
         
             
            - lib/generators/simbiotes/initializer/templates/simbiotes.rb.erb
         
     | 
| 
      
 171 
     | 
    
         
            +
            - lib/generators/simbiotes/initializer/templates/simbiotes_module.rb.erb
         
     | 
| 
       170 
172 
     | 
    
         
             
            - lib/generators/simbiotes/initializer/templates/simbiotes_settings.rb.erb
         
     | 
| 
       171 
173 
     | 
    
         
             
            - lib/generators/simbiotes/initializer/templates/simbiotes_targets.rb.erb
         
     | 
| 
       172 
174 
     | 
    
         
             
            - lib/generators/simbiotes/install/USAGE
         
     | 
| 
         @@ -228,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       228 
230 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       229 
231 
     | 
    
         
             
            requirements: []
         
     | 
| 
       230 
232 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       231 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 233 
     | 
    
         
            +
            rubygems_version: 2.5.2
         
     | 
| 
       232 
234 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       233 
235 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       234 
236 
     | 
    
         
             
            summary: The easy way to integrate the IoT in your web app.
         
     |