bumblemvp 1.0.1

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: befa1bd47829f6ee912031d1708b2009b1e25479
4
+ data.tar.gz: ced2af3e6b46c8e9121b12650a3323ce8d6c2713
5
+ SHA512:
6
+ metadata.gz: ef636370eb30db3805d36784dfd8b4f36c827d9be6428a0c2edc6d96a049fc6f8c37f5bb612fabb2d99abbda1e0fa8d602580f97661cf4484a82fd443d4aad7a
7
+ data.tar.gz: 2e2428a1a650f1e6721a0d873dd29cfa44ceed7b25e61db7f2e021ce933f948ab4fecf728a54ce30314722e7a89323f907f0793267e3ef9094e129c9d0ce8e13
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at dev.robertsimoes@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bumble.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 robertsimoes
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,38 @@
1
+ # BumbleMVP 🐝
2
+
3
+ Bumble is a simple command line ruby gem to assist Android development with generating entities in the Model-View-Present Pattern.
4
+
5
+ ## Installation
6
+
7
+ Install globally as Ruby Gem.
8
+
9
+ ```
10
+ $ gem install bumblemvp
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Say you want to create an entity like a Task for your To-do app
16
+
17
+ ```
18
+ bumble generate Task
19
+ ```
20
+
21
+ This generates a new package for the Task entity, as well as sets up some basic skeleton interfaces for the View and Presenters objects
22
+
23
+ Bumble was developed using [Google's Samples](https://github.com/googlesamples/android-architecture/tree/todo-mvp/)
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/robertsimoes/bumble. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
34
+
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/bumble ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bumble'
3
+
4
+ cli = Bumble::CLI.new
5
+ Bumble::CLI.start(ARGV)
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bumble"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bumble.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bumble/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bumblemvp"
8
+ spec.version = Bumble::VERSION
9
+ spec.authors = ["robertsimoes"]
10
+ spec.email = ["dev.robertsimoes@gmail.com"]
11
+
12
+ spec.summary = %q{MVP generators for android}
13
+ spec.description = %q{Bumble is a small ruby command-line tool to generate files in the model view presenter pattern.}
14
+ spec.homepage = "http://www.github.com/robertsimoes/bumblemvp.git"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
23
+ spec.executables = ["bumble"]
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.14"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ end
@@ -0,0 +1,3 @@
1
+ module Bumble
2
+ VERSION = "1.0.1"
3
+ end
data/lib/bumble.rb ADDED
@@ -0,0 +1,158 @@
1
+
2
+ require "bumble/version"
3
+ require 'rubygems'
4
+ require 'thor'
5
+ require 'fileutils'
6
+
7
+ module Bumble
8
+ class CLI < Thor
9
+ desc "generate <entity>", "Generates, Model, View and Presenter classes for entity"
10
+ def generate(entity)
11
+ # Create the data directory for model
12
+ _root = FileUtils.pwd
13
+ cap_entity = entity.capitalize
14
+ genereate_model(cap_entity)
15
+ FileUtils.cd(_root)
16
+ # Create presentors
17
+ generate_vp(cap_entity)
18
+
19
+ end
20
+
21
+
22
+
23
+ private
24
+ def write(file,val)
25
+ File.open(file, 'w') { |file| file.write(val) }
26
+ end
27
+
28
+ def make_dir(dir)
29
+ FileUtils.mkdir(dir) unless File.exist? dir
30
+ end
31
+
32
+ def make_file(file)
33
+ FileUtils.touch(file) unless File.exist? file
34
+ end
35
+
36
+ def generate_vp(entity)
37
+
38
+ make_dir(entity)
39
+ FileUtils.cd(entity)
40
+
41
+ contract = "#{entity}Contract.java"
42
+ make_file(contract)
43
+ write(contract,create_contract(entity))
44
+ end
45
+
46
+ # Creates directories:
47
+ # data/
48
+ # source/
49
+ # local/
50
+ # remote/
51
+ def genereate_model(entity)
52
+ datadir = "data"
53
+ sourcedir = "source"
54
+ localdir = "local"
55
+ remotedir = "remote"
56
+ ext = ".java"
57
+ model_file ="#{entity}"+ext
58
+
59
+ make_dir(datadir)
60
+ FileUtils.cd(datadir)
61
+
62
+ FileUtils.touch(model_file)
63
+ write(model_file,create_model(entity))
64
+
65
+
66
+ # Create Repos and DAOs
67
+ make_dir(sourcedir)
68
+ FileUtils.cd(sourcedir)
69
+ make_dir(localdir)
70
+ make_dir(remotedir)
71
+
72
+ # Write Interface
73
+ entity_src ="#{entity}DataSource.java"
74
+ make_file(entity_src)
75
+ write(entity_src,create_data_src(entity))
76
+
77
+ # Write Implementation Skeleton
78
+ entity_repo = "#{entity}Respository.java"
79
+ make_file(entity_repo)
80
+ write(entity_repo,create_data_repo(entity))
81
+ end
82
+
83
+ def create_model(model)
84
+ return "public class #{model} {\n//TODO \n}"
85
+ end
86
+
87
+ def create_contract(model)
88
+ return "interface #{model}sContract {
89
+
90
+ interface View {
91
+
92
+ void show#{model}s(List<#{model}> tasks);
93
+
94
+ void showLoadingError();
95
+
96
+ }
97
+
98
+ interface Presenter {
99
+
100
+ void result(int requestCode, int resultCode);
101
+
102
+ void load#{model}s(boolean forceUpdate);
103
+
104
+ void addNew#{model}();
105
+
106
+ }"
107
+ end
108
+
109
+ def create_data_src(model)
110
+ return "public class #{model}sRespository implements #{model}sDataSource {
111
+
112
+ private static #{model}sRepository INSTANCE = null;
113
+
114
+ private final #{model}sDataSource m#{model}sRemoteDataSource;
115
+
116
+ private final #{model}sDataSource m#{model}sLocalDataSource;
117
+
118
+ public static #{model}sRepository getInstance() {
119
+ if (INSTANCE == null) {
120
+ INSTANCE = new #{model}sRepository();
121
+ }
122
+ return INSTANCE;
123
+ }
124
+
125
+ /*
126
+ */
127
+ public static void destroyInstance() {
128
+ INSTANCE = null;
129
+ }
130
+ }"
131
+ end
132
+
133
+ def create_data_repo(model)
134
+ return "public interface #{model}sDataSource {
135
+
136
+ interface Load#{model}sCallback {
137
+
138
+ void onLoaded(List<#{model}> loaded);
139
+
140
+ void onDataNotAvailable();
141
+ }
142
+
143
+ interface Get#{model}Callback {
144
+
145
+ void on#{model}Loaded(#{model} task);
146
+
147
+ void onDataNotAvailable();
148
+ }
149
+
150
+ void get#{model}s(Load#{model}sCallback callback)
151
+ void get#{model}(String id, Get#{model}Callback callback)
152
+ void save(#{model} saveItem)
153
+ void delete#{model}(String id);
154
+ void deleteAll#{model}s();
155
+ }"
156
+ end
157
+ end
158
+ end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bumblemvp
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - robertsimoes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-05-08 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.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Bumble is a small ruby command-line tool to generate files in the model
42
+ view presenter pattern.
43
+ email:
44
+ - dev.robertsimoes@gmail.com
45
+ executables:
46
+ - bumble
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".DS_Store"
51
+ - ".gitignore"
52
+ - CODE_OF_CONDUCT.md
53
+ - Gemfile
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - bin/bumble
58
+ - bin/console
59
+ - bin/setup
60
+ - bumble.gemspec
61
+ - lib/bumble.rb
62
+ - lib/bumble/version.rb
63
+ homepage: http://www.github.com/robertsimoes/bumblemvp.git
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.6.10
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: MVP generators for android
87
+ test_files: []