trigger_switch_d 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.
- data/bin/ts_setup +12 -7
 - data/bin/tsd +1 -1
 - data/lib/tellstick/proxy_io.rb +5 -1
 - data/lib/trigger_switch_d/action.rb +2 -4
 - data/lib/trigger_switch_d/config.rb +1 -1
 - data/samples/environment.rb +1 -1
 - metadata +3 -3
 
    
        data/bin/ts_setup
    CHANGED
    
    | 
         @@ -29,6 +29,8 @@ 
     | 
|
| 
       29 
29 
     | 
    
         
             
            #    (for system wide folder)
         
     | 
| 
       30 
30 
     | 
    
         
             
            #    ts_setup system
         
     | 
| 
       31 
31 
     | 
    
         | 
| 
      
 32 
     | 
    
         
            +
            require 'open3'
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
       32 
34 
     | 
    
         
             
            if ((ARGV.length != 1) || ((ARGV[0] =~ /^(home|system)$/) == nil))
         
     | 
| 
       33 
35 
     | 
    
         
             
              puts <<-EOS
         
     | 
| 
       34 
36 
     | 
    
         
             
            # ==Usage
         
     | 
| 
         @@ -53,13 +55,16 @@ def create(path) 
     | 
|
| 
       53 
55 
     | 
    
         
             
              config = "config"
         
     | 
| 
       54 
56 
     | 
    
         
             
              config_path = "#{path}/#{config}"
         
     | 
| 
       55 
57 
     | 
    
         
             
              db_path = "#{path}/#{db}"
         
     | 
| 
       56 
     | 
    
         
            -
               
     | 
| 
       57 
     | 
    
         
            -
               
     | 
| 
       58 
     | 
    
         
            -
               
     | 
| 
       59 
     | 
    
         
            -
               
     | 
| 
       60 
     | 
    
         
            -
               
     | 
| 
       61 
     | 
    
         
            -
               
     | 
| 
       62 
     | 
    
         
            -
               
     | 
| 
      
 58 
     | 
    
         
            +
              gem_path = "/#{Gem.bin_path('trigger_switch_d', 'ts_setup', ">=0").split("/")[1..-3].join("/")}"
         
     | 
| 
      
 59 
     | 
    
         
            +
              Open3.popen3("mkdir #{path}")
         
     | 
| 
      
 60 
     | 
    
         
            +
              Open3.popen3("mkdir #{path}/log")
         
     | 
| 
      
 61 
     | 
    
         
            +
              Open3.popen3("mkdir #{db_path}")
         
     | 
| 
      
 62 
     | 
    
         
            +
              Open3.popen3("mkdir #{config_path}")
         
     | 
| 
      
 63 
     | 
    
         
            +
              Open3.popen3("touch #{db_path}/devices")
         
     | 
| 
      
 64 
     | 
    
         
            +
              Open3.popen3("touch #{db_path}/scheduled_actions")
         
     | 
| 
      
 65 
     | 
    
         
            +
              Open3.popen3("cp #{gem_path}/samples/environment.rb #{config_path}")
         
     | 
| 
      
 66 
     | 
    
         
            +
              Open3.popen3("cp #{gem_path}/samples/lookup.dsl #{config_path}")
         
     | 
| 
      
 67 
     | 
    
         
            +
              Open3.popen3("cp -R #{gem_path}/samples #{path}")
         
     | 
| 
       63 
68 
     | 
    
         
             
            end
         
     | 
| 
       64 
69 
     | 
    
         | 
| 
       65 
70 
     | 
    
         
             
            case ARGV[0]
         
     | 
    
        data/bin/tsd
    CHANGED
    
    | 
         @@ -60,7 +60,7 @@ $LOAD_PATH.push File.join(File.dirname(__FILE__),".." ,"lib" ) 
     | 
|
| 
       60 
60 
     | 
    
         
             
            require 'tellstick'
         
     | 
| 
       61 
61 
     | 
    
         
             
            require 'trigger_switch_d'
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
       63 
     | 
    
         
            -
            if $0  
     | 
| 
      
 63 
     | 
    
         
            +
            if ($0 =~ /bin\/tsd/) != nil
         
     | 
| 
       64 
64 
     | 
    
         
             
              file = File.open(TriggerSwitchD::ConfigFactory::ProperEnvironmentFile.new.path,"r")
         
     | 
| 
       65 
65 
     | 
    
         
             
              app = TriggerSwitchD::Application.new(file)
         
     | 
| 
       66 
66 
     | 
    
         
             
              file.close
         
     | 
    
        data/lib/tellstick/proxy_io.rb
    CHANGED
    
    | 
         @@ -22,7 +22,7 @@ module Tellstick 
     | 
|
| 
       22 
22 
     | 
    
         
             
                  @init_args = args
         
     | 
| 
       23 
23 
     | 
    
         
             
                  @class_to_proxy = klass
         
     | 
| 
       24 
24 
     | 
    
         
             
                  @tio = nil
         
     | 
| 
       25 
     | 
    
         
            -
                   
     | 
| 
      
 25 
     | 
    
         
            +
                  open
         
     | 
| 
       26 
26 
     | 
    
         
             
                end
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
                def method_missing(method_id)
         
     | 
| 
         @@ -52,6 +52,10 @@ module Tellstick 
     | 
|
| 
       52 
52 
     | 
    
         
             
                  @tio.gets
         
     | 
| 
       53 
53 
     | 
    
         
             
                end
         
     | 
| 
       54 
54 
     | 
    
         | 
| 
      
 55 
     | 
    
         
            +
                def to_s
         
     | 
| 
      
 56 
     | 
    
         
            +
                  open
         
     | 
| 
      
 57 
     | 
    
         
            +
                  @tio
         
     | 
| 
      
 58 
     | 
    
         
            +
                end
         
     | 
| 
       55 
59 
     | 
    
         
             
                private
         
     | 
| 
       56 
60 
     | 
    
         | 
| 
       57 
61 
     | 
    
         
             
                def create_io_instance
         
     | 
| 
         @@ -96,10 +96,8 @@ module TriggerSwitchD 
     | 
|
| 
       96 
96 
     | 
    
         
             
                end
         
     | 
| 
       97 
97 
     | 
    
         | 
| 
       98 
98 
     | 
    
         
             
                def self.__action_gut__(*args)
         
     | 
| 
       99 
     | 
    
         
            -
                  args. 
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
                    Tellstick::create(output,model_name).send(*params)
         
     | 
| 
       102 
     | 
    
         
            -
                  end
         
     | 
| 
      
 99 
     | 
    
         
            +
                  output, model_name, *params = args.flatten
         
     | 
| 
      
 100 
     | 
    
         
            +
                  Tellstick::create(output,model_name).send(*params)
         
     | 
| 
       103 
101 
     | 
    
         
             
                end
         
     | 
| 
       104 
102 
     | 
    
         | 
| 
       105 
103 
     | 
    
         
             
                def self.methodize_executable(executable)
         
     | 
| 
         @@ -90,7 +90,7 @@ module TriggerSwitchD 
     | 
|
| 
       90 
90 
     | 
    
         | 
| 
       91 
91 
     | 
    
         
             
                def self.set_type(name)
         
     | 
| 
       92 
92 
     | 
    
         
             
                  types = {"log_object" => "Hash.new(STDOUT).merge({:spec => StringIO.new, :development => STDOUT, 
         
     | 
| 
       93 
     | 
    
         
            -
                                          :file =>  
     | 
| 
      
 93 
     | 
    
         
            +
                                          :file => File.open(log_path,\"a+\")})",
         
     | 
| 
       94 
94 
     | 
    
         
             
                            "output" => "Hash.new(STDOUT).merge({:spec => StringIO.new, :development => STDOUT, 
         
     | 
| 
       95 
95 
     | 
    
         
             
                                          :vcp => Tellstick::ProxyIO.new(SerialPort,Config.vcp_port,4800,Proc.new { |sp| sp.puts(\"~^M~AT S7=45 S0=0 L1 V1 X4 &c1 E1 Q0^M\"); sp.puts(\"S+\"); sp.gets })})"}
         
     | 
| 
       96 
96 
     | 
    
         
             
                  return "@#{name}=value" unless types.keys.include? name
         
     | 
    
        data/samples/environment.rb
    CHANGED
    
    | 
         @@ -23,7 +23,7 @@ Config.geo_position = {:north => 54.57525, :west => -12.94125} 
     | 
|
| 
       23 
23 
     | 
    
         
             
            #       number instead of the xxxxxxxx
         
     | 
| 
       24 
24 
     | 
    
         
             
            Config.log_path = "~/.trigger_switch_d/log"
         
     | 
| 
       25 
25 
     | 
    
         
             
            Config.db_path = "~/.trigger_switch_d/db"
         
     | 
| 
       26 
     | 
    
         
            -
            Config.dsl_path = "config"
         
     | 
| 
      
 26 
     | 
    
         
            +
            Config.dsl_path = "~/.trigger_switch_d/config"
         
     | 
| 
       27 
27 
     | 
    
         
             
            # Config.vcp_port = "/dev/tty.usbserial-xxxxxxxx"
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
29 
     | 
    
         
             
            #Log: can be one of :file, :development or :spec (:spec is for the rspecs, ie don't use)
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version 
     | 
|
| 
       5 
5 
     | 
    
         
             
              segments: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              - 0
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 1
         
     | 
| 
       8 
     | 
    
         
            -
              -  
     | 
| 
       9 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 8 
     | 
    
         
            +
              - 3
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.1.3
         
     | 
| 
       10 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       11 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       12 
12 
     | 
    
         
             
            - "Pontus Str\xC3\xB6mdahl"
         
     | 
| 
         @@ -14,7 +14,7 @@ autorequire: 
     | 
|
| 
       14 
14 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       15 
15 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
            date: 2010-04- 
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2010-04-09 00:00:00 +02:00
         
     | 
| 
       18 
18 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       19 
19 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       20 
20 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     |