jeog 0.0.1

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.
@@ -0,0 +1,20 @@
1
+ Copyright 2011 Jason Coene
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ Jeog is a command line tool and simple library for processing Jeog files.
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
9
+ require 'jeog/version'
10
+
11
+ task :build do
12
+ system "gem build jeog.gemspec"
13
+ end
14
+
15
+ task :install => :build do
16
+ system "gem install jeog-#{Jeog::VERSION}.gem"
17
+ end
18
+
19
+ task :release => :build do
20
+ system "git tag -a #{Jeog::VERSION} -m 'Tagging #{Jeog::VERSION}'"
21
+ system "git push --tags"
22
+ system "gem push jeog-#{Jeog::VERSION}.gem"
23
+ system "rm jeog-#{Jeog::VERSION}.gem"
24
+ end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'jeog/cli'
5
+ require 'jeog/version'
6
+
7
+ Jeog::Cli.go
@@ -0,0 +1,4 @@
1
+ require 'jeog/version'
2
+ require 'jeog/cli'
3
+ require 'jeog/file'
4
+ require 'jeog/data'
@@ -0,0 +1,50 @@
1
+ require 'jeog/version'
2
+ require 'jeog/file'
3
+ require 'jeog/data'
4
+ require 'trollop'
5
+
6
+ module Jeog
7
+
8
+ class Cli
9
+
10
+ def self.parse_options
11
+ @opts = Trollop::options do
12
+ version "jeog #{Jeog::VERSION}"
13
+ banner 'Usage: jeog [OPTION]... [FILE]...'
14
+ banner ''
15
+ opt :version, 'Print version and exit', :short => 'v'
16
+ opt :help, 'Show this message', :short => 'h'
17
+ end
18
+ Trollop::die 'requires at least one file to be given' if ARGV.empty?
19
+ @files = ARGV[0..-1]
20
+ end
21
+
22
+ def self.go
23
+ parse_options
24
+
25
+ @files.each do |file_name|
26
+ begin
27
+ file = Jeog::File.new file_name
28
+ data = Jeog::Data.new file.json_data
29
+ data.add_file_stat file.stat
30
+ dest_file_name = "#{file.directory}/#{file.alternative_json_file}"
31
+ ::File.open(dest_file_name, 'w') { |f| f.write(data.to_json) }
32
+ rescue Errno::ENOENT
33
+ puts "jeog: #{file_name}: No such file or directory"
34
+ exit 1
35
+ rescue Errno::EACCES
36
+ puts "jeog: #{file_name}: Permission denied"
37
+ exit 1
38
+ rescue Errno::EISDIR
39
+ puts "jeog: #{file_name}: Is a directory"
40
+ exit 1
41
+ rescue Errno::EPIPE
42
+ exit 1
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ end
49
+
50
+ end
@@ -0,0 +1,21 @@
1
+ require 'jeog/version'
2
+ require 'multi_json'
3
+
4
+ module Jeog
5
+
6
+ class Data
7
+
8
+ def initialize(json_string)
9
+ @jeog_hash = MultiJson.decode json_string
10
+ end
11
+
12
+ def add_file_stat(file_stat)
13
+ @jeog_hash["jeogFileAttributes"] = { "aTime" => file_stat.atime, "mTime" => file_stat.mtime, "cTime" => file_stat.ctime }
14
+ end
15
+
16
+ def to_json
17
+ MultiJson.encode @jeog_hash
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ require 'jeog/version'
2
+
3
+ module Jeog
4
+ class File
5
+ attr_accessor :file_name, :directory, :file
6
+
7
+ def initialize(file_name)
8
+ @file_name = file_name
9
+ @directory, @file = ::File.split file_name
10
+ end
11
+
12
+ def stat
13
+ ::File.stat @file_name
14
+ end
15
+
16
+ def raw_data
17
+ ::IO.read @file_name
18
+ end
19
+
20
+ def json_data
21
+ ::IO.read(@file_name, nil, 4)
22
+ end
23
+
24
+ def alternative_json_file
25
+ "#{@file.gsub(/\.jeog/, '')}.json"
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module Jeog
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jeog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jason Coene
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-08-16 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: trollop
16
+ requirement: &70125164358940 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.16.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70125164358940
25
+ - !ruby/object:Gem::Dependency
26
+ name: multi_json
27
+ requirement: &70125164356980 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.3
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70125164356980
36
+ description: Handles the opening and parsing of Jeog files.
37
+ email:
38
+ - jcoene@gmail.com
39
+ executables:
40
+ - jeog
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - bin/jeog
45
+ - lib/jeog/cli.rb
46
+ - lib/jeog/data.rb
47
+ - lib/jeog/file.rb
48
+ - lib/jeog/version.rb
49
+ - lib/jeog.rb
50
+ - MIT-LICENSE
51
+ - Rakefile
52
+ - README.md
53
+ homepage: http://github.com/jcoene/jeog
54
+ licenses: []
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ segments:
66
+ - 0
67
+ hash: -4083542816922891015
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ segments:
75
+ - 0
76
+ hash: -4083542816922891015
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 1.8.6
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: A simple gem to handle jeog files.
83
+ test_files: []