andeogen 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 160886a3685c0c80dfe58605ad65cbf0ef154ed0
4
+ data.tar.gz: d198df2e7901fc69222b14f1fac36fe72daed877
5
+ SHA512:
6
+ metadata.gz: 52a1d3db68c4823f674b56b72dffe086247f79b4a9da9da0ebfacefcfa6184b9d99bc1e212f9a17f56d54255d365b5c943b3693e4a6452f26f47d45edf1aad0d
7
+ data.tar.gz: e71d7b04efc2e047d8fc57095b90912c1f5beafb430b38c5d4523ad126b744fa655e0e6f429b7530f93d355e202ea00c86a7393ffce2784b0431ae65a04df12c
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in andeogen.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,14 @@
1
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
2
+ Version 2, December 2004
3
+
4
+ Copyright (C) 2004 Sam Hocevar
5
+ 14 rue de Plaisance, 75014 Paris, France
6
+ Everyone is permitted to copy and distribute verbatim or modified
7
+ copies of this license document, and changing it is allowed as long
8
+ as the name is changed.
9
+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
10
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
11
+ 0. You just DO WHAT THE FUCK YOU WANT TO.
12
+
13
+
14
+ David Hagege <david.hagege@gmail.com>
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # andeogen
2
+
3
+ andeogen is a tiny gem to ease android layout development.
4
+ It's showing the files dependencies used in the given layouts and let you execute a command on them.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'andeogen'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install andeogen
19
+
20
+ ## Usage
21
+
22
+ pcboy@home ☭ res % andeogen --help
23
+ Options:
24
+ --command, -c <s>: the command to execute on selected items
25
+ --files, -f <s+>: the layouts to parse
26
+ --help, -h: Show this message
27
+
28
+
29
+ Example:
30
+
31
+ pcboy@home ☭ res % andeogen --command vim --files layout/chat_msg.xml layout/chat_msgs.xml
32
+ [
33
+ [0] "src/main/res/drawable-xhdpi/bubble_yellow.9.png",
34
+ [1] "AndroidChatBubbles/HelloBubbles/res/drawable-xhdpi/bubble_yellow.9.png",
35
+ [2] "src/main/res/drawable/edittext.xml",
36
+ [3] "src/main/res/drawable-hdpi-v4/edittext_indented_active.9.png",
37
+ [4] "src/main/res/drawable-hdpi-v4/edittext_indented_normal.9.png"
38
+ ]
39
+ Comma-separate the files' number you want to execute your <command> on:
40
+ 2
41
+
42
+ Will run vim on edittext.xml
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/andeogen.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'andeogen/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "andeogen"
8
+ spec.version = Andeogen::VERSION
9
+ spec.authors = ["pcboy"]
10
+ spec.email = ["david.hagege@gmail.com"]
11
+ spec.description = %q{Andeogen is a tiny gem to ease android layout development}
12
+ spec.summary = %q{}
13
+ spec.homepage = ""
14
+ spec.license = "WTFPL"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = ["andeogen"]
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_dependency "nokogiri"
24
+ spec.add_dependency "awesome_print"
25
+ spec.add_dependency "trollop"
26
+ end
data/bin/andeogen ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'andeogen'
4
+ require 'trollop'
5
+
6
+ OPTS = Trollop::options do
7
+ opt :command, "the command to execute on selected items", :type => String
8
+ opt :files, "the layouts to parse", :type => :strings
9
+ end
10
+
11
+ unless OPTS[:command] && OPTS[:files] && OPTS[:files].count > 0
12
+ Trollop::die :command, "you need to specify a command to execute on each item"
13
+ Trollop::die :files, "no layout file(s) specified"
14
+ end
15
+
16
+ Andeogen::Andeogen.new.parse(OPTS[:files]).execute
data/lib/andeogen.rb ADDED
@@ -0,0 +1,61 @@
1
+ require "andeogen/version"
2
+
3
+ require 'nokogiri'
4
+ require 'awesome_print'
5
+
6
+ module Andeogen
7
+ class Andeogen
8
+
9
+ attr_accessor :results
10
+
11
+ def initialize
12
+ @results = []
13
+ end
14
+
15
+ def parse(files)
16
+ files.map do |file|
17
+ Nokogiri::XML(open(file).read).traverse do |elem|
18
+ elem.attributes.map do |k,v|
19
+ if !(v.value =~ /@android:/) &&
20
+ v.value =~ /\A@[style|layout|drawable|color].+\z/
21
+ findpath(v.value)
22
+ end
23
+ end if elem.respond_to?(:attributes)
24
+ end
25
+ end
26
+ self
27
+ end
28
+
29
+ def execute
30
+ unless @results.empty?
31
+ ap @results
32
+ numbers = if @results.count == 1
33
+ 0
34
+ else
35
+ puts "Comma-separate the files' number you want to execute your <command> on:"
36
+ gets.strip.split(',').map(&:to_i)
37
+ end
38
+ exec("#{OPTS[:command]} #{numbers.map{|x|
39
+ "#{Shellwords.escape("#{root_path}/#{@results[x]}")}"}.join(" ")}")
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def root_path
46
+ return @root_path unless @root_path.nil?
47
+ dir = Dir.pwd
48
+ dir = begin
49
+ File.expand_path("..", dir)
50
+ end until dir == "/" || !(Dir.open(dir).entries & ['.git', '.hg']).empty?
51
+ @root_path = dir
52
+ end
53
+
54
+ def findpath(elem)
55
+ Dir.chdir root_path do
56
+ @results += Dir.glob("**/*#{elem.gsub(/@.+\//,'')}*")
57
+ .delete_if{|x| x.include?('.class')}
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,3 @@
1
+ module Andeogen
2
+ VERSION = "0.0.3"
3
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: andeogen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - pcboy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
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: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: awesome_print
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: trollop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Andeogen is a tiny gem to ease android layout development
84
+ email:
85
+ - david.hagege@gmail.com
86
+ executables:
87
+ - andeogen
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - Gemfile
93
+ - LICENSE.txt
94
+ - README.md
95
+ - Rakefile
96
+ - andeogen.gemspec
97
+ - bin/andeogen
98
+ - lib/andeogen.rb
99
+ - lib/andeogen/version.rb
100
+ homepage: ''
101
+ licenses:
102
+ - WTFPL
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.0.0
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: ''
124
+ test_files: []