pluto-merge 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6f65a81d1169d50cf94b9d886708d28cfa39d69a
4
+ data.tar.gz: b69cf925744453ad8b98f23862cf9d09214dfba2
5
+ SHA512:
6
+ metadata.gz: 59bea70bcb0aef67af58f204d86bafffc879172837b344c1df9c39b2f25b056f0d2a05eb9985680912c919223fd5a924207dd432716b147550c9dc9aef2cda91
7
+ data.tar.gz: 3c5c941a71df99c91b3746ba281683c48dd7b20995a46405987c02345cba1e655e363133a4e31ebc3ae1b0d25b86bb53fa75992e6fb942cf7b20438e097b7316
@@ -0,0 +1,4 @@
1
+
2
+ ### 0.0.1 / 2014-12-13
3
+
4
+ * Everything is new. First release
@@ -0,0 +1,11 @@
1
+ HISTORY.md
2
+ Manifest.txt
3
+ README.md
4
+ Rakefile
5
+ config/pluto.index.yml
6
+ lib/pluto/merge.rb
7
+ lib/pluto/merge/formatter.rb
8
+ lib/pluto/merge/installer.rb
9
+ lib/pluto/merge/lister.rb
10
+ lib/pluto/merge/manifest_helpers.rb
11
+ lib/pluto/merge/version.rb
@@ -0,0 +1,23 @@
1
+ # pluto-merge gem - planet site generator (that is, merge 'n' manage planet templates)
2
+
3
+ * home :: [github.com/feedreader/pluto-merge](https://github.com/feedreader/pluto-merge)
4
+ * bugs :: [github.com/feedreader/pluto-merge/issues](https://github.com/feedreader/pluto-merge/issues)
5
+ * gem :: [rubygems.org/gems/pluto-merge](https://rubygems.org/gems/pluto-merge)
6
+ * rdoc :: [rubydoc.info/gems/pluto-merge](http://rubydoc.info/gems/pluto-merge)
7
+ * forum :: [groups.google.com/group/feedreader](http://groups.google.com/group/feedreader)
8
+
9
+
10
+
11
+ ## Usage
12
+
13
+
14
+
15
+ ## License
16
+
17
+ The `pluto-merge` scripts are dedicated to the public domain.
18
+ Use it as you please with no restrictions whatsoever.
19
+
20
+ ## Questions? Comments?
21
+
22
+ Send them along to the [Planet Pluto and Friends Forum/Mailing List](http://groups.google.com/group/feedreader).
23
+ Thanks!
@@ -0,0 +1,32 @@
1
+ require 'hoe'
2
+ require './lib/pluto/merge/version.rb'
3
+
4
+ Hoe.spec 'pluto-merge' do
5
+
6
+ self.version = PlutoMerge::VERSION
7
+
8
+ self.summary = "pluto-merge - planet site generator (that is, merge 'n' manage planet templates)"
9
+ self.description = summary
10
+
11
+ self.urls = ['https://github.com/feedreader/pluto-merge']
12
+
13
+ self.author = 'Gerald Bauer'
14
+ self.email = 'feedreader@googlegroups.com'
15
+
16
+ # switch extension to .markdown for gihub formatting
17
+ self.readme_file = 'README.md'
18
+ self.history_file = 'HISTORY.md'
19
+
20
+ self.extra_deps = [
21
+ ['pluto-models', '>= 1.2.2'],
22
+ ['pakman', '>= 0.5.0'],
23
+ ['fetcher', '>= 0.4.4'],
24
+ ]
25
+
26
+ self.licenses = ['Public Domain']
27
+
28
+ self.spec_extras = {
29
+ required_ruby_version: '>= 1.9.2'
30
+ }
31
+
32
+ end
@@ -0,0 +1,23 @@
1
+ #########################################
2
+ # Pluto Update Index for Template Packs
3
+
4
+
5
+ #############
6
+ # shortcuts for fetching template packs
7
+ # maps shortcut to URI
8
+
9
+ blank: https://raw.github.com/planet-templates/planet-blank/master/blank.txt
10
+
11
+ top: https://raw.github.com/planet-templates/planet-top/master/top.txt
12
+
13
+ news: https://raw.github.com/planet-templates/planet-news/master/news.txt
14
+
15
+ feeds: https://raw.github.com/planet-templates/planet-feeds/master/feeds.txt
16
+
17
+ classic: https://raw.github.com/planet-templates/planet-classic/master/classic.txt
18
+
19
+
20
+ ####
21
+ # all:
22
+ # - add why? why not??
23
+ #
@@ -0,0 +1,30 @@
1
+ # encoding: utf-8
2
+
3
+ require 'pluto/models'
4
+
5
+ # 3rd party ruby gems/libs
6
+
7
+ require 'pakman' # template pack manager
8
+ require 'fetcher'
9
+
10
+ # our own code
11
+
12
+ require 'pluto/merge/version' # note: let version always get first
13
+ require 'pluto/merge/manifest_helpers'
14
+ require 'pluto/merge/installer'
15
+ require 'pluto/merge/lister'
16
+ require 'pluto/merge/formatter'
17
+
18
+
19
+ module Pluto
20
+
21
+ def self.generator # convenience alias for banner (matches HTML generator meta tag)
22
+ "Pluto #{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
23
+ end
24
+
25
+ end # module Pluto
26
+
27
+
28
+
29
+ # say hello
30
+ puts PlutoMerge.banner if $DEBUG || (defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG)
@@ -0,0 +1,84 @@
1
+ # encoding: utf-8
2
+
3
+
4
+ module Pluto
5
+
6
+ class Formatter
7
+
8
+ include LogUtils::Logging
9
+
10
+ include Models
11
+ include ManifestHelper
12
+
13
+ include TextUtils::DateHelper # e.g. lets us use time_ago_in_words
14
+ include TextUtils::HypertextHelper # e.g. lets us use link_to, strip_tags, sanitize, textify, etc.
15
+
16
+ def initialize( opts, config )
17
+ @opts = opts
18
+ @config = config
19
+ end
20
+
21
+ attr_reader :opts, :config, :site
22
+
23
+
24
+ def run( arg )
25
+ ### remove - always use make( site_key )
26
+ ## fix: change arg to planet_key or just key or similar
27
+ # todo: rename run to some less generic - merge/build/etc. ??
28
+
29
+ site_key = arg
30
+ site_key = site_key.downcase.gsub('.ini','').gsub('.yml','') # remove .ini|.yml extension if present
31
+
32
+ manifest_name = opts.manifest
33
+ output_path = opts.output_path
34
+
35
+ make_for(site_key, manifest_name, output_path )
36
+ end
37
+
38
+
39
+ def make_for( site_key, manifest_name, output_path )
40
+
41
+ ## fix: remove reference to opts
42
+ ## - e.g. now still used for auto-installer
43
+
44
+ manifest_name = manifest_name.downcase.gsub('.txt', '' ) # remove .txt if present
45
+
46
+ logger.debug "manifest=#{manifest_name}"
47
+
48
+ # check for matching manifests
49
+ manifests = installed_template_manifests.select { |m| m[0] == manifest_name+'.txt' }
50
+
51
+ if manifests.empty?
52
+
53
+ ### try - autodownload
54
+ puts "*** template pack '#{manifest_name}' not found; trying auto-install..."
55
+
56
+ Installer.new( opts ).install( manifest_name )
57
+
58
+ ### try again
59
+
60
+ # check for matching manifests
61
+ manifests = installed_template_manifests.select { |m| m[0] == manifest_name+'.txt' }
62
+
63
+ if manifests.empty?
64
+ puts "*** error: unknown template pack '#{manifest_name}'; use pluto ls to list installed template packs"
65
+ exit 2
66
+ end
67
+ end
68
+
69
+ manifestsrc = manifests[0][1]
70
+ pakpath = output_path
71
+
72
+ @site = Site.find_by_key( site_key )
73
+ if @site.nil?
74
+ puts "*** warn: no site with key '#{site_key}' found; using untitled site record"
75
+ @site = Site.new
76
+ @site.title = 'Planet Untitled'
77
+ end
78
+
79
+ Pakman::Templater.new.merge_pak( manifestsrc, pakpath, binding, site_key )
80
+ end
81
+
82
+ end # class Formatter
83
+
84
+ end # module Pluto
@@ -0,0 +1,61 @@
1
+ # encoding: utf-8
2
+
3
+
4
+ module Pluto
5
+
6
+ class Installer
7
+
8
+ ### fix: remove opts, use config (wrapped!!)
9
+
10
+ include LogUtils::Logging
11
+
12
+ def initialize( opts )
13
+ @opts = opts
14
+ end
15
+
16
+ attr_reader :opts
17
+
18
+
19
+ def install( shortcut_or_source )
20
+
21
+ logger.debug "fetch >#{shortcut_or_source}<"
22
+
23
+ ## check for builtin shortcut (assume no / or \)
24
+ if shortcut_or_source.index( '/' ).nil? && shortcut_or_source.index( '\\' ).nil?
25
+ shortcut = shortcut_or_source
26
+ sources = opts.map_fetch_shortcut( shortcut )
27
+
28
+ if sources.empty?
29
+ puts "** Error: No mapping found for shortcut '#{shortcut}'."
30
+ return
31
+ end
32
+ puts " Mapping fetch shortcut '#{shortcut}' to: #{sources.join(',')}"
33
+ else
34
+ sources = [shortcut_or_source] # pass arg through unmapped
35
+ end
36
+
37
+ sources.each do |source|
38
+ install_template( source )
39
+ end
40
+
41
+ end # method run
42
+
43
+
44
+ def install_template( src )
45
+ # src = 'http://github.com/geraldb/slideshow/raw/d98e5b02b87ee66485431b1bee8fb6378297bfe4/code/templates/fullerscreen.txt'
46
+ # src = 'http://github.com/geraldb/sandbox/raw/13d4fec0908fbfcc456b74dfe2f88621614b5244/s5blank/s5blank.txt'
47
+ uri = URI.parse( src )
48
+ logger.debug "scheme: #{uri.scheme}, host: #{uri.host}, port: #{uri.port}, path: #{uri.path}"
49
+
50
+ pakname = File.basename( uri.path ).downcase.gsub('.txt','')
51
+ pakpath = File.expand_path( "#{opts.config_path}/#{pakname}" )
52
+
53
+ logger.debug "packname >#{pakname}<"
54
+ logger.debug "pakpath >#{pakpath}<"
55
+
56
+ Pakman::Fetcher.new.fetch_pak( src, pakpath )
57
+ end
58
+
59
+ end # class Installer
60
+
61
+ end # module Pluto
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+
3
+
4
+ module Pluto
5
+
6
+ class Lister
7
+
8
+ include LogUtils::Logging
9
+
10
+ include ManifestHelper
11
+
12
+ def initialize( opts )
13
+ @opts = opts
14
+ end
15
+
16
+ attr_reader :opts
17
+
18
+ def list
19
+ home = Env.home
20
+ ## replace home w/ ~ (to make out more readable (shorter))
21
+ ## e.g. use gsub( home, '~' )
22
+
23
+ puts ''
24
+ puts 'Installed template packs in search path'
25
+
26
+ installed_template_manifest_patterns.each_with_index do |pattern,i|
27
+ puts " [#{i+1}] #{pattern.gsub(home,'~')}"
28
+ end
29
+ puts ' include:'
30
+
31
+ manifests = installed_template_manifests
32
+ if manifests.empty?
33
+ puts " -- none --"
34
+ else
35
+ manifests.each do |manifest|
36
+ pakname = manifest[0].gsub('.txt','')
37
+ manifestpath = manifest[1].gsub(home,'~')
38
+ puts "%16s (%s)" % [pakname,manifestpath]
39
+ end
40
+ end
41
+ end # method list
42
+
43
+ end # class Lister
44
+
45
+ end # module Pluto
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+
3
+ module Pluto
4
+
5
+ ###
6
+ # Note: requires/needs
7
+ # opts.config_path reference
8
+
9
+
10
+ module ManifestHelper
11
+
12
+ ## shared methods for handling manifest lookups
13
+ ##
14
+ # note: required attribs (in host class) include:
15
+ # - opts.config_path
16
+
17
+ def installed_template_manifest_patterns
18
+
19
+ # 1) search . # that is, working/current dir
20
+ # 2) search <config_dir>
21
+ # 3) search <gem>/templates
22
+
23
+ ###
24
+ # Note
25
+ # -- for now - no longer ship w/ builtin template packs
26
+ # - download on demand if needed
27
+
28
+ builtin_patterns = [
29
+ ## "#{Pluto.root}/templates/*.txt"
30
+ ]
31
+ config_patterns = [
32
+ ## "#{File.expand_path(opts.config_path)}/*.txt",
33
+ "#{File.expand_path(opts.config_path)}/*/*.txt"
34
+ ]
35
+ current_patterns = [
36
+ ## "*.txt",
37
+ "*/*.txt",
38
+ "node_modules/*/*.txt", # note: add support for npm installs - use/make slideshow required in name? for namespace in the future???
39
+ ]
40
+
41
+ patterns = []
42
+ patterns += current_patterns
43
+ patterns += config_patterns
44
+ patterns += builtin_patterns
45
+ end
46
+
47
+ def installed_template_manifests
48
+ excludes = [
49
+ "Manifest.txt",
50
+ "*/Manifest.txt"
51
+ ]
52
+
53
+ Pakman::Finder.new.find_manifests( installed_template_manifest_patterns, excludes )
54
+ end
55
+
56
+
57
+ end # module Manifest
58
+ end # module Slideshow
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+
4
+ module PlutoMerge
5
+
6
+ MAJOR = 1
7
+ MINOR = 1
8
+ PATCH = 0
9
+ VERSION = [MAJOR,MINOR,PATCH].join('.')
10
+
11
+ def self.version
12
+ VERSION
13
+ end
14
+
15
+ def self.banner
16
+ ### todo: add RUBY_PATCHLEVEL or RUBY_PATCH_LEVEL e.g. -p124
17
+ "pluto-merge/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
18
+ end
19
+
20
+ def self.root
21
+ "#{File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )}"
22
+ end
23
+
24
+ end # module PlutoUpdate
25
+
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pluto-merge
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gerald Bauer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pluto-models
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.2.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: pakman
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.5.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.5.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: fetcher
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.4.4
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.4.4
55
+ - !ruby/object:Gem::Dependency
56
+ name: rdoc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: hoe
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.13'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.13'
83
+ description: pluto-merge - planet site generator (that is, merge 'n' manage planet
84
+ templates)
85
+ email: feedreader@googlegroups.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files:
89
+ - HISTORY.md
90
+ - Manifest.txt
91
+ - README.md
92
+ files:
93
+ - HISTORY.md
94
+ - Manifest.txt
95
+ - README.md
96
+ - Rakefile
97
+ - config/pluto.index.yml
98
+ - lib/pluto/merge.rb
99
+ - lib/pluto/merge/formatter.rb
100
+ - lib/pluto/merge/installer.rb
101
+ - lib/pluto/merge/lister.rb
102
+ - lib/pluto/merge/manifest_helpers.rb
103
+ - lib/pluto/merge/version.rb
104
+ homepage: https://github.com/feedreader/pluto-merge
105
+ licenses:
106
+ - Public Domain
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options:
110
+ - "--main"
111
+ - README.md
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: 1.9.2
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.2
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: pluto-merge - planet site generator (that is, merge 'n' manage planet templates)
130
+ test_files: []