pullentity-client 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +15 -0
  2. data/.DS_Store +0 -0
  3. data/.gitignore +47 -0
  4. data/CHANGELOG.md +6 -0
  5. data/Gemfile +5 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +29 -0
  8. data/Rakefile +1 -0
  9. data/bin/pullentity +5 -0
  10. data/lib/.DS_Store +0 -0
  11. data/lib/pullentity-client/.DS_Store +0 -0
  12. data/lib/pullentity-client/builder/middleman.rb +14 -0
  13. data/lib/pullentity-client/cli.rb +85 -0
  14. data/lib/pullentity-client/generate/auth.rb +173 -0
  15. data/lib/pullentity-client/generate/exporter.rb +107 -0
  16. data/lib/pullentity-client/generate/project.rb +99 -0
  17. data/lib/pullentity-client/generate/view.rb +47 -0
  18. data/lib/pullentity-client/helpers.rb +146 -0
  19. data/lib/pullentity-client/logger.rb +14 -0
  20. data/lib/pullentity-client/templates/.DS_Store +0 -0
  21. data/lib/pullentity-client/templates/app/.DS_Store +0 -0
  22. data/lib/pullentity-client/templates/app/assets/.DS_Store +0 -0
  23. data/lib/pullentity-client/templates/app/assets/fonts/fontawesome-webfont.eot +0 -0
  24. data/lib/pullentity-client/templates/app/assets/fonts/fontawesome-webfont.svg +255 -0
  25. data/lib/pullentity-client/templates/app/assets/fonts/fontawesome-webfont.ttf +0 -0
  26. data/lib/pullentity-client/templates/app/assets/fonts/fontawesome-webfont.woff +0 -0
  27. data/lib/pullentity-client/templates/app/assets/images/.DS_Store +0 -0
  28. data/lib/pullentity-client/templates/app/assets/images/favicon.ico +0 -0
  29. data/lib/pullentity-client/templates/app/assets/javascripts/application.js.erb +4 -0
  30. data/lib/pullentity-client/templates/app/assets/javascripts/mustache.js +535 -0
  31. data/lib/pullentity-client/templates/app/assets/stylesheets/application.css.scss +1 -0
  32. data/lib/pullentity-client/templates/app/assets/stylesheets/customtheme.css.scss +1 -0
  33. data/lib/pullentity-client/templates/app/index.html.haml +15 -0
  34. data/lib/pullentity-client/templates/app/views/.DS_Store +0 -0
  35. data/lib/pullentity-client/templates/app/views/list.haml +11 -0
  36. data/lib/pullentity-client/templates/app/views/shared/body.haml +26 -0
  37. data/lib/pullentity-client/templates/app/views/shared/css.haml +48 -0
  38. data/lib/pullentity-client/templates/app/views/shared/head.haml +19 -0
  39. data/lib/pullentity-client/templates/app/views/shared/js.haml +43 -0
  40. data/lib/pullentity-client/templates/app/views/themes/home.haml +21 -0
  41. data/lib/pullentity-client/templates/app/views/themes/theme1.haml +21 -0
  42. data/lib/pullentity-client/templates/defaults/Gemfile.erb +8 -0
  43. data/lib/pullentity-client/templates/defaults/LICENSE.erb +1 -0
  44. data/lib/pullentity-client/templates/defaults/Readme.mkd.erb +1 -0
  45. data/lib/pullentity-client/templates/defaults/build.yml.erb +2 -0
  46. data/lib/pullentity-client/templates/defaults/config.erb +23 -0
  47. data/lib/pullentity-client/templates/defaults/gitignore.erb +2 -0
  48. data/lib/pullentity-client/templates/defaults/layout.haml.erb +13 -0
  49. data/lib/pullentity-client/templates/defaults/pullentity.yml.erb +5 -0
  50. data/lib/pullentity-client/templates/defaults/test-data.js.erb +87 -0
  51. data/lib/pullentity-client/templates/rakefile +0 -0
  52. data/lib/pullentity-client/templates/specs/app_spec.coffee.erb +3 -0
  53. data/lib/pullentity-client/utils.rb +81 -0
  54. data/lib/pullentity-client/version.rb +5 -0
  55. data/lib/pullentity-client.rb +39 -0
  56. data/pullentity-client.gemspec +39 -0
  57. data/spec/cli/command_spec.rb +90 -0
  58. data/spec/pullentity-client/builder/middleman_spec.rb +22 -0
  59. data/spec/pullentity-client/generate/exporter_spec.rb +53 -0
  60. data/spec/pullentity-client/generate/project_spec.rb +90 -0
  61. data/spec/pullentity-client/logger_spec.rb +25 -0
  62. data/spec/pullentity-client/utils_spec.rb +94 -0
  63. data/spec/spec_helper.rb +42 -0
  64. data/vendor/assets/fonts/fontawesome-webfont.eot +0 -0
  65. data/vendor/assets/fonts/fontawesome-webfont.svg +255 -0
  66. data/vendor/assets/fonts/fontawesome-webfont.ttf +0 -0
  67. data/vendor/assets/fonts/fontawesome-webfont.woff +0 -0
  68. data/vendor/assets/images/.DS_Store +0 -0
  69. data/vendor/assets/images/pullentity/.DS_Store +0 -0
  70. data/vendor/assets/javascripts/pullentity/.DS_Store +0 -0
  71. data/vendor/assets/javascripts/pullentity.js +0 -0
  72. data/vendor/assets/stylesheets/.DS_Store +0 -0
  73. data/vendor/assets/stylesheets/pullentity/themes/default.css.scss +0 -0
  74. data/vendor/assets/stylesheets/pullentity.css.scss +1 -0
  75. metadata +335 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZjQ3ZGIxNmY5MDA4MzY4MzZjMjAzMmNlMjM3ZDNlNmY3OGNmM2FmOQ==
5
+ data.tar.gz: !binary |-
6
+ MGVmNjAyNjFkMDk3YTFjMGRjODgyMjY4OTRhN2U4MTI4MjliNjNiNQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZmRkMzFhYWI3ZTNiODUzMDdjN2NmZWYwZmE1OWI5ZDJlYzIzMjMxNjJiMzY1
10
+ N2RhOWYyNGI1NjY5YTQ3ZDFiN2U0OTdlMjZhZjU1NmUxMjc4Mzc3MmJiOThi
11
+ NTQxYTM5YWZhNWI3MzkzZTdmMWJkYzY3NjFlMDRmNWE1YjYzNzg=
12
+ data.tar.gz: !binary |-
13
+ YWFmMGRhY2U5Yjg3YTcwMTFhMTI5NWYyNDI4NjQzODI3MmJhNGNkODk3Nzc4
14
+ YjY1MDdiMjM5Nzk2MmRjMzE4OGNhNGI5Yzc2NWNjMjUwMzcyOGU3MzQwMTFm
15
+ YTc2YTMxYzM0OThlMDQzZDI3Yjg3YmZlNDg5ZWYxNzk0NDVjYTk=
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,47 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .rvmrc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+
20
+ # Numerous always-ignore extensions
21
+ *.diff
22
+ *.err
23
+ *.orig
24
+ *.log
25
+ *.rej
26
+ *.swo
27
+ *.swp
28
+ *.vi
29
+ *~
30
+ *.sass-cache
31
+ .rvmrc
32
+ .dropbox
33
+ *.sw?
34
+ coverage*
35
+ doc
36
+ rdoc
37
+ pkg
38
+ tmp
39
+ tags
40
+ rerun.txt
41
+ Gemfile.lock
42
+ .bundle
43
+ *.gem
44
+ dailyfocus
45
+ .lock
46
+
47
+ pkg
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ 0.0.1
2
+ 2013/03/18
3
+ Add assets to build export json
4
+ 2013/03/17
5
+ general layout creation
6
+ exporting to json
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pullentity-client.gemspec
4
+ gemspec
5
+ gem "debugger"
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 miguel michelson
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Pullentity::Client
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'pullentity-client'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install pullentity-client
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/pullentity ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'pullentity-client'
4
+
5
+ Pullentity::Client::CLI.start
data/lib/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,14 @@
1
+ module Pullentity::Client
2
+ module Builder
3
+ class Middleman
4
+ class << self
5
+ include ::Pullentity::Client::Utils
6
+
7
+ def build
8
+ system "middleman build --verbose"
9
+ end
10
+
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,85 @@
1
+ require "thor/group"
2
+ require "debugger"
3
+ module Pullentity
4
+ module Client
5
+ class CLI < Thor
6
+ include Utils
7
+ include Thor::Actions
8
+
9
+ STATUS_TYPES = {:success => 0,
10
+ :general_error => 1,
11
+ :not_supported => 3,
12
+ :not_found => 4,
13
+ :incorrect_usage => 64,
14
+ }
15
+
16
+ no_tasks {
17
+ def cli_error(message, exit_status=nil)
18
+ $stderr.puts message
19
+ exit_status = STATUS_TYPES[exit_status] if exit_status.is_a?(Symbol)
20
+ exit(exit_status || 1)
21
+ end
22
+ }
23
+
24
+ ### TODO: When these commands list grows big, we need to move them into a seperate commands.rb file
25
+ map %w(--version -v) => 'info'
26
+ desc "info", "information about Pullentity::Client::Generator."
27
+ def info
28
+ say "Version #{::Pullentity::Client::VERSION}"
29
+ end
30
+
31
+ map %w(r) => 'server'
32
+ desc "server ", "run middleman app"
33
+ def server
34
+ system "echo == :::pullentity-client STARTING::: =="
35
+ system "bundle exec middleman server"
36
+ end
37
+
38
+ map %w(b) => 'build'
39
+ desc "build ", "builds middleman/ios/android app"
40
+ long_desc "Build pullentity-client static files (middleman), See 'pullentity-client help build' for more information.
41
+ \n\nExample:
42
+ \n\npullentity-client build mm ==> build middleman static files."
43
+
44
+ #method_option :attributes, :type => :hash, :default => {}, :required => true
45
+ #method_options :type => "all"
46
+ #method_options :ver => "5.1"
47
+ def build(type="", ver="5.1")
48
+ puts "echo ::== pullentity-client BUILD =="
49
+ ::Pullentity::Client::Builder::Middleman.build
50
+ end
51
+
52
+ map %(n) => 'login'
53
+ desc "auth login <email> ", "login and configures auth_token."
54
+ long_desc "login and configures auth_token"
55
+ def login(email)
56
+ ::Pullentity::Client::Generate::Auth.start(['set_login', email])
57
+ end
58
+
59
+ map %(n) => 'sites'
60
+ desc "list sites", "needs auth_token."
61
+ long_desc "list sites, needs auth token , run pullentity login help"
62
+ def sites
63
+ ::Pullentity::Client::Generate::Auth.start(['list_sites'])
64
+ end
65
+
66
+ map %(ex) => 'export'
67
+ desc "export", "exports a new Pullentity Client project."
68
+ long_desc "builds & exports site to theme"
69
+ def export
70
+ ::Pullentity::Client::Generate::Exporter.start(['export'])
71
+ end
72
+
73
+ map %(n) => 'select'
74
+ desc "select site", "needs auth_token."
75
+ long_desc "select site, needs auth token , run pullentity login help"
76
+ def select_site
77
+ ::Pullentity::Client::Generate::Auth.start(['select_site'])
78
+ end
79
+
80
+ register Pullentity::Client::Generate::Project, :project, "project", "project generator"
81
+ #register Pullentity::Client::Generate::Exporter, :export, "export", "export theme"
82
+
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,173 @@
1
+ require 'session'
2
+ require "debugger"
3
+ module Pullentity
4
+ module Client
5
+ module Generate
6
+ class Auth < Thor
7
+
8
+ include ::Pullentity::Client::Utils
9
+
10
+ no_tasks {
11
+
12
+ def domain
13
+ "http://pullentity.com"
14
+ #"http://pullentity.dev:3000"
15
+ end
16
+
17
+ def login(email)
18
+ begin
19
+ hsh = YAML.load_file(location + "pullentity.yml")
20
+ rescue => e
21
+ say "Error, make sure you are inside a pullentity project", :red
22
+ say "and pullentity.yml file is created" , :red
23
+ raise
24
+ end
25
+ say("In order to retreive your authentication token we need your pullentity password", :yellow)
26
+ password = ask("write your password: ", :magenta )
27
+ uri = URI.parse("#{domain}/api/v1/login.json")
28
+ http = Net::HTTP.new(uri.host, uri.port)
29
+ request = Net::HTTP::Post.new(uri.request_uri)
30
+ request.set_form_data({"email" => email, "password" => password })
31
+ response = http.request(request)
32
+
33
+ json_body = JSON.parse(response.body)
34
+ if json_body["status"] && json_body["status"] == "success"
35
+ say "Congratz!, Your token is:"
36
+ say json_body["auth_token"], :green
37
+ say "we saved it in pullentity.yml", :green
38
+ hsh["auth_token"] = json_body["auth_token"]
39
+ File.open("#{location}/pullentity.yml", "w"){|f| YAML.dump(hsh, f)}
40
+ else
41
+ say response.body, :red
42
+ end
43
+ end
44
+
45
+ def check_for_yaml
46
+ begin
47
+ hsh = YAML.load_file(location + "pullentity.yml")
48
+ @token = hsh["auth_token"]
49
+ @site = hsh["site"]
50
+ @theme_name = hsh["theme_name"]
51
+ if hsh["auth_token"].empty?
52
+ say "Error, the auth_token is empty", :red
53
+ say "run: pullentity login" , :yellow
54
+ end
55
+ rescue => e
56
+ say "Error, make sure you are inside a pullentity project", :red
57
+ say "and pullentity.yml file is created" , :red
58
+ raise
59
+ end
60
+ end
61
+
62
+ def write_site_in_yaml(site)
63
+ begin
64
+ hsh = YAML.load_file(location + "pullentity.yml")
65
+ rescue => e
66
+ say "Error, make sure you are inside a pullentity project", :red
67
+ say "and pullentity.yml file is created" , :red
68
+ raise
69
+ end
70
+ hsh["site"] = site
71
+ File.open("#{location}/pullentity.yml", "w"){|f| YAML.dump(hsh, f)}
72
+ end
73
+
74
+ def site_api_call()
75
+ check_for_yaml
76
+ uri = URI.parse("#{domain}/api/v1/sites.json?auth_token=#{@token}")
77
+ http = Net::HTTP.new(uri.host, uri.port)
78
+ request = Net::HTTP::Get.new(uri.request_uri)
79
+ response = http.request(request)
80
+ @json_body = JSON.parse(response.body)
81
+ end
82
+
83
+ def export_api_call()
84
+ check_for_yaml
85
+
86
+ conn = Faraday.new(:url => domain) do |f|
87
+ f.request :multipart
88
+ f.request :url_encoded # form-encode POST params
89
+ #f.response :logger # log requests to STDOUT
90
+ f.adapter Faraday.default_adapter # make requests with Net::HTTP
91
+ end
92
+
93
+ payload = { :theme => Faraday::UploadIO.new("#{location}/pullentity_build.json", 'text/json') }
94
+ response = conn.put("/api/v1/import_theme?auth_token=#{@token}&subdomain=#{@site}&theme_name=#{@theme_name}", payload )
95
+ @json_body = JSON.parse(response.body)
96
+ say "#{@json_body[:status]} #{@json_body[:message]}", :green
97
+ end
98
+
99
+ def prompt_for_site_select
100
+ site_api_call
101
+ count = 0
102
+ arr = {}
103
+ @json_body.each do |site|
104
+ count += 1
105
+ arr[count] = site
106
+ say "[#{count}] Site: #{site["name"]}", :white
107
+ end
108
+ selector(arr)
109
+ end
110
+
111
+ def selector(arr)
112
+ answer = ask "select the site", :yellow
113
+ if arr[answer.to_i]
114
+ write_site_in_yaml(arr[answer.to_i]["subdomain"])
115
+ say "you have selected #{arr[answer.to_i]["name"]}", :green
116
+ say "we configure site name in pullentity.yml", :green
117
+ else
118
+ say "plase select one on the list" , :red
119
+ selector(arr)
120
+ end
121
+ end
122
+
123
+ def get_sites
124
+ site_api_call
125
+ @json_body.each do |site|
126
+ say "Site ID: ##{site["id"]}", :white
127
+ say " Name: " + site["name"].to_s, :green
128
+ say " Domain: " + site["keywords"].to_s, :green
129
+ say " Custom domain: " + site["custom_domain"].to_s, :green
130
+ say " Subdomain: " + site["subdomain"].to_s, :green
131
+ say " Activated: " + site["activated"].to_s, :green
132
+ end
133
+ end
134
+
135
+ def location
136
+ base_location
137
+ end
138
+
139
+ def source_root
140
+ File.dirname(__FILE__)
141
+ end
142
+
143
+ }
144
+
145
+ #map %(n) => 'login'
146
+ desc "auth login <email> ", "login and configures auth_token."
147
+ long_desc "login and configures auth_token"
148
+ def set_login(email)
149
+ login(email)
150
+ end
151
+
152
+ desc "list sites", ""
153
+ def list_sites
154
+ get_sites
155
+ end
156
+
157
+ desc "select site", ""
158
+ def select_site
159
+ prompt_for_site_select
160
+ end
161
+
162
+ desc "export theme site", ""
163
+ def export(name)
164
+ say "exporting current theme...", :green
165
+ export_api_call
166
+ end
167
+
168
+
169
+
170
+ end
171
+ end
172
+ end
173
+ end
@@ -0,0 +1,107 @@
1
+ require 'session'
2
+ require 'faraday'
3
+ module Pullentity
4
+ module Client
5
+ module Generate
6
+ class Exporter < Thor
7
+
8
+ include ::Pullentity::Client::Utils
9
+
10
+ class << self
11
+
12
+ include ::Pullentity::Client::Utils
13
+
14
+ def create(name)
15
+ build_theme_list
16
+ build_shared_views
17
+ build_hash_output(name)
18
+ create_with_template('pullentity_build.json', 'defaults/build.yml', { :json=> @full_app_hash })
19
+ end
20
+
21
+ def build_theme_list
22
+ @theme_list = []
23
+ Dir.foreach(location.join("build/views/themes") ).grep(/.html/).each do |theme|
24
+ @theme_list << {
25
+ :name => theme.gsub(".html", "") ,
26
+ :content => File.open(location.join("build/views/themes/#{theme}")).readlines.join("")
27
+ }
28
+ end
29
+ end
30
+
31
+ def name_from_yaml
32
+ yml = YAML.load(File.open(location.join("pullentity.yml")))
33
+ return yml["theme_name"]
34
+ end
35
+
36
+ def build_shared_views
37
+
38
+ @js = Nokogiri::HTML(File.open(location.join("build/views/shared/js.html")).readlines.join("")).css("script").first.content
39
+ @head = File.open(location.join("build/views/shared/head.html")).readlines.join("")
40
+ @css = Nokogiri::HTML(File.open(location.join("build/views/shared/css.html")).readlines.join("")).css("style").first.content
41
+ @layout = File.open(location.join("build/views/shared/body.html")).readlines.join("")
42
+ @list = File.open(location.join("build/views/list.html")).readlines.join("")
43
+ end
44
+
45
+ def build_hash_output(name)
46
+ @full_app_hash = {
47
+
48
+ :theme_name => name,
49
+ :themes => @theme_list,
50
+ :js => @js,
51
+ :css => @css,
52
+ :layout => @layout,
53
+ :head=> @head,
54
+ :list=> @list,
55
+ :assets => assets_hash
56
+ }
57
+
58
+ end
59
+
60
+ def assets_hash
61
+ images = []
62
+ Dir.foreach(location.join("build/assets/images") ).grep(/.jpg|.jpeg|.png|.gif|.ico/).each do |image|
63
+ images << image
64
+ end
65
+ fonts = []
66
+ Dir.foreach(location.join("build/assets/fonts") ).grep(/.eot|.svg|.ttf|.woff/).each do |font|
67
+ fonts << font
68
+ end
69
+ js = File.open(location.join("build/assets/javascripts/application.js")).readlines.join("")
70
+ css = File.open(location.join("build/assets/stylesheets/application.css")).readlines.join("")
71
+
72
+ { :images => images , :js => js, :css => css , :fonts=> fonts }
73
+
74
+ end
75
+
76
+ def location
77
+ base_location
78
+ end
79
+
80
+
81
+ def source_root
82
+ File.dirname(__FILE__)
83
+ end
84
+
85
+ end
86
+
87
+ map %(n) => 'export'
88
+ desc "export", "exports a new Pullentity Client project."
89
+ long_desc "Exports a new Pullentity project"
90
+ def export
91
+ begin
92
+ name_for = YAML.load_file(location + "pullentity.yml")["theme_name"]
93
+ rescue => e
94
+ say "Error, make sure you are inside a pullentity project", :red
95
+ say "and pullentity.yml file is created" , :red
96
+ raise
97
+ end
98
+ name_for = YAML.load_file(location + "pullentity.yml")["theme_name"]
99
+ ::Pullentity::Client::Builder::Middleman.build
100
+ ::Pullentity::Client::Generate::Exporter.create(name_for)
101
+ ::Pullentity::Client::Generate::Auth.start(['export', name_for])
102
+ end
103
+
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,99 @@
1
+ require 'session'
2
+ module Pullentity
3
+ module Client
4
+ module Generate
5
+ class Project < Thor
6
+
7
+ include ::Pullentity::Client::Utils
8
+
9
+ class << self
10
+
11
+ attr_accessor :project_name, :device_platform, :app_id
12
+
13
+ include ::Pullentity::Client::Utils
14
+
15
+ def create(name)
16
+ @project_name = name
17
+
18
+ begin
19
+ create_directories('tmp')
20
+ copy_defaults
21
+ remove_old_files
22
+ generate_files
23
+ log "Your Pullentity Theme project is ready for you to get coding!"
24
+ rescue => e
25
+ error "There was an error generating your Pullentity Client project. #{e} #{e.backtrace}"
26
+ end
27
+ end
28
+
29
+ def copy_defaults
30
+ end
31
+
32
+ def generate_files
33
+ create_project_directory
34
+ full_app_hash = {:app_name => @project_name, :app_name_underscore => underscore(@project_name), :platform => @device_platform}
35
+ create_with_template('.gitignore', 'defaults/gitignore', full_app_hash)
36
+ create_with_template('Gemfile', 'defaults/Gemfile', full_app_hash)
37
+ create_with_template('LICENSE', 'defaults/LICENSE', full_app_hash)
38
+ create_with_template('pullentity.yml', 'defaults/pullentity.yml', full_app_hash)
39
+
40
+ create_with_template('config.rb', 'defaults/config', full_app_hash)
41
+ default_templates = ['Readme.mkd']
42
+ default_templates.each do |tempfile|
43
+ create_with_template(tempfile, "defaults/#{tempfile}", full_app_hash)
44
+ end
45
+
46
+ FileUtils.cp_r(templates("app/."), location.join("source/") )
47
+
48
+ create_with_template('source/assets/javascripts/test-data.js', 'defaults/test-data.js', full_app_hash)
49
+ create_with_template('source/layout.haml', 'defaults/layout.haml', full_app_hash)
50
+
51
+ end
52
+
53
+ def create_project_directory
54
+ create_directories('docs', 'spec',
55
+ "source/assets",
56
+ "source/assets/images",
57
+ "source/assets/fonts",
58
+ "source/assets/stylesheets",
59
+ "source/assets/javascripts",
60
+ "source/views",
61
+ "source/models")
62
+ end
63
+
64
+ def remove_old_files
65
+ end
66
+
67
+ def location
68
+ base_location.join(@project_name)
69
+ end
70
+
71
+ def source_root
72
+ File.dirname(__FILE__)
73
+ end
74
+
75
+ end
76
+
77
+ map %(n) => 'new'
78
+ desc "project new <name> ", "generates a new Pullentity Client project."
79
+ long_desc "Generates a new Pullentity project. See 'pullentity help new' for more information.
80
+ \n\nExample:
81
+ \n\npullentity project new demo ==> Creates a new project skeleton."
82
+ def new(name)
83
+ if File.exist?(base_location.join(name))
84
+
85
+ if yes?("#{name} already exists, do you want to override? (yes or no)")
86
+ ::Pullentity::Client::Generate::Project.create(name)
87
+ else
88
+ say "Skipping #{name} because it already exists"
89
+ end
90
+ else
91
+ ::Pullentity::Client::Generate::Project.create(name)
92
+ end
93
+
94
+ end
95
+
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,47 @@
1
+ module Pullentity::Client
2
+ module Generate
3
+ class View < Thor
4
+
5
+ include Thor::Actions
6
+
7
+ attr_accessor :name, :model
8
+
9
+ no_tasks {
10
+ include ::Pullentity::Client::Utils
11
+
12
+ def generate_files(view_directory, template)
13
+ spec_template = templates("specs/app_spec.coffee.erb")
14
+ template_destination = "source/#{view_directory}/#{(@context[:domain] || '').downcase}/_#{@name}.haml"
15
+ spec_destination = "spec/#{view_directory}/#{(@context[:domain] || '').downcase}/#{@name}_spec.coffee"
16
+ template( template, template_destination )
17
+ template( spec_template, spec_destination )
18
+ end
19
+
20
+ def create(name, context={})
21
+ say "really cool stuff here soon!"
22
+ end
23
+
24
+ }
25
+
26
+ map %w(s) => 'scaffold'
27
+ desc "view scaffold <list/complexlist/tabbar/toolbar/dialog> <domain> <name>", "generate a scaffold for pullentity elements."
28
+ def scaffold(cs_type, domain, name)
29
+ create(name, {
30
+ :domain => domain,
31
+ :cs_type => cs_type,
32
+ :name => name })
33
+ end
34
+
35
+ map %w(g) => 'generate'
36
+ #TODO: models, bridges
37
+ desc "generate <view> <name>", "generate a view"
38
+ def generate(type, name)
39
+ case
40
+ when type =~ /view/i
41
+ create(name)
42
+ end
43
+ end
44
+
45
+ end
46
+ end
47
+ end