flickru 0.4.4 → 0.5.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: 6a232ff981265c75b9600596b486f6df9b14cb66
4
- data.tar.gz: f44447d52df46409e781cac65f242ed53a6876f0
3
+ metadata.gz: 01b148927c183da5d1d20f7f8d96ce1a1c30cfa8
4
+ data.tar.gz: 2e4c16f7818c236236485bba98058a9e0e8a43b6
5
5
  SHA512:
6
- metadata.gz: 2da1b2b790679d03aff92a3518fc5725faa891194d85982f74d61345028db19b546a9322cdcee5aeb5474a666eec0dc5b5aa8ab80fd93ec6e7ec1d40924549e0
7
- data.tar.gz: '049ebfd5474fe867f865a6fabb0c175f2ba7e9ab1fcb86cc75ff8088dbf67cba95f2b84ab4aa116c9112493f450821754b6c3d4e7240c89d5fc18d2aab73bbf5'
6
+ metadata.gz: abe4f57e9c7cea3ce46ca73c78e9628315dbd31dbe8c77f64b0b22c2d60a37912e565177faf6e9555922b3ab57b0623c8bbe54e297cafff2b550f541723b07b0
7
+ data.tar.gz: 5a4f6c2939af7362f62a8169138fdfffb0add5dd0673b516f72ca0cedc34a1f6a6d236266587059064fccb59670beeb693dd2187d7801d4f73b995bd46655cc8
@@ -1,81 +1,14 @@
1
- #!/usr/bin/env bash
1
+ #!/usr/bin/env ruby
2
2
 
3
- ###########
4
- # Globals #
5
- ###########
3
+ rb_file = File.expand_path(__FILE__)
6
4
 
7
- APP_NAME=`basename $0`
8
- PAGE=`echo "$1" | tr ' ' '_'`
5
+ bin_dir = File.dirname(rb_file)
6
+ gem_dir = File.dirname(bin_dir)
7
+ share_dir = File.join(gem_dir, 'share')
9
8
 
10
- #############
11
- # Functions #
12
- #############
9
+ sh_file = File.join(share_dir, File.basename(__FILE__) + '.sh')
13
10
 
14
- function usage() {
15
- echo "$APP_NAME - find coordinates of a place described by Wikipedia"
16
- echo "usage: $APP_NAME <place Wikipedia page>"
17
- echo "example: $APP_NAME 'Mille-Isles, Quebec'"
18
- }
11
+ args = %Q{"#{ARGV.join(' ')}"}
19
12
 
20
- function error() {
21
- echo -e "\033[31m$APP_NAME:$1: $2\033[0m" 1>&2
22
- }
23
-
24
- #################
25
- # Preconditions #
26
- #################
27
-
28
- if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
29
- usage
30
- exit
31
- elif [[ $# -ne 1 ]]; then
32
- usage
33
- error $LINENO "wrong number of arguments"
34
- exit 1
35
- fi
36
-
37
- #########
38
- # Setup #
39
- #########
40
-
41
- # temporal file management
42
- if [[ -d /tmp ]]; then
43
- TMP="/tmp/$PAGE.tmp.$$.$RANDOM.html"
44
- else
45
- TMP="$PAGE.tmp.html"
46
- fi
47
- function clean_up() {
48
- rm -f "$TMP"
49
- exit $1
50
- }
51
- trap clean_up SIGHUP SIGINT SIGTERM
52
-
53
- ########
54
- # Main #
55
- ########
56
-
57
- wget -o /dev/null -O "$TMP" "http://en.wikipedia.org/wiki/$PAGE"
58
-
59
- if [[ $? -ne 0 ]]; then
60
- error $LINENO "Wikipedia page '$PAGE' not found"
61
- clean_up 1
62
- fi
63
-
64
- URL=`cat "$TMP" | tr '"' '\n' | grep geohack | head -n 1 | sed -e 's|^//||' -e 's|&amp;|\&|'`
65
-
66
- if [[ -z "$URL" ]]; then
67
- error $LINENO "location not found in Wikipedia page '$PAGE'"
68
- clean_up 1
69
- fi
70
-
71
- curl "$URL" -o "$TMP" 2> /dev/null
72
-
73
- if [[ $? -ne 0 ]]; then
74
- error $LINENO "GeoHack URL '$URL' not found"
75
- clean_up 1
76
- fi
77
-
78
- cat "$TMP" | grep '<span class="geo"' \
79
- | sed -e 's|^.*"Latitude">\([^<]*\)</span>, .*"Longitude">\([^<]*\)</span>.*$|\1, \2|'
80
-
81
- clean_up
13
+ print `#{sh_file} #{args}`
14
+ exit $?.exitstatus
@@ -1,5 +1,5 @@
1
1
  module Flickru
2
2
  unless defined? VERSION
3
- VERSION = "0.4.4"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -0,0 +1,86 @@
1
+ #!/usr/bin/env bash
2
+
3
+ ###########
4
+ # Globals #
5
+ ###########
6
+
7
+ APP_NAME=`basename $0`
8
+ PAGE=`echo "$1" | tr ' ' '_'`
9
+
10
+ #############
11
+ # Functions #
12
+ #############
13
+
14
+ function usage() {
15
+ echo "$APP_NAME - find coordinates of a place described by Wikipedia"
16
+ echo "usage: $APP_NAME <place Wikipedia page>"
17
+ echo "example: $APP_NAME 'Mille-Isles, Quebec'"
18
+ }
19
+
20
+ function error() {
21
+ echo -e "\033[31m$APP_NAME:$1: $2\033[0m" 1>&2
22
+ }
23
+
24
+ #################
25
+ # Preconditions #
26
+ #################
27
+
28
+ if ! `hash wget 2> /dev/null`; then
29
+ error $LINENO "wget command not found"
30
+ exit 1
31
+ fi
32
+
33
+ if [[ "$1" == "-h" ]] || [[ "$1" == "--help" ]]; then
34
+ usage
35
+ exit
36
+ elif [[ $# -ne 1 ]]; then
37
+ usage
38
+ error $LINENO "wrong number of arguments"
39
+ exit 1
40
+ fi
41
+
42
+ #########
43
+ # Setup #
44
+ #########
45
+
46
+ # temporal file management
47
+ if [[ -d /tmp ]]; then
48
+ TMP="/tmp/$PAGE.tmp.$$.$RANDOM.html"
49
+ else
50
+ TMP="$PAGE.tmp.html"
51
+ fi
52
+ function clean_up() {
53
+ rm -f "$TMP"
54
+ exit $1
55
+ }
56
+ trap clean_up SIGHUP SIGINT SIGTERM
57
+
58
+ ########
59
+ # Main #
60
+ ########
61
+
62
+ wget -o /dev/null -O "$TMP" "http://en.wikipedia.org/wiki/$PAGE"
63
+
64
+ if [[ $? -ne 0 ]]; then
65
+ error $LINENO "Wikipedia page '$PAGE' not found"
66
+ clean_up 1
67
+ fi
68
+
69
+ URL=`cat "$TMP" | tr '"' '\n' | grep geohack | head -n 1 | sed -e 's|^//||' -e 's|&amp;|\&|'`
70
+
71
+ if [[ -z "$URL" ]]; then
72
+ error $LINENO "location not found in Wikipedia page '$PAGE'"
73
+ clean_up 1
74
+ fi
75
+
76
+ curl "$URL" -o "$TMP" 2> /dev/null
77
+
78
+ if [[ $? -ne 0 ]]; then
79
+ error $LINENO "GeoHack URL '$URL' not found"
80
+ clean_up 1
81
+ fi
82
+
83
+ cat "$TMP" | grep '<span class="geo"' \
84
+ | sed -e 's|^.*"Latitude">\([^<]*\)</span>, .*"Longitude">\([^<]*\)</span>.*$|\1, \2|'
85
+
86
+ clean_up
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flickru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesus Pardillo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-15 00:00:00.000000000 Z
11
+ date: 2016-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -234,6 +234,7 @@ email:
234
234
  - dev@jesuspardillo.com
235
235
  executables:
236
236
  - flickru
237
+ - geowiki
237
238
  extensions: []
238
239
  extra_rdoc_files: []
239
240
  files:
@@ -249,6 +250,7 @@ files:
249
250
  - lib/flickru/ruby.rb
250
251
  - lib/flickru/string.rb
251
252
  - lib/flickru/version.rb
253
+ - share/geowiki.sh
252
254
  - spec/flickru_spec.rb
253
255
  - var/ts/tc_accuracies/Testing Collection/Troll Face@Spain#Country/Troll Face@Spain#Country.jpg
254
256
  - var/ts/tc_accuracies/Testing Collection/Troll Face@Spain#ReGiOn/Troll Face@Spain#ReGiOn.jpg