bubbles 0.0.5 → 0.1.0

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 (58) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE.txt +21 -0
  3. data/README.md +524 -80
  4. data/bubbles.gemspec +29 -21
  5. data/lib/bubbles/cursor.rb +169 -0
  6. data/lib/bubbles/file_picker.rb +397 -0
  7. data/lib/bubbles/help.rb +170 -0
  8. data/lib/bubbles/key.rb +96 -0
  9. data/lib/bubbles/list.rb +365 -0
  10. data/lib/bubbles/paginator.rb +158 -0
  11. data/lib/bubbles/progress.rb +276 -0
  12. data/lib/bubbles/spinner/spinners.rb +77 -0
  13. data/lib/bubbles/spinner.rb +122 -0
  14. data/lib/bubbles/stopwatch.rb +189 -0
  15. data/lib/bubbles/table.rb +248 -0
  16. data/lib/bubbles/text_area.rb +503 -0
  17. data/lib/bubbles/text_input.rb +543 -0
  18. data/lib/bubbles/timer.rb +196 -0
  19. data/lib/bubbles/version.rb +4 -1
  20. data/lib/bubbles/viewport.rb +296 -0
  21. data/lib/bubbles.rb +18 -35
  22. data/sig/bubbles/cursor.rbs +87 -0
  23. data/sig/bubbles/file_picker.rbs +138 -0
  24. data/sig/bubbles/help.rbs +88 -0
  25. data/sig/bubbles/key.rbs +63 -0
  26. data/sig/bubbles/list.rbs +138 -0
  27. data/sig/bubbles/paginator.rbs +90 -0
  28. data/sig/bubbles/progress.rbs +123 -0
  29. data/sig/bubbles/spinner/spinners.rbs +32 -0
  30. data/sig/bubbles/spinner.rbs +74 -0
  31. data/sig/bubbles/stopwatch.rbs +97 -0
  32. data/sig/bubbles/table.rbs +119 -0
  33. data/sig/bubbles/text_area.rbs +161 -0
  34. data/sig/bubbles/text_input.rbs +183 -0
  35. data/sig/bubbles/timer.rbs +107 -0
  36. data/sig/bubbles/version.rbs +5 -0
  37. data/sig/bubbles/viewport.rbs +125 -0
  38. data/sig/bubbles.rbs +4 -0
  39. metadata +66 -67
  40. data/.gitignore +0 -14
  41. data/.rspec +0 -2
  42. data/.travis.yml +0 -10
  43. data/Gemfile +0 -4
  44. data/LICENSE +0 -20
  45. data/Rakefile +0 -6
  46. data/bin/console +0 -14
  47. data/bin/setup +0 -8
  48. data/exe/bubbles +0 -5
  49. data/lib/bubbles/bubblicious_file.rb +0 -42
  50. data/lib/bubbles/command_queue.rb +0 -43
  51. data/lib/bubbles/common_uploader_interface.rb +0 -13
  52. data/lib/bubbles/config.rb +0 -149
  53. data/lib/bubbles/dir_watcher.rb +0 -53
  54. data/lib/bubbles/uploaders/local_dir.rb +0 -39
  55. data/lib/bubbles/uploaders/s3.rb +0 -36
  56. data/lib/bubbles/uploaders/s3_ensure_connection.rb +0 -26
  57. data/tmp/dummy_local_dir_uploader_dir/.gitkeep +0 -0
  58. data/tmp/dummy_processing_dir/.gitkeep +0 -0
@@ -1,149 +0,0 @@
1
- module Bubbles
2
- class Config
3
- def self.home_config
4
- Pathname.new(Dir.home).join('.bubbles/config.yml').to_s
5
- end
6
-
7
- def self.var_config
8
- '/var/lib/bubbles/config.yml'
9
- end
10
-
11
- attr_writer :config_path, :logger, :source_dir, :processing_dir, :log_path,
12
- :log_level, :sleep_interval, :uploader_classes, :num_of_files_to_schedule,
13
- :uniq_filename_randomizer, :local_dir_uploader_path, :s3_access_key_id, :s3_secret_access_key,
14
- :s3_region, :s3_path, :s3_bucket, :use_default_config_locations, :local_dir_metadata_file_path
15
-
16
- def log_path
17
- @log_path || config_yml['log_path'] || STDOUT
18
- end
19
-
20
- def log_level
21
- @log_level || config_yml['log_level'] || 0
22
- end
23
-
24
- def logger
25
- @logger ||= Logger.new(log_path).tap { |l| l.level = log_level }
26
- end
27
-
28
- def source_dir
29
- @source_dir ||= config_yml.fetch('source_dir') { raise_config_required }
30
- pathnamed(@source_dir)
31
- end
32
-
33
- def processing_dir
34
- @processing_dir ||= config_yml.fetch('processing_dir') { raise_config_required }
35
- pathnamed(@processing_dir)
36
- end
37
-
38
- def uploader_classes
39
- return @uploader_classes if @uploader_classes
40
- if uploaders = config_yml['uploaders']
41
- uploaders.map { |u| Object.const_get(u) }
42
- else
43
- [Bubbles::Uploaders::S3]
44
- end
45
- end
46
-
47
- def local_dir_metadata_file_path
48
- err_msg = 'You need to set `local_dir_metadata_file_path`'
49
- @local_dir_metadata_file_path ||= config_yml.fetch('local_dir_metadata_file_path') { raise err_msg }
50
- end
51
-
52
- def local_dir_uploader_path
53
- err_msg = 'As you are using LocalDir uploader,' +
54
- ' you need to specify `local_dir_uploader_path` in your config' +
55
- ' so the uploader knows where to upload'
56
- @local_dir_uploader_path ||= config_yml.fetch('local_dir_uploader_path') { raise err_msg }
57
- pathnamed(@local_dir_uploader_path)
58
- end
59
-
60
- # number of seconds between every command execution in queue seconds, defaults to 1
61
- def sleep_interval
62
- @sleep_interval \
63
- || config_yml['sleep_interval'] \
64
- || 1
65
- end
66
-
67
- # how many files should DirWatcher schedule for upload, defaults to 1
68
- def num_of_files_to_schedule
69
- @num_of_files_to_schedule || 1
70
- end
71
-
72
- def config_path
73
- if @config_path
74
- raise "Config file #{@config_path} does not exist" unless File.exist?(@config_path)
75
- @config_path
76
- elsif File.exist?(self.class.var_config) && use_default_config_locations
77
- self.class.var_config
78
- elsif File.exist?(self.class.home_config) && use_default_config_locations
79
- self.class.home_config
80
- end
81
- end
82
-
83
- def uniq_filename_randomizer
84
- @uniq_filename_randomizer ||= ->() { SecureRandom.uuid }
85
- end
86
-
87
- def s3_credentials
88
- @aws_credentials ||= Aws::Credentials.new(s3_access_key_id, s3_secret_access_key)
89
- end
90
-
91
- def s3_region
92
- @s3_region \
93
- || config_yml['s3_region'] \
94
- || raise('Please provide s3_region in your config file')
95
- end
96
-
97
- def s3_path
98
- @s3_path \
99
- || config_yml['s3_path'] \
100
- || ''
101
- end
102
-
103
- def s3_acl
104
- @s3_acl \
105
- || config_yml['s3_acl'] \
106
- || 'private'
107
- end
108
-
109
- def s3_bucket
110
- @s3_bucket \
111
- || config_yml['s3_bucket'] \
112
- || raise('Please provide s3_bucket in your config file')
113
- end
114
-
115
- private
116
- def use_default_config_locations
117
- return @use_default_config_locations unless @use_default_config_locations.nil?
118
- true
119
- end
120
-
121
- def s3_access_key_id
122
- @s3_access_key_id \
123
- || config_yml['s3_access_key_id'] \
124
- || raise('Please provide s3_access_key_id in your config file')
125
- end
126
-
127
- def s3_secret_access_key
128
- @s3_secret_access_key \
129
- || config_yml['s3_secret_access_key'] \
130
- || raise('Please provide s3_secret_access_key in your config file')
131
- end
132
-
133
- def config_yml
134
- if config_path
135
- @config_yml ||= YAML.load_file(config_path)
136
- else
137
- {}
138
- end
139
- end
140
-
141
- def raise_config_required
142
- raise "Please provide configuration file. You can do this by creating #{self.class.home_config} or check project github README.md"
143
- end
144
-
145
- def pathnamed(location_obj)
146
- location_obj.respond_to?(:basename) ? location_obj : Pathname.new(location_obj)
147
- end
148
- end
149
- end
@@ -1,53 +0,0 @@
1
- module Bubbles
2
- class DirWatcher
3
- extend Forwardable
4
- DestinationIsNotDirectory = Class.new(StandardError)
5
-
6
- def initialize(config:, command_queue:)
7
- @config = config
8
- @command_queue = command_queue
9
- end
10
-
11
- def call
12
- check_source_dir_existence
13
- check_processing_dir_existence
14
-
15
- source_dir_files
16
- .last(num_of_files_to_schedule)
17
- .each do |file|
18
- bfile = BubbliciousFile.new(file: file, config: config)
19
- bfile.copy_to_processing_dir
20
-
21
- uploader_classes.each do |uploader_class|
22
- command_queue << uploader_class.new(bfile: bfile, command_queue: command_queue, config: config)
23
- end
24
-
25
- command_queue << bfile.public_method(:remove_file)
26
- end
27
-
28
- command_queue << self
29
- end
30
-
31
- def inspect
32
- "#<#{self.class.name} source_dir: #{source_dir}, processing_dir: #{processing_dir}>"
33
- end
34
-
35
- def source_dir_files
36
- Dir
37
- .glob(source_dir.join('**/*').to_s)
38
- .select { |x| Pathname.new(x).file? }
39
- end
40
-
41
- private
42
- attr_reader :command_queue, :config
43
- def_delegators :config, :source_dir, :processing_dir, :num_of_files_to_schedule, :uploader_classes
44
-
45
- def check_source_dir_existence
46
- raise DestinationIsNotDirectory unless source_dir.directory?
47
- end
48
-
49
- def check_processing_dir_existence
50
- raise DestinationIsNotDirectory unless processing_dir.directory?
51
- end
52
- end
53
- end
@@ -1,39 +0,0 @@
1
- module Bubbles
2
- module Uploaders
3
- class LocalDir
4
- extend Forwardable
5
- include Bubbles::CommonUploaderInterface
6
-
7
- def call
8
- config.logger.debug("#{self.class.name}: transfering #{uid_file} to #{local_dir_uploader_path}")
9
- FileUtils.cp(uid_file, local_dir_uploader_path)
10
- write_metadata
11
- rescue Errno::ENOENT => e
12
- config.logger.error("#{e.message}")
13
- command_queue.reschedule(self)
14
- end
15
-
16
- def inspect
17
- "<##{self.class.name} uid_file: #{uid_file} to: #{local_dir_uploader_path}>"
18
- end
19
-
20
- private
21
- def_delegators :config, :local_dir_uploader_path, :local_dir_metadata_file_path
22
- def_delegators :bfile, :uid_file, :uid_file_name, :metadata
23
-
24
- def write_metadata
25
- File.open(local_dir_metadata_file_path, 'a') do |f|
26
- f.write yaml_append
27
- end
28
- end
29
-
30
- def yaml_append
31
- <<EOF
32
- -
33
- key: #{uid_file_name}
34
- metadata: #{metadata.to_json}
35
- EOF
36
- end
37
- end
38
- end
39
- end
@@ -1,36 +0,0 @@
1
- module Bubbles
2
- module Uploaders
3
- class S3
4
- extend Forwardable
5
- include Bubbles::CommonUploaderInterface
6
-
7
- def call
8
- File.open(uid_file, 'rb') do |file|
9
- s3.put_object(bucket: s3_bucket, key: s3_full_path, body: file, acl: config.s3_acl, metadata: metadata)
10
- end
11
- rescue => e
12
- config.logger.error("#{e.message}")
13
- command_queue.reschedule(self)
14
- end
15
-
16
- def inspect
17
- "<##{self.class.name} uid_file: #{uid_file} to: s3://#{s3_bucket}#{s3_full_path}>"
18
- end
19
-
20
- private
21
- def_delegators :config, :s3_bucket, :s3_path, :s3_credentials, :s3_region
22
- def_delegators :bfile, :uid_file, :uid_file_name, :metadata
23
-
24
- def s3
25
- @s3 ||= Aws::S3::Client.new({
26
- region: s3_region,
27
- credentials: s3_credentials
28
- })
29
- end
30
-
31
- def s3_full_path
32
- Pathname.new(s3_path).join(uid_file_name).to_s
33
- end
34
- end
35
- end
36
- end
@@ -1,26 +0,0 @@
1
- module Bubbles
2
- module Uploaders
3
- class S3EnsureConnection
4
- extend Forwardable
5
- include Bubbles::CommonUploaderInterface
6
-
7
- def call
8
- s3.list_buckets
9
- end
10
-
11
- def inspect
12
- "<##{self.class.name} testing connection to s3 bucket>"
13
- end
14
-
15
- private
16
- def_delegators :config, :s3_bucket, :s3_credentials, :s3_region
17
-
18
- def s3
19
- @s3 ||= Aws::S3::Client.new({
20
- region: s3_region,
21
- credentials: s3_credentials
22
- })
23
- end
24
- end
25
- end
26
- end
File without changes
File without changes