grassgis 0.4.1 → 0.4.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 +4 -4
- data/.gitignore +22 -22
- data/.travis.yml +7 -7
- data/Gemfile +4 -4
- data/LICENSE.txt +22 -22
- data/README.md +578 -577
- data/Rakefile +22 -22
- data/Vagrantfile +18 -18
- data/grassgis.gemspec +28 -28
- data/lib/grassgis/context.rb +1 -1
- data/lib/grassgis/error.rb +4 -4
- data/lib/grassgis/location.rb +53 -53
- data/lib/grassgis/mapset.rb +31 -31
- data/lib/grassgis/module.rb +73 -73
- data/lib/grassgis/support.rb +26 -26
- data/lib/grassgis/version.rb +3 -3
- data/lib/grassgis.rb +8 -8
- metadata +3 -3
data/Rakefile
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
|
3
|
-
require 'rake/testtask'
|
4
|
-
Rake::TestTask.new(:test) do |test|
|
5
|
-
test.libs << 'lib' << 'test'
|
6
|
-
test.pattern = 'test/**/test_*.rb'
|
7
|
-
test.verbose = true
|
8
|
-
end
|
9
|
-
|
10
|
-
require 'rdoc/task'
|
11
|
-
Rake::RDocTask.new do |rdoc|
|
12
|
-
version = GrassGis::VERSION
|
13
|
-
|
14
|
-
rdoc.rdoc_dir = 'rdoc'
|
15
|
-
rdoc.title = "GrassGis #{version}"
|
16
|
-
rdoc.main = "README.md"
|
17
|
-
rdoc.rdoc_files.include('README*')
|
18
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
19
|
-
rdoc.markup = 'markdown' if rdoc.respond_to?(:markup)
|
20
|
-
end
|
21
|
-
|
22
|
-
task :default => :test
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'rake/testtask'
|
4
|
+
Rake::TestTask.new(:test) do |test|
|
5
|
+
test.libs << 'lib' << 'test'
|
6
|
+
test.pattern = 'test/**/test_*.rb'
|
7
|
+
test.verbose = true
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'rdoc/task'
|
11
|
+
Rake::RDocTask.new do |rdoc|
|
12
|
+
version = GrassGis::VERSION
|
13
|
+
|
14
|
+
rdoc.rdoc_dir = 'rdoc'
|
15
|
+
rdoc.title = "GrassGis #{version}"
|
16
|
+
rdoc.main = "README.md"
|
17
|
+
rdoc.rdoc_files.include('README*')
|
18
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
19
|
+
rdoc.markup = 'markdown' if rdoc.respond_to?(:markup)
|
20
|
+
end
|
21
|
+
|
22
|
+
task :default => :test
|
data/Vagrantfile
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
# -*- mode: ruby -*-
|
2
|
-
# vi: set ft=ruby :
|
3
|
-
|
4
|
-
Vagrant.configure(2) do |config|
|
5
|
-
config.vm.box = "ubuntu/trusty32"
|
6
|
-
|
7
|
-
config.vm.provision "shell", inline: <<-SHELL
|
8
|
-
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
|
9
|
-
sudo add-apt-repository -y ppa:grass/grass-stable
|
10
|
-
sudo apt-get update -y
|
11
|
-
sudo apt-get install -y grass7
|
12
|
-
sudo apt-get install -y grass7-dev
|
13
|
-
sudo apt-get install -y build-essential
|
14
|
-
sudo apt-get install -y ruby-dev
|
15
|
-
sudo apt-get install -y libsqlite3-dev
|
16
|
-
sudo gem install bundler
|
17
|
-
SHELL
|
18
|
-
end
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.configure(2) do |config|
|
5
|
+
config.vm.box = "ubuntu/trusty32"
|
6
|
+
|
7
|
+
config.vm.provision "shell", inline: <<-SHELL
|
8
|
+
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable
|
9
|
+
sudo add-apt-repository -y ppa:grass/grass-stable
|
10
|
+
sudo apt-get update -y
|
11
|
+
sudo apt-get install -y grass7
|
12
|
+
sudo apt-get install -y grass7-dev
|
13
|
+
sudo apt-get install -y build-essential
|
14
|
+
sudo apt-get install -y ruby-dev
|
15
|
+
sudo apt-get install -y libsqlite3-dev
|
16
|
+
sudo gem install bundler
|
17
|
+
SHELL
|
18
|
+
end
|
data/grassgis.gemspec
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'grassgis/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "grassgis"
|
8
|
-
spec.version = GrassGis::VERSION
|
9
|
-
spec.authors = ["Javier Goizueta"]
|
10
|
-
spec.email = ["jgoizueta@gmail.com"]
|
11
|
-
spec.summary = %q{Support for scripting GRASS GIS in Ruby}
|
12
|
-
spec.description = %q{Support for scripting GRASS GIS in Ruby.}
|
13
|
-
spec.homepage = "https://github.com/jgoizueta/grassgis"
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_dependency "sys_cmd", "~> 1.1"
|
22
|
-
|
23
|
-
spec.add_development_dependency "bundler", "~> 1.9"
|
24
|
-
spec.add_development_dependency "rake"
|
25
|
-
spec.add_development_dependency "minitest", "~> 5.4"
|
26
|
-
|
27
|
-
spec.required_ruby_version = '>= 1.9.3'
|
28
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'grassgis/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "grassgis"
|
8
|
+
spec.version = GrassGis::VERSION
|
9
|
+
spec.authors = ["Javier Goizueta"]
|
10
|
+
spec.email = ["jgoizueta@gmail.com"]
|
11
|
+
spec.summary = %q{Support for scripting GRASS GIS in Ruby}
|
12
|
+
spec.description = %q{Support for scripting GRASS GIS in Ruby.}
|
13
|
+
spec.homepage = "https://github.com/jgoizueta/grassgis"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "sys_cmd", "~> 1.1"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "minitest", "~> 5.4"
|
26
|
+
|
27
|
+
spec.required_ruby_version = '>= 1.9.3'
|
28
|
+
end
|
data/lib/grassgis/context.rb
CHANGED
@@ -23,7 +23,7 @@ module GrassGis
|
|
23
23
|
config[:png_auto_write] = true unless config.key?(:png_auto_write)
|
24
24
|
config[:gnuplot] ||= 'gnuplot -persist'
|
25
25
|
config[:gui] ||= 'wxpython'
|
26
|
-
config[:
|
26
|
+
config[:python] ||= 'python'
|
27
27
|
|
28
28
|
config[:errors] ||= :raise
|
29
29
|
config[:echo] = :commands unless config.key?(:echo)
|
data/lib/grassgis/error.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module GrassGis
|
2
|
-
class Error < StandardError
|
3
|
-
end
|
4
|
-
end
|
1
|
+
module GrassGis
|
2
|
+
class Error < StandardError
|
3
|
+
end
|
4
|
+
end
|
data/lib/grassgis/location.rb
CHANGED
@@ -1,53 +1,53 @@
|
|
1
|
-
module GrassGis
|
2
|
-
class Location
|
3
|
-
def initialize(context)
|
4
|
-
@context = context
|
5
|
-
@configuration = @context.configuration
|
6
|
-
@gisdbase = @configuration[:gisdbase]
|
7
|
-
@location = @configuration[:location]
|
8
|
-
@path = File.join(@gisdbase, @location)
|
9
|
-
end
|
10
|
-
|
11
|
-
attr_reader :path
|
12
|
-
|
13
|
-
def to_s
|
14
|
-
@location
|
15
|
-
end
|
16
|
-
|
17
|
-
def exists?
|
18
|
-
File.directory?(@path)
|
19
|
-
end
|
20
|
-
|
21
|
-
def create!(options = {})
|
22
|
-
raise Error, "Location #{@location} already exists" if exists?
|
23
|
-
raise Error, "A file with the same name #{@location} exists" if File.exists?(@path)
|
24
|
-
raise Error, "GRASSDBASE doesn't exist" unless File.directory?(@gisdbase)
|
25
|
-
epsg = options[:epsg]
|
26
|
-
limits = options[:limits]
|
27
|
-
desc = options[:desc]
|
28
|
-
raise Error, "An EPSG code is needed to define a new loaction" unless epsg
|
29
|
-
@context.g.proj '-t', epsg: epsg, location: @location
|
30
|
-
permanent = permanent_path
|
31
|
-
if desc
|
32
|
-
desc_file = File.join(permanent, 'MYNAME')
|
33
|
-
File.write desc_file, desc
|
34
|
-
end
|
35
|
-
if limits
|
36
|
-
w, s, e, n = limits
|
37
|
-
res = options[:res]
|
38
|
-
# @context.g.mapset mapset: 'PERMANENT', location: @location
|
39
|
-
@context.change_mapset 'PERMANENT'
|
40
|
-
@context.g.region w: w, s: s, e: e, n: n, res: res
|
41
|
-
FileUtils.cp File.join(permanent, 'WIND'), File.join(permanent, 'DEFAULT_WIND')
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def mapset_path(mapset)
|
46
|
-
File.join(@path, mapset)
|
47
|
-
end
|
48
|
-
|
49
|
-
def permanent_path
|
50
|
-
mapset_path('PERMANENT')
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
1
|
+
module GrassGis
|
2
|
+
class Location
|
3
|
+
def initialize(context)
|
4
|
+
@context = context
|
5
|
+
@configuration = @context.configuration
|
6
|
+
@gisdbase = @configuration[:gisdbase]
|
7
|
+
@location = @configuration[:location]
|
8
|
+
@path = File.join(@gisdbase, @location)
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :path
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
@location
|
15
|
+
end
|
16
|
+
|
17
|
+
def exists?
|
18
|
+
File.directory?(@path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def create!(options = {})
|
22
|
+
raise Error, "Location #{@location} already exists" if exists?
|
23
|
+
raise Error, "A file with the same name #{@location} exists" if File.exists?(@path)
|
24
|
+
raise Error, "GRASSDBASE doesn't exist" unless File.directory?(@gisdbase)
|
25
|
+
epsg = options[:epsg]
|
26
|
+
limits = options[:limits]
|
27
|
+
desc = options[:desc]
|
28
|
+
raise Error, "An EPSG code is needed to define a new loaction" unless epsg
|
29
|
+
@context.g.proj '-t', epsg: epsg, location: @location
|
30
|
+
permanent = permanent_path
|
31
|
+
if desc
|
32
|
+
desc_file = File.join(permanent, 'MYNAME')
|
33
|
+
File.write desc_file, desc
|
34
|
+
end
|
35
|
+
if limits
|
36
|
+
w, s, e, n = limits
|
37
|
+
res = options[:res]
|
38
|
+
# @context.g.mapset mapset: 'PERMANENT', location: @location
|
39
|
+
@context.change_mapset 'PERMANENT'
|
40
|
+
@context.g.region w: w, s: s, e: e, n: n, res: res
|
41
|
+
FileUtils.cp File.join(permanent, 'WIND'), File.join(permanent, 'DEFAULT_WIND')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def mapset_path(mapset)
|
46
|
+
File.join(@path, mapset)
|
47
|
+
end
|
48
|
+
|
49
|
+
def permanent_path
|
50
|
+
mapset_path('PERMANENT')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/grassgis/mapset.rb
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
module GrassGis
|
2
|
-
class Mapset
|
3
|
-
def initialize(context)
|
4
|
-
@context = context
|
5
|
-
@configuration = @context.configuration
|
6
|
-
@location = Location.new(@context)
|
7
|
-
@mapset = @configuration[:mapset]
|
8
|
-
@path = File.join(@location.path, @mapset)
|
9
|
-
end
|
10
|
-
|
11
|
-
attr_reader :path
|
12
|
-
|
13
|
-
def to_s
|
14
|
-
@mapset
|
15
|
-
end
|
16
|
-
|
17
|
-
def exists?
|
18
|
-
File.directory?(@path)
|
19
|
-
end
|
20
|
-
|
21
|
-
def create!(options = {})
|
22
|
-
raise Error, "Mapset #{@mapset} already exists" if exists?
|
23
|
-
raise Error, "A file with the same name #{@mapset} exists" if File.exists?(@path)
|
24
|
-
raise Error, "Location doesn't exist" unless @location.exists?
|
25
|
-
# @context.g.mapet '-c', mapset: @mapset, location: @location.to_s, dbase: @configuration[:gisdbase]
|
26
|
-
FileUtils.mkdir_p @path
|
27
|
-
permanent = @location.permanent_path
|
28
|
-
FileUtils.cp File.join(permanent, 'DEFAULT_WIND'), File.join(@path, 'WIND')
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
1
|
+
module GrassGis
|
2
|
+
class Mapset
|
3
|
+
def initialize(context)
|
4
|
+
@context = context
|
5
|
+
@configuration = @context.configuration
|
6
|
+
@location = Location.new(@context)
|
7
|
+
@mapset = @configuration[:mapset]
|
8
|
+
@path = File.join(@location.path, @mapset)
|
9
|
+
end
|
10
|
+
|
11
|
+
attr_reader :path
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
@mapset
|
15
|
+
end
|
16
|
+
|
17
|
+
def exists?
|
18
|
+
File.directory?(@path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def create!(options = {})
|
22
|
+
raise Error, "Mapset #{@mapset} already exists" if exists?
|
23
|
+
raise Error, "A file with the same name #{@mapset} exists" if File.exists?(@path)
|
24
|
+
raise Error, "Location doesn't exist" unless @location.exists?
|
25
|
+
# @context.g.mapet '-c', mapset: @mapset, location: @location.to_s, dbase: @configuration[:gisdbase]
|
26
|
+
FileUtils.mkdir_p @path
|
27
|
+
permanent = @location.permanent_path
|
28
|
+
FileUtils.cp File.join(permanent, 'DEFAULT_WIND'), File.join(@path, 'WIND')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/grassgis/module.rb
CHANGED
@@ -1,73 +1,73 @@
|
|
1
|
-
module GrassGis
|
2
|
-
|
3
|
-
# Generate and execute GRASS commands
|
4
|
-
#
|
5
|
-
# r = GrassGis::Module.new('r')
|
6
|
-
# r.resamp.stats '-n', input: "map1@mapset1", output: "map2"
|
7
|
-
#
|
8
|
-
# To execute a command without arguments, +run+ must be invoked explicitly:
|
9
|
-
#
|
10
|
-
# g = GrassGis::Module.new('g')
|
11
|
-
# g.region.run
|
12
|
-
#
|
13
|
-
class Module
|
14
|
-
def initialize(id, options = {})
|
15
|
-
@id = id.to_s
|
16
|
-
@parent = options[:parent]
|
17
|
-
@context = options[:context]
|
18
|
-
end
|
19
|
-
|
20
|
-
def name
|
21
|
-
if @parent
|
22
|
-
"#{@parent.name}.#{@id}"
|
23
|
-
else
|
24
|
-
@id
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
# Executes the command (with given arguments)
|
29
|
-
# returns a SysCmd object (with status, status_value, output, error_output methods)
|
30
|
-
def run(*args)
|
31
|
-
stdin = nil
|
32
|
-
cmd = SysCmd.command name do
|
33
|
-
args.each do |arg|
|
34
|
-
case arg
|
35
|
-
when Hash
|
36
|
-
arg.each do |key, value|
|
37
|
-
next if value.nil?
|
38
|
-
case value
|
39
|
-
when Array
|
40
|
-
value = value*","
|
41
|
-
when String
|
42
|
-
if value.include?("\n")
|
43
|
-
raise "Cannot pass multiple options through STDIN" if stdin
|
44
|
-
stdin = Support.unindent(value)
|
45
|
-
value = "-"
|
46
|
-
input stdin
|
47
|
-
end
|
48
|
-
end
|
49
|
-
option key.to_s, equal_value: value
|
50
|
-
end
|
51
|
-
else
|
52
|
-
option arg
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
if @context
|
57
|
-
@context.execute cmd
|
58
|
-
end
|
59
|
-
cmd
|
60
|
-
end
|
61
|
-
|
62
|
-
def method_missing(method, *args)
|
63
|
-
m = Module.new(method, parent: self, context: @context)
|
64
|
-
if args.size > 0
|
65
|
-
m.run *args
|
66
|
-
else
|
67
|
-
m
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
1
|
+
module GrassGis
|
2
|
+
|
3
|
+
# Generate and execute GRASS commands
|
4
|
+
#
|
5
|
+
# r = GrassGis::Module.new('r')
|
6
|
+
# r.resamp.stats '-n', input: "map1@mapset1", output: "map2"
|
7
|
+
#
|
8
|
+
# To execute a command without arguments, +run+ must be invoked explicitly:
|
9
|
+
#
|
10
|
+
# g = GrassGis::Module.new('g')
|
11
|
+
# g.region.run
|
12
|
+
#
|
13
|
+
class Module
|
14
|
+
def initialize(id, options = {})
|
15
|
+
@id = id.to_s
|
16
|
+
@parent = options[:parent]
|
17
|
+
@context = options[:context]
|
18
|
+
end
|
19
|
+
|
20
|
+
def name
|
21
|
+
if @parent
|
22
|
+
"#{@parent.name}.#{@id}"
|
23
|
+
else
|
24
|
+
@id
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Executes the command (with given arguments)
|
29
|
+
# returns a SysCmd object (with status, status_value, output, error_output methods)
|
30
|
+
def run(*args)
|
31
|
+
stdin = nil
|
32
|
+
cmd = SysCmd.command name do
|
33
|
+
args.each do |arg|
|
34
|
+
case arg
|
35
|
+
when Hash
|
36
|
+
arg.each do |key, value|
|
37
|
+
next if value.nil?
|
38
|
+
case value
|
39
|
+
when Array
|
40
|
+
value = value*","
|
41
|
+
when String
|
42
|
+
if value.include?("\n")
|
43
|
+
raise "Cannot pass multiple options through STDIN" if stdin
|
44
|
+
stdin = Support.unindent(value)
|
45
|
+
value = "-"
|
46
|
+
input stdin
|
47
|
+
end
|
48
|
+
end
|
49
|
+
option key.to_s, equal_value: value
|
50
|
+
end
|
51
|
+
else
|
52
|
+
option arg
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
if @context
|
57
|
+
@context.execute cmd
|
58
|
+
end
|
59
|
+
cmd
|
60
|
+
end
|
61
|
+
|
62
|
+
def method_missing(method, *args)
|
63
|
+
m = Module.new(method, parent: self, context: @context)
|
64
|
+
if args.size > 0
|
65
|
+
m.run *args
|
66
|
+
else
|
67
|
+
m
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
data/lib/grassgis/support.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
module GrassGis
|
2
|
-
module Support
|
3
|
-
module_function
|
4
|
-
|
5
|
-
def unindent(text, indent = nil)
|
6
|
-
text = text.gsub(/\t/, ' '*8)
|
7
|
-
mx = text.scan(/^ *[^\n\r]/)
|
8
|
-
.flatten
|
9
|
-
.map{ |s| s[-1,1]==' ' ? nil : (s.size-1) }
|
10
|
-
.compact.min
|
11
|
-
if mx && mx>0
|
12
|
-
text.gsub!(/^ {1,#{mx}}/, "")
|
13
|
-
end
|
14
|
-
lines = text.split(/\r?\n/)
|
15
|
-
if lines.first.strip.empty? || lines.last.strip.empty?
|
16
|
-
lines.shift while lines.first.strip.empty?
|
17
|
-
lines.pop while lines.last.strip.empty?
|
18
|
-
end
|
19
|
-
if indent
|
20
|
-
indent = ' ' * indent if indent.kind_of?(Numeric)
|
21
|
-
lines = lines.map { |line| "#{indent}#{line}" }
|
22
|
-
end
|
23
|
-
lines.join("\n")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
1
|
+
module GrassGis
|
2
|
+
module Support
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def unindent(text, indent = nil)
|
6
|
+
text = text.gsub(/\t/, ' '*8)
|
7
|
+
mx = text.scan(/^ *[^\n\r]/)
|
8
|
+
.flatten
|
9
|
+
.map{ |s| s[-1,1]==' ' ? nil : (s.size-1) }
|
10
|
+
.compact.min
|
11
|
+
if mx && mx>0
|
12
|
+
text.gsub!(/^ {1,#{mx}}/, "")
|
13
|
+
end
|
14
|
+
lines = text.split(/\r?\n/)
|
15
|
+
if lines.first.strip.empty? || lines.last.strip.empty?
|
16
|
+
lines.shift while lines.first.strip.empty?
|
17
|
+
lines.pop while lines.last.strip.empty?
|
18
|
+
end
|
19
|
+
if indent
|
20
|
+
indent = ' ' * indent if indent.kind_of?(Numeric)
|
21
|
+
lines = lines.map { |line| "#{indent}#{line}" }
|
22
|
+
end
|
23
|
+
lines.join("\n")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/grassgis/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module GrassGis
|
2
|
-
VERSION = "0.4.
|
3
|
-
end
|
1
|
+
module GrassGis
|
2
|
+
VERSION = "0.4.2"
|
3
|
+
end
|
data/lib/grassgis.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'sys_cmd'
|
2
|
-
require 'grassgis/version'
|
3
|
-
require 'grassgis/error'
|
4
|
-
require 'grassgis/support'
|
5
|
-
require 'grassgis/module'
|
6
|
-
require 'grassgis/location'
|
7
|
-
require 'grassgis/mapset'
|
8
|
-
require 'grassgis/context'
|
1
|
+
require 'sys_cmd'
|
2
|
+
require 'grassgis/version'
|
3
|
+
require 'grassgis/error'
|
4
|
+
require 'grassgis/support'
|
5
|
+
require 'grassgis/module'
|
6
|
+
require 'grassgis/location'
|
7
|
+
require 'grassgis/mapset'
|
8
|
+
require 'grassgis/context'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grassgis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Goizueta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sys_cmd
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.2.2
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Support for scripting GRASS GIS in Ruby
|