clockker 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 577133b16adfca331464a0507a93165f8a512687
4
- data.tar.gz: f79729e1efa08d8e3bdfbb90e9edc42323379131
3
+ metadata.gz: a5917fe8052498f65072fe075093b1af5d725ea0
4
+ data.tar.gz: 0c09c0cbb7b630660b8f0326ba799a5c08fea671
5
5
  SHA512:
6
- metadata.gz: 2b3956f51e0a3b4660e0fb1068ee146dec57047e67f9a10673f7b3ae94cf10d6fdde9a69bdf5618aa86c8634a7aed2f374af53771cdc0766488c7af0063d54b1
7
- data.tar.gz: 5aae16c9040e0455b3bd8738e7061e6f9be3d6f62a1b18c8603716b5af10a5cafd340d13c1b6f1faf5f290f1c72b09a7ca13c783b5350cb2f4264f5b18948411
6
+ metadata.gz: 4c674892ffb7178e58fa8430582014ae8d456e92dce3c303aa344f0e8c53cab6897298638b5b0c58a243beb6f4d8aa821ea0a58d639f3a22b9610d77d7574f2d
7
+ data.tar.gz: efe5566b8355c97fc08f2015047aae7450231c39b8001e8658c582488a587afe388bfe75bcc33171b4392dac4936f519be0492c950d97a3e12c36924eff155c4
data/README.md CHANGED
@@ -30,6 +30,9 @@ Clockker takes several command-line options:
30
30
  `-s=x` / `--submit-frequency=x`
31
31
  : upload changed files list to Clockk server every <x> seconds. Default: 300 seconds.
32
32
 
33
+ `-d` / `--development`
34
+ : Development mode. In addition to submitting to the Clockk server, also submit the same artifacts to the server running at localhost:4000. Errors on the local server are logged and ignored.
35
+
33
36
  `-w=x y z` / `--whitelist=x y z`
34
37
  : Space-separated list of absolute paths to watch. Defaults to your home directory (~).
35
38
 
data/lib/clockker/cli.rb CHANGED
@@ -16,6 +16,7 @@ module Clockker
16
16
  method_option :identifier, aliases: '-i', type: :string, desc: "The identifier for this computer.", default: identifier
17
17
  method_option :submit_frequency, aliases: '-s', default: 300, desc: "Submit changeset to Clockk server every N seconds", type: :numeric
18
18
  method_option :verbose, aliases: '-v', default: 'fatal', lazy_default: 'info', enum: %w{debug info warn error fatal}, desc: "Set verbosity (default: info)"
19
+ method_option :development, aliases: '-d', default: false, desc: "Submit to a development server at localhost:4000 as well as the production server"
19
20
  def watch
20
21
  logger = Logger.new(STDERR)
21
22
  case options[:verbose]
@@ -49,6 +50,7 @@ module Clockker
49
50
  clockker_config.region = options[:region] if options[:region]
50
51
  clockker_config.whitelist = options[:whitelist] if options[:whitelist]
51
52
  clockker_config.blacklist = options[:blacklist] if options[:blacklist]
53
+ clockker_config.development = options[:development] if options[:development]
52
54
 
53
55
  if options[:token].nil? && clockker_config.token.nil?
54
56
  puts "You must provide a value for the token, either as a parameter (--token=x) or in the ~/.clockker_config file."
@@ -2,7 +2,7 @@ require 'JSON'
2
2
 
3
3
  module Clockker
4
4
  class Config
5
- attr_accessor :whitelist, :blacklist, :config_version, :token, :region, :identifier, :submit_frequency, :log_level
5
+ attr_accessor :whitelist, :blacklist, :config_version, :token, :region, :identifier, :submit_frequency, :log_level, :development
6
6
  def initialize(overrides = {})
7
7
  if File.exists?(File.join(Dir.home, '.clockker'))
8
8
  clockker_config = JSON.parse(File.read(File.join(Dir.home, '.clockker')))
@@ -18,6 +18,7 @@ module Clockker
18
18
  @region = clockker_config["region"]
19
19
  @submit_frequency = clockker_config["submit_frequency"]
20
20
  @log_level = clockker_config["log_level"]
21
+ @development = clockker_config["development"]
21
22
 
22
23
  # override values specified at the command line
23
24
  overrides.each do |key, value|
@@ -1,5 +1,5 @@
1
1
  module Clockker
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
 
4
4
  def self.macos_version
5
5
  @mov ||= `sw_vers -productVersion`
@@ -17,7 +17,7 @@ module Clockker
17
17
 
18
18
  @queue = Queue.new
19
19
  @watcher = Thread.new { create_watcher('/', white_black_list, logger) }
20
- @submitter = Thread.new { create_submitter(config.submit_frequency, config.region, config.token, config.identifier, logger) }
20
+ @submitter = Thread.new { create_submitter(config.submit_frequency, config.region, config.token, config.identifier, logger, config.development) }
21
21
 
22
22
  @watcher.join
23
23
  @submitter.join
@@ -42,10 +42,11 @@ module Clockker
42
42
  logger.info "#{Time.now} fswatcher done"
43
43
  end
44
44
 
45
- def create_submitter(submit_frequency, region, token, identifier, logger)
46
- logger.info "#{Time.now} submitting to clockk.com every #{submit_frequency} seconds with token #{token} from identifier #{identifier} with version #{Clockker.version}"
45
+ def create_submitter(submit_frequency, region, token, identifier, logger, development)
46
+ logger.info "#{Time.now} submitting to clockk.com #{"and localhost:4000 " if development}every #{submit_frequency} seconds with token #{token} from identifier #{identifier} with version #{Clockker.version}"
47
47
  t_start = Time.now
48
48
  clockk_agent_uri = URI("https://#{region}.clockk.io/api/v1/agent/artifacts")
49
+ clockk_local_uri = URI("http://localhost:4000/api/v1/agent/artifacts")
49
50
  @changeset = []
50
51
  loop do
51
52
  submit_now = false
@@ -84,6 +85,14 @@ module Clockker
84
85
  http.post(clockk_agent_uri.path, data, header)
85
86
  end
86
87
 
88
+ begin
89
+ Net::HTTP.start(clockk_local_uri.hostname, clockk_local_uri.port, use_ssl: clockk_local_uri.scheme == 'https') do |http|
90
+ http.post(clockk_local_uri.path, data, header)
91
+ end
92
+ rescue Exception => q
93
+ logger.info "#{Time.now} Failed to reach localhost:4000; ignoring"
94
+ end
95
+
87
96
  @changeset = []
88
97
  rescue Exception => e
89
98
  logger.info "#{Time.now} Reached exception #{e}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clockker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Doerwald
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-01 00:00:00.000000000 Z
11
+ date: 2018-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb-fsevent