pakyow-support 0.9.1 → 0.10.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 +4 -4
- data/pakyow-rake/CHANGELOG.md +11 -0
- data/{pakyow-support/MIT-LICENSE → pakyow-rake/LICENSE} +1 -1
- data/pakyow-rake/README.md +30 -0
- data/pakyow-rake/lib/pakyow-rake.rb +4 -0
- data/pakyow-rake/lib/tasks/app.rake +13 -0
- data/pakyow-rake/lib/tasks/bindings.rake +57 -0
- data/pakyow-rake/lib/tasks/routes.rake +42 -0
- metadata +16 -20
- data/pakyow-support/CHANGES +0 -7
- data/pakyow-support/README +0 -1
- data/pakyow-support/lib/pakyow-support.rb +0 -6
- data/pakyow-support/lib/support/array.rb +0 -9
- data/pakyow-support/lib/support/dir.rb +0 -32
- data/pakyow-support/lib/support/dup.rb +0 -23
- data/pakyow-support/lib/support/file.rb +0 -5
- data/pakyow-support/lib/support/hash.rb +0 -47
- data/pakyow-support/lib/support/string.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18fe4035f112887d12a4721b40383f7a24c50065
|
4
|
+
data.tar.gz: b3a5807b4bdf5ab10cf170c09536bfdab3e5405d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 569dcad220acd75c60c28bedee9f91990d8f565505c18567d300ab844a6c0785cc57f1472ff3eb7ee1592a5e153ac87b4906c5347c5be9b16922cd2baec7cb2e
|
7
|
+
data.tar.gz: e8e6207ed333345df34d9c1dac7e691f13719a6acfde185b77370aabc7308faced460094579c141d27d9dcc8b4e2e84aabef7b4593cc30ca22ef7eff12c302e7
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# pakyow-rake
|
2
|
+
|
3
|
+
Rake tasks for Pakyow projects.
|
4
|
+
|
5
|
+
# Download
|
6
|
+
|
7
|
+
The latest version of Pakyow Rake can be installed with RubyGems:
|
8
|
+
|
9
|
+
```
|
10
|
+
gem install pakyow-rake
|
11
|
+
```
|
12
|
+
|
13
|
+
Source code can be downloaded as part of the Pakyow project on Github:
|
14
|
+
|
15
|
+
- https://github.com/pakyow/pakyow/tree/master/pakyow-rake
|
16
|
+
|
17
|
+
# License
|
18
|
+
|
19
|
+
Pakyow Rake is released free and open-source under the [MIT
|
20
|
+
License](http://opensource.org/licenses/MIT).
|
21
|
+
|
22
|
+
# Support
|
23
|
+
|
24
|
+
Found a bug? Tell us about it here:
|
25
|
+
|
26
|
+
- https://github.com/pakyow/pakyow/issues
|
27
|
+
|
28
|
+
We'd love to have you in the community:
|
29
|
+
|
30
|
+
- http://pakyow.org/get-involved
|
@@ -0,0 +1,13 @@
|
|
1
|
+
namespace :pakyow do
|
2
|
+
desc 'Prepare the app by configuring and loading code'
|
3
|
+
task :prepare do
|
4
|
+
require './app/setup'
|
5
|
+
Pakyow::App.prepare(ENV['APP_ENV'] || ENV['RACK_ENV'])
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'Stage the app by preparing and loading routes / views'
|
9
|
+
task :stage do
|
10
|
+
require './app/setup'
|
11
|
+
Pakyow::App.stage(ENV['APP_ENV'] || ENV['RACK_ENV'])
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
namespace :pakyow do
|
2
|
+
desc 'List bindings across all views, or a specific view path'
|
3
|
+
task :bindings, [:view_path] => :stage do |t, args|
|
4
|
+
BindingAnalyzer.analyze(args[:view_path])
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
class BindingAnalyzer
|
9
|
+
def self.analyze(view_path)
|
10
|
+
bindings = []
|
11
|
+
|
12
|
+
Pakyow::Config.presenter.view_stores.each_pair do |view_store, store_path|
|
13
|
+
Pakyow.app.presenter.store(view_store).infos do |info, path|
|
14
|
+
path = String.normalize_path(path) unless path == "/"
|
15
|
+
next if view_path && path != String.normalize_path(view_path)
|
16
|
+
next if bindings.select{|b| b[:path] == path}.length > 0
|
17
|
+
|
18
|
+
view = Pakyow.app.presenter.store(view_store).view(path)
|
19
|
+
bindings << { path: path, scopes: view.doc.scopes}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
bindings.each do |set|
|
24
|
+
set[:path] = '/' if set[:path].empty?
|
25
|
+
next if set[:scopes].empty?
|
26
|
+
|
27
|
+
Pakyow.logger << "\n" + set[:path]
|
28
|
+
|
29
|
+
log_bindings(set[:scopes])
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.log_bindings(bindings, nested = "")
|
34
|
+
bindings.each do |binding|
|
35
|
+
space = " "
|
36
|
+
|
37
|
+
scope_str = space.dup
|
38
|
+
scope_str << "#{nested} > " unless nested.empty?
|
39
|
+
scope_str << binding[:scope].to_s
|
40
|
+
Pakyow.logger << scope_str
|
41
|
+
|
42
|
+
props = binding[:props]
|
43
|
+
if props.count > 0
|
44
|
+
binding[:props].each {|prop|
|
45
|
+
Pakyow.logger << space + " #{prop[:prop]}"
|
46
|
+
}
|
47
|
+
else
|
48
|
+
Pakyow.logger << space + " (no props)"
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
next_nested = binding[:scope]
|
53
|
+
next_nested = "#{nested} > #{next_nested}" unless nested.empty?
|
54
|
+
log_bindings(binding[:nested], next_nested)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
namespace :pakyow do
|
2
|
+
desc 'List all routes (method, path, group[name])'
|
3
|
+
task :routes => [:stage] do
|
4
|
+
Pakyow::Router.instance.sets.each do |set_data|
|
5
|
+
set_name, set = set_data
|
6
|
+
|
7
|
+
Pakyow.logger << "\n#{set_name} routes"
|
8
|
+
|
9
|
+
all_routes = []
|
10
|
+
set.routes.each {|route_data|
|
11
|
+
method, routes = route_data
|
12
|
+
|
13
|
+
routes.each {|route|
|
14
|
+
group = nil
|
15
|
+
set.lookup[:grouped].each_pair {|name,routes|
|
16
|
+
if routes.values.include?(route)
|
17
|
+
group = name
|
18
|
+
break
|
19
|
+
end
|
20
|
+
}
|
21
|
+
|
22
|
+
name = route[2]
|
23
|
+
name = "#{group}[#{name}]" if group
|
24
|
+
|
25
|
+
all_routes << {
|
26
|
+
method: method,
|
27
|
+
path: File.join('/', route[4]),
|
28
|
+
name: name
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
all_routes.sort{|a,b| a[:path] <=> b[:path]}.each {|route|
|
34
|
+
s = " #{route[:method].upcase}\t#{route[:path]}"
|
35
|
+
s << ", #{route[:name]}" if route[:name]
|
36
|
+
Pakyow.logger << s
|
37
|
+
}
|
38
|
+
|
39
|
+
Pakyow.logger << ''
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pakyow-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Powell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -16,38 +16,35 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '3.
|
19
|
+
version: '3.2'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '3.
|
27
|
-
description: Supporting code
|
26
|
+
version: '3.2'
|
27
|
+
description: Supporting code for Pakyow
|
28
28
|
email: bryan@metabahn.com
|
29
29
|
executables: []
|
30
30
|
extensions: []
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
|
-
- pakyow-
|
34
|
-
- pakyow-
|
35
|
-
- pakyow-
|
36
|
-
- pakyow-
|
37
|
-
- pakyow-
|
38
|
-
- pakyow-
|
39
|
-
- pakyow-
|
40
|
-
|
41
|
-
- pakyow-support/lib/support/hash.rb
|
42
|
-
- pakyow-support/lib/support/string.rb
|
43
|
-
homepage: http://pakyow.com
|
33
|
+
- pakyow-rake/CHANGELOG.md
|
34
|
+
- pakyow-rake/LICENSE
|
35
|
+
- pakyow-rake/README.md
|
36
|
+
- pakyow-rake/lib/pakyow-rake.rb
|
37
|
+
- pakyow-rake/lib/tasks/app.rake
|
38
|
+
- pakyow-rake/lib/tasks/bindings.rake
|
39
|
+
- pakyow-rake/lib/tasks/routes.rake
|
40
|
+
homepage: http://pakyow.org
|
44
41
|
licenses:
|
45
42
|
- MIT
|
46
43
|
metadata: {}
|
47
44
|
post_install_message:
|
48
45
|
rdoc_options: []
|
49
46
|
require_paths:
|
50
|
-
- pakyow-
|
47
|
+
- pakyow-rake/lib
|
51
48
|
required_ruby_version: !ruby/object:Gem::Requirement
|
52
49
|
requirements:
|
53
50
|
- - ">="
|
@@ -60,9 +57,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
57
|
version: '0'
|
61
58
|
requirements: []
|
62
59
|
rubyforge_project:
|
63
|
-
rubygems_version: 2.
|
60
|
+
rubygems_version: 2.4.5
|
64
61
|
signing_key:
|
65
62
|
specification_version: 4
|
66
|
-
summary:
|
63
|
+
summary: Pakyow Support
|
67
64
|
test_files: []
|
68
|
-
has_rdoc:
|
data/pakyow-support/CHANGES
DELETED
data/pakyow-support/README
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
TODO
|
@@ -1,32 +0,0 @@
|
|
1
|
-
class Dir
|
2
|
-
# visit dir, then all files in dir, then walk_dir each directory in dir
|
3
|
-
def self.walk(dir, &block)
|
4
|
-
yield dir
|
5
|
-
all = Dir.entries(dir)
|
6
|
-
partition = all.partition{|e| File.file?("#{dir}/#{e}")}
|
7
|
-
files = partition[0]
|
8
|
-
dirs = partition[1]
|
9
|
-
files.each{|f| yield "#{dir}/#{f}" unless f.start_with?(".")}
|
10
|
-
dirs.each{|d| walk("#{dir}/#{d}", &block) unless d.start_with?(".")}
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.print(dir)
|
14
|
-
puts "/#{dir}"
|
15
|
-
Dir.walk(dir) {|full_path|
|
16
|
-
path = full_path.gsub(Regexp.new("#{dir}\/?"), '')
|
17
|
-
next if path.empty?
|
18
|
-
|
19
|
-
prefix = "|"
|
20
|
-
path.scan(/\//).size.times do
|
21
|
-
prefix += " |"
|
22
|
-
end
|
23
|
-
|
24
|
-
path.gsub!(/^.*\//, '')
|
25
|
-
puts "#{prefix}-- #{path}"
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.within_dir?(dir1, dir2)
|
30
|
-
(dir1.split('/') - dir2.split('/')).empty?
|
31
|
-
end
|
32
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Pakyow
|
2
|
-
module Utils
|
3
|
-
module Dup
|
4
|
-
UNCLONEABLE = [Symbol, Fixnum]
|
5
|
-
def self.deep(value)
|
6
|
-
return value if UNCLONEABLE.include?(value.class)
|
7
|
-
|
8
|
-
if value.is_a?(Hash)
|
9
|
-
result = value.clone
|
10
|
-
value.each { |k, v| result[deep(k)] = deep(v) }
|
11
|
-
result
|
12
|
-
elsif value.is_a?(Array)
|
13
|
-
result = value.clone
|
14
|
-
result.clear
|
15
|
-
value.each{ |v| result << deep(v) }
|
16
|
-
result
|
17
|
-
else
|
18
|
-
value.clone
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
class Hash
|
2
|
-
def deep_merge(second)
|
3
|
-
merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
|
4
|
-
self.merge(second, &merger)
|
5
|
-
end
|
6
|
-
|
7
|
-
def deep_merge!(second)
|
8
|
-
merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge!(v2, &merger) : v2 }
|
9
|
-
self.merge!(second, &merger)
|
10
|
-
end
|
11
|
-
|
12
|
-
# Creates an indifferent hash. This means that when indifferentized, this hash:
|
13
|
-
# { 'foo' => 'bar' }
|
14
|
-
#
|
15
|
-
# Can be accessed like this:
|
16
|
-
# { :foo => 'bar' }
|
17
|
-
#
|
18
|
-
def self.strhash(hash)
|
19
|
-
indifferentize(hash)
|
20
|
-
end
|
21
|
-
|
22
|
-
# Converts keys to symbols.
|
23
|
-
def self.symbolize_keys(hash)
|
24
|
-
Hash[hash.map{|(k,v)| [k.to_sym,v]}]
|
25
|
-
end
|
26
|
-
|
27
|
-
# Converts keys/values to symbols.
|
28
|
-
def self.symbolize(hash)
|
29
|
-
Hash[hash.map{|(k,v)| [k.to_sym,v.to_sym]}]
|
30
|
-
end
|
31
|
-
|
32
|
-
protected
|
33
|
-
|
34
|
-
# (see {strhash})
|
35
|
-
def self.indifferentize(hash)
|
36
|
-
hash.each_pair do |key, value|
|
37
|
-
hash[key] = indifferentize(value) if value.is_a? ::Hash
|
38
|
-
end
|
39
|
-
|
40
|
-
indifferent_hash.merge(hash)
|
41
|
-
end
|
42
|
-
|
43
|
-
# (see {strhash})
|
44
|
-
def self.indifferent_hash
|
45
|
-
Hash.new { |hash,key| hash[key.to_s] if Symbol === key }
|
46
|
-
end
|
47
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
class String
|
2
|
-
# split . seperated string at the last .
|
3
|
-
def self.split_at_last_dot(s)
|
4
|
-
split_index = s.rindex('.')
|
5
|
-
return s,nil unless split_index
|
6
|
-
left = s[0,split_index]
|
7
|
-
right = s[split_index+1,s.length-(split_index+1)]
|
8
|
-
return left,right
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.remove_route_vars(route_spec)
|
12
|
-
return unless route_spec
|
13
|
-
arr = route_spec.split('/')
|
14
|
-
new_arr = []
|
15
|
-
arr.each {|e| new_arr << e unless e[0,1] == ':'}
|
16
|
-
ret = new_arr.join('/')
|
17
|
-
return '/' if ret == ''
|
18
|
-
return ret
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.parse_path_from_caller(caller)
|
22
|
-
caller.match(/^(.+)(:?:\d+(:?:in `.+')?$)/)[1]
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.normalize_path(path)
|
26
|
-
return path if path.is_a?(Regexp)
|
27
|
-
|
28
|
-
path = path[1, path.length - 1] if path[0, 1] == '/'
|
29
|
-
path = path[0, path.length - 1] if path[path.length - 1, 1] == '/'
|
30
|
-
path
|
31
|
-
end
|
32
|
-
end
|