mode 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/.travis.yml +1 -0
- data/bin/mode +3 -8
- data/lib/connect.rb +13 -0
- data/lib/mode.rb +18 -5
- data/lib/mode/api/link.rb +4 -0
- data/lib/mode/api/request.rb +20 -10
- data/lib/mode/auth/access_token.rb +16 -0
- data/lib/mode/cli/connect.rb +1 -1
- data/lib/mode/commands/analyze_field.rb +1 -3
- data/lib/mode/commands/connect.rb +24 -49
- data/lib/mode/commands/helpers.rb +23 -18
- data/lib/mode/commands/import.rb +2 -4
- data/lib/mode/commands/login.rb +88 -25
- data/lib/mode/config.rb +60 -2
- data/lib/mode/connector/connect.rb +11 -0
- data/lib/mode/connector/daemon.rb +54 -12
- data/lib/mode/connector/daemonizer.rb +107 -0
- data/lib/mode/connector/data_source.rb +36 -9
- data/lib/mode/connector/scheduler.rb +6 -5
- data/lib/mode/connector/uploader.rb +3 -4
- data/lib/mode/version.rb +1 -1
- data/mode.gemspec +7 -4
- data/spec/api/request_spec.rb +9 -6
- data/spec/commands/connect_spec.rb +45 -59
- data/spec/commands/helpers_spec.rb +9 -22
- data/spec/commands/import_spec.rb +5 -0
- data/spec/commands/login_spec.rb +87 -76
- data/spec/config_spec.rb +9 -0
- data/spec/connector/daemon_spec.rb +11 -6
- data/spec/connector/daemonizer_spec.rb +106 -0
- data/spec/connector/data_source_spec.rb +15 -17
- data/spec/connector/registrar_spec.rb +5 -6
- data/spec/connector/scheduler_spec.rb +3 -2
- data/spec/connector/uploader_spec.rb +9 -9
- metadata +65 -65
- data/lib/mode/configurable.rb +0 -46
- data/lib/mode/connector/config.rb +0 -31
- data/spec/connector/config_spec.rb +0 -46
data/lib/mode/configurable.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
module Mode
|
2
|
-
module Configurable
|
3
|
-
def self.included(klass)
|
4
|
-
klass.send :attr_reader, :path
|
5
|
-
klass.send :extend, ClassMethods
|
6
|
-
end
|
7
|
-
|
8
|
-
module ClassMethods
|
9
|
-
def exists?(path)
|
10
|
-
File.exist?(full_path(path))
|
11
|
-
end
|
12
|
-
|
13
|
-
def init(path, filename = nil)
|
14
|
-
File.open(full_path(path, filename), 'w+') do |file|
|
15
|
-
file.write({}.to_yaml)
|
16
|
-
end
|
17
|
-
|
18
|
-
new(path, filename)
|
19
|
-
end
|
20
|
-
|
21
|
-
def default_dir
|
22
|
-
File.expand_path("~/.mode")
|
23
|
-
end
|
24
|
-
|
25
|
-
def full_path(path, filename = nil)
|
26
|
-
File.expand_path(File.join(path, filename || default_filename))
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def initialize(path, filename = nil)
|
31
|
-
@path = self.class.full_path(path, filename)
|
32
|
-
|
33
|
-
if File.exist?(@path)
|
34
|
-
configure YAML.load_file(@path)
|
35
|
-
else
|
36
|
-
raise "Could not load configuration file from #{@path}"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def save
|
41
|
-
File.open(path, 'w+') do |file|
|
42
|
-
file.write(to_yaml)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
|
3
|
-
module Mode
|
4
|
-
module Connector
|
5
|
-
class Config < Mode::Config
|
6
|
-
include Mode::Configurable
|
7
|
-
|
8
|
-
# Config Variables
|
9
|
-
attr_accessor :data_sources
|
10
|
-
|
11
|
-
class << self
|
12
|
-
def default_filename
|
13
|
-
'connect.yml'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def configure(config = {})
|
20
|
-
@data_sources ||= []
|
21
|
-
config.each do |name, props|
|
22
|
-
data_sources << Mode::Connector::DataSource.new(name, props)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def to_yaml
|
27
|
-
data_sources.to_yaml
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Mode::Connector::Config do
|
4
|
-
let(:tmpdir) { Dir.mktmpdir }
|
5
|
-
|
6
|
-
before do
|
7
|
-
initialize_logger
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should initialize" do
|
11
|
-
Mode::Connector::Config.exists?(tmpdir).should == false
|
12
|
-
config = Mode::Connector::Config.init(tmpdir)
|
13
|
-
Mode::Connector::Config.exists?(tmpdir).should == true
|
14
|
-
|
15
|
-
config.data_sources.should == []
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should initialize with data sources" do
|
19
|
-
config = Mode::Connector::Config.init(tmpdir)
|
20
|
-
config.data_sources << Mode::Connector::DataSource.new('test', {})
|
21
|
-
config.save
|
22
|
-
|
23
|
-
config = Mode::Connector::Config.new(tmpdir)
|
24
|
-
config.data_sources.length.should == 1
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should raise if config file doesn't exist" do
|
28
|
-
expect { config = Mode::Connector::Config.new('fake.yml') }.to raise_error
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should save" do
|
32
|
-
config = Mode::Connector::Config.init(tmpdir)
|
33
|
-
config.data_sources << Mode::Connector::DataSource.new('test', {})
|
34
|
-
config.save
|
35
|
-
|
36
|
-
File.read(config.path).should == config.send(:to_yaml)
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should have FILENAME" do
|
40
|
-
Mode::Connector::Config::default_filename.should == 'connect.yml'
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should generate full path" do
|
44
|
-
Mode::Connector::Config.full_path(tmpdir).should == File.join(tmpdir, 'connect.yml')
|
45
|
-
end
|
46
|
-
end
|