mode 0.0.10 → 0.0.11

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.travis.yml +1 -0
  4. data/bin/mode +3 -8
  5. data/lib/connect.rb +13 -0
  6. data/lib/mode.rb +18 -5
  7. data/lib/mode/api/link.rb +4 -0
  8. data/lib/mode/api/request.rb +20 -10
  9. data/lib/mode/auth/access_token.rb +16 -0
  10. data/lib/mode/cli/connect.rb +1 -1
  11. data/lib/mode/commands/analyze_field.rb +1 -3
  12. data/lib/mode/commands/connect.rb +24 -49
  13. data/lib/mode/commands/helpers.rb +23 -18
  14. data/lib/mode/commands/import.rb +2 -4
  15. data/lib/mode/commands/login.rb +88 -25
  16. data/lib/mode/config.rb +60 -2
  17. data/lib/mode/connector/connect.rb +11 -0
  18. data/lib/mode/connector/daemon.rb +54 -12
  19. data/lib/mode/connector/daemonizer.rb +107 -0
  20. data/lib/mode/connector/data_source.rb +36 -9
  21. data/lib/mode/connector/scheduler.rb +6 -5
  22. data/lib/mode/connector/uploader.rb +3 -4
  23. data/lib/mode/version.rb +1 -1
  24. data/mode.gemspec +7 -4
  25. data/spec/api/request_spec.rb +9 -6
  26. data/spec/commands/connect_spec.rb +45 -59
  27. data/spec/commands/helpers_spec.rb +9 -22
  28. data/spec/commands/import_spec.rb +5 -0
  29. data/spec/commands/login_spec.rb +87 -76
  30. data/spec/config_spec.rb +9 -0
  31. data/spec/connector/daemon_spec.rb +11 -6
  32. data/spec/connector/daemonizer_spec.rb +106 -0
  33. data/spec/connector/data_source_spec.rb +15 -17
  34. data/spec/connector/registrar_spec.rb +5 -6
  35. data/spec/connector/scheduler_spec.rb +3 -2
  36. data/spec/connector/uploader_spec.rb +9 -9
  37. metadata +65 -65
  38. data/lib/mode/configurable.rb +0 -46
  39. data/lib/mode/connector/config.rb +0 -31
  40. data/spec/connector/config_spec.rb +0 -46
@@ -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