glueby 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -1
- data/.ruby-version +1 -1
- data/.travis.yml +3 -2
- data/README.md +27 -17
- data/glueby.gemspec +1 -1
- data/lib/generators/glueby/{initializer_generator.rb → contract/initializer_generator.rb} +0 -0
- data/lib/generators/glueby/contract/templates/initializer.rb.erb +3 -0
- data/lib/generators/glueby/contract/templates/key_table.rb.erb +15 -0
- data/lib/generators/glueby/{templates → contract/templates}/timestamp_table.rb.erb +2 -1
- data/lib/generators/glueby/contract/templates/utxo_table.rb.erb +15 -0
- data/lib/generators/glueby/contract/templates/wallet_table.rb.erb +10 -0
- data/lib/generators/glueby/contract/timestamp_generator.rb +26 -0
- data/lib/generators/glueby/contract/wallet_adapter_generator.rb +46 -0
- data/lib/glueby.rb +18 -1
- data/lib/glueby/contract.rb +3 -14
- data/lib/glueby/contract/active_record/timestamp.rb +8 -5
- data/lib/glueby/contract/errors.rb +6 -0
- data/lib/glueby/contract/payment.rb +54 -0
- data/lib/glueby/contract/timestamp.rb +39 -38
- data/lib/glueby/contract/token.rb +193 -0
- data/lib/glueby/contract/tx_builder.rb +197 -31
- data/lib/glueby/generator.rb +5 -0
- data/lib/glueby/generator/migrate_generator.rb +38 -0
- data/lib/glueby/internal.rb +6 -0
- data/lib/glueby/internal/rpc.rb +35 -0
- data/lib/glueby/internal/wallet.rb +122 -0
- data/lib/glueby/internal/wallet/abstract_wallet_adapter.rb +131 -0
- data/lib/glueby/internal/wallet/active_record.rb +15 -0
- data/lib/glueby/internal/wallet/active_record/key.rb +72 -0
- data/lib/glueby/internal/wallet/active_record/utxo.rb +50 -0
- data/lib/glueby/internal/wallet/active_record/wallet.rb +54 -0
- data/lib/glueby/internal/wallet/active_record_wallet_adapter.rb +133 -0
- data/lib/glueby/internal/wallet/errors.rb +11 -0
- data/lib/glueby/internal/wallet/tapyrus_core_wallet_adapter.rb +158 -0
- data/lib/glueby/version.rb +1 -1
- data/lib/glueby/wallet.rb +51 -0
- data/lib/tasks/glueby/contract/timestamp.rake +5 -5
- data/lib/tasks/glueby/contract/wallet_adapter.rake +42 -0
- metadata +30 -10
- data/lib/generators/glueby/templates/initializer.rb.erb +0 -4
- data/lib/generators/glueby/timestamp_generator.rb +0 -57
- data/lib/glueby/contract/rpc.rb +0 -15
@@ -1,57 +0,0 @@
|
|
1
|
-
module Glueby
|
2
|
-
module Contract
|
3
|
-
class TimestampGenerator < Rails::Generators::Base
|
4
|
-
include ::Rails::Generators::Migration
|
5
|
-
|
6
|
-
source_root File.expand_path('templates', __dir__)
|
7
|
-
|
8
|
-
def self.next_migration_number(dirname)
|
9
|
-
# ::ActiveRecord::Migration.next_migration_number(number)
|
10
|
-
# ::ActiveRecord::Generators::Base.next_migration_number(dirname)
|
11
|
-
next_migration_number = current_migration_number(dirname) + 1
|
12
|
-
::ActiveRecord::Migration.next_migration_number(next_migration_number)
|
13
|
-
end
|
14
|
-
|
15
|
-
def create_migration_file
|
16
|
-
migration_dir = File.expand_path("db/migrate")
|
17
|
-
|
18
|
-
if self.class.migration_exists?(migration_dir, "create_timestamp")
|
19
|
-
::Kernel.warn "Migration already exists: create_timestamp"
|
20
|
-
else
|
21
|
-
migration_template(
|
22
|
-
"timestamp_table.rb.erb",
|
23
|
-
"db/migrate/create_timestamp.rb",
|
24
|
-
migration_version: migration_version,
|
25
|
-
table_options: table_options,
|
26
|
-
)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
MYSQL_ADAPTERS = [
|
31
|
-
"ActiveRecord::ConnectionAdapters::MysqlAdapter",
|
32
|
-
"ActiveRecord::ConnectionAdapters::Mysql2Adapter"
|
33
|
-
].freeze
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def migration_version
|
38
|
-
major = ::Rails::VERSION::MAJOR
|
39
|
-
if major >= 5
|
40
|
-
"[#{major}.#{::Rails::VERSION::MINOR}]"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def mysql?
|
45
|
-
MYSQL_ADAPTERS.include?(::ActiveRecord::Base.connection.class.name)
|
46
|
-
end
|
47
|
-
|
48
|
-
def table_options
|
49
|
-
if mysql?
|
50
|
-
', { options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci" }'
|
51
|
-
else
|
52
|
-
""
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|