sifttter-redux 0.5.1 → 0.5.2

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: 8428d3a20d173ff492101ecc333afa4920f6335f
4
- data.tar.gz: 1ecda6813567e1d839fda7116b859e568c896aea
3
+ metadata.gz: 125b9d118c416b34ebe992b95f18bb55d97d3807
4
+ data.tar.gz: a5e68191e9b9a584427e86e241f8ab0933b19104
5
5
  SHA512:
6
- metadata.gz: bac421d706ad288bbd317a72a03eed6f42ec233650aa4b7023254c87c49baefff9215d2842c7c1fd72ebf312ee253e872c2c683320005623471efe00a42ef667
7
- data.tar.gz: 4b61980d4dca38b59833e2d16dd53b057fe075f50246e69490d8c1c477ada6e6c0454d81a2b39a478d8e9e6c5bf90486250661f95e868429bee2ad9c30cadccb
6
+ metadata.gz: 1e59c3223ed42ccb22ff39a66673f5ce906646157a0e42f97c23a5e217da86bffdaeec2b977ea65c971812fd2c60becd605d11bdc6d408ce68a1160d201258bf
7
+ data.tar.gz: b8d58d3b7ce838909504694dd5346ee94874b790cda987604ed1facf27890cf2d814aaef527c2634484615c874d9d88d6bd2497ae3d29189213d83e38e11efff
data/.gitignore CHANGED
@@ -1,8 +1,5 @@
1
1
  Gemfile.lock
2
2
  .bundle
3
3
  .DS_Store
4
- features
5
4
  results.html
6
- README.rdoc
7
- Sifttter-Redux.rdoc
8
5
  *.gem
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.5.2 (2014-03-18)
2
+
3
+ * New Configuration management system
4
+
1
5
  # 0.5.1 (2014-03-18)
2
6
 
3
7
  * Fixed a bug regarding missing Methadone references
File without changes
data/README.md CHANGED
@@ -39,7 +39,7 @@ SYNOPSIS
39
39
  srd [global options] command [command options] [arguments...]
40
40
 
41
41
  VERSION
42
- 0.5.1
42
+ 0.5.2
43
43
 
44
44
  GLOBAL OPTIONS
45
45
  --help - Show this message
data/Rakefile CHANGED
@@ -1,9 +1,84 @@
1
1
  require 'rake/clean'
2
- require 'rake/testtask'
2
+ require 'rubygems'
3
+ require 'rubygems/package_task'
4
+ require 'rdoc/task'
5
+ require 'cucumber'
6
+ require 'cucumber/rake/task'
7
+ Rake::RDocTask.new do |rd|
8
+ rd.main = "README.rdoc"
9
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
10
+ rd.title = 'Your application title'
11
+ end
12
+
13
+ spec = eval(File.read('sifttter_redux.gemspec'))
14
+
15
+ Gem::PackageTask.new(spec) do |pkg|
16
+ end
17
+ CUKE_RESULTS = 'results.html'
18
+ CLEAN << CUKE_RESULTS
19
+ desc 'Run features'
20
+ Cucumber::Rake::Task.new(:features) do |t|
21
+ opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
22
+ opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
23
+ t.cucumber_opts = opts
24
+ t.fork = false
25
+ end
26
+
27
+ desc 'Run features tagged as work-in-progress (@wip)'
28
+ Cucumber::Rake::Task.new('features:wip') do |t|
29
+ tag_opts = ' --tags ~@pending'
30
+ tag_opts = ' --tags @wip'
31
+ t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
32
+ t.fork = false
33
+ end
3
34
 
35
+ task :cucumber => :features
36
+ task 'cucumber:wip' => 'features:wip'
37
+ task :wip => 'features:wip'
38
+ require 'rake/testtask'
4
39
  Rake::TestTask.new do |t|
5
40
  t.libs << "test"
6
41
  t.test_files = FileList['test/*_test.rb']
7
42
  end
8
43
 
9
- task :default => [:test]
44
+ task :default => [:test,:features]
45
+
46
+ # require 'rake/clean'
47
+ # require 'rubygems'
48
+ # require 'rubygems/package_task'
49
+ # require 'cucumber'
50
+ # require 'cucumber/rake/task'
51
+ # spec = eval(File.read('sifttter_redux.gemspec'))
52
+ #
53
+ # Gem::PackageTask.new(spec) do |pkg|
54
+ # end
55
+ #
56
+ # CUKE_RESULTS = 'results.html'
57
+ # CLEAN << CUKE_RESULTS
58
+ #
59
+ # desc 'Run features'
60
+ # Cucumber::Rake::Task.new(:features) do |t|
61
+ # opts = "features --format html -o #{CUKE_RESULTS} --format progress -x"
62
+ # opts += " --tags #{ENV['TAGS']}" if ENV['TAGS']
63
+ # t.cucumber_opts = opts
64
+ # t.fork = false
65
+ # end
66
+ #
67
+ # desc 'Run features tagged as work-in-progress (@wip)'
68
+ # Cucumber::Rake::Task.new('features:wip') do |t|
69
+ # tag_opts = ' --tags ~@pending'
70
+ # tag_opts = ' --tags @wip'
71
+ # t.cucumber_opts = "features --format html -o #{CUKE_RESULTS} --format pretty -x -s#{tag_opts}"
72
+ # t.fork = false
73
+ # end
74
+ #
75
+ # task :cucumber => :features
76
+ # task 'cucumber:wip' => 'features:wip'
77
+ # task :wip => 'features:wip'
78
+ # require 'rake/testtask'
79
+ # Rake::TestTask.new do |t|
80
+ # t.libs << "test"
81
+ # t.test_files = FileList['test/*_test.rb']
82
+ # end
83
+ #
84
+ # task :default => [:test,:features]
data/bin/srd CHANGED
@@ -59,19 +59,20 @@ switch([:verbose], desc: 'Turns on verbose output')
59
59
  # Pre, Post, and Error
60
60
  # ======================================================
61
61
  pre do |global, command, options, args|
62
+
62
63
  # Load SifttterRedux configuration module.
63
64
  Configuration::load(SRD_CONFIG_FILEPATH)
64
-
65
+
65
66
  # Set up logging.
66
67
  CLIMessage::activate_logging
67
- CLIMessage::log_level(Configuration['sifttter_redux']['log_level'])
68
+ CLIMessage::log_level(Configuration::sifttter_redux[:log_level] || Logger::WARN)
68
69
 
69
70
  if File.exists?(SRD_CONFIG_FILEPATH)
70
- current_version = Gem::Version.new(Configuration['sifttter_redux']['version'])
71
+ current_version = Gem::Version.new(Configuration::sifttter_redux[:version])
71
72
  last_config_change_version = Gem::Version.new(NEWEST_CONFIG_VERSION)
72
73
 
73
74
  # If the config file needs updating, force the user to do that first.
74
- if Configuration['sifttter_redux']['version'].nil? || current_version < last_config_change_version
75
+ if Configuration::sifttter_redux[:version].nil? || current_version < last_config_change_version
75
76
  CLIMessage::info('This version needs to make some config changes.')
76
77
  CLIMessage::info("Don't worry; when prompted, your current values for")
77
78
  CLIMessage::info("existing config options will be presented (so it'll")
@@ -124,10 +125,10 @@ command :exec do |c|
124
125
  CLIMessage::info("Creating #{ first_date == second_date ? 'entry' : 'entries' }: #{ date_string }")
125
126
 
126
127
  # Download Sifttter files from Dropbox.
127
- dbu = DropboxUploader.new(Configuration['db_uploader']['exe_filepath'])
128
+ dbu = DropboxUploader.new(Configuration::db_uploader[:exe_filepath])
128
129
  dbu.verbose = SifttterRedux.verbose
129
- dbu.local_target = Configuration['sifttter_redux']['sifttter_local_filepath']
130
- dbu.remote_target = Configuration['sifttter_redux']['sifttter_remote_filepath']
130
+ dbu.local_target = Configuration::sifttter_redux[:sifttter_local_filepath]
131
+ dbu.remote_target = Configuration::sifttter_redux[:sifttter_remote_filepath]
131
132
  dbu.message = 'Downloading Sifttter files...'
132
133
 
133
134
  CLIMessage::info_block(dbu.message || dbu::DEFAULT_MESSAGE, 'Done.', SifttterRedux.verbose) do
@@ -140,9 +141,9 @@ command :exec do |c|
140
141
  end
141
142
 
142
143
  # Upload any Day One entries to Dropbox (if there are any).
143
- unless Dir[Configuration['sifttter_redux']['dayone_local_filepath'] + '/*'].empty?
144
- dbu.local_target = "#{ Configuration['sifttter_redux']['dayone_local_filepath'] }/*"
145
- dbu.remote_target = Configuration['sifttter_redux']['dayone_remote_filepath']
144
+ unless Dir[Configuration::sifttter_redux[:dayone_local_filepath] + '/*'].empty?
145
+ dbu.local_target = "#{ Configuration::sifttter_redux[:dayone_local_filepath] }/*"
146
+ dbu.remote_target = Configuration::sifttter_redux[:dayone_remote_filepath]
146
147
  dbu.message = 'Uploading Day One entries to Dropbox...'
147
148
 
148
149
  CLIMessage::info_block(dbu.message || dbu::DEFAULT_MESSAGE, 'Done.', SifttterRedux.verbose) do
@@ -108,6 +108,7 @@ module SifttterRedux
108
108
  'FATAL' => Logger::FATAL,
109
109
  'UNKNOWN' => Logger::UNKNOWN
110
110
  }
111
+
111
112
  def self.log_level(level)
112
113
  @@logger.level = LOG_LEVELS[level] if LOG_LEVELS.key?(level)
113
114
  end
@@ -8,92 +8,44 @@ module SifttterRedux
8
8
  # into which they get stored.
9
9
  # ======================================================
10
10
  module Configuration
11
+ extend self
12
+
13
+ @_data = {}
11
14
  # ====================================================
12
15
  # Methods
13
16
  # ====================================================
14
17
  # ----------------------------------------------------
15
- # [] method
18
+ # deep_merge! method
16
19
  #
17
- # Returns the Hash of data for a particular section.
18
- # @param section_name The section in which to look
19
- # @return Hash
20
+ # Deep merges two hashes.
21
+ # deep_merge by Stefan Rusterholz;
22
+ # see http://www.ruby-forum.com/topic/142809
23
+ # @return Void
20
24
  # ----------------------------------------------------
21
- def self.[](section_name)
22
- if section_exists?(section_name)
23
- @data[section_name]
24
- else
25
- error = "Section does not exist: #{ section_name }"
26
- fail ArgumentError, error
27
- end
25
+ def deep_merge!(target, data)
26
+ merger = proc{|key, v1, v2|
27
+ Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
28
+ target.merge! data, &merger
28
29
  end
29
30
 
30
- # ----------------------------------------------------
31
- # []= method
32
- #
33
- # Assigns the passed hash to the section. NOTE THAT THE
34
- # PREVIOUS CONTENTS OF THAT SECTION ARE OVERWRITTEN.
35
- # @param section_name The section in which to look
36
- # @param hash The Hash that gets merged into the section
37
- # @return Void
38
- # ----------------------------------------------------
39
- def self.[]=(section_name, hash)
40
- if hash.is_a?(Hash)
41
- @data[section_name] = {}
42
- @data[section_name].merge!(hash)
43
- else
44
- error = "Parameter is not a Hash: #{ hash }"
45
- fail ArgumentError, error
46
- end
31
+ def method_missing(name, *args, &block)
32
+ @_data[name.to_sym] || {}
47
33
  end
48
34
 
49
- # ----------------------------------------------------
50
- # add_section method
51
- #
52
- # Creates a new section in the configuration data.
53
- # @param section_name The section to add
54
- # @return Void
55
- # ----------------------------------------------------
56
35
  def self.add_section(section_name)
57
- if !self.section_exists?(section_name)
58
- @data[section_name] = {}
59
- else
60
- CLIMessage::warning("Can't create already-existing section: #{ section_name }")
61
- end
36
+ @_data[section_name] = {} unless @_data.key?(section_name)
62
37
  end
63
-
64
- # ----------------------------------------------------
65
- # config_path method
66
- #
67
- # Returns the filepath to the flat configuration file.
68
- # @return String
69
- # ----------------------------------------------------
38
+
70
39
  def self.config_path
71
- @config_path
40
+ @_config_path
72
41
  end
73
-
74
- # ----------------------------------------------------
75
- # delete_section method
76
- #
77
- # Deletes a section from the configuration data.
78
- # @param section_name The section to delete
79
- # @return Void
80
- # ----------------------------------------------------
42
+
81
43
  def self.delete_section(section_name)
82
- if self.section_exists?(section_name)
83
- @data.delete(section_name)
84
- else
85
- CLIMessage::warning("Can't delete non-existing section: #{ section_name }")
86
- end
44
+ @_data.delete(section_name) if @_data.key?(section_name)
87
45
  end
88
46
 
89
- # ----------------------------------------------------
90
- # dump method
91
- #
92
- # Returns the data Hash
93
- # @return Hash
94
- # ----------------------------------------------------
95
47
  def self.dump
96
- @data
48
+ @_data
97
49
  end
98
50
 
99
51
  # ----------------------------------------------------
@@ -105,12 +57,11 @@ module SifttterRedux
105
57
  # @return Void
106
58
  # ----------------------------------------------------
107
59
  def self.load(path)
108
- @config_path = path
109
-
60
+ @_config_path = path
61
+
110
62
  if File.exists?(path)
111
- @data = YAML.load_file(path)
112
- else
113
- @data = {}
63
+ data = YAML.load_file(path)
64
+ deep_merge!(@_data, data)
114
65
  end
115
66
  end
116
67
 
@@ -121,7 +72,7 @@ module SifttterRedux
121
72
  # @return Void
122
73
  # ----------------------------------------------------
123
74
  def self.reset
124
- @data = {}
75
+ @_data = {}
125
76
  end
126
77
 
127
78
  # ----------------------------------------------------
@@ -132,18 +83,7 @@ module SifttterRedux
132
83
  # @return Void
133
84
  # ----------------------------------------------------
134
85
  def self.save
135
- File.open(@config_path, 'w') { |f| f.write(@data.to_yaml) }
136
- end
137
-
138
- # ----------------------------------------------------
139
- # section_exists? method
140
- #
141
- # Checks for the existance of the passed section.
142
- # @param section_name The section to look for
143
- # @return Bool
144
- # ----------------------------------------------------
145
- def self.section_exists?(section_name)
146
- @data.key?(section_name)
86
+ File.open(@_config_path, 'w') { |f| f.write(@_data.to_yaml) }
147
87
  end
148
88
  end
149
89
  end
@@ -46,9 +46,9 @@ module SifttterRedux
46
46
  date_regex = "(?:#{ date.strftime("%B") } 0?#{ date.strftime("%-d") }, #{ date.strftime("%Y") })"
47
47
  time_regex = "(?:\d{1,2}:\d{1,2}\s?[AaPpMm]{2})"
48
48
 
49
- files = `find #{ Configuration['sifttter_redux']['sifttter_local_filepath'] } -type f -name "*.txt" | grep -v -i daily | sort`
49
+ files = `find #{ Configuration::sifttter_redux[:sifttter_local_filepath] } -type f -name "*.txt" | grep -v -i daily | sort`
50
50
  if files.empty?
51
- CLIMessage::error("No Sifttter files to parse; is #{ Configuration['sifttter_redux']['sifttter_remote_filepath'] } the correct remote filepath?")
51
+ CLIMessage::error("No Sifttter files to parse; is #{ Configuration::sifttter_redux[:sifttter_remote_filepath] } the correct remote filepath?")
52
52
  return
53
53
  end
54
54
 
@@ -86,9 +86,9 @@ module SifttterRedux
86
86
  entrytext += project.gsub(/.txt/, ' ') + "\n\n"
87
87
  end
88
88
 
89
- Dir.mkdir(Configuration['sifttter_redux']['dayone_local_filepath']) if !Dir.exists?(Configuration['sifttter_redux']['dayone_local_filepath'])
89
+ Dir.mkdir(Configuration::sifttter_redux[:dayone_local_filepath]) if !Dir.exists?(Configuration::sifttter_redux[:dayone_local_filepath])
90
90
 
91
- fh = File.new(File.expand_path(Configuration['sifttter_redux']['dayone_local_filepath'] + '/' + uuid + '.doentry'), 'w+')
91
+ fh = File.new(File.expand_path(Configuration::sifttter_redux[:dayone_local_filepath] + '/' + uuid + '.doentry'), 'w+')
92
92
  fh.puts template.result(binding)
93
93
  fh.close
94
94
  CLIMessage::success("Entry logged for #{ date_for_title }...")
@@ -1,4 +1,6 @@
1
1
  module SifttterRedux
2
- VERSION = '0.5.1'
3
- NEWEST_CONFIG_VERSION = '0.4.7'
2
+ DESCRIPTION = 'A customized IFTTT-to-Day One service that allows for smart installation and automated running on a standalone *NIX device (such as a Raspberry Pi).'
3
+ SUMMARY = 'Automated IFTTT to Day One engine.'
4
+ VERSION = '0.5.2'
5
+ NEWEST_CONFIG_VERSION = '0.5.2'
4
6
  end
@@ -40,8 +40,8 @@ module SifttterRedux
40
40
  # ----------------------------------------------------
41
41
  def self.cleanup_temp_files
42
42
  dirs = [
43
- Configuration['sifttter_redux']['dayone_local_filepath'],
44
- Configuration['sifttter_redux']['sifttter_local_filepath']
43
+ Configuration::sifttter_redux[:dayone_local_filepath],
44
+ Configuration::sifttter_redux[:sifttter_local_filepath]
45
45
  ]
46
46
 
47
47
  CLIMessage::info_block('Removing temporary local files...') do
@@ -65,8 +65,8 @@ module SifttterRedux
65
65
  CLIMessage::section_block('CONFIGURING DROPBOX UPLOADER...') do
66
66
  until valid_path_chosen
67
67
  # Prompt the user for a location to save Dropbox Uploader.
68
- if reinit && !Configuration['db_uploader']['base_filepath'].nil?
69
- default = Configuration['db_uploader']['base_filepath']
68
+ if reinit && !Configuration::db_uploader[:base_filepath].nil?
69
+ default = Configuration::db_uploader[:base_filepath]
70
70
  else
71
71
  default = DBU_LOCAL_FILEPATH
72
72
  end
@@ -94,8 +94,12 @@ module SifttterRedux
94
94
  CLIMessage::info_block('Initializing Dropbox Uploader...') { system "#{ executable_path }" }
95
95
  end
96
96
 
97
- Configuration::add_section('db_uploader') unless reinit
98
- Configuration['db_uploader'].merge!('base_filepath' => path, 'dbu_filepath' => dbu_path, 'exe_filepath' => executable_path)
97
+ Configuration::add_section(:db_uploader) unless reinit
98
+ Configuration::db_uploader.merge!({
99
+ base_filepath: path,
100
+ dbu_filepath: dbu_path,
101
+ exe_filepath: executable_path
102
+ })
99
103
  else
100
104
  CLIMessage::error("Sorry, but #{ path } isn't a valid directory.")
101
105
  end
@@ -159,10 +163,11 @@ module SifttterRedux
159
163
  Configuration::reset
160
164
  Configuration::add_section('sifttter_redux')
161
165
  end
162
- Configuration['sifttter_redux'].merge!({
163
- 'config_location' => Configuration::config_path,
164
- 'log_level' => 'WARN',
165
- 'version' => VERSION,
166
+
167
+ Configuration::sifttter_redux.merge!({
168
+ config_location: Configuration::config_path,
169
+ log_level: 'WARN',
170
+ version: VERSION,
166
171
  })
167
172
 
168
173
  # Run the wizard to download Dropbox Uploader.
@@ -172,36 +177,37 @@ module SifttterRedux
172
177
  CLIMessage::section_block('COLLECTING PREFERENCES...') do
173
178
  pref_prompts = [
174
179
  {
175
- prompt: 'Location for downloaded Sifttter files from Dropbox',
180
+ prompt: 'Temporary path to download Sifttter files to',
176
181
  default: SFT_LOCAL_FILEPATH,
177
- key: 'sifttter_local_filepath',
178
- section: 'sifttter_redux'
182
+ key: :sifttter_local_filepath,
183
+ section: :sifttter_redux
179
184
  },
180
185
  {
181
- prompt: 'Location of Sifttter files in Dropbox',
186
+ prompt: 'Path to Sifttter files in Dropbox',
182
187
  default: SFT_REMOTE_FILEPATH,
183
- key: 'sifttter_remote_filepath',
184
- section: 'sifttter_redux'
188
+ key: :sifttter_remote_filepath,
189
+ section: :sifttter_redux
185
190
  },
186
191
  {
187
- prompt: 'Location for downloaded Day One files from Dropbox',
192
+ prompt: 'Temporary path to download Day One files to',
188
193
  default: DO_LOCAL_FILEPATH,
189
- key: 'dayone_local_filepath',
190
- section: 'sifttter_redux'
194
+ key: :dayone_local_filepath,
195
+ section: :sifttter_redux
191
196
  },
192
197
  {
193
- prompt: 'Location of Day One files in Dropbox',
198
+ prompt: 'Path to Day One files in Dropbox',
194
199
  default: DO_REMOTE_FILEPATH,
195
- key: 'dayone_remote_filepath',
196
- section: 'sifttter_redux'
200
+ key: :dayone_remote_filepath,
201
+ section: :sifttter_redux
197
202
  }
198
203
  ]
199
204
 
200
205
  pref_prompts.each do |prompt|
201
- d = reinit ? Configuration[prompt[:section]][prompt[:key]] : prompt[:default]
206
+ d = reinit ? Configuration::send(prompt[:section].to_sym)[prompt[:key]] : prompt[:default]
202
207
  pref = CLIMessage::prompt(prompt[:prompt], d)
203
208
 
204
- Configuration[prompt[:section]].merge!(prompt[:key] => File.expand_path(pref))
209
+ pref = File.expand_path(pref) if pref.start_with?('~')
210
+ Configuration::send(prompt[:section].to_sym).merge!(prompt[:key] => pref)
205
211
  CLIMessage::debug("Value for #{ prompt[:key] }: #{ pref }")
206
212
  end
207
213
  end
@@ -1,27 +1,31 @@
1
- # Ensure we require the local version and not one we might have installed already
2
- require File.join([File.dirname(__FILE__), 'lib', 'sifttter_redux', 'version.rb'])
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sifttter_redux/version'
3
5
 
4
- spec = Gem::Specification.new do |s|
5
- s.name = 'sifttter-redux'
6
- s.version = SifttterRedux::VERSION
7
- s.author = 'Aaron Bach'
8
- s.email = 'bachya1208@gmail.com'
9
- s.homepage = 'https://github.com/bachya/sifttter-redux'
10
- s.platform = Gem::Platform::RUBY
11
- s.summary = 'Automated IFTTT to Day One engine.'
12
- s.description = 'A customized IFTTT-to-Day One service that allows for smart installation and automated running on a standalone *NIX device (such as a Raspberry Pi).'
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'sifttter-redux'
8
+ spec.version = SifttterRedux::VERSION
9
+ spec.authors = ['Aaron Bach']
10
+ spec.email = ['bachya1208@googlemail.com']
11
+ spec.summary = SifttterRedux::SUMMARY
12
+ spec.description = SifttterRedux::DESCRIPTION
13
+ spec.homepage = 'https://github.com/bachya/sifttter-redux'
14
+ spec.license = 'MIT'
15
+ spec.platform = Gem::Platform::RUBY
13
16
 
14
- s.files = `git ls-files`.split("\n")
15
- s.test_files = `git ls-files -- test`.split("\n")
16
- s.require_paths << 'lib'
17
- s.bindir = 'bin'
18
- s.executables << 'srd'
17
+ spec.require_paths = ["lib"]
18
+ spec.files = `git ls-files`.split("\n")
19
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
21
 
20
- s.license = 'MIT'
21
- s.rdoc_options = ['--charset=UTF-8']
22
- s.extra_rdoc_files = %w[README.md HISTORY.md LICENSE.txt]
22
+ spec.license = 'MIT'
23
+ spec.rdoc_options = ['--charset=UTF-8']
24
+ spec.extra_rdoc_files = %w[README.md HISTORY.md LICENSE]
23
25
 
24
- s.add_development_dependency('rake', '~> 0')
25
- s.add_runtime_dependency('chronic', '0.10.2')
26
- s.add_runtime_dependency('gli','2.9.0')
26
+ spec.add_development_dependency('rake', '~> 0')
27
+ spec.add_development_dependency('rdoc', '~> 0')
28
+ spec.add_development_dependency('aruba', '~> 0')
29
+ spec.add_runtime_dependency('chronic', '0.10.2')
30
+ spec.add_runtime_dependency('gli','2.9.0')
27
31
  end
@@ -50,20 +50,5 @@ class CLIMessageTest < Test::Unit::TestCase
50
50
  def test_warning_message
51
51
  assert_output('# test'.yellow + "\n") { SifttterRedux::CLIMessage::warning('test') }
52
52
  end
53
-
54
- # def test_prompt
55
- # with_stdin do |answer|
56
- # answer.puts 'default'
57
- # assert_equal(SifttterRedux::CLIMessage::prompt('Hit enter to give the default response', 'default'), 'default')
58
- # end
59
- # end
60
- #
61
- # def with_stdin
62
- # stdin = $stdin # remember $stdin
63
- # $stdin, write = IO.pipe # create pipe assigning its "read end" to $stdin
64
- # yield write # pass pipe's "write end" to block
65
- # ensure
66
- # write.close # close pipe
67
- # $stdin = stdin # restore $stdin
68
- # end
53
+
69
54
  end
@@ -12,26 +12,29 @@ class ConfigurationTest < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  def test_add_data
15
- SifttterRedux::Configuration::add_section('section1')
16
- SifttterRedux::Configuration['section1'] = { 'a' => 'test', 'b' => 'test' }
17
- assert_equal(SifttterRedux::Configuration::dump, { 'section1' => { 'a' => 'test', 'b' => 'test' } })
15
+ SifttterRedux::Configuration::reset
16
+ SifttterRedux::Configuration::add_section(:section1)
17
+ SifttterRedux::Configuration::section1.merge!( a: 'test', b: 'test' )
18
+ assert_equal(SifttterRedux::Configuration::dump, { section1: { a: 'test', b: 'test' } })
18
19
 
19
- SifttterRedux::Configuration['section1']['a'] = 'bigger test'
20
- SifttterRedux::Configuration['section1']['c'] = 'little test'
21
- assert_equal(SifttterRedux::Configuration::dump, { 'section1' => { 'a' => 'bigger test', 'b' => 'test', 'c' => 'little test' } })
20
+ SifttterRedux::Configuration::section1[:a] = 'bigger test'
21
+ SifttterRedux::Configuration::section1[:c] = 'little test'
22
+ assert_equal(SifttterRedux::Configuration::dump, { section1: { a: 'bigger test', b: 'test', c: 'little test' } })
22
23
  end
23
24
 
24
25
  def test_add_section
25
- SifttterRedux::Configuration::add_section('section1')
26
- SifttterRedux::Configuration::add_section('section2')
27
- assert_equal(SifttterRedux::Configuration::dump, { 'section1' => {}, 'section2' => {} })
26
+ SifttterRedux::Configuration::reset
27
+ SifttterRedux::Configuration::add_section(:section1)
28
+ SifttterRedux::Configuration::add_section(:section2)
29
+ assert_equal(SifttterRedux::Configuration::dump, { section1: {}, section2: {} })
28
30
  end
29
31
 
30
32
  def test_add_section_duplicate
31
- SifttterRedux::Configuration::add_section('section1')
32
- SifttterRedux::Configuration::add_section('section2')
33
- SifttterRedux::Configuration::add_section('section2')
34
- assert_equal(SifttterRedux::Configuration::dump, { 'section1' => {}, 'section2' => {} })
33
+ SifttterRedux::Configuration::reset
34
+ SifttterRedux::Configuration::add_section(:section1)
35
+ SifttterRedux::Configuration::add_section(:section2)
36
+ SifttterRedux::Configuration::add_section(:section2)
37
+ assert_equal(SifttterRedux::Configuration::dump, { section1: {}, section2: {} })
35
38
  end
36
39
 
37
40
  def test_config_path
@@ -39,38 +42,37 @@ class ConfigurationTest < Test::Unit::TestCase
39
42
  end
40
43
 
41
44
  def test_delete_section
42
- SifttterRedux::Configuration::add_section('section1')
43
- SifttterRedux::Configuration::add_section('section2')
44
- SifttterRedux::Configuration::delete_section('section2')
45
- assert_equal(SifttterRedux::Configuration::dump, { 'section1' => {} })
45
+ SifttterRedux::Configuration::reset
46
+ SifttterRedux::Configuration::add_section(:section1)
47
+ SifttterRedux::Configuration::add_section(:section2)
48
+ SifttterRedux::Configuration::delete_section(:section2)
49
+ assert_equal(SifttterRedux::Configuration::dump, { section1: {} })
46
50
  end
47
51
 
48
52
  def test_delete_section_nonexistant
49
- SifttterRedux::Configuration::add_section('section1')
53
+ SifttterRedux::Configuration::reset
54
+ SifttterRedux::Configuration::add_section(:section1)
50
55
  SifttterRedux::Configuration::delete_section('section12723762323')
51
- assert_equal(SifttterRedux::Configuration::dump, { 'section1' => {} })
56
+ assert_equal(SifttterRedux::Configuration::dump, { section1: {} })
52
57
  end
53
58
 
54
59
  def test_reset
55
- SifttterRedux::Configuration::add_section('section1')
56
- SifttterRedux::Configuration::add_section('section2')
57
- SifttterRedux::Configuration::add_section('section3')
60
+ SifttterRedux::Configuration::reset
61
+ SifttterRedux::Configuration::add_section(:section1)
62
+ SifttterRedux::Configuration::add_section(:section2)
63
+ SifttterRedux::Configuration::add_section(:section3)
58
64
  SifttterRedux::Configuration::reset
59
65
  assert_equal(SifttterRedux::Configuration::dump, {})
60
66
  end
61
67
 
62
68
  def test_save
63
- SifttterRedux::Configuration::add_section('section1')
64
- SifttterRedux::Configuration['section1'] = { 'a' => 'test', 'b' => 'test' }
69
+ SifttterRedux::Configuration::reset
70
+ SifttterRedux::Configuration::add_section(:section1)
71
+ SifttterRedux::Configuration.section1.merge!({ a: 'test', b: 'test' })
65
72
  SifttterRedux::Configuration::save
66
73
 
67
74
  File.open('/tmp/srd_config', 'r') do |f|
68
- assert_output("---\nsection1:\n a: test\n b: test\n") { puts f.read }
75
+ assert_output("---\n:section1:\n :a: test\n :b: test\n") { puts f.read }
69
76
  end
70
77
  end
71
-
72
- def test_section_exists
73
- SifttterRedux::Configuration::add_section('section1')
74
- assert_equal(SifttterRedux::Configuration::section_exists?('section1'), true)
75
- end
76
78
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sifttter-redux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Bach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-18 00:00:00.000000000 Z
11
+ date: 2014-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: aruba
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: chronic
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -54,20 +82,21 @@ dependencies:
54
82
  version: 2.9.0
55
83
  description: A customized IFTTT-to-Day One service that allows for smart installation
56
84
  and automated running on a standalone *NIX device (such as a Raspberry Pi).
57
- email: bachya1208@gmail.com
85
+ email:
86
+ - bachya1208@googlemail.com
58
87
  executables:
59
88
  - srd
60
89
  extensions: []
61
90
  extra_rdoc_files:
62
91
  - README.md
63
92
  - HISTORY.md
64
- - LICENSE.txt
93
+ - LICENSE
65
94
  files:
66
95
  - ".gitignore"
67
96
  - ".travis.yml"
68
97
  - Gemfile
69
98
  - HISTORY.md
70
- - LICENSE.txt
99
+ - LICENSE
71
100
  - README.md
72
101
  - Rakefile
73
102
  - bin/srd
@@ -92,7 +121,6 @@ rdoc_options:
92
121
  - "--charset=UTF-8"
93
122
  require_paths:
94
123
  - lib
95
- - lib
96
124
  required_ruby_version: !ruby/object:Gem::Requirement
97
125
  requirements:
98
126
  - - ">="