jaspion-miya 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0fd0f17d5988c470993e5b7c9ee7436b229b5b3a
4
+ data.tar.gz: 817c61eef5975c97c30b5a17ba550b42cfcb44d6
5
+ SHA512:
6
+ metadata.gz: dab6e6f47b2adead855479d8de5120bb63ddcfb3e4e6b4d7b908043d877374c13886f087ec152cb41cee2d66342ad6fc89af12f71b2682441f8dd7b464b7732b
7
+ data.tar.gz: 33f1101f4c14897231ea962a461a4ab73856311e44353e0c0f93d421448af1c08add0586aa39203e771a54aadef9192e2cf7cdea8e35038d435701b2bdb42d02
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /spec/res/xcode/MiyaTest/Miya/
11
+ /spec/res/xcode/MiyaTest/MiyaTest.xcodeproj/
12
+ /spec/res/xcode/MiyaTest/.miya/
13
+ script.old
14
+ .DS_Store
15
+ .byebug_history
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ # A sample Gemfile
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Toshiro Sugii
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Miya
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/miya`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'miya'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install miya
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec miya` to use the gem in this directory, ignoring other installed copies of this gem.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/miya. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'jaspion/miya'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require 'pry'
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
data/bin/miya ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'jaspion/miya'
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/exe/miya ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'jaspion/miya'
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jaspion/miya/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'jaspion-miya'
8
+ spec.version = Jaspion::Miya::VERSION
9
+ spec.authors = ['rtoshiro']
10
+ spec.email = ['rtoshiro@printwtf.com']
11
+
12
+ spec.summary = 'Generic code generator'
13
+ spec.description = 'We have a lot of template codes available to easily generate some codes'
14
+ spec.homepage = 'http://www.printwtf.com'
15
+ spec.license = 'MIT'
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
+ else
22
+ raise 'RubyGems 2.0 or newer is required' \
23
+ 'to protect against public gem pushes.'
24
+ end
25
+
26
+ spec.bindir = 'bin'
27
+ spec.executables = ['miya']
28
+ spec.require_paths = ['lib']
29
+ spec.files = `git ls-files -z`.split("\x0").reject { |f|
30
+ f.match(%r{^(test|spec|features)/})
31
+ }
32
+ spec.add_development_dependency 'bundler'
33
+ spec.add_development_dependency 'rake'
34
+ spec.add_development_dependency 'rspec'
35
+ spec.add_development_dependency 'byebug'
36
+
37
+ spec.add_dependency 'erubis'
38
+ end
data/lib/jaspion.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'jaspion/miya'
2
+
3
+ # Module Jaspion
4
+ module Jaspion
5
+ end
@@ -0,0 +1,43 @@
1
+ # Author:: Toshiro Sugii
2
+ # Copyright:: Copyright (c) 2016 Toshiro Sugii
3
+ # License:: Distributes under the same terms as Ruby
4
+ require 'byebug'
5
+ require 'jaspion/miya/version'
6
+
7
+ require 'jaspion/miya/object'
8
+ require 'jaspion/miya/template'
9
+
10
+ # requires all android templates
11
+ require 'jaspion/miya/android'
12
+ Dir[File.dirname(__FILE__) + '/miya/android/*.rb'].each { |file| require file }
13
+
14
+ # requires all objectivec templates
15
+ require 'jaspion/miya/objectivec'
16
+ Dir[File.dirname(__FILE__) + '/miya/objectivec/*.rb'].each { |file| require file }
17
+
18
+ # requires all swift templates
19
+ require 'jaspion/miya/swift'
20
+ Dir[File.dirname(__FILE__) + '/miya/swift/*.rb'].each { |file| require file }
21
+
22
+ # Native Ruby class
23
+ class String
24
+ # "Un"capitalizes an String
25
+ def uncapitalize
26
+ self[0, 1].downcase + self[1..-1]
27
+ end
28
+ end
29
+
30
+ # Native Ruby class
31
+ class Class
32
+ # Returns all descendants classes
33
+ def descendants
34
+ cls = ObjectSpace.each_object(Class).select { |klass| klass < self }
35
+ cls.sort! { |a,b| a.name.downcase <=> b.name.downcase }
36
+ end
37
+ end
38
+
39
+ module Jaspion
40
+ # Module Miya
41
+ module Miya
42
+ end
43
+ end
@@ -0,0 +1,39 @@
1
+ # Author:: Toshiro Sugii
2
+ # Copyright:: Copyright (c) 2016 Toshiro Sugii
3
+ # License:: Distributes under the same terms as Ruby
4
+ require 'jaspion/miya/object'
5
+
6
+ module Jaspion
7
+ module Miya
8
+ # Represents an Android Object class
9
+ class Android < Miya::Object
10
+ attr_accessor :package
11
+
12
+ def instance_variables
13
+ " private #{type} #{name.uncapitalize};"
14
+ end
15
+
16
+ def ui?
17
+ self.class.name.include?('View') || self.class.name.include?('Edit')
18
+ end
19
+
20
+ # Represents the Java class package
21
+ def package
22
+ @package = '' if @package.nil?
23
+ @package
24
+ end
25
+
26
+ # Generates inflating parameters
27
+ #
28
+ # @return [String] An initializer for this object view, if ui?
29
+ def inflate_view
30
+ if ui?
31
+ str = " this.#{name.uncapitalize} = (#{type})"
32
+ str << " findViewById(R.id.#{name.downcase});"
33
+ return str
34
+ end
35
+ ''
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,17 @@
1
+ # Author:: Toshiro Sugii
2
+ # Copyright:: Copyright (c) 2016 Toshiro Sugii
3
+ # License:: Distributes under the same terms as Ruby
4
+ module Jaspion
5
+ module Miya
6
+ class Android
7
+ # Represents an Android Activity template
8
+ class Activity < Miya::Android
9
+ def imports
10
+ %(import android.content.Context;
11
+ import android.support.v7.app.AppCompatActivity;
12
+ import android.os.Bundle;)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ # Author:: Toshiro Sugii
2
+ # Copyright:: Copyright (c) 2016 Toshiro Sugii
3
+ # License:: Distributes under the same terms as Ruby
4
+ module Jaspion
5
+ module Miya
6
+ class Android
7
+ # Represents an Android ListView template
8
+ class ListView < Miya::Android
9
+ def imports
10
+ 'import android.widget.ListView;'
11
+ end
12
+
13
+ def instance_variables
14
+ "#{super}\n private #{name}Adapter #{name.uncapitalize}Adapter;"
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # Author:: Toshiro Sugii
2
+ # Copyright:: Copyright (c) 2016 Toshiro Sugii
3
+ # License:: Distributes under the same terms as Ruby
4
+ module Jaspion
5
+ module Miya
6
+ class Android
7
+ # Represents an Android RelativeLayout template
8
+ class RelativeLayout < Miya::Android
9
+ def imports
10
+ %(import android.widget.RelativeLayout;)
11
+ end
12
+
13
+ def templates
14
+ nil
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,49 @@
1
+ # Author:: Toshiro Sugii
2
+ # Copyright:: Copyright (c) 2016 Toshiro Sugii
3
+ # License:: Distributes under the same terms as Ruby
4
+ module Jaspion
5
+ module Miya
6
+ class Android
7
+ # Represents an Android Retrofit template
8
+ # (http://square.github.io/retrofit/)
9
+ class Retrofit < Miya::Android
10
+ def imports
11
+ %(
12
+ import com.squareup.okhttp.OkHttpClient;
13
+ import com.squareup.okhttp.ResponseBody;
14
+ import com.squareup.okhttp.logging.HttpLoggingInterceptor;
15
+ import retrofit.Call;
16
+ import retrofit.Callback;
17
+ import retrofit.GsonConverterFactory;
18
+ import retrofit.Response;
19
+ import retrofit.Retrofit;
20
+ import #{name}RESTInterface;)
21
+ end
22
+
23
+ def instance_variables
24
+ " private #{name}RESTInterface #{name.uncapitalize}RESTInterface;"
25
+ end
26
+
27
+ def instance_methods
28
+ %(
29
+ protected void loadRetrofit() {
30
+ if (BuildConfig.DEBUG) {
31
+ HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
32
+ logging.setLevel(HttpLoggingInterceptor.Level.BASIC);
33
+ OkHttpClient httpClient = new OkHttpClient();
34
+ httpClient.interceptors().add(logging);
35
+ }
36
+
37
+ this.#{name} = new Retrofit.Builder()
38
+ .baseUrl(#{name}RESTInterface.BASE_URL)
39
+ .addConverterFactory(GsonConverterFactory.create())
40
+ .client(httpClient)
41
+ .build();
42
+
43
+ this.#{name.uncapitalize}RESTInterface = retrofit.create(#{name}RESTInterface.class);
44
+ })
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,19 @@
1
+ # Author:: Toshiro Sugii
2
+ # Copyright:: Copyright (c) 2016 Toshiro Sugii
3
+ # License:: Distributes under the same terms as Ruby
4
+ module Jaspion
5
+ module Miya
6
+ class Android
7
+ # Represents an Android TextView template
8
+ class TextView < Miya::Android
9
+ def imports
10
+ %(import android.widget.TextView;)
11
+ end
12
+
13
+ def templates
14
+ nil
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,30 @@
1
+ module Jaspion
2
+ module Miya
3
+ # Represents an generic programming language Class
4
+ module Class
5
+ def imports
6
+ ''
7
+ end
8
+
9
+ def instance_variables
10
+ ''
11
+ end
12
+
13
+ def instance_methods
14
+ ''
15
+ end
16
+
17
+ def class_variables
18
+ ''
19
+ end
20
+
21
+ def class_methods
22
+ ''
23
+ end
24
+
25
+ def ui?
26
+ false
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,78 @@
1
+ # Author:: Toshiro Sugii
2
+ # Copyright:: Copyright (c) 2016 Toshiro Sugii
3
+ # License:: Distributes under the same terms as Ruby
4
+ require 'jaspion/miya/template'
5
+ require 'jaspion/miya/class'
6
+
7
+ module Jaspion
8
+ module Miya
9
+ # Represents a single class object
10
+ class Object
11
+ include Jaspion::Miya::Class
12
+
13
+ # Object name - Like variable name
14
+ attr_accessor :name
15
+
16
+ # Object type - Like variable type
17
+ attr_accessor :type
18
+
19
+ # Objects can contain other object inside
20
+ attr_accessor :children
21
+
22
+ # Initializes an Object object
23
+ # Object's type is defined by the last path of the Ruby class name
24
+ #
25
+ # @param name [String] Object name
26
+ #
27
+ # @param import [String] Import value
28
+ def initialize(name)
29
+ @type = self.class.name.split('::').last
30
+ @name = name
31
+ @children = []
32
+ end
33
+
34
+ # Pushes an new Object object
35
+ #
36
+ # @param name [Object] Object object
37
+ def push_child(object)
38
+ children.push(object)
39
+ end
40
+
41
+ # Look for a Object type inside @objects array
42
+ #
43
+ # @param type [String] Name of type object to find
44
+ #
45
+ # @return [Object] If has object, returns it else returns nil
46
+ def fetch_child(type)
47
+ children.find { |c| c.type.eql?(type) }
48
+ end
49
+
50
+ # Generate an array of Template objects
51
+ #
52
+ # @return [Array] List of the Template object that belongs to this class
53
+ def templates
54
+ [Miya::Template.new(self, nil)]
55
+ end
56
+
57
+ # Creates a new instance of the specified Object depending on the
58
+ # plataform's name
59
+ #
60
+ # @param class_name [String] Object class name
61
+ # @param instance_name [String] Object's instance name
62
+ #
63
+ # @return [Object] The Object instance depending on the specified
64
+ # plataform
65
+ def self.create(class_name, instance_name)
66
+ return nil unless const_defined?(class_name)
67
+
68
+ clazz = const_get(class_name)
69
+ clazz.new(instance_name)
70
+ end
71
+
72
+ # Returns all available template classes
73
+ def self.available_classes
74
+ descendants
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,42 @@
1
+ # Author:: Toshiro Sugii
2
+ # Copyright:: Copyright (c) 2016 Toshiro Sugii
3
+ # License:: Distributes under the same terms as Ruby
4
+ require 'jaspion/miya/object'
5
+
6
+ module Jaspion
7
+ module Miya
8
+ # Represents an Objective-C Object class
9
+ class Objectivec < Miya::Object
10
+ attr_accessor :xib_reference
11
+ alias xib_reference? xib_reference
12
+
13
+ def initialize(name)
14
+ super(name)
15
+ @xib_reference = true
16
+ end
17
+
18
+ def instance_variables
19
+ str = super
20
+ if xib_reference? && ui?
21
+ str << "\n IBOutlet @property (nonatomic, weak)"
22
+ else
23
+ str << "\n @property (nonatomic, strong)"
24
+ end
25
+ str << " #{type} *#{name.uncapitalize};"
26
+ str
27
+ end
28
+
29
+ def interface_methods
30
+ ''
31
+ end
32
+
33
+ def protocols
34
+ []
35
+ end
36
+
37
+ def ui?
38
+ self.class.name.include?('View')
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,55 @@
1
+ # Author:: Toshiro Sugii
2
+ # Copyright:: Copyright (c) 2016 Toshiro Sugii
3
+ # License:: Distributes under the same terms as Ruby
4
+ module Jaspion
5
+ module Miya
6
+ class Objectivec
7
+ # Represents an Android Activity template
8
+ class UITableView < Miya::Objectivec
9
+ def protocols
10
+ super | ['UITableViewDataSource', 'UITableViewDelegate']
11
+ end
12
+
13
+ def instance_methods
14
+ %(#{super}
15
+ - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
16
+ {
17
+ return 0.f;
18
+ }
19
+
20
+ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
21
+ {
22
+ return 0;
23
+ }
24
+
25
+ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
26
+ {
27
+ return 0;
28
+ }
29
+
30
+ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
31
+ {
32
+ UITableViewCell *cell = nil;
33
+
34
+ cell = (UITableViewCell *) [tableView dequeueReusableCellWithIdentifier:@""];
35
+ if (!cell)
36
+ {
37
+ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@""];
38
+ }
39
+
40
+ return cell;
41
+ }
42
+
43
+ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
44
+ {
45
+ }
46
+ )
47
+ end
48
+
49
+ def viewDidLoad
50
+ ''
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,29 @@
1
+ # Author:: Toshiro Sugii
2
+ # Copyright:: Copyright (c) 2016 Toshiro Sugii
3
+ # License:: Distributes under the same terms as Ruby
4
+ module Jaspion
5
+ module Miya
6
+ class Objectivec
7
+ # Represents an Android Activity template
8
+ class UIViewController < Miya::Objectivec
9
+ def imports
10
+
11
+ end
12
+ def viewDidLoad
13
+ ''
14
+ end
15
+
16
+ def didReceiveMemoryWarning
17
+ ''
18
+ end
19
+
20
+ def templates
21
+ [
22
+ Miya::Template.new(self, File.join(Template.dir_path, 'objectivec', 'viewcontroller.h.erb')),
23
+ Miya::Template.new(self, File.join(Template.dir_path, 'objectivec', 'viewcontroller.m.erb'))
24
+ ]
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,24 @@
1
+ # Author:: Toshiro Sugii
2
+ # Copyright:: Copyright (c) 2016 Toshiro Sugii
3
+ # License:: Distributes under the same terms as Ruby
4
+ require 'jaspion/miya/object'
5
+
6
+ module Jaspion
7
+ module Miya
8
+ # Represents an Android Object class
9
+ class Swift < Miya::Object
10
+ def instance_variables
11
+ return "@IBOutlet var #{name.uncapitalize} : #{type}!" if ui?
12
+ "let #{name.uncapitalize} : #{type}!"
13
+ end
14
+
15
+ def class_methods
16
+ ''
17
+ end
18
+
19
+ def instance_methods
20
+ ''
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ # Author:: Toshiro Sugii
2
+ # Copyright:: Copyright (c) 2016 Toshiro Sugii
3
+ # License:: Distributes under the same terms as Ruby
4
+ require 'jaspion/miya/swift'
5
+
6
+ module Jaspion
7
+ module Miya
8
+ class Swift
9
+ # Represents an Android Activity template
10
+ class UIViewController < Miya::Swift
11
+ def imports
12
+ ''
13
+ end
14
+
15
+ def viewDidLoad
16
+ ''
17
+ end
18
+
19
+ def didReceiveMemoryWarning
20
+ ''
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,57 @@
1
+ # Author:: Toshiro Sugii
2
+ # Copyright:: Copyright (c) 2016 Toshiro Sugii
3
+ # License:: Distributes under the same terms as Ruby
4
+ require 'erubis'
5
+
6
+ module Jaspion
7
+ module Miya
8
+ # Represents a result file template that can be manipulated
9
+ class Template
10
+ # Object object that template is related to
11
+ attr_accessor :object
12
+
13
+ # Template file path
14
+ attr_accessor :file_path
15
+
16
+ class << self
17
+ # Returns all available classes
18
+ #
19
+ # @return [String] Directory path of /template
20
+ def dir_path
21
+ File.expand_path(File.join(__FILE__, '..', '..', '..', 'templates'))
22
+ end
23
+ end
24
+
25
+ # Initializes an Template object
26
+ #
27
+ # @param object [Object] Object object related to this template
28
+ #
29
+ # @param path [String] Source - template path
30
+ # => If path == nil, it tries to figure out the path by Object class name
31
+ def initialize(object = nil, path = nil)
32
+ @object = object
33
+ @file_path = (path || default_file_path)
34
+ end
35
+
36
+ def default_file_path
37
+ unless object.nil?
38
+ path_components = object.class.name.split('::')[1..-1]
39
+ path_components[0] = self.class.dir_path
40
+ return File.join(*path_components.map(&:downcase)) + '.erb'
41
+ end
42
+ end
43
+
44
+ # Returns the parsed template code using ERUBIS
45
+ # The template file should be in /template directory
46
+ #
47
+ # @return [String] Parsed code
48
+ def source_code
49
+ return nil if @file_path.nil? || !File.file?(@file_path)
50
+ Erubis::Eruby.new(File.read(@file_path)).evaluate(object)
51
+ end
52
+
53
+ def save(path)
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,6 @@
1
+ module Jaspion
2
+ module Miya
3
+ VERSION = '0.1.0'.freeze
4
+ NAME = 'Miya'.freeze
5
+ end
6
+ end
@@ -0,0 +1,32 @@
1
+ package ;
2
+
3
+ <%= imports %>
4
+ <% children.each do |child| %>
5
+ <%= child.imports %>
6
+ <% end %>
7
+
8
+ public class <%= name %> extends AppCompatActivity {
9
+ <% children.each do |child| %>
10
+ <%= child.class_variables -%>
11
+ <% end %>
12
+ <% children.each do |child| %>
13
+ <%= child.instance_variables %>
14
+ <% end %>
15
+
16
+ @Override
17
+ protected void onCreate(Bundle savedInstanceState) {
18
+ super.onCreate(savedInstanceState);
19
+ setContentView(R.layout.activity);
20
+
21
+ this.context = this;
22
+ <% children.each do |child| %>
23
+ <%= child.inflate_view %>
24
+ <% end %>
25
+ }
26
+ <% children.each do |child| %>
27
+ <%= child.instance_methods %>
28
+ <% end %>
29
+ <% children.each do |child| %>
30
+ <%= child.class_methods %>
31
+ <% end %>
32
+ }
@@ -0,0 +1,45 @@
1
+ package;
2
+
3
+ import android.content.Context;
4
+ import android.view.LayoutInflater;
5
+ import android.view.View;
6
+ import android.view.ViewGroup;
7
+ import android.widget.BaseAdapter;
8
+
9
+ public class <%= @name %>Adapter extends BaseAdapter {
10
+ protected Context context;
11
+
12
+ public <%= @name %>Adapter(Context context) {
13
+ super();
14
+ this.context = context;
15
+ }
16
+
17
+ @Override
18
+ public int getCount() {
19
+ return 0;
20
+ }
21
+
22
+ @Override
23
+ public Object getItem(int i) {
24
+ return null;
25
+ }
26
+
27
+ @Override
28
+ public long getItemId(int i) {
29
+ return 0;
30
+ }
31
+
32
+ @Override
33
+ public View getView(int i, View view, ViewGroup viewGroup) {
34
+ View layout = view;
35
+ if (layout == null) {
36
+ layout = LayoutInflater.from(context).inflate(R.layout.<%= @name %>, null);
37
+ }
38
+
39
+ <% children.each do |child| %>
40
+ <%= child.inflate_view -%>
41
+ <% end %>
42
+
43
+ return layout;
44
+ }
45
+ }
@@ -0,0 +1,48 @@
1
+ package ;
2
+
3
+ import android.content.Context;
4
+ import android.support.v7.widget.RecyclerView;
5
+ import android.view.LayoutInflater;
6
+ import android.view.View;
7
+ import android.view.ViewGroup;
8
+
9
+ public class <%= @name %>Adapter extends RecyclerView.Adapter<<%= @name %>Adapter.ViewHolder> {
10
+ private Context context;
11
+
12
+ public <%= @name %>Adapter(Context context) {
13
+ this.context = context;
14
+ }
15
+
16
+ @Override
17
+ public int getItemViewType(int position) {
18
+ return 0;
19
+ }
20
+
21
+ @Override
22
+ public <%= @name %>Adapter.ViewHolder onCreateViewHolder(ViewGroup parent,
23
+ int viewType) {
24
+ View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.<%= @name %>Adapter, parent, false);
25
+
26
+ ViewHolder vh = new ViewHolder(v);
27
+ return vh;
28
+ }
29
+
30
+ @Override
31
+ public void onBindViewHolder(final ViewHolder holder, int position) {
32
+
33
+ }
34
+
35
+ @Override
36
+ public int getItemCount() {
37
+ return 0;
38
+ }
39
+
40
+ public class ViewHolder extends RecyclerView.ViewHolder {
41
+ public View rootView;
42
+
43
+ public ViewHolder(View v) {
44
+ super(v);
45
+ this.rootView = v;
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,25 @@
1
+ package <%= package %>;
2
+
3
+ import com.squareup.okhttp.RequestBody;
4
+ import com.squareup.okhttp.ResponseBody;
5
+
6
+ import retrofit.Call;
7
+ import retrofit.http.Field;
8
+ import retrofit.http.FormUrlEncoded;
9
+ import retrofit.http.Multipart;
10
+ import retrofit.http.POST;
11
+ import retrofit.http.Part;
12
+
13
+ public interface <%= name %>RESTService {
14
+ @FormUrlEncoded
15
+ @POST("/login")
16
+ Call<ExampleModel> login(@Field("login") String login, @Field("password") String password);
17
+
18
+ @FormUrlEncoded
19
+ @POST("/download")
20
+ Call<ExampleModel> download(@Field("login") String login, @Field("password") String password);
21
+
22
+ @Multipart
23
+ @POST("/upload")
24
+ Call<ExampleModel> upload(@Part("login") RequestBody login, @Part("password") RequestBody password, @Part("fileUpload\"; filename=\"myfile.zip\"") RequestBody file);
25
+ }
@@ -0,0 +1,19 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ @interface <%= @name %> : UIViewController <%
4
+ ps = []
5
+ children.each do |child|
6
+ ps = ps | child.protocols
7
+ end
8
+ %><% if ps.count > 0 %><<%= ps.join(', ') %>><% end %>
9
+ {
10
+ <% children.each do |child| %>
11
+ <%= child.instance_variables %>
12
+ <% end %>
13
+ }
14
+
15
+ <% children.each do |child| %>
16
+ <%= child.interface_methods -%>
17
+ <% end %>
18
+
19
+ @end
@@ -0,0 +1,26 @@
1
+ #import "<%= @name %>.h"
2
+
3
+ @implementation <%= @name %>
4
+
5
+ - (void)viewDidLoad
6
+ {
7
+ [super viewDidLoad];
8
+ <% children.each do |child| %>
9
+ <%= child.viewDidLoad -%>
10
+ <% end %>
11
+ }
12
+
13
+ - (void)didReceiveMemoryWarning
14
+ {
15
+ [super didReceiveMemoryWarning];
16
+ }
17
+
18
+ <% children.each do |child| %>
19
+ <%= child.class_methods -%>
20
+ <% end %>
21
+
22
+ <% children.each do |child| %>
23
+ <%= child.instance_methods -%>
24
+ <% end %>
25
+
26
+ @end
@@ -0,0 +1,39 @@
1
+ //
2
+ // <%= name %>.swift
3
+ //
4
+ // Created on <%= Time.now.strftime("%Y-%m-%d") %>
5
+ // Copyright (c) <%= Time.now.strftime("%Y") %>. All rights reserved.
6
+ // Generated by Miya https://github.com/Jaspion/Miya
7
+ //
8
+
9
+ import UIKit
10
+
11
+ class <%= name %>: UIViewController {
12
+ <% children.each do |child| %>
13
+ <%= child.instance_variables -%>
14
+ <% end %>
15
+
16
+ override func viewDidLoad() {
17
+ super.viewDidLoad()
18
+
19
+ <% children.each do |child| %>
20
+ <%= child.viewDidLoad -%>
21
+ <% end %>
22
+ }
23
+
24
+ override func didReceiveMemoryWarning() {
25
+ super.didReceiveMemoryWarning()
26
+
27
+ <% children.each do |child| %>
28
+ <%= child.didReceiveMemoryWarning -%>
29
+ <% end %>
30
+ }
31
+
32
+ <% children.each do |child| %>
33
+ <%= child.class_methods -%>
34
+ <% end %>
35
+
36
+ <% children.each do |child| %>
37
+ <%= child.instance_methods -%>
38
+ <% end %>
39
+ }
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jaspion-miya
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - rtoshiro
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-26 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: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
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: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
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: erubis
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: We have a lot of template codes available to easily generate some codes
84
+ email:
85
+ - rtoshiro@printwtf.com
86
+ executables:
87
+ - miya
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - .rspec
93
+ - .travis.yml
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/miya
101
+ - bin/setup
102
+ - exe/miya
103
+ - jaspion-miya.gemspec
104
+ - lib/jaspion.rb
105
+ - lib/jaspion/miya.rb
106
+ - lib/jaspion/miya/android.rb
107
+ - lib/jaspion/miya/android/activity.rb
108
+ - lib/jaspion/miya/android/listview.rb
109
+ - lib/jaspion/miya/android/relativelayout.rb
110
+ - lib/jaspion/miya/android/retrofit.rb
111
+ - lib/jaspion/miya/android/textview.rb
112
+ - lib/jaspion/miya/class.rb
113
+ - lib/jaspion/miya/object.rb
114
+ - lib/jaspion/miya/objectivec.rb
115
+ - lib/jaspion/miya/objectivec/uitableview.rb
116
+ - lib/jaspion/miya/objectivec/uiviewcontroller.rb
117
+ - lib/jaspion/miya/swift.rb
118
+ - lib/jaspion/miya/swift/uiviewcontroller.rb
119
+ - lib/jaspion/miya/template.rb
120
+ - lib/jaspion/miya/version.rb
121
+ - lib/templates/android/activity.erb
122
+ - lib/templates/android/listview.erb
123
+ - lib/templates/android/recyclerview.erb
124
+ - lib/templates/android/retrofit.erb
125
+ - lib/templates/objectivec/viewcontroller.h.erb
126
+ - lib/templates/objectivec/viewcontroller.m.erb
127
+ - lib/templates/swift/uiviewcontroller.erb
128
+ homepage: http://www.printwtf.com
129
+ licenses:
130
+ - MIT
131
+ metadata:
132
+ allowed_push_host: https://rubygems.org
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.4.8
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: Generic code generator
153
+ test_files: []