columbus3 0.3.0 → 0.4.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edbdaa1d3a33d32631aa09d31bc18031922c1d29
4
- data.tar.gz: 8f752d7479d59cd52124bd2ba4c97a7efa7529ac
3
+ metadata.gz: 8c00cb92f8e4ce111bc55fde1ba803980007527d
4
+ data.tar.gz: 095e7942545cb34f47ffa77b887478109f6bae04
5
5
  SHA512:
6
- metadata.gz: d046ab5901c867276226fc1a6787d1254f325762dc047fadc734e3ed59a6e9b482b914bfc76109638a4e6b83ad513e63f07df8daf4f5dc1f58dcea0d788a662f
7
- data.tar.gz: 2f49fde9fe667fce154be6a9bf3acb2cc82e850b7071c9de8a2dd822e0f219491e25b0b589d1042e15b62100677f621bff2c9350eb0491d01c17a3715cfb9340
6
+ metadata.gz: 0b1db031f90efc89a6de3ebb78eb94b536778c7577b5b8a7d8adc3abbf52bfbeb2d11305b96ab5c293b76fa0af217f70d7610ef49eaf8b000c53538958e95f81
7
+ data.tar.gz: f4447afbad97edb832345b01d2da52192967f2adeb72a2024fcf6e4438768b610c105cea0aa3d7a84c224571fd61f93f894db3e308a316c8f48d1029b7b07b78
data/README.textile CHANGED
@@ -33,22 +33,27 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
33
33
 
34
34
  h2. Version History
35
35
 
36
+ *0.4.0*
37
+ * Improved syntax for search:
38
+ ** new option -r searches in sub-directories
39
+ ** new option --fields allows to specify the fields to look for
40
+
36
41
  *0.3.0*
37
- ** Added documentation for @search@ command; added this README file
38
- ** New command @graph@ plots data about a track (look for @_graph.html@ in the current directory)
39
- ** Added @--force@ option to @process@
40
- ** Internals: fixes to the @sidecar@ class
42
+ * Added documentation for @search@ command; added this README file
43
+ * New command @graph@ plots data about a track (look for @_graph.html@ in the current directory)
44
+ * Added @--force@ option to @process@
45
+ * Internals: fixes to the @sidecar@ class
41
46
 
42
47
  *0.2.1*
43
- ** Fixed bug in time parsing
48
+ * Fixed bug in time parsing
44
49
 
45
50
  *0.2.0*
46
- ** Fixes to syntax
47
- ** Print man page if not arguments are provided
48
- ** Added --filename option to *show* command
51
+ * Fixes to syntax
52
+ * Print man page if not arguments are provided
53
+ * Added --filename option to *show* command
49
54
 
50
55
  *0.1.0*
51
- ** Initial release
56
+ * Initial release
52
57
 
53
58
  h2. License
54
59
 
data/exe/columbus3 CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "slop"
4
4
  require "columbus3"
5
+ require "find"
5
6
 
6
7
  appname = "columbus3"
7
8
  version = Columbus3::VERSION
@@ -58,10 +59,23 @@ Examples of simple searches
58
59
  'max_speed > 120' any track with a max speed greater than 120 km/h
59
60
  'min_height == 10' any track with a min height lower than 10 meters
60
61
 
61
- Examplex of more more complex searches
62
+ Examples of complex searches
62
63
  'location ~ "USA" and start_date >= 2015-01-01' tracks in the USA after or on Jan 1, 2015
63
64
  'start_location ~ "Trenton" and end_location ~ "New York"' trips from Trenton to New York
64
65
 
66
+ List of supported fields in output
67
+ path -> relative path of the CSV file
68
+ filename -> basename of the CSV file
69
+ start_location -> start location
70
+ end_location -> end location
71
+ start_date -> start date (and time)
72
+ end_date -> end date (and time)
73
+ duration -> duration in seconds
74
+ min_speed -> minimum speed in km/h
75
+ max_speed -> maximum speed in km/h
76
+ min_height -> minimum height in meters
77
+ max_height -> maximum height in meters
78
+
65
79
  VERSION
66
80
  This is version #{version}
67
81
 
@@ -129,19 +143,33 @@ opts = Slop.parse :help => true do
129
143
 
130
144
  ##############################################################################
131
145
  command :search do
132
- banner "#{appname} search [--help] [--dir directory] query"
146
+ banner "#{appname} search [--help] [-r] [--dir directory] [--fields fields] query"
133
147
  description "Search dir for tracks matching query"
134
148
 
135
149
  on "--debug", "Show how the query is processed"
150
+ on "-r", "--recurse", "Recurse in subdirectories"
136
151
  on "-d", "--dir=", "Directory with sidecar files"
152
+ on "-fields=", "Comma separated list of fields to show"
137
153
 
138
154
  run do |opts, args|
139
155
  cmd ="search"
140
156
 
141
157
  debug = opts.to_hash[:debug]
142
158
  directory = opts.to_hash[:dir] || "."
159
+ recurse = opts.to_hash[:recurse]
160
+ fields_opt = opts.to_hash[:fields]
161
+
162
+ if fields? then
163
+ fields = fields_opt.split(",").map { |x| x.to_sym }
164
+ else
165
+ fields = [:path, :filename, :start_location, :end_location, :start_date, :end_date, :duration, :min_speed, :max_speed, :min_height, :max_height]
166
+ end
143
167
 
144
- files = Dir.glob(directory + "/" + "*.yaml")
168
+ if recurse then
169
+ files = Find.find(directory).select { |e| File.extname(e) == ".yaml" }
170
+ else
171
+ files = Dir.glob(File.join(directory, "*.yaml"))
172
+ end
145
173
  query = QueryParser.new.parse(args.join(" "))
146
174
 
147
175
  if debug then
@@ -153,7 +181,7 @@ opts = Slop.parse :help => true do
153
181
  sidecar_search.load files
154
182
  match = sidecar_search.search query
155
183
  match.each do |m|
156
- string = [:filename, :start_location, :end_location, :start_date, :end_date, :duration, :min_speed, :max_speed, :min_height, :max_height].map { |x| "#{m[x]}"}.join("\t")
184
+ string = fields.map { |x| "#{m[x]}"}.join("\t")
157
185
  puts string
158
186
  end
159
187
  end
@@ -47,7 +47,7 @@ module Columbus3
47
47
  end
48
48
 
49
49
  def load array
50
- @metadata = array.each.map { |x| YAML.load(File.read(x)) }
50
+ @metadata = array.each.map { |x| YAML.load(File.read(x)).merge({ :path => x }) }
51
51
  end
52
52
 
53
53
  def search term
@@ -1,3 +1,3 @@
1
1
  module Columbus3
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: columbus3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adolfo Villafiorita
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-15 00:00:00.000000000 Z
11
+ date: 2015-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler